metag 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (C) 2012 Kevin Sołtysiak <soltysiak.kevin@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # Metag
2
+
3
+ This gem provides ActionView helpers to ease the use of `meta` tags.
4
+ It also provides helpers ready to use for
5
+ [Open Graph tags](https://developers.facebook.com/docs/opengraph/objects/)
6
+ and [Twitter Cards tags](https://dev.twitter.com/docs/cards).
7
+
8
+ ## Usage
9
+
10
+ Several helpers are available :
11
+
12
+ ### meta_tag
13
+
14
+ Generic helper. The last argument given (exception made of hashes)
15
+ will be used as `content`, while the others will be joined in order
16
+ to form the `property`. You can pass `separator: ':'` as last argument
17
+ to change the default separator (which is ':').
18
+
19
+ ```ruby
20
+ meta_tag :name, :value
21
+ => "<meta content=\"value\" property=\"name\" />"
22
+
23
+ meta_tag :name, :of, :my, :property, :value
24
+ => "<meta content=\"value\" property=\"name:of:my:property\" />"
25
+
26
+ meta_tag :name, :of, :my, :property, :value, separator: '/'
27
+ => "<meta content=\"value\" property=\"name/of/my/property\" />"
28
+ ````
29
+
30
+ ### Variants
31
+
32
+ Three others helpers are available: `facebook_tag`, `opengraph_tag`,
33
+ and `twitter_tag` (they're respectively aliased to `fb_tag`, `og_tag`,
34
+ and `tw_tag`). They're just sugar for `meta_tag` with the first argument
35
+ set as `fb`, `og`, and `twitter` respectively.
36
+
37
+ ## Questions, Feedback
38
+ Feel free to pint me on Twitter (@ksol).
39
+
40
+ ## Contributing
41
+ I don't think there's a lot much to do on this, but hey. If you have any idea
42
+ of improvement, or anything else, you can use the issues. Or you can just
43
+ fork, fix, then send me a pull request.
44
+
45
+ ## Copyright
46
+ See MIT.md for further details.
@@ -0,0 +1 @@
1
+ require 'metag/railtie' if defined? Rails
@@ -0,0 +1,13 @@
1
+ require 'metag/tag'
2
+ require 'metag/sugar'
3
+
4
+ module Metag #:nodoc:
5
+ class Railtie < ::Rails::Railtie #:nodoc:
6
+ initializer 'meta-helper.initialize' do
7
+ ActiveSupport.on_load(:action_view) do
8
+ ::ActionView::Base.send :include, Metag::Tag
9
+ ::ActionView::Base.send :include, Metag::Sugar
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ require 'metag/tag'
2
+
3
+ module Metag #:nodoc:
4
+ module Sugar
5
+ def facebook_tag(*args)
6
+ meta_tag :fb, *args
7
+ end
8
+ alias :fb_tag :facebook_tag
9
+
10
+ def opengraph_tag(*args)
11
+ meta_tag :og, *args
12
+ end
13
+ alias :og_tag :opengraph_tag
14
+
15
+ def twitter_tag(*args)
16
+ meta_tag :twitter, *args
17
+ end
18
+ alias :tw_tag :twitter_tag
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module Metag #:nodoc:
2
+ module Tag
3
+ def meta_tag(*args)
4
+ # Handle options
5
+ options = args.pop if args.last.is_a?(Hash)
6
+ options = (options || {}).reverse_merge(separator: ':')
7
+
8
+ # Ensure the presence of at least 2 args (property & content)
9
+ if (size = args.size) < 2
10
+ raise ArgumentError, "wrong number of arguments(#{size} for 2)"
11
+ end
12
+
13
+ # Meta tag attributes
14
+ attrs = {}
15
+ attrs[:content] = args.pop
16
+ attrs[:property] = args.map(&:to_s).join(options[:separator])
17
+
18
+ tag :meta, attrs
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Metag #:nodoc:
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'metag/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "metag"
7
+ s.version = Metag::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.license = "MIT"
10
+ s.authors = ["Kevin Sołtysiak"]
11
+ s.email = ["soltysiak.kevin@gmail.com"]
12
+ s.description = "This library provides ActionView helpers for meta tags generation"
13
+ s.summary = "Meta tags generation helpers"
14
+ s.homepage = "https://github.com/ksol/metag"
15
+ s.files = `git ls-files`.split("\n")
16
+ s.require_paths = ["lib"]
17
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metag
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kevin Sołtysiak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-14 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: This library provides ActionView helpers for meta tags generation
15
+ email:
16
+ - soltysiak.kevin@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - MIT.md
22
+ - README.md
23
+ - lib/metag.rb
24
+ - lib/metag/railtie.rb
25
+ - lib/metag/sugar.rb
26
+ - lib/metag/tag.rb
27
+ - lib/metag/version.rb
28
+ - metag.gemspec
29
+ homepage: https://github.com/ksol/metag
30
+ licenses:
31
+ - MIT
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 1.8.24
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Meta tags generation helpers
54
+ test_files: []