para-seo_tools 0.4.6 → 0.5.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: 963b8c1e96cb711ed75e3331dc352557be853672
4
- data.tar.gz: b22ecd8d54cf19e155e598eaafded1204292e664
3
+ metadata.gz: 7897b0a3299f5d4e457e8eba6b499c24e7a0b2c0
4
+ data.tar.gz: d5356532cdaeb00740c523d945665a5f945fcf56
5
5
  SHA512:
6
- metadata.gz: ec6e122729a5b47932f5659c5a53e11b04360b97819efc6e93939216cab0b412b3bebd4c57aff4913cbfeb74a4c366c34198b9b8f7270fee69f51b5dbfac6bb4
7
- data.tar.gz: 94f0d7408d3a93399a80e248d84d7947cb300f0cdc97f897a5a55f16b283e630f57b954e8d583ca16652ee5ac7ff3413ac1af8d94569d91a00195c6478c7820f
6
+ metadata.gz: 2f21f538ce3f45348d99cbc0936bda4f9699f8bf8bf137cffb368ccfb8b18aaedb3484e565a194ad03f09a2bfb0de4ea37dfce2b7527f8cf24cfe885006c2480
7
+ data.tar.gz: a79fb1e83edf1f3c587d109910ec1af1ffc8beabeb683ae3637139eb34da1c7c47f6133bc75d13668906e27f383b8b1375a22c41d04c1b20bc93e5cefc696f30
data/README.md CHANGED
@@ -11,7 +11,7 @@ for filling out all the pages' meta tags.
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'seo_tools-para'
14
+ gem 'para-seo_tools'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -29,7 +29,7 @@ gem install seo_tools-para
29
29
  Run the installation generator :
30
30
 
31
31
  ```bash
32
- rails generate seo_tools:install
32
+ rails generate para:seo_tools:install
33
33
  ```
34
34
 
35
35
  ## Usage
@@ -48,7 +48,7 @@ In the following section, you'll find how to :
48
48
 
49
49
  ### 1. Define the sitemap
50
50
 
51
- When you run the `seo_tools:install` generator, a file is created at
51
+ When you run the `para:seo_tools:install` generator, a file is created at
52
52
  `config/skeleton.rb` for you to create the sitemap.
53
53
 
54
54
  This file allows you to define which pages you want to make available for
@@ -233,7 +233,7 @@ end
233
233
  Then use the following rake task :
234
234
 
235
235
  ```bash
236
- rake seo_tools:skeleton:build
236
+ rake para:seo_tools:skeleton:build
237
237
  ```
238
238
 
239
239
  #### Domain and subdomains handling
@@ -1,10 +1,10 @@
1
- %ul.panel-controls
1
+ %ul.actions-control
2
2
  %li
3
- = link_to run_admin_skeleton_refresh_path, class: 'btn btn-default', remote: true, data: { :'job-tracker-button' => true } do
3
+ = link_to run_admin_skeleton_refresh_path, class: 'btn btn-default btn-shadow', remote: true, data: { :'job-tracker-button' => true } do
4
4
  = fa_icon 'refresh'
5
5
  = t('para.seo_tools.pages.refresh_skeleton')
6
6
 
7
7
  %li
8
- = link_to ping_admin_skeleton_refresh_path, class: 'btn btn-default', remote: true, data: { :'job-tracker-button' => true } do
8
+ = link_to ping_admin_skeleton_refresh_path, class: 'btn btn-default btn-shadow', remote: true, data: { :'job-tracker-button' => true } do
9
9
  = fa_icon 'cloud-upload'
10
10
  = t('para.seo_tools.pages.ping_search_engines')
@@ -1,18 +1,16 @@
1
1
  = search_form_for @q, builder: SimpleForm::FormBuilder, url: @component.path, html: { data: { :'filters-form' => true } } do |form|
