snipp 0.1.2 → 0.1.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3fe28bcb97c4bfddc6f9f3af0ab3352ab44a9022
4
+ data.tar.gz: 37378dcaf3d98fff4233e99f124b9d0abcde804a
5
+ SHA512:
6
+ metadata.gz: d44c1a42af362498e15a06ecdb1c7945c57e6a183b70e5e4f383ade7fce119b97a4c16711b7a39541713966bcf6aa593a42e435f5e03690bf73deeb53bc57863
7
+ data.tar.gz: b6a6566047313f3fca18a54363ae03b3161204dcd2d89fbad7dc0e76f51116cafacaa8ab44652567006e5320c5215b0a30c531b06d8fe8e8e50a5a6c2970fa57
data/README.md CHANGED
@@ -10,23 +10,15 @@ Search Engine Optimization (SEO) helpers for Ruby on Rails
10
10
  - Rich snippets and structured data
11
11
 
12
12
  ## Installation
13
-
14
- Add this line to your application's Gemfile:
13
+ Add the "snipp" to your application's Gemfile:
15
14
 
16
15
  ```ruby
17
16
  gem 'snipp'
18
17
  ```
19
- And then execute:
20
- ```sh
21
- $ bundle
22
- ```
23
- Or install it yourself as:
24
- ```sh
25
- $ gem install snipp
26
- ```
27
- ## Usage
28
- ### HTML Meta Tags
29
- Call `html_meta_tags` in an view template
18
+ And run `bundle install` command.
19
+
20
+ ## HTML Meta Tags
21
+ Call `html_meta_tags` in a view template.
30
22
  ```html+ruby
31
23
  <!DOCTYPE html>
32
24
  <html>
@@ -39,8 +31,16 @@ Call `html_meta_tags` in an view template
39
31
  ...
40
32
  ```
41
33
 
42
- #### Contents
43
- direct set
34
+ ### Set content attribute values
35
+ The priority of setting values
36
+
37
+ 1. Call `set_html_meta`
38
+ 2. Use I18n dictionary (controller action scope)
39
+ 3. Use I18n dictionary (default scope)
40
+ 4. Set Snipp.config.html_meta_tags
41
+
42
+ #### Use helper
43
+ Call `set_html_meta` in a view.
44
44
  ```ruby
45
45
  set_html_meta({
46
46
  title: "Page Title",
@@ -57,7 +57,8 @@ set_html_meta({
57
57
  })
58
58
  ```
59
59
 
60
- controller/action
60
+ #### User I18n dictionary files
61
+ for each controller action
61
62
  ```ruby
62
63
  I18n.t(:title, scope: [:views, params[:controller], params[:action], :meta])
63
64
  ```
