meta_tags 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d7c3be2f90a4bf1e3a4fd71868bf3f70206077f
4
- data.tar.gz: e8f7122e74b90b721931040e293afdafcc39a815
3
+ metadata.gz: 09a5a32f00942761acacbede938e26c47a3e1ccf
4
+ data.tar.gz: 85cd2cc73a51304adaf9cc9b9a5454643a3903db
5
5
  SHA512:
6
- metadata.gz: 6eb4ae7f68556a5f7ad40b90571b9d2308a5851428f9aa7bce7609e937da80f1f1ac3c26814b83bce09a7a7083ab39f87869af0717ed4e2b089aa35dbdb2e45f
7
- data.tar.gz: 1e0534967227d8cdca13a676d582864011fbd4b8f4927516dde521d798bc95022e03082fb59b57127f975c977c9d2bfd9980b3f6f9b65c700ba015ca920bd928
6
+ metadata.gz: a4f64085f847531a73a741a278b7ae4ceb5dcedad58e1bec53f468a51fce5ec9c57dab0fb82b9ed72a4ba7a2940c5c52ea89809e9bed515abbe4e2bc6ce408aa
7
+ data.tar.gz: 060ac92075fe6d8885c79060d3b8d1acd175be1b4667fbe6ca22564825b26135f07479a7a9febbee1a24e6cd35b0e5d181378a15ce2b85a1b8f169a84f274cbb
@@ -1,17 +1,12 @@
1
1
  module MetaTags
2
- class ConfigGenerator < Rails::Generators::Base
2
+ class InstallGenerator < Rails::Generators::Base
3
3
  # Copied files come from templates folder
4
4
  source_root File.expand_path('../templates', __FILE__)
5
5
 
6
6
  # Generator desc
7
- desc "Meta-tags config generator"
8
-
9
- def welcome
10
- say "Configuring Meta-tags dependencies and files !"
11
- end
7
+ desc "Meta-tags install generator"
12
8
 
13
9
  def copy_initializer_file
14
- say "Installing default initializer template"
15
10
  copy_file "initializer.rb", "config/initializers/meta_tags.rb"
16
11
  end
17
12
 
@@ -19,4 +14,4 @@ module MetaTags
19
14
  rake "meta_tags_railtie:install:migrations"
20
15
  end
21
16
  end
22
- end
17
+ end
@@ -1,7 +1,4 @@
1
- # encoding: utf-8
2
-
3
1
  MetaTags.config do |config|
4
-
5
2
  # Default title methods to be checked for title
6
3
  #
7
4
  # config.title_methods = %w(title name)
@@ -22,4 +19,4 @@ MetaTags.config do |config|
22
19
  # Defaults to true
23
20
  #
24
21
  # config.keep_default_title_present = false
25
- end
22
+ end
@@ -1,6 +1,17 @@
1
1
  require "meta_tags/engine"
2
2
 
3
3
  module MetaTags
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :Controller
7
+ autoload :MetaTaggable
8
+ autoload :MetaTaggableMacro
9
+ autoload :Renderer
10
+ autoload :Store
11
+ autoload :Tags
12
+ autoload :Vendors
13
+ autoload :ViewHelpers
14
+
4
15
  mattr_accessor :title_methods
5
16
  @@title_methods = %w(title name)
6
17
 
@@ -10,8 +21,8 @@ module MetaTags
10
21
  mattr_accessor :image_methods
11
22
  @@image_methods = %w(image picture avatar)
12
23
 
13
- mattr_accessor :keep_default_title_present
14
- @@keep_default_title_present = true
24
+ mattr_accessor :defaults
25
+ @@defaults = nil
15
26
 
16
27
  class << self
17
28
  def config
@@ -1,130 +1,31 @@
1
1
  module MetaTags
2
2
  module Controller
3
3
  extend ActiveSupport::Concern
4
- include PageDataHelper
5
-
6
- module ClassMethods
7
- attr_accessor :meta_tags, :model_name, :modifier_block
8
-
9
- def meta_tags_defaults(options)
10
- @meta_tags = Container.new(options)
11
- end
12
-
13
- def meta_tags_from(model_name = nil, &block)
14
- @model_name = model_name && model_name.to_s
15
- @modifier_block = block_given? ? block : nil
16
- end
17
- end
18
4
 