2
- %table
3
- %tbody
4
- %tr
5
- - if Para::SeoTools.handle_subdomain
6
- %td{ width: '15%', style: 'padding-right: 10px;' }
7
- = form.input_field :subdomain_eq, as: :selectize, collection: Para::SeoTools::Page.available_subdomains, class: 'form-control', placeholder: t('para.seo_tools.pages.subdomain')
8
- - if @available_locales.length > 1
9
- %td{ width: '15%', style: 'padding-right: 10px;' }
10
- = form.input_field :locale_eq, as: :selectize, collection: @available_locales, class: 'form-control', placeholder: t('para.seo_tools.pages.choose_locale')
11
- %td{ width: '80%' }
12
- .col-sm-12
13
- .input-group
14
- %span.input-group-addon
15
- %i.fa.fa-search
16
- = form.input_field :identifier_or_path_or_title_or_description_or_keywords_or_canonical_cont, as: :string, placeholder: t('para.shared.search'), class: 'form-control'
17
- %td{ width: '20%' }
18
- = form.submit t('para.shared.search'), class: 'btn btn-default btn-block'
2
+
3
+ - if Para::SeoTools.handle_subdomain
4
+ .flextable-item
5
+ = form.input_field :subdomain_eq, as: :selectize, collection: Para::SeoTools::Page.available_subdomains, class: 'form-control', placeholder: t('para.seo_tools.pages.subdomain')
6
+
7
+ - if @available_locales.length > 1
8
+ .flextable-item
9
+ = form.input_field :locale_eq, as: :selectize, collection: @available_locales, class: 'form-control', placeholder: t('para.seo_tools.pages.choose_locale')
10
+
11
+ .flextable-item.flextable-primary
12
+ .input-group.filter-form
13
+ = form.input_field :identifier_or_path_or_title_or_description_or_keywords_or_canonical_cont, as: :string, placeholder: t('para.shared.search'), class: 'form-control'
14
+ .input-group-btn
15
+ %button.btn{ type: 'submit' }
16
+ = fa_icon 'search'
@@ -1,13 +1,14 @@
1
1
  = para_form_for(resource) do |form|
2
- = form.fieldset do
3
- = form.input :path, disabled: true
2
+ = form.tabs do |tabs|
3
+ = tabs.tab :informations, icon: 'info-circle' do
4
+ = form.input :path, disabled: true
4
5
 
5
- = meta_tag_input form, :title
6
- = meta_tag_input form, :description
7
- = meta_tag_input form, :keywords
6
+ = meta_tag_input form, :title
7
+ = meta_tag_input form, :description
8
+ = meta_tag_input form, :keywords
8
9
 
9
- = form.fieldset title: t('para.seo_tools.pages.additional_meta_tags') do
10
- = meta_tag_input form, :image, as: :image
11
- = meta_tag_input form, :canonical
10
+ = tabs.tab :additional_meta_tags, icon: 'cog' do
11
+ = meta_tag_input form, :image, as: :image, hint: t('para.seo_tools.pages.image_hint')
12
+ = meta_tag_input form, :canonical, hint: t('para.seo_tools.pages.canonical_hint')
12
13
 
13
14
  = form.actions
@@ -5,7 +5,7 @@
5
5
  = table.header_for(:title)
6
6
  = table.header_for(:description)
7
7
  = table.header_for(:locale) if @available_locales.length > 1
8
- %th
8
+ %th.table-row-actions
9
9
 
10
10
  = table.rows(resources) do |resource|
11
11
  = table.data_for(resource.subdomain) if Para::SeoTools.handle_subdomain
@@ -14,9 +14,8 @@
14
14
  = table.data_for(resource.meta_tag(:description))
15
15
  = table.data_for(resource, :locale) if @available_locales.length > 1
16
16
 
17
- %td
18
- .pull-right.btn-group
19
- = table.edit_button(resource)
17
+ %td.table-row-actions
18
+ = table.edit_button(resource)
20
19
 
