Class: Decidim::SocialShareServiceManifest
- Inherits:
-
Object
- Object
- Decidim::SocialShareServiceManifest
- Includes:
- ActiveModel::Validations, AttributeObject::Model
- Defined in:
- decidim-core/lib/decidim/social_share_service_manifest.rb
Overview
This class represents an abstract social network to be used for sharing URLs Serves as a replacement for our usage of the social-share-button gem
Constant Summary
Constants included from AttributeObject::TypeMap
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Method Summary collapse
-
#formatted_share_uri(title, args) ⇒ String?
Format a given URL to be shareable All the services gives us a controller that accepts different get parameters.
-
#icon_path ⇒ String
Path of the icon file.
Methods included from AttributeObject::Model
#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h
Instance Method Details
#formatted_share_uri(title, args) ⇒ String?
Format a given URL to be shareable All the services gives us a controller that accepts different get parameters. As this parameters are used in an URL we need to escape them
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'decidim-core/lib/decidim/social_share_service_manifest.rb', line 29 def formatted_share_uri(title, args) return "#" unless link? formatted_args = escape_args(args.compact) format(full_share_uri(formatted_args.keys), title: url_escape(title), **formatted_args) rescue KeyError # This happens when all the arguments needed for the `format()` call are # not provided in the `formatted_args` array. E.g. the URL of the page # can be nil in some dummy views during the tests when they do not define # the meta URL, i.e. `add_decidim_meta_tags` has not been called in these # views or it has been called with an empty URL. nil end |
#icon_path ⇒ String
Path of the icon file
46 47 48 |
# File 'decidim-core/lib/decidim/social_share_service_manifest.rb', line 46 def icon_path ActionController::Base.helpers.asset_pack_path("media/images/#{icon}") end |