19
5
  included do
20
- helper_method :meta_tags, :meta_tags_container, :set_meta_tag,
21
- :meta_tags_data
22
-
23
- after_filter do
24
- meta_tags_container.reset_changed_status if meta_tags_container
25
- end
6
+ helper_method :meta_tags_store
26
7
  end
27
8
 
28
- attr_reader :instance
29
-
30
- def meta_tags_container
31
- @_meta_tags_container ||= ::ApplicationController.meta_tags.dup
9
+ def meta_tags_store
10
+ @meta_tags_store ||= MetaTags::Store.new(self)
32
11
  end
33
12
 
34
- def meta_tags_data
35
- process_meta_tags
36
- meta_tags_container
37
- end
13
+ protected
38
14
 
39
15
  def meta_tags_for(identifier)
40
16
  if identifier.kind_of?(ActiveRecord::Base)
41
17
  @instance = identifier
42
18
  elsif (list = MetaTags::List.where(identifier: identifier.to_s).first)
43
- %w(title description keywords).each do |key|
44
- if (value = list.send(:"meta_#{ key }").presence)
45
- meta_tags_container.send(:"#{ key }=", value)
19
+ [:title, :description, :keywords].each do |tag_name|
20
+ if (value = list.send(:"meta_#{ tag_name }").presence)
21
+ set_meta_tag(tag_name, value)
46
22
  end
47
23
  end
48
24
  end
49
25
  end
50
26
 
51
- def meta_tags(*providers)
52
- options = providers.pop if providers.last.is_a? Hash
53
- charset = options[:encoding] rescue 'utf-8'
54
-
55
- data = meta_tags_data
56
-
57
- # Required meta tags
58
- markup = <<-HTML
59
- <meta charset="#{ charset }">
60
- <title>#{ data.title }</title>
61
- HTML
62
-
63
- if data.keywords.presence
64
- markup << "<meta name=\"keywords\" content=\"#{ data.keywords }\">"
65
- end
66
-
67
- # Default meta tags
68
- markup << markup_from_provider(:default)
69
-
70
- # Meta tags by provider
71
- providers.each do |provider|
72
- str = markup_from_provider provider
73
-
74
- # Prevents same meta tags added twice
75
- markup << str if !markup.include?(str)
76
- end
77
-
78
- markup.html_safe
79
- end
80
-
81
- def markup_from_provider(provider = :default)
82
- tags = case provider.to_sym
83
- when :open_graph
84
- {
85
- title: "property=\"og:title\"",
86
- description: "property=\"og:description\"",
87
- image: "property=\"og:image\"",
88
- type: "property=\"og:type\"",
89
- url: "property=\"og:url\"",
90
- site_name: "property=\"og:site_name\""
91
- }
92
- when :twitter
93
- {
94
- title: "name=\"twitter:title\"",
95
- description: "name=\"twitter:description\"",
96
- image: "name=\"twitter:image\"",
97
- url: "name=\"twitter:url\"",
98
- site: "name=\"twitter:site\"",
99
- card: "name=\"twitter:card\""
100
- }
101
- else
102
- {
103
- description: "name=\"description\"",
104
- }
105
- end
106
-
107
- tags.each_with_object("") do |(key, property_string), buffer|
108
- if (content = meta_tags_container.send(key)).presence
109
- buffer << "<meta #{ property_string } content=\"#{ content }\">\n"
110
- end
111
- end
112
- end
113
-
114
- def process_meta_tags
115
- Container::TAGS_LIST.each do |label|
116
- next if meta_tags_container.send(:"#{ label }_changed?")
117
-
118
- if (data = process_meta_tag(label))
119
- set_meta_tag(label, data)
120
- end
121
- end
122
- end
123
-
124
- def set_meta_tag(key, value, options = {})
125
- if value.presence && !options[:force]
126
- meta_tags_container.send("#{ key }=", value)
127
- end
27
+ def set_meta_tag(tag_name, value)
28
+ meta_tags_store.send(:"#{ tag_name }=", value)
128
29
  end
129
30
  end
130
31
  end