21
- = link_to resource.path, target: '_blank', class: 'btn btn-default hint--left', data: { hint: t('para.seo_tools.pages.see_in_app') } do
22
- = fa_icon 'eye'
20
+ = link_to resource.path, target: '_blank', class: 'btn btn-sm btn-icon-default btn-shadow hint--left', aria: { label: t('para.seo_tools.pages.see_in_app') } do
21
+ = fa_icon 'eye'
@@ -4,11 +4,16 @@ fr:
4
4
  pages:
5
5
  see_in_app: "Voir la page"
6
6
  default_meta_tag_value: "Valeur par défaut : <b>%{value}</b>"
7
- additional_meta_tags: "Meta-données avancées"
8
7
  refresh_skeleton: "Mettre à jour"
9
8
  ping_search_engines: "Envoyer le sitemap aux moteurs de recherche"
10
9
  choose_locale: "Choisissez une langue"
11
10
  subdomain: Sous-domaine
11
+ image_hint: |
12
+ Cette image sera utilisée par défaut comme prévisualisation de la page
13
+ lors de son partage sur les réseaux sociaux.
14
+ canonical_hint: |
15
+ Si la page ne doit pas être référencée au profit d'une autre page,
16
+ collez ici l'adresse de la page à référencer à la place.
12
17
 
13
18
  jobs:
14
19
  para/seo_tools/skeleton/job:
@@ -18,6 +23,16 @@ fr:
18
23
  progressing: "Le plan du site est actuellement envoyé aux différents moteurs de recherche ..."
19
24
  success: "Le plan du site a bien été transmis aux moteurs de recherche !"
20
25
 
26
+ components:
27
+ component:
28
+ sitemap: "Gestion SEO / Plan du site"
29
+
30
+ forms:
31
+ tabs:
32
+ para/seo_tools/page:
33
+ informations: "Informations"
34
+ additional_meta_tags: "Meta-données avancées"
35
+
21
36
  activemodel:
22
37
  models:
23
38
  para/seo_tools/skeleton/job: "Mise à jour du plan du site"
@@ -31,8 +46,8 @@ fr:
31
46
  title: "Titre"
32
47
  description: "Description"
33
48
  keywords: "Mots-clés de la page"
34
- image: "Image pour le partage sur les réseaux sociaux"
35
- canonical: "URL canonique"
49
+ image: "Image pour le partage"
50
+ canonical: "URL canonique (Canonical)"
36
51
  locale: "Langue"
37
52
  subdomain: "Sous-domaine"
38
53
 
@@ -1,11 +1,11 @@
1
1
  # Use `lazy: true` to avoid generating the pages skeleton on server run
2
2
  #
3
- # You'll then have to run `rake seo_tools:skeleton:build` to refresh it or use
4
- # the `Para::SeoTools::Skeleton::Job.perform` method in some worker to
3
+ # You'll then have to run `rake para:seo_tools:skeleton:build` to refresh it or
4
+ # use the `Para::SeoTools::Skeleton::Job.perform` method in some worker to
5
5
  # refresh it periodically
6
6
  #
7
7
  # Note that you also have to always refresh the sitemap manually with the
8
- # following task : `rake seo_tools:sitemap:generate`
8
+ # following task : `rake para:seo_tools:sitemap:generate`
9
9
  #
10
10
  Para::SeoTools::Skeleton.draw(lazy: false) do
11
11
  # Define your website SEO targetted structure here.
@@ -16,11 +16,13 @@ Para::SeoTools::Skeleton.draw(lazy: false) do
16
16
  #
17
17
  # page :posts
18
18
  #
19
+ #
19
20
  # If you want to define the page path yourself, just add the `:path` option
20
21
  # to the `page` call
21
22
  #
22
23
  # page :home, path: root_path
23
24
  #
25
+ #
24
26
  # When the page is linked to a resource : often, a #show page, you'll need to
