snipp 0.1.1 → 0.1.2

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.
@@ -1,10 +1,14 @@
1
1
  <%
2
2
  set_html_meta({
3
+ og: {
4
+ type: "article"
5
+ },
3
6
  link: {
4
7
  canonical: "http://127.0.0.1/canonical"
5
8
  }
6
9
  }, {
7
- value: "Embedding Values"
10
+ value: "Embedding Values",
11
+ text: "Insert"
8
12
  })
9
13
  %>
10
14
  <h1>Html - Snippets Sample</h1>
@@ -3,17 +3,27 @@ en:
3
3
  meta:
4
4
  title: "Default Title"
5
5
  description: "Default Description"
6
- keywords: "Default Description"
6
+ keywords: "Default Keywords"
7
+ og:
8
+ site_name: "Snipp"
9
+ title: "Default Title for Open Graph"
10
+ description: "Default Description for Open Graph"
11
+ type: "website"
7
12
 
8
13
  views:
9
14
  snipp:
10
15
  html:
11
16
  meta:
12
17
  title: "HTML Title -- %{value}"
18
+ description: "Render from I18n"
19
+ page_title: "HTML Title -- %{value} Page %{page}"
20
+ og:
21
+ title: "Open Graph Title from I18n"
22
+
13
23
  breadcrumb:
14
24
  meta:
15
25
  title: "Snipp"
16
-
26
+
17
27
  breadcrumb:
18
28
  # Sample
19
29
  index: "Top"
@@ -4,6 +4,7 @@ module Snipp
4
4
 
5
5
  def set_html_meta args, options = {}
6
6
  i18n_options = {
7
+ #scope: ([:views].push(*params[:controller].split('/')) << params[:action] << :meta),
7
8
  scope: [:views, params[:controller], params[:action], :meta],
8
9
  default_scope: [:default, :meta]
9
10
  }.merge(options)
@@ -11,8 +12,8 @@ module Snipp
11
12
  link = args.delete(:link)
12
13
  html_meta.merge!(link: link) if link
13
14
 
14
- Snipp.config.html_meta_tags.merge(args).each do |name, content|
15
- value = html_meta_contents(name, content, i18n_options)
15
+ Snipp.config.html_meta_tags.each do |name, content|
16
+ value = html_meta_contents(name, content, args[name], i18n_options)
16
17
  html_meta[name] = value unless value.blank?
17
18
  end
18
19
  end
@@ -40,24 +41,24 @@ module Snipp
40
41
  end
41
42
 
42
43
  meta_link.each do |rel, href|
43
- result << tag(:link, :rel => rel, :href => href) unless href.blank?
44
+ result << tag(:link, rel: rel, href: href) unless href.blank?
44
45
  end
45
46
 
46
47
  result.blank? ? nil : result.html_safe
47
48
  end
48
49
 
49
- private
50
- def html_meta_contents property, content, options = {}
50
+ private
51
+ def html_meta_contents property, content, arg, options = {}
51
52
  result = {}
52
53
  if content.is_a?(Hash)
54
+ opts = options.dup
55
+ opts[:scope] << property
56
+ opts[:default_scope] << property
53
57
  content.each do |key, value|
54
- options = options.dup
55
- options[:scope] << property
56
- options[:default_scope] << property
57
- result[key] = html_meta_contents(key, value, options)
58
+ result[key] = html_meta_contents(key, value, (arg ? arg[key] : nil), opts)
58
59
  end
59
60
  else
60
- result = content
61
+ result = arg||content
61
62
  result = I18n.t(property, options.merge(default: '')) if result.blank?
62
63
  result = I18n.t(property, scope: options[:default_scope], default: '') if result.blank?
63
64
  end
@@ -75,7 +76,7 @@ module Snipp
75
76
  if c.is_a?(Hash)
76
77
  result << build_meta_property_tags(property, c)
77
78
  else
78
- result << tag(:meta, :property => "#{property}", :content => c) unless c.blank?
79
+ result << tag(:meta, property: "#{property}", content: c) unless c.blank?
79
80
  end
80
81
  end
81
82
  end
@@ -1,3 +1,3 @@
1
1
  module Snipp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.description = %q{Search Engine Optimization (SEO) helpers for Ruby on Rails}
12
12
  gem.summary = %q{Let search engines understand the content on your website}
13
13
  gem.homepage = "https://github.com/yulii/snipp"
14
+ gem.license = 'MIT'
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -11,21 +11,25 @@ end
11
11
  app.initialize!
12
12
 
13
13
  # routing
14
- ITEMTYPES = [:index, :html, :breadcrumb, :geo]
14
+ ITEMTYPES = [:index, :html, :breadcrumb, :geo]
15
+ #ACTION_NAME = lambda {|e| "action#{e}" }
15
16
  app.routes.draw do
16
17
 