@@ -72,7 +73,7 @@ For more information
72
73
  - read locale files in [`config/locales`](https://github.com/yulii/snipp/tree/master/app/views/snipp)
73
74
 
74
75
 
75
- ### Rich Snippets
76
+ ## Rich Snippets
76
77
  Call `item_tag` like `content_tag`
77
78
 
78
79
  ```html+ruby
@@ -99,7 +100,7 @@ This would output
99
100
  </div>
100
101
  ```
101
102
 
102
- #### Breadcrumbs
103
+ ### Breadcrumbs
103
104
  1. Define naming routes. You can specify a name for any route using the :as option in Rails Application.
104
105
  2. Setup the Rails Application for Internationalization (i18n).
105
106
  3. Call `breadcrumb` method.
@@ -120,14 +121,14 @@ en:
120
121
  Link to `root_path`, `food_path`, `food_fruit_path`.
121
122
 
122
123
 
123
- ##### Change the separator
124
+ #### Change the separator
124
125
  Use the :s or :separator option.
125
126
 
126
127
  ```html+ruby
127
128
  <%= breadcrumb [:index, :foods, :fruits], s: "/" %>
128
129
  ```
129
130
 
130
- ##### Use variables and Customize labels
131
+ #### Use variables and Customize labels
131
132
 
132
133
  ```html+ruby
133
134
  <%= breadcrumb [:index, :foods, :fruits, { path: fruits_color_path('Red'), label: 'Red' }, { path: food_path(color: 'Red', name: 'Apple'), label: 'Apple' }], s: "/" %>
@@ -4,8 +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),
8
- scope: [:views, params[:controller], params[:action], :meta],
7
+ scope: (([:views] + params[:controller].split('/')) << params[:action] << :meta),
9
8
  default_scope: [:default, :meta]
10
9
  }.merge(options)
11
10
 
@@ -18,6 +17,16 @@ module Snipp
18
17
  end
19
18
  end
20
19
 
20
+ def set_html_meta! args
21
+ @html_meta = {}
22
+ link = args.delete(:link)
23
+ html_meta.merge!(link: link) if link
24
+
25
+ args.each do |name, content|
26
+ html_meta[name] = html_meta_contents(name, content, content, {}) if content
27
+ end
28
+ end
29
+
21
30
  def html_meta_tags
22
31
  result = ''
23
32
  set_html_meta({}) if html_meta.empty?
@@ -1,3 +1,3 @@
1
1
  module Snipp
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  describe Snipp::ActionViewExtension do
5
5
 
6
6
  before do
7
- Snipp::Hooks.init
7
+ # Snipp::Hooks.init
8
8
  end
9
9
 
10
10
  end
@@ -0,0 +1,28 @@
1
+ # coding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe Snipp::Hooks do
5
+
6
+ let(:execute) { lambda { Snipp::Hooks.init } }
7
+
8
+ context "when calls `Snipp::Hooks.init`" do
9
+ it { expect(execute).not_to raise_error }
10
+ end
11
+
12
+ context "when `Snipp.config.markup` is invalid" do
13
+ before do
14
+ Snipp.configure do |config|
15
+ config.markup = :undefined
16
+ end
17
+ end
18
+
19
+ it { expect(execute).to raise_error(NotImplementedError) }
20
+ end
21
+
22
+ after do
23
+ Snipp.configure do |config|
24
+ config.markup = :microdata
25
+ end
26
+ end
27
+
28
+ end
@@ -17,6 +17,9 @@ class Snipp::Markup::Html::Spec
17
17
  description: I18n.t("og.description" ,scope: DEFAULT_SCOPE),
18
18
  type: "article"
19
19
  }
20
+ LINK = {
21
+ canonical: 'http://127.0.0.1/canonical'
22
+ }
20
23
  end
21
24
 
22
25
  describe Snipp::Markup::Html do
@@ -38,6 +41,11 @@ describe Snipp::Markup::Html do
38
41
  expect(page).to have_selector("meta[property=\"og:#{key}\"][content=\"#{value}\"]", count: 1)
39
42
  end
40
43
  end
44
+ Snipp::Markup::Html::Spec::LINK.each do |key, value|
45
+ it "should have a `link[rel=\"#{key}\"]` tag" do
46
+ expect(page).to have_selector("link[rel=\"#{key}\"][href=\"#{value}\"]", count: 1)
47
+ end
48
+ end
41
49
  end
42
50
 
43
51
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snipp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - yulii
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-31 00:00:00.000000000 Z
11
+ date: 2013-09-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.2.11
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.2.11
30
27
  description: Search Engine Optimization (SEO) helpers for Ruby on Rails
@@ -60,6 +57,7 @@ files:
60
57
  - snipp.gemspec
61
58
  - spec/fake_rails.rb
62
59
  - spec/snipp/helpers/action_view_extension_spec.rb
60
+ - spec/snipp/hooks_spec.rb
63
61
  - spec/snipp/markups/html_spec.rb
64
62
  - spec/snipp/markups/microdata/breadcrumb_spec.rb
65
63
  - spec/snipp/markups/microdata/geo_spec.rb
@@ -68,31 +66,31 @@ files:
68
66
  homepage: https://github.com/yulii/snipp
69
67
  licenses:
70
68
  - MIT
69
+ metadata: {}
71
70
  post_install_message:
72
71
  rdoc_options: []
73
72
  require_paths:
74
73
  - lib
75
74
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
75
  requirements:
78
- - - ! '>='
76
+ - - '>='
79
77
  - !ruby/object:Gem::Version
80
78
  version: '0'
81
79
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
80
  requirements:
84
- - - ! '>='
81
+ - - '>='
85
82
  - !ruby/object:Gem::Version
86
83
  version: '0'
87
84
  requirements: []
88
85
  rubyforge_project:
89
- rubygems_version: 1.8.24
86
+ rubygems_version: 2.0.7
90
87
  signing_key:
91
- specification_version: 3
88
+ specification_version: 4
92
89
  summary: Let search engines understand the content on your website
93
90
  test_files:
94
91
  - spec/fake_rails.rb
95
92
  - spec/snipp/helpers/action_view_extension_spec.rb
93
+ - spec/snipp/hooks_spec.rb
96
94
  - spec/snipp/markups/html_spec.rb
97
95
  - spec/snipp/markups/microdata/breadcrumb_spec.rb
98
96
  - spec/snipp/markups/microdata/geo_spec.rb