@@ -1,21 +1,21 @@
1
- require "meta_tags/container"
2
- require "meta_tags/page_data_helper"
3
- require "meta_tags/controller"
4
- require "meta_tags/meta_taggable"
5
- require "meta_tags/meta_taggable_macro"
6
-
7
1
  module MetaTags
8
2
  class Railtie < Rails::Engine
9
- initializer "include controller config" do
3
+ initializer "include controller helpers" do
10
4
  ActiveSupport.on_load(:action_controller) do
11
5
  include Controller
12
6
  end
13
7
  end
14
8
 
9
+ initializer "include view helpers" do
10
+ ActiveSupport.on_load(:action_view) do
11
+ include ViewHelpers
12
+ end
13
+ end
14
+
15
15
  initializer "mix meta_taggable macro in Active Record" do
16
16
  ActiveSupport.on_load(:active_record) do
17
17
  include MetaTaggableMacro
18
18
  end
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -17,5 +17,11 @@ module MetaTags
17
17
  def meta_tagged?
18
18
  meta_tags_list.presence
19
19
  end
20
+
21
+ module ClassMethods
22
+ def meta_taggable?
23
+ true
24
+ end
25
+ end
20
26
  end
21
- end
27
+ end
@@ -2,14 +2,18 @@ module MetaTags
2
2
  module MetaTaggableMacro
3
3
  extend ActiveSupport::Concern
4
4
 
5
+ def meta_tagged?
6
+ false
7
+ end
8
+
5
9
  module ClassMethods
6
10
  def acts_as_meta_taggable
7
11
  include MetaTaggable
8
12
  end
9
- end
10
13
 
11
- def meta_tagged?
12
- false
14
+ def meta_taggable?
15
+ false
16
+ end
13
17
  end
14
18
  end
15
- end
19
+ end
@@ -0,0 +1,69 @@
1
+ module MetaTags
2
+ class Renderer
3
+ LINE_SEPARATOR = "\n"
4
+
5
+ attr_reader :template, :vendors
6
+
7
+ delegate :content_tag, :tag, to: :template
8
+
9
+ def initialize(template, vendors: nil)
10
+ @template = template
11
+ @vendors = vendors
12
+ end
13
+
14
+ def render
15
+ [
16
+ charset_tag,
17
+ title_tag,
18
+ description_tag,
19
+ keywords_tag,
20
+ vendor_tags
21
+ ].compact.join(LINE_SEPARATOR).html_safe
22
+ end
23
+
24
+ private
25
+
26
+ def title_tag
27
+ if (title = meta_tags.title).present?
28
+ content_tag(:title, title)
29
+ end
30
+ end
31
+
32
+ def charset_tag
33
+ tag(:meta, charset: meta_tags.charset)
34
+ end
35
+
36
+ def description_tag
37
+ if (description = meta_tags.description).present?
38
+ tag(:meta, name: 'description', value: description)
39
+ end
40
+ end
41
+
42
+ def keywords_tag
43
+ if (keywords = meta_tags.keywords).present?
44
+ tag(:meta, name: 'keywords', value: keywords)
45
+ end
46
+ end
47
+
48
+ def vendor_tags
49
+ return unless vendors
50
+
51
+ vendor_tags = vendors.each_with_object([]) do |vendor_name, tags|
52
+ vendor_class = MetaTags::Vendors.for(vendor_name)
53
+ vendor = vendor_class.new(template)
54
+
55
+ vendor.tags.each do |tag_name|
56
+ if (value = meta_tags.send(tag_name)).present?
57
+ tags << vendor.render(tag_name, value)
58
+ end
59
+ end
60
+ end
61
+
62
+ vendor_tags.join(LINE_SEPARATOR)
63
+ end
64
+
65
+ def meta_tags
66
+ @meta_tags ||= template.controller.meta_tags_store
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,48 @@
1
+ module MetaTags
2
+ class Store
3
+ attr_reader :controller, :defaults
4
+
5
+ TAGS = :title, :description, :image, :url, :site_name, :keywords, :type,
6
+ :site, :card, :charset
7
+
8
+ attr_writer *TAGS
9
+
10
+ def initialize(controller)
11
+ @controller = controller
12
+
13
+ @defaults = if MetaTags.defaults
14
+ controller.instance_exec(&MetaTags.defaults)
15
+ else
16
+ {}
17
+ end
18
+ end
19
+
20
+ def charset
21
+ @charset ||= 'utf-8'
22
+ end
23
+
24
+ TAGS.each do |tag_name|
25
+ define_method(tag_name) do
26
+ fetch_value_for(tag_name)
27
+ end unless method_defined?(tag_name)
28
+ end
29
+
30
+ private
31
+
32
+ def fetch_value_for(tag_name)
33
+ ivar_name = :"@#{ tag_name }"
34
+
35
+ if (value = instance_variable_get(ivar_name)).present?
36
+ value
37
+ else
38
+ value = if (processor = MetaTags::Tags[tag_name])
39
+ processor.new(controller).value
40
+ end
41
+
42
+ value = defaults[tag_name] unless value.present?
43
+
44
+ instance_variable_set(ivar_name, value) if value
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,25 @@
1
+ module MetaTags
2
+ module Tags
3
+ extend ActiveSupport::Autoload
4
+
5
+ autoload :Base
6
+ autoload :Title
7
+ autoload :Description
8
+ autoload :Keywords
9
+ autoload :Image
10
+ autoload :Url
11
+
12
+ def self.[](tag_name)
13
+ processors[tag_name]
14
+ end
15
+
16
+ private
17
+
18
+ def self.processors
19
+ @processors ||= [:title, :description, :keywords, :image, :url].reduce({}) do |hash, tag|
20
+ hash[tag] = MetaTags::Tags.const_get(tag.to_s.camelize)
21
+ hash
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,7 +3,7 @@ module MetaTags
3
3
  class Base
4
4
  attr_accessor :controller
5
5
 
6
- def initialize controller
6
+ def initialize(controller)
7
7
  @controller = controller
8
8
  end
9
9
 
@@ -13,12 +13,11 @@ module MetaTags
13
13
  controller.params.key?(:id)
14
14
  end
15
15
 
16
- def action_i18n label
17
- options = modifier_options.merge(default: "")
18
- I18n.t(action_key(label), options).presence
16
+ def action_i18n(label)
17
+ I18n.t(action_key(label), default: '').presence
19
18
  end
20
19
 
21
- def action_key label
20
+ def action_key(label)
22
21
  key = %w(meta_tags controller)
23
22
  key << controller.params[:controller]
24
23
  key << controller.params[:action]
@@ -26,24 +25,13 @@ module MetaTags
26
25
  key.join(".")
27
26
  end
28
27
 
28
+ # TODO : Define if we'll still support instance meta tags and refactor
29
+ # accordingly
29
30
  def instance
30
- return controller.instance if controller.instance
31
-
32
- @instance ||= if model_name
33
- controller.instance_variable_get(:"@#{ model_name }")
34
- end
35
31
  end
36
32
 
37
33
  def model_name
38
- controller.class.model_name.presence
39
- end
40
-
41
- def modifier_options
42
- @modifier_options ||= if controller.class.modifier_block
43
- instance_eval(&controller.class.modifier_block)
44
- else
45
- {}
46
- end
34
+ @model_name ||= controller.class.name.gsub(/Controller$/, '').singularize.underscore
47
35
  end
48
36
  end
49
37
  end
@@ -5,7 +5,7 @@ module MetaTags
5
5
  class Description < Base
6
6
  include TruncateHtmlHelper
7
7
 
8
- def process!
8
+ def value
9
9
  meta_taggable_description || instance_description || action_name
10
10
  end
11
11
 
@@ -37,4 +37,4 @@ module MetaTags
37
37
  end
38
38
  end
39
39
  end
40
- end
40
+ end
@@ -1,7 +1,7 @@
1
1
  module MetaTags
2
2
  module Tags
3
3
  class Image < Base
4
- def process!
4
+ def value
5
5
  instance_image
6
6
  end
7
7
 
@@ -20,4 +20,4 @@ module MetaTags
20
20
  end
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -1,7 +1,7 @@
1
1
  module MetaTags
2
2
  module Tags
3
3
  class Keywords < Base
4
- def process!
4
+ def value
5
5
  meta_taggable_keywords
6
6
  end
7
7
 
@@ -13,4 +13,4 @@ module MetaTags
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -1,7 +1,7 @@
1
1
  module MetaTags
2
2
  module Tags
3
3
  class Title < Base
4
- def process!
4
+ def value
5
5
  meta_taggable_title || instance_title || action_name || model_name_translation
6
6
  end
7
7
 
@@ -41,4 +41,4 @@ module MetaTags
41
41
  end
42
42
  end
43
43
  end
44
- end
44
+ end
@@ -1,9 +1,9 @@
1
1
  module MetaTags
2
2
  module Tags
3
3
  class Url < Base
4
- def process!
4
+ def value
5
5
  controller.request.original_url
6
6
  end
7
7
  end
8
8
  end
9
- end
9
+ end
@@ -0,0 +1,13 @@
1
+ module MetaTags
2
+ module Vendors
3
+ extend ActiveSupport::Autoload
4
+
5
+ autoload :Base
6
+ autoload :OpenGraph
7
+ autoload :Twitter
8
+
9
+ def self.for(vendor_name)
10
+ const_get(vendor_name.to_s.camelize)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module MetaTags
2
+ module Vendors
3
+ class Base
4
+ attr_reader :template
5
+
6
+ def initialize(template)
7
+ @template = template
8
+ end
9
+
10
+ def render(key, value)
11
+ tag(:meta, key_name => attribute_name_for(key), value: value)
12
+ end
13
+
14
+ protected
15
+
16
+ def attribute_name_for(key)
17
+ [namespace, key].join(':')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module MetaTags
2
+ module Vendors
3
+ class OpenGraph
4
+ def tags
5
+ [:title, :description, :image, :type, :url, :site_name]
6
+ end
7
+
8
+ protected
9
+
10
+ def key_name
11
+ 'property'
12
+ end
13
+
14
+ def namespace
15
+ 'og'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module MetaTags
2
+ module Vendors
3
+ class Twitter
4
+ def tags
5
+ [:title, :description, :image, :url, :site, :card]
6
+ end
7
+
8
+ protected
9
+
10
+ def key_name
11
+ 'name'
12
+ end
13
+
14
+ def namespace
15
+ 'twitter'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module MetaTags
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,7 @@
1
+ module MetaTags
2
+ module ViewHelpers
3
+ def meta_tags(options = {})
4
+ MetaTags::Renderer.new(self, options).render
5
+ end
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Valentin Ballestrino, Damien Corticchiato
7
+ - Valentin Ballestrino
8
+ - Damien Corticchiato
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-05-31 00:00:00.000000000 Z
12
+ date: 2015-06-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: sanitize
@@ -52,7 +53,8 @@ dependencies:
52
53
  - - ">="
53
54
  - !ruby/object:Gem::Version
54
55
  version: '0'
55
- description: 'Simple gem to handle basical title, meta tags and og: tags'
56
+ description: HTML meta tags management for Rails with support for Facebook's OpenGraph
57
+ tags and Twitter cards
56
58
  email:
57
59
  - vala@glyph.fr
58
60
  executables: []
@@ -64,22 +66,28 @@ files:
64
66
  - Rakefile
65
67
  - app/models/meta_tags/list.rb
66
68
  - db/migrate/20140114154410_create_meta_tags_list.rb
67
- - lib/generators/meta_tags/config/config_generator.rb
68
- - lib/generators/meta_tags/config/templates/initializer.rb
69
+ - lib/generators/meta_tags/install/install_generator.rb
70
+ - lib/generators/meta_tags/install/templates/initializer.rb
69
71
  - lib/meta_tags.rb
70
- - lib/meta_tags/container.rb
71
72
  - lib/meta_tags/controller.rb
72
73
  - lib/meta_tags/engine.rb
73
74
  - lib/meta_tags/meta_taggable.rb
74
75
  - lib/meta_tags/meta_taggable_macro.rb
75
- - lib/meta_tags/page_data_helper.rb
76
+ - lib/meta_tags/renderer.rb
77
+ - lib/meta_tags/store.rb
78
+ - lib/meta_tags/tags.rb
76
79
  - lib/meta_tags/tags/base.rb
77
80
  - lib/meta_tags/tags/description.rb
78
81
  - lib/meta_tags/tags/image.rb
79
82
  - lib/meta_tags/tags/keywords.rb
80
83
  - lib/meta_tags/tags/title.rb
81
84
  - lib/meta_tags/tags/url.rb
85
+ - lib/meta_tags/vendors.rb
86
+ - lib/meta_tags/vendors/base.rb
87
+ - lib/meta_tags/vendors/open_graph.rb
88
+ - lib/meta_tags/vendors/twitter.rb
82
89
  - lib/meta_tags/version.rb
90
+ - lib/meta_tags/view_helpers.rb
83
91
  - lib/tasks/meta_tags_tasks.rake
84
92
  - test/dummy/README.rdoc
85
93
  - test/dummy/Rakefile
@@ -155,7 +163,7 @@ files:
155
163
  - test/dummy/tmp/cache/assets/E10/A50/sprockets%2F3ceec61ba671c1fc8fec279989fb9d1d
156
164
  - test/meta_tags_test.rb
157
165
  - test/test_helper.rb
158
- homepage: http://glyph.fr
166
+ homepage: https://github.com/glyph-fr/meta_tags
159
167
  licenses: []
160
168
  metadata: {}
161
169
  post_install_message:
@@ -177,7 +185,7 @@ rubyforge_project:
177
185
  rubygems_version: 2.4.4
178
186
  signing_key:
179
187
  specification_version: 4
180
- summary: 'Simple gem to handle basical title, meta tags and og: tags'
188
+ summary: HTML meta tags management for Rails
181
189
  test_files:
182
190
  - test/dummy/app/assets/images/illustration.jpg
183
191
  - test/dummy/app/assets/javascripts/application.js
@@ -1,67 +0,0 @@
1
- require "sanitize"
2
-
3
- module MetaTags
4
- class Container
5
- attr_accessor :default_title,
6
- :default_description,
7
- :default_image,
8
- :default_url,
9
- :default_site_name,
10
- :default_keywords,
11
- :default_type,
12
- :default_site,
13
- :default_card,
14
- :title_changed,
15
- :description_changed,
16
- :image_changed,
17
- :url_changed,
18
- :site_name_changed,
19
- :keywords_changed,
20
- :type_changed,
21
- :site_changed,
22
- :card_changed
23
-
24
- TAGS_LIST = %w(
25
- title description image url site_name keywords type site card
26
- )
27
-
28
- TAGS_LIST.each do |label|
29
- define_method(label) do
30
- Sanitize.clean(
31
- instance_variable_get(:"@#{ label }") || send(:"default_#{ label }")
32
- )
33
- end
34
-
35
- define_method(:"#{ label }=") do |value|
36
- instance_variable_set(:"@#{ label }_changed", true)
37
- instance_variable_set(:"@#{ label }", value)
38
- end
39
-
40
- define_method(:"#{ label }_changed?") do
41
- !!instance_variable_get(:"@#{ label }_changed")
42
- end
43
- end
44
-
45
- def initialize options
46
- options.each do |label, value|
47
- self.send(:"default_#{ label }=", value)
48
- end
49
- end
50
-
51
- def title=(value)
52
- @title_changed = true
53
- if default_title == value || !MetaTags.keep_default_title_present
54
- @title = value
55
- elsif MetaTags.keep_default_title_present
56
- @title = "#{ value } - #{ default_title }"
57
- end
58
- end
59
-
60
-
61
- def reset_changed_status
62
- TAGS_LIST.each do |label|
63
- self.send(:"#{ label }_changed=", false)
64
- end
65
- end
66
- end
67
- end
@@ -1,23 +0,0 @@
1
- require "meta_tags/tags/base"
2
- require "meta_tags/tags/title"
3
- require "meta_tags/tags/description"
4
- require "meta_tags/tags/keywords"
5
- require "meta_tags/tags/image"
6
- require "meta_tags/tags/url"
7
-
8
- module MetaTags
9
- module PageDataHelper
10
- def process_meta_tag tag
11
- if (processor = processors[tag])
12
- processor.new(self).process!
13
- end
14
- end
15
-
16
- def processors
17
- @processors ||= %w(title description image keywords url).reduce({}) do |hash, tag|
18
- hash[tag] = MetaTags::Tags.const_get(tag.camelize)
19
- hash
20
- end
21
- end
22
- end
23
- end