25
27
  # pass the `:resource` option
26
28
  #
@@ -28,10 +30,36 @@ Para::SeoTools::Skeleton.draw(lazy: false) do
28
30
  # page :post, resource: post
29
31
  # end
30
32
  #
33
+ #
31
34
  # Also, you can pass options for the sitemap generation tool.
32
35
  # The options are `:priority`, `:change_frequency` which are left blank
33
36
  # by default.
34
37
  #
35
38
  # page :posts, priority: 1, change_frequency: 'weekly'
36
39
  #
40
+ #
41
+ # By default, when you pass a resource to a route, it will try to find
42
+ # default a title and description from your resource, using the method
43
+ # configured in the seo_tools.rb initializer at `config.title_methods` and
44
+ # `config.description_methods`.
45
+ #
46
+ # For non-resource pages or if you need to add your own defaults, you can
47
+ # pass them to the `#page` method the following way :
48
+ #
49
+ # page :posts, defaults: { title: 'Blog index', description: 'Read our blog ...' }
50
+ # page :post, resource: post, defaults: { description: post.excerpt }
51
+ #
52
+ #
53
+ # By default, every page that is not referenced in the skeleton will not be
54
+ # indexed by search engines.
55
+ #
56
+ # But if some of your skeleton pages shouldn't be
57
+ # indexed or links shouldn't be followed on that page, you can explicitly pass
58
+ # the `:noindex` and `:nofollow` options to the `#page` method.
59
+ #
60
+ # It allows to let the admins edit the page title but avoids it to be indexed.
61
+ #
62
+ # page :posts, noindex: true
63
+ # page :report_abuse, noindex: true, nofollow: true
64
+ #
37
65
  end
@@ -16,7 +16,7 @@ module Para
16
16
  protected
17
17
 
18
18
  def meta_tags_from(resource)
19
- @instance = resource
19
+ @resource = resource
20
20
  end
21
21
 
22
22
  def set_meta_tags_from_page(page)
@@ -5,6 +5,7 @@ module Para
5
5
 
6
6
  autoload :PageHelper
7
7
  autoload :ViewHelper
8
+ autoload :DefaultDataMethodsHelper
8
9
  end
9
10
  end
10
11
  end
@@ -0,0 +1,31 @@
1
+ module Para
2
+ module SeoTools
3
+ module Helpers
4
+ module DefaultDataMethodsHelper
5
+ def default_title_for(resource)
6
+ default_data_from_method_for(:title, resource)
7
+ end
8
+
9
+ def default_description_for(resource)
10
+ default_data_from_method_for(:description, resource)
11
+ end
12
+
13
+ def default_image_for(resource)
14
+ default_data_from_method_for(:image, resource)
15
+ end
16
+
17
+ # Try all default methods on resource
18
+ def default_data_from_method_for(method, resource)
19
+ return unless resource
20
+
21
+ Para::SeoTools.send(:"#{ method }_methods").each do |method|
22
+ data = resource.try(method)
23
+ return data if data.present?
24
+ end
25
+ # Avoid returning the methods enumerable returned by the #each call
26
+ nil
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -21,7 +21,8 @@ module Para
21
21
  keywords_tag,
22
22
  canonical_tag,
23
23
  vendor_tags,
24
- hreflang_tags
24
+ hreflang_tags,
25
+ index_tags
25
26
  ].flatten.compact.join(LINE_SEPARATOR).html_safe
26
27
  end
27
28
 
@@ -81,6 +82,19 @@ module Para
81
82
  end
82
83
  end
83
84
 
85
+ def index_tags
86
+ noindex = !meta_tags.page || meta_tags.page.config['noindex']
87
+ nofollow = meta_tags.page && meta_tags.page.config['nofollow']
88
+
89
+ if noindex || nofollow
90
+ content = []
91
+ content << 'noindex' if noindex
92
+ content << 'nofollow' if nofollow
93
+
94
+ tag(:meta, name: 'robots', content: content.join(','))
95
+ end
96
+ end
97
+
84
98
  def meta_tags
85
99
  @meta_tags ||= template.controller.meta_tags_store
86
100
  end
@@ -34,9 +34,9 @@ module Para
34
34
  key.join(".")
35
35
  end
36
36
 
37
- # TODO : Define if we'll still support instance meta tags and refactor
37
+ # TODO : Define if we'll still support resource meta tags and refactor
38
38
  # accordingly
39
- def instance
39
+ def resource
40
40
  end
41
41
 
42
42
  def model_name
@@ -3,9 +3,11 @@ module Para
3
3
  module MetaTags
4
4
  module Tags
5
5
  class Description < Base
6
+ include Para::SeoTools::Helpers::DefaultDataMethodsHelper
7
+
6
8
  def value
7
9
  self.class.process(
8
- meta_taggable_description || instance_description || action_name
10
+ meta_taggable_description || resource_description || action_name
9
11
  )
10
12
  end
11
13
 
@@ -16,22 +18,12 @@ module Para
16
18
  private
17
19
 
18
20
  def meta_taggable_description
19
- instance && instance.meta_tagged? &&
20
- instance.meta_tags_list.meta_description.presence
21
+ resource && resource.meta_tagged? &&
22
+ resource.meta_tags_list.meta_description.presence
21
23
  end
22
24
 
23
- def instance_description
24
- if instance
25
- Para::SeoTools.description_methods.each do |method|
26
- if instance.respond_to?(method)
27
- if (description = instance.send(method).presence)
28
- return description
29
- end
30
- end
31
- end
32
-
33
- return nil
34
- end
25
+ def resource_description
26
+ default_description_for(resource)
35
27
  end
36
28
 
37
29
  def action_name
@@ -4,7 +4,7 @@ module Para
4
4
  module Tags
5
5
  class Image < Base
6
6
  def value
7
- self.class.process(instance_image)
7
+ self.class.process(resource_image)
8
8
  end
9
9
 
10
10
  def self.process(value)
@@ -23,16 +23,8 @@ module Para
23
23
 
24
24
  private
25
25
 
26
- def instance_image
27
- if member_action?
28
- Para::SeoTools.image_methods.each do |method|
29
- if instance.respond_to?(method) && instance.send(method)
30
- return instance.send(method).url
31
- end
32
- end
33
-
34
- nil
35
- end
26
+ def resource_image
27
+ default_image_for(resource).try(:url)
36
28
  end
37
29
 
38
30
  def self.url_from(value)
@@ -10,8 +10,8 @@ module Para
10
10
  private
11
11
 
12
12
  def meta_taggable_keywords
13
- instance && instance.meta_tagged? &&
14
- instance.meta_tags_list.meta_keywords.presence
13
+ resource && resource.meta_tagged? &&
14
+ resource.meta_tags_list.meta_keywords.presence
15
15
  end
16
16
  end
17
17
  end
@@ -3,26 +3,21 @@ module Para
3
3
  module MetaTags
4
4
  module Tags
5
5
  class Title < Base
6
+ include Para::SeoTools::Helpers::DefaultDataMethodsHelper
7
+
6
8
  def value
7
- meta_taggable_title || instance_title || action_name || model_name_translation
9
+ meta_taggable_title || resource_title || action_name || model_name_translation
8
10
  end
9
11
 
10
12
  private
11
13
 
12
14
  def meta_taggable_title
13
- instance && instance.meta_tagged? &&
14
- instance.meta_tags_list.meta_title.presence
15
+ resource && resource.meta_tagged? &&
16
+ resource.meta_tags_list.meta_title.presence
15
17
  end
16
18
 
