meta-tags-helpers 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rails'
4
+
5
+ group :development do
6
+ gem "bundler"
7
+ gem "jeweler", "~> 1.8.4"
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,93 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.7)
5
+ actionpack (= 3.2.7)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.7)
8
+ activemodel (= 3.2.7)
9
+ activesupport (= 3.2.7)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.4)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.3)
17
+ activemodel (3.2.7)
18
+ activesupport (= 3.2.7)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.7)
21
+ activemodel (= 3.2.7)
22
+ activesupport (= 3.2.7)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.7)
26
+ activemodel (= 3.2.7)
27
+ activesupport (= 3.2.7)
28
+ activesupport (3.2.7)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ builder (3.0.0)
33
+ erubis (2.7.0)
34
+ git (1.2.5)
35
+ hike (1.2.1)
36
+ i18n (0.6.0)
37
+ jeweler (1.8.4)
38
+ bundler (~> 1.0)
39
+ git (>= 1.2.5)
40
+ rake
41
+ rdoc
42
+ journey (1.0.4)
43
+ json (1.7.4)
44
+ mail (2.4.4)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.19)
49
+ multi_json (1.3.6)
50
+ polyglot (0.3.3)
51
+ rack (1.4.1)
52
+ rack-cache (1.2)
53
+ rack (>= 0.4)
54
+ rack-ssl (1.3.2)
55
+ rack
56
+ rack-test (0.6.1)
57
+ rack (>= 1.0)
58
+ rails (3.2.7)
59
+ actionmailer (= 3.2.7)
60
+ actionpack (= 3.2.7)
61
+ activerecord (= 3.2.7)
62
+ activeresource (= 3.2.7)
63
+ activesupport (= 3.2.7)
64
+ bundler (~> 1.0)
65
+ railties (= 3.2.7)
66
+ railties (3.2.7)
67
+ actionpack (= 3.2.7)
68
+ activesupport (= 3.2.7)
69
+ rack-ssl (~> 1.3.2)
70
+ rake (>= 0.8.7)
71
+ rdoc (~> 3.4)
72
+ thor (>= 0.14.6, < 2.0)
73
+ rake (0.9.2.2)
74
+ rdoc (3.12)
75
+ json (~> 1.4)
76
+ sprockets (2.1.3)
77
+ hike (~> 1.2)
78
+ rack (~> 1.0)
79
+ tilt (~> 1.1, != 1.3.0)
80
+ thor (0.15.4)
81
+ tilt (1.3.3)
82
+ treetop (1.4.10)
83
+ polyglot
84
+ polyglot (>= 0.3.1)
85
+ tzinfo (0.3.33)
86
+
87
+ PLATFORMS
88
+ ruby
89
+
90
+ DEPENDENCIES
91
+ bundler
92
+ jeweler (~> 1.8.4)
93
+ rails
data/README.md CHANGED
@@ -52,10 +52,10 @@ The first example above will produce the following html:
52
52
 
53
53
  ### Setting meta tags from controller/partials/other views
54
54
 
55
- You can get/set some of defautls (see below) through handy helpers within controllers or views:
55
+ You can customize some of defautls (see below) through handy helpers within controllers or views:
56
56
 
57
57
  ``` rb
58
- meta_title(value = nil) # get or set "meta_title" used in defaults
58
+ meta_title(value = nil)
59
59
  meta_description(value = nil)
60
60
  meta_image(value = nil)
61
61
  meta_type(value = nil)
@@ -67,21 +67,22 @@ meta_type(value = nil)
67
67
  This is the default options hash:
68
68
 
69
69
  ``` rb