17
18
  ITEMTYPES.each do |e|
18
19
  get "/#{e}" => "snipp##{e}", as: e
19
20
  end
20
21
 
21
- # HTML Meta Tags
22
- get "/html" => "snipp#html", as: :html
23
-
24
22
  # for Breadcumb
25
23
  get "/foods" => "snipp#breadcrumb", as: :foods
26
24
  get "/foods/fruits" => "snipp#breadcrumb", as: :fruits
27
25
  get "/foods/fruits/:color" => "snipp#breadcrumb", as: :fruits_color
28
26
  get "/foods/fruits/:color/:name" => "snipp#breadcrumb", as: :food
27
+
28
+ # scope "/admin" ,:module=>'admin' ,as: :admin do
29
+ # 10.times do |e|
30
+ # get "/#{ACTION_NAME.call(e)}" => "snipp##{ACTION_NAME.call(e)}"
31
+ # end
32
+ # end
29
33
  end
30
34
 
31
35
  # controllers
@@ -33,13 +37,21 @@ class ApplicationController < ActionController::Base ; end
33
37
 
34
38
  class SnippController < ApplicationController
35
39
 
36
- ITEMTYPES.each do |e|
37
- define_method e do
38
- end
39
- end
40
+ ITEMTYPES.each {|e| define_method(e, lambda {}) }
40
41
 
41
42
  end
42
43
 
44
+ #module Admin
45
+ # class SnippController < ApplicationController
46
+ #
47
+ # 10.times do |e|
48
+ # define_method ACTION_NAME.call(e) do
49
+ # render text: ACTION_NAME.call(e), layout: "application"
50
+ # end
51
+ # end
52
+ #
53
+ # end
54
+ #end
43
55
 
44
56
  # helpers
45
57
  Object.const_set(:ApplicationHelper, Module.new)
@@ -6,10 +6,17 @@ class Snipp::Markup::Html::Spec
6
6
  DEFAULT_SCOPE = [:default, :meta]
7
7
  PAGE_SCOPE = [:views, :snipp, :html, :meta]
8
8
 
9
- META = [
10
- { id: "TDK", title: I18n.t(:title, scope: PAGE_SCOPE, value: "Embedding Values"), description: I18n.t(:description, scope: DEFAULT_SCOPE), keywords: I18n.t(:keywords, scope: DEFAULT_SCOPE) }
11
- ]
12
-
9
+ META = {
10
+ title: I18n.t(:title ,scope: PAGE_SCOPE, value: "Embedding Values"),
11
+ description: I18n.t(:description ,scope: PAGE_SCOPE),
12
+ keywords: I18n.t(:keywords ,scope: DEFAULT_SCOPE)
13
+ }
14
+ OG = {
15
+ site_name: I18n.t("og.site_name" ,scope: DEFAULT_SCOPE),
16
+ title: I18n.t("og.title" ,scope: PAGE_SCOPE ,text: "Insert"),
17
+ description: I18n.t("og.description" ,scope: DEFAULT_SCOPE),
18
+ type: "article"
19
+ }
13
20
  end
14
21
 
15
22
  describe Snipp::Markup::Html do
@@ -17,21 +24,20 @@ describe Snipp::Markup::Html do
17
24
  before do
18
25
  Snipp::Hooks.init
19
26
  visit "/html"
27
+ #puts page.html
20
28
  end
21
29
 
22
- describe "HTML Meta Tags" do
23
-
24
- Snipp::Markup::Html::Spec::META.each do |e|
25
- id = e.delete(:id)
26
- context id do
27
- e.each do |key, value|
28
- it "should have a `#{key}` tag" do
29
- expect(page).to have_selector("meta[name=\"#{key}\"][content=\"#{value}\"]", count: 1)
30
- end
31
- end
30
+ context "HTML Meta Tags" do
31
+ Snipp::Markup::Html::Spec::META.each do |key, value|
32
+ it "should have a `#{key}` tag" do
33
+ expect(page).to have_selector("meta[name=\"#{key}\"][content=\"#{value}\"]", count: 1)
34
+ end
35
+ end
36
+ Snipp::Markup::Html::Spec::OG.each do |key, value|
37
+ it "should have a `og:#{key}` tag" do
38
+ expect(page).to have_selector("meta[property=\"og:#{key}\"][content=\"#{value}\"]", count: 1)
32
39
  end
33
40
  end
34
-
35
41
  end
36
42
 
37
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snipp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-24 00:00:00.000000000 Z
12
+ date: 2013-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -66,7 +66,8 @@ files:
66
66
  - spec/snipp_spec.rb
67
67
  - spec/spec_helper.rb
68
68
  homepage: https://github.com/yulii/snipp
69
- licenses: []
69
+ licenses:
70
+ - MIT
70
71
  post_install_message:
71
72
  rdoc_options: []
72
73
  require_paths: