nocms-seo 1.0.0

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: 820073f4b26b84a5622a41c1d9da4fd16219eec0
4
+ data.tar.gz: 4c14dd7a0cb6cba6693115e70a5eb8021d34faa5
5
+ SHA512:
6
+ metadata.gz: 8e7be0e0093ad51ecc5a9aba002b055d5c6834a1bafa9a563f50fd88984a1adb2f3d43a1fb357bcadb7d0b239ad67a24b66be7490def0b04cd9e3b91cfd430c2
7
+ data.tar.gz: cccda20236617866db46809249ebbd60311c861d02a073652cbbe635ef59d1f2b42ff7122d0e238998bf9b94c2da4d8f7f27e0fd041adb1f9ffd933a679c3c16
@@ -0,0 +1,28 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Seo'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rspec/core'
23
+ require 'rspec/core/rake_task'
24
+
25
+ desc "Run all specs in spec directory (excluding plugin specs)"
26
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
27
+
28
+ task :default => :spec
@@ -0,0 +1,12 @@
1
+ module NoCms::Seo::Concerns::ControllerWithSeo
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_action :set_seo_info
6
+
7
+ def set_seo_info
8
+ @seo_info = NoCms::Seo::Presenters::BasePresenter.new
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,29 @@
1
+ module NoCms::Seo::SeoHelper
2
+
3
+ def canonical_url_tag canonical_url = ''
4
+ canonical_url = canonical_url.blank? ? @seo_info.canonical_url(request.host_with_port) : canonical_url
5
+ content_tag :link, nil, rel: 'canonical', href: canonical_url unless canonical_url.blank?
6
+ end
7
+
8
+ def meta_description_tag default_description = ''
9
+ description = default_description.blank? ? @seo_info.description : default_description
10
+ content_tag :meta, nil, name: 'description', content: description unless description.blank?
11
+ end
12
+
13
+ def title_tag default_title
14
+ title = default_title.blank? ? @seo_info.title : default_title
15
+ content_tag :title, title unless title.blank?
16
+ end
17
+
18
+ def robots_tag options = {}
19
+ options ||= {}
20
+ no_index = options[:no_index].nil? ? @seo_info.no_index? : options[:no_index]
21
+ no_follow = options[:no_follow].nil? ? @seo_info.no_follow? : options[:no_follow]
22
+ content = no_index ? "noindex" : "index"
23
+ content += ', '
24
+ content += no_follow ? "nofollow" : "follow"
25
+
26
+ content_tag :meta, nil, name: 'robots', content: content
27
+ end
28
+
29
+ end
@@ -0,0 +1,5 @@
1
+ module NoCms::Seo
2
+ def self.table_name_prefix
3
+ 'no_cms_seo_'
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ module NoCms::Seo::Concerns::ModelWithSeo
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ has_one :seo_info, class_name: 'NoCms::Seo::Info', as: :target
6
+ accepts_nested_attributes_for :seo_info
7
+
8
+ def seo_info
9
+ super || build_seo_info
10
+ end
11
+
12
+ def dup_with_seo
13
+ dupped_model = dup_without_seo
14
+ dupped_model.seo_info = seo_info.dup
15
+ dupped_model
16
+ end
17
+ alias_method_chain :dup, :seo
18
+ end
19
+
20
+ end
@@ -0,0 +1,5 @@
1
+ class NoCms::Seo::Info < ActiveRecord::Base
2
+ belongs_to :target, polymorphic: true
3
+ translates :title, :description
4
+ accepts_nested_attributes_for :translations
5
+ end
@@ -0,0 +1,23 @@
1
+ class NoCms::Seo::Presenters::BasePresenter
2
+
3
+ def title
4
+ I18n.t('no_cms.seo.default_title')
5
+ end
6
+
7
+ def description
8
+ I18n.t('no_cms.seo.default_description')
9
+ end
10
+
11
+ def canonical_url host
12
+ ""
13
+ end
14
+
15
+ def no_index?
16
+ false
17
+ end
18
+
19
+ def no_follow?
20
+ false
21
+ end
22
+
23
+ end
@@ -0,0 +1,44 @@
1
+ module NoCms::Seo::Presenters
2
+ class SeoInfoPresenter
3
+
4
+ attr_accessor :object, :base_presenter
5
+
6
+ def initialize object
7
+ self.object = object
8
+ self.base_presenter = NoCms::Seo::Presenters::BasePresenter.new
9
+ end
10
+
11
+ def title
12
+ self.object.seo_info.title.blank? ? default_title : self.object.seo_info.title
13
+ end
14
+
15
+ def default_title
16
+ base_presenter.title
17
+ end
18
+
19
+ def description
20
+ self.object.seo_info.description.blank? ? default_description : self.object.seo_info.description
21
+ end
22
+
23
+ def default_description
24
+ base_presenter.description
25
+ end
26
+
27
+ def no_index?
28
+ default_no_index? || self.object.seo_info.no_index?
29
+ end
30
+
31
+ def default_no_index?
32
+ false
33
+ end
34
+
35
+ def no_follow?
36
+ default_no_follow? || self.object.seo_info.no_follow?
37
+ end
38
+
39
+ def default_no_follow?
40
+ false
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,24 @@
1
+ <div class="row">
2
+ <%= f.label :title %>
3
+ <%= f.text_field :title %>
4
+ </div>
5
+ <div class="row">
6
+ <%= f.label :description %>
7
+ <%= f.text_area :description %>
8
+ </div>
9
+ <div class="row">
10
+ <%= f.label :exclude_from_sitemap, t('.robots_options') %>
11
+
12
+ # <%= f.label :exclude_from_sitemap do %>
13
+ <%= f.check_box :exclude_from_sitemap %>
14
+ <%= t '.exclude_from_sitemap' %>
15
+ <% end -%>
16
+ <%= f.label :no_index do %>
17
+ <%= f.check_box :no_index %>
18
+ <%= t '.no_index' %>
19
+ <% end -%>
20
+ <%= f.label :no_follow do %>
21
+ <%= f.check_box :no_follow %>
22
+ <%= t '.no_follow' %>
23
+ <% end -%>
24
+ </div>
@@ -0,0 +1,23 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ no_cms/seo/info: Seo Info
5
+ attributes:
6
+ no_cms/seo/info:
7
+ description: Description
8
+ exclude_from_sitemap: Exclude from sitemap
9
+ no_follow: Don't follow links (meta nofollow)
10
+ no_index: Don't index (meta noindex)
11
+ robots_options: Options for robots and search engines
12
+ no_cms:
13
+ seo:
14
+ default_description: ""
15
+ default_title: ""
16
+ admin:
17
+ seo:
18
+ infos:
19
+ form:
20
+ exclude_from_sitemap: Exclude from sitemap
21
+ no_follow: Don't follow links (meta nofollow)
22
+ no_index: Don't index (meta noindex)
23
+ robots_options: Options for robots and search engines
@@ -0,0 +1,23 @@
1
+ es:
2
+ activerecord:
3
+ models:
4
+ no_cms/seo/info: Seo Info
5
+ attributes:
6
+ no_cms/seo/info:
7
+ description: Descripción
8
+ exclude_from_sitemap: Excluir del sitemap
9
+ no_follow: No seguir enlaces (meta nofollow)
10
+ no_index: No indexar (meta noindex)
11
+ robots_options: Opciones para robots y motores de búsqueda
12
+ no_cms:
13
+ seo:
14
+ default_description: ""
15
+ default_title: ""
16
+ admin:
17
+ seo:
18
+ infos:
19
+ form:
20
+ exclude_from_sitemap: Excluir del sitemap
21
+ no_follow: No seguir enlaces (meta nofollow)
22
+ no_index: No indexar (meta noindex)
23
+ robots_options: Opciones para robots y motores de búsqueda
@@ -0,0 +1,19 @@
1
+ class CreateNoCmsSeoInfos < ActiveRecord::Migration
2
+ def change
3
+ create_table :no_cms_seo_infos do |t|
4
+ t.belongs_to :target, polymorphic: true, index: true
5
+
6
+ t.timestamps
7
+ end
8
+
9
+
10
+ create_table :no_cms_seo_info_translations do |t|
11
+ t.belongs_to :no_cms_seo_info, index: true
12
+ t.string :locale
13
+
14
+ t.string :title
15
+ t.text :description
16
+ t.timestamps
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ class AddExcludeFromRobotsToNoCmsSeoInfo < ActiveRecord::Migration
2
+ def change
3
+ add_column :no_cms_seo_infos, :exclude_from_robots_txt, :boolean, default: false
4
+ add_column :no_cms_seo_infos, :no_index, :boolean, default: false
5
+ add_column :no_cms_seo_infos, :no_follow, :boolean, default: false
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ class RenameExcludeFromRobotsInNoCmsSeoInfos < ActiveRecord::Migration
2
+
3
+ def up
4
+ add_column :no_cms_seo_infos, :exclude_from_sitemap, :boolean, default: false
5
+ NoCms::Seo::Info.update_all 'exclude_from_sitemap=exclude_from_robots_txt'
6
+ remove_column :no_cms_seo_infos, :exclude_from_robots_txt, :boolean, default: false
7
+ end
8
+
9
+ def down
10
+ add_column :no_cms_seo_infos, :exclude_from_robots_txt, :boolean, default: false
11
+ NoCms::Seo::Info.update_all 'exclude_from_robots_txt=exclude_from_sitemap'
12
+ remove_column :no_cms_seo_infos, :exclude_from_sitemap, :boolean, default: false
13
+ end
14
+
15
+ end
@@ -0,0 +1,9 @@
1
+ require 'globalize'
2
+
3
+ module NoCms
4
+ module Seo
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace NoCms::Seo
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module NoCms
2
+ module Seo
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ require "no_cms/seo/engine"
2
+
3
+ module NoCms
4
+ module Seo
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nocms-seo
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Simplelogica
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.3'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.3'
33
+ - !ruby/object:Gem::Dependency
34
+ name: globalize
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 4.0.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '5.1'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 4.0.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '5.1'
53
+ - !ruby/object:Gem::Dependency
54
+ name: sqlite3
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ description: Gem with SEO functionality independent from any CMS and embeddable in
68
+ any Rails 4 app
69
+ email:
70
+ - gems@simplelogica.net
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - Rakefile
76
+ - app/controllers/no_cms/seo/concerns/controller_with_seo.rb
77
+ - app/helpers/no_cms/seo/seo_helper.rb
78
+ - app/models/no_cms/seo.rb
79
+ - app/models/no_cms/seo/concerns/model_with_seo.rb
80
+ - app/models/no_cms/seo/info.rb
81
+ - app/presenters/no_cms/seo/presenters/base_presenter.rb
82
+ - app/presenters/no_cms/seo/presenters/seo_info_presenter.rb
83
+ - app/views/no_cms/admin/seo/infos/_form.html.erb
84
+ - config/locales/en.yml
85
+ - config/locales/es.yml
86
+ - db/migrate/20140415142547_create_no_cms_seo_infos.rb
87
+ - db/migrate/20140526083501_add_exclude_from_robots_to_no_cms_seo_info.rb
88
+ - db/migrate/20140526101137_rename_exclude_from_robots_in_no_cms_seo_infos.rb
89
+ - lib/no_cms/seo/engine.rb
90
+ - lib/no_cms/seo/version.rb
91
+ - lib/nocms-seo.rb
92
+ homepage: https://github.com/simplelogica/nocms-seo
93
+ licenses: []
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Gem with SEO functionality independent from any CMS and embeddable in any
115
+ Rails 4 app
116
+ test_files: []