17
- def instance_title
18
- if instance
19
- Para::SeoTools.title_methods.each do |method|
20
- if instance.respond_to?(method) && (title = instance.send(method)).presence
21
- return title
22
- end
23
- end
24
- return nil
25
- end
19
+ def resource_title
20
+ default_title_for(resource)
26
21
  end
27
22
 
28
23
  def action_name
@@ -10,8 +10,11 @@ module Para
10
10
  prepare
11
11
 
12
12
  SitemapGenerator::Sitemap.create do
13
- Para::SeoTools::Page.where('path ~* ?', Para::SeoTools.sitemap_path_regexp).find_each do |page|
14
- add page.path, host: page.host
13
+ Para::SeoTools::Page.where(
14
+ "path ~* ? AND CAST(config->>'noindex' AS boolean) != ?",
15
+ Para::SeoTools.sitemap_path_regexp, true
16
+ ).find_each do |page|
17
+ add(page.path, host: page.host) unless page.config['noindex']
15
18
  end
16
19
  end
17
20
  end
@@ -5,6 +5,7 @@ module Para
5
5
 
6
6
  class PageBuilder
7
7
  include Rails.application.routes.url_helpers
8
+ include Para::SeoTools::Helpers::DefaultDataMethodsHelper
8
9
 
9
10
  attr_reader :name, :resource, :locale, :defaults, :config
10
11
 
@@ -58,8 +59,9 @@ module Para
58
59
  # Override path (i.e.: slug changed)
59
60
  page.path = path if path.to_s != page.path
60
61
  page.locale = locale
62
+
61
63
  # Do not override meta tags if already present
62
- page.defaults = defaults
64
+ page.defaults = process_defaults
63
65
  page.config = config
64
66
  end
65
67
  end
@@ -74,6 +76,15 @@ module Para
74
76
  end
75
77
  end
76
78
 
79
+ def process_defaults
80
+ return {} if defaults == false
81
+
82
+ defaults[:title] ||= default_title_for(resource)
83
+ defaults[:description] ||= default_description_for(resource)
84
+
85
+ defaults
86
+ end
87
+
77
88
  def self.model_for(page)
78
89
  models[unique_identifier_for(page)] ||= ::Para::SeoTools::Page.new(
79
90
  identifier: page.identifier
@@ -10,7 +10,7 @@ module Para
10
10
  @default_page_options = options
11
11
  end
12
12
 
13
- def page(name, options = {} , &block)
13
+ def page(name, options = {}, &block)
14
14
  options.reverse_merge!(default_page_options)
15
15
 
16
16
  Skeleton::PageBuilder.new(name, options).tap do |page|
@@ -1,5 +1,5 @@
1
1
  module Para
2
2
  module SeoTools
3
- VERSION = "0.4.6"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@ namespace :para do
3
3
  namespace :skeleton do
4
4
  desc "Builds or refreshes the app skeleton."
5
5
  task build: :environment do
6
+ puts " * Build app skeleton ..."
6
7
  Para::SeoTools::Skeleton.build(load_skeleton: true)
7
8
  end
8
9
  end
@@ -10,6 +11,9 @@ namespace :para do
10
11
  namespace :sitemap do
11
12
  desc "Generates a new sitemap."
12
13
  task generate: :environment do
14
+ Rake.application.invoke_task('para:seo_tools:skeleton:build')
15
+
16
+ puts " * Generate sitemap ..."
13
17
  Para::SeoTools::Sitemap.generate!
14
18
  end
15
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: para-seo_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -125,6 +125,7 @@ files:
125
125
  - lib/para/seo_tools/controller.rb
126
126
  - lib/para/seo_tools/engine.rb
127
127
  - lib/para/seo_tools/helpers.rb
128
+ - lib/para/seo_tools/helpers/default_data_methods_helper.rb
128
129
  - lib/para/seo_tools/helpers/page_helper.rb
129
130
  - lib/para/seo_tools/helpers/view_helper.rb
130
131
  - lib/para/seo_tools/meta_tags.rb