70
- default = {
71
- :charset => "utf-8",
72
- :"X-UA-Compatible" => "IE=edge,chrome=1",
73
- :viewport => "width=device-width",
74
- :title => meta_title,
75
- :description => meta_description,
76
- :og => {
77
- :url => "#{request.url}",
78
- :type => meta_type || "article",
79
- :title => opts[:title] || meta_title,
80
- :description => opts[:description] || meta_description,
81
- :image => (opts[:og] && opts[:og][:image]) || meta_image
82
- }
83
- }
84
-
70
+ default = {
71
+ :charset => "utf-8",
72
+ :"X-UA-Compatible" => "IE=edge,chrome=1",
73
+ :viewport => "width=device-width",
74
+ :title => meta_title,
75
+ :description => meta_description,
76
+ :og => {
77
+ :url => "#{request.url}",
78
+ :type => meta_type || "article",
79
+ :title => opts[:title] || meta_title,
80
+ :description => opts[:description] || meta_description,
81
+ :image => (opts[:og] && opts[:og][:image]) || meta_image
82
+ },
83
+ :"csrf-param" => request_forgery_protection_token,
84
+ :"csrf-token" => form_authenticity_token
85
+ }
85
86
  ```
86
87
 
87
88
 
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "meta-tags-helpers"
18
+ gem.homepage = "http://github.com/mcasimir/kaminari-bootstrap"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Rails meta tags helpers}
21
+ gem.description = %Q{Rails meta tags helpers}
22
+ gem.email = "maurizio.cas@gmail.com"
23
+ gem.authors = ["mcasimir"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+
29
+ task :push do
30
+ message = ENV["message"] || "commit #{Time.now}"
31
+ `git add . && git commit -a -m '#{message}' && git push`
32
+ end
33
+
34
+ task "release:patch" do
35
+ Rake::Task["gemspec"].invoke
36
+ Rake::Task["version:bump:patch"]
37
+ Rake::Task["push"].invoke
38
+ Rake::Task["release"].invoke
39
+ end
40
+
41
+ task "release:minor" do
42
+ Rake::Task["gemspec"].invoke
43
+ Rake::Task["version:bump:minor"]
44
+ Rake::Task["push"].invoke
45
+ Rake::Task["release"].invoke
46
+ end
47
+
48
+ task "release:major" do
49
+ Rake::Task["gemspec"].invoke
50
+ Rake::Task["version:bump:major"]
51
+ Rake::Task["push"].invoke
52
+ Rake::Task["release"].invoke
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,23 @@
1
+ # Author:: Maurizio Casimirri (mailto:maurizio.cas@gmail.com)
2
+ # Copyright:: Copyright (c) 2012 Maurizio Casimirri
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ require 'meta_tags_helpers'
@@ -0,0 +1,114 @@
1
+ # Author:: Maurizio Casimirri (mailto:maurizio.cas@gmail.com)
2
+ # Copyright:: Copyright (c) 2012 Maurizio Casimirri
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+
24
+ module MetaTagsHelpers
25
+
26
+ module ActionViewExtension
27
+
28
+ def meta_tags(*args)
29
+ opts = args.extract_options!
30
+ default = {
31
+ :charset => "utf-8",
32
+ :"X-UA-Compatible" => "IE=edge,chrome=1",
33
+ :viewport => "width=device-width",
34
+ :title => meta_title,
35
+ :description => meta_description,
36
+ :og => {
37
+ :url => "#{request.url}",
38
+ :type => meta_type || "article",
39
+ :title => opts[:title] || meta_title,
40
+ :description => opts[:description] || meta_description,
41
+ :image => (opts[:og] && opts[:og][:image]) || meta_image
42
+ },
43
+ :"csrf-param" => request_forgery_protection_token,
44
+ :"csrf-token" => form_authenticity_token
45
+ }
46
+
47
+ meta_hash = default.deep_merge(opts)
48
+
49
+ # separates namespaced keys
50
+ namespaces = meta_hash.select { |k,v| v.is_a?(Hash) }
51
+
52
+ # delete nil/false/namespaced keys
53
+ meta_hash.delete_if { |k,v| v.blank? || v == false || v.is_a?(Hash)}
54
+
55
+ namespaces.each { |ns, namespaced|
56
+ namespaced.delete_if { |k,v|
57
+ v.blank? || v == false || v.is_a?(Hash)
58
+ }
59
+ namespaced.each {|k,v|
60
+ meta_hash[:"#{ns}:#{k}"] = v
61
+ }
62
+ }
63
+
64
+ html = ""
65
+ html << "<title>#{h(meta_hash.delete(:title)) }</title>\n"
66
+ meta_hash.each {|k,v|
67
+ html << "<meta name=\"#{h(k)}\" content=\"#{h(v)}\" />\n"
68
+ }
69
+ html.html_safe
70
+ end
71
+
72
+ end
73
+
74
+ module ActionControllerExtension
75
+ extend ActiveSupport::Concern
76
+ included do
77
+ helper_method :meta_title, :meta_description, :meta_image, :meta_type
78
+ end
79
+
80
+ def meta_title(*args)
81
+ if title = args.first
82
+ @meta_title = title
83
+ else
84
+ @meta_title
85
+ end
86
+ end
87
+
88
+ def meta_description(*args)
89
+ if desc = args.first
90
+ @meta_description = desc
91
+ else
92
+ @meta_description
93
+ end
94
+ end
95
+
96
+ def meta_image(*args)
97
+ if img = args.first
98
+ @meta_image = img
99
+ else
100
+ @meta_image
101
+ end
102
+ end
103
+
104
+ def meta_type(*args)
105
+ if t = args.first
106
+ @meta_type = t
107
+ else
108
+ @meta_type
109
+ end
110
+ end
111
+
112
+ end
113
+ ActionController::Base.send :include, MetaTagsHelpers::ActionControllerExtension
114
+ ActionView::Base.send :include, MetaTagsHelpers::ActionViewExtension
@@ -0,0 +1,52 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "meta-tags-helpers"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["mcasimir"]
12
+ s.date = "2012-08-06"
13
+ s.description = "Rails meta tags helpers"
14
+ s.email = "maurizio.cas@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "README.md",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/meta-tags-helpers.rb",
25
+ "lib/meta_tags_helpers.rb",
26
+ "meta-tags-helpers.gemspec"
27
+ ]
28
+ s.homepage = "http://github.com/mcasimir/kaminari-bootstrap"
29
+ s.licenses = ["MIT"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = "1.8.24"
32
+ s.summary = "Rails meta tags helpers"
33
+
34
+ if s.respond_to? :specification_version then
35
+ s.specification_version = 3
36
+
37
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
38
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
39
+ s.add_development_dependency(%q<bundler>, [">= 0"])
40
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
41
+ else
42
+ s.add_dependency(%q<rails>, [">= 0"])
43
+ s.add_dependency(%q<bundler>, [">= 0"])
44
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
45
+ end
46
+ else
47
+ s.add_dependency(%q<rails>, [">= 0"])
48
+ s.add_dependency(%q<bundler>, [">= 0"])
49
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
50
+ end
51
+ end
52
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta-tags-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -66,7 +66,14 @@ extensions: []
66
66
  extra_rdoc_files:
67
67
  - README.md
68
68
  files:
69
+ - Gemfile
70
+ - Gemfile.lock
69
71
  - README.md
72
+ - Rakefile
73
+ - VERSION
74
+ - lib/meta-tags-helpers.rb
75
+ - lib/meta_tags_helpers.rb
76
+ - meta-tags-helpers.gemspec
70
77
  homepage: http://github.com/mcasimir/kaminari-bootstrap
71
78
  licenses:
72
79
  - MIT
@@ -82,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
89
  version: '0'
83
90
  segments:
84
91
  - 0
85
- hash: 2464010401342255116
92
+ hash: -3286765402056605777
86
93
  required_rubygems_version: !ruby/object:Gem::Requirement
87
94
  none: false
88
95
  requirements: