enjoy_cms_seo 0.4.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +1 -0
- data/app/helpers/enjoy/seo/seo_helper.rb +17 -0
- data/app/models/concerns/enjoy/seo/decorators/seo.rb +5 -0
- data/app/models/concerns/enjoy/seo/decorators/sitemap_data.rb +5 -0
- data/app/models/concerns/enjoy/seo/seoable.rb +71 -0
- data/app/models/concerns/enjoy/seo/sitemap_data_field.rb +17 -0
- data/app/models/enjoy/seo/seo.rb +16 -0
- data/app/models/enjoy/seo/sitemap_data.rb +16 -0
- data/app/views/blocks/_ga.html.slim +8 -0
- data/app/views/blocks/_ym.html.slim +31 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/initializers/enjoy_cms_seo.rb +34 -0
- data/config/locales/ru.enjoy.seo.yml +29 -0
- data/enjoy_cms_seo.gemspec +41 -0
- data/lib/enjoy/seo/admin/seo.rb +43 -0
- data/lib/enjoy/seo/admin/sitemap_data.rb +29 -0
- data/lib/enjoy/seo/admin.rb +4 -0
- data/lib/enjoy/seo/configuration.rb +24 -0
- data/lib/enjoy/seo/engine.rb +5 -0
- data/lib/enjoy/seo/models/active_record/seo.rb +14 -0
- data/lib/enjoy/seo/models/active_record/sitemap_data.rb +11 -0
- data/lib/enjoy/seo/models/mongoid/seo.rb +25 -0
- data/lib/enjoy/seo/models/mongoid/sitemap_data.rb +25 -0
- data/lib/enjoy/seo/models/seo.rb +47 -0
- data/lib/enjoy/seo/models/sitemap_data.rb +17 -0
- data/lib/enjoy/seo/version.rb +5 -0
- data/lib/enjoy_cms_seo.rb +55 -0
- data/lib/generators/enjoy/seo/config/install_generator.rb +13 -0
- data/lib/generators/enjoy/seo/config/templates/enjoy_seo.erb +6 -0
- data/lib/generators/enjoy/seo/migrations/migration_generator.rb +18 -0
- data/lib/generators/enjoy/seo/migrations/templates/migration_seos.rb +48 -0
- data/release.sh +7 -0
- metadata +182 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e45f47795595d6cea18a1f735406e49def31f7d2
|
4
|
+
data.tar.gz: 3e7be364730a306fbf380140b8e64cdc748f75cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c213a4dd03cdbd04cff23c3f600d0e5dfc59c3e602a799de25893fd9f15d563b46c9c2e32f3af3613f265ef1e7fcf524fe38e47c9450ee730bde494188493f64
|
7
|
+
data.tar.gz: cd350acf9d14bdb1a66863a33f7099654146b4f11b4672f069ab02211c828cb59dc0da5f746380dcbad232707430ff375bb5c8b4e94ffaff3128406b41eaeeaa
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
enjoy_cms_seo
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Alexander Kiseliev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# EnjoyCmsSeo
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/enjoy_cms_seo`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'enjoy_cms_seo'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install enjoy_cms_seo
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/enjoy_cms_seo.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Enjoy::Seo::SeoHelper
|
2
|
+
|
3
|
+
def enjoy_ym_counter_tag(counter_id)
|
4
|
+
render partial: "blocks/ym", locals: {counter_id: counter_id}
|
5
|
+
end
|
6
|
+
def enjoy_ga_counter_tag(counter_id)
|
7
|
+
render partial: "blocks/ga", locals: {counter_id: counter_id}
|
8
|
+
end
|
9
|
+
def render_enjoy_counters(opts = {})
|
10
|
+
ret = []
|
11
|
+
ym_counter_id = opts[:ym_counter_id] || Settings.ym_counter_id
|
12
|
+
ga_counter_id = opts[:ga_counter_id] || Settings.ga_counter_id
|
13
|
+
ret << enjoy_ym_counter_tag(ym_counter_id) unless ym_counter_id.blank?
|
14
|
+
ret << enjoy_ga_counter_tag(ga_counter_id) unless ga_counter_id.blank?
|
15
|
+
ret.join
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Enjoy::Seo::Seoable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
LOCALIZED_FIELDS = [:h1, :title, :keywords, :description, :og_title]
|
4
|
+
FIELDS = LOCALIZED_FIELDS + [:og_image, :robots]
|
5
|
+
|
6
|
+
included do
|
7
|
+
has_one :seo, as: :seoable, autosave: true, class_name: "Enjoy::Seo::Seo"
|
8
|
+
accepts_nested_attributes_for :seo
|
9
|
+
|
10
|
+
delegate(*FIELDS, to: :seo)
|
11
|
+
delegate(*(FIELDS.map {|f| "#{f}=".to_sym }), to: :seo)
|
12
|
+
|
13
|
+
if Enjoy::Seo.config.localize
|
14
|
+
delegate(*(LOCALIZED_FIELDS.map {|f| "#{f}_translations".to_sym }), to: :seo)
|
15
|
+
delegate(*(LOCALIZED_FIELDS.map {|f| "#{f}_translations=".to_sym }), to: :seo)
|
16
|
+
end
|
17
|
+
|
18
|
+
alias seo_without_build seo
|
19
|
+
def seo
|
20
|
+
seo_without_build || build_seo
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def default_seo_h1
|
25
|
+
if self.respond_to?(:name)
|
26
|
+
self.name
|
27
|
+
elsif self.respond_to?(:title)
|
28
|
+
self.title
|
29
|
+
end
|
30
|
+
end
|
31
|
+
def default_seo_title
|
32
|
+
if self.respond_to?(:name)
|
33
|
+
self.name
|
34
|
+
elsif self.respond_to?(:title)
|
35
|
+
self.title
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def default_seo_keywords
|
39
|
+
""
|
40
|
+
end
|
41
|
+
def default_seo_description
|
42
|
+
""
|
43
|
+
end
|
44
|
+
def default_seo_og_title
|
45
|
+
if self.respond_to?(:name)
|
46
|
+
self.name
|
47
|
+
elsif self.respond_to?(:title)
|
48
|
+
self.title
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_default_seo?
|
53
|
+
true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def page_title
|
58
|
+
return self.title unless self.title.blank?
|
59
|
+
self.name if self.respond_to?(:name)
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_og_title
|
63
|
+
return self.og_title unless self.og_title.blank?
|
64
|
+
self.name if self.respond_to?(:name)
|
65
|
+
end
|
66
|
+
|
67
|
+
def og_image_jcrop_options
|
68
|
+
{aspectRation: 800.0/600.0}
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Enjoy::Seo::SitemapDataField
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
FIELDS = [:sitemap_show, :sitemap_lastmod, :sitemap_changefreq, :sitemap_priority]
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_one :sitemap_data, as: :sitemap_data_field, autosave: true, class_name: "Enjoy::Seo::SitemapData"
|
7
|
+
accepts_nested_attributes_for :sitemap_data
|
8
|
+
|
9
|
+
delegate *FIELDS, to: :sitemap_data
|
10
|
+
delegate *(FIELDS.map {|f| "#{f}=".to_sym }), to: :sitemap_data
|
11
|
+
|
12
|
+
alias sitemap_data_without_build sitemap_data
|
13
|
+
def sitemap_data
|
14
|
+
sitemap_data_without_build || build_sitemap_data
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
if Enjoy.active_record?
|
3
|
+
class Seo < ActiveRecord::Base
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class Seo
|
8
|
+
include Enjoy::Seo::Models::Seo
|
9
|
+
|
10
|
+
include Enjoy::Seo::Decorators::Seo
|
11
|
+
|
12
|
+
rails_admin(&Enjoy::Seo::Admin::Seo.config(false, rails_admin_add_fields) { |config|
|
13
|
+
rails_admin_add_config(config)
|
14
|
+
})
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
if Enjoy.active_record?
|
3
|
+
class SitemapData < ActiveRecord::Base
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class SitemapData
|
8
|
+
include Enjoy::Seo::Models::SitemapData
|
9
|
+
|
10
|
+
include Enjoy::Seo::Decorators::SitemapData
|
11
|
+
|
12
|
+
rails_admin(&Enjoy::Seo::Admin::SitemapData.config(false, rails_admin_add_fields) { |config|
|
13
|
+
rails_admin_add_config(config)
|
14
|
+
})
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
javascript:
|
2
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
3
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
4
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
5
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
6
|
+
|
7
|
+
ga('create', '#{counter_id}', 'auto');
|
8
|
+
ga('send', 'pageview');
|
@@ -0,0 +1,31 @@
|
|
1
|
+
/! Yandex.Metrika counter
|
2
|
+
javascript:
|
3
|
+
(function (d, w, c) {
|
4
|
+
(w[c] = w[c] || []).push(function() {
|
5
|
+
try {
|
6
|
+
w.yaCounter#{counter_id} = new Ya.Metrika({
|
7
|
+
id:#{counter_id},
|
8
|
+
clickmap:true,
|
9
|
+
trackLinks:true,
|
10
|
+
accurateTrackBounce:true,
|
11
|
+
webvisor:true,
|
12
|
+
trackHash:true
|
13
|
+
});
|
14
|
+
} catch(e) { }
|
15
|
+
});
|
16
|
+
|
17
|
+
var n = d.getElementsByTagName("script")[0],
|
18
|
+
s = d.createElement("script"),
|
19
|
+
f = function () { n.parentNode.insertBefore(s, n); };
|
20
|
+
s.type = "text/javascript";
|
21
|
+
s.async = true;
|
22
|
+
s.src = "https://mc.yandex.ru/metrika/watch.js";
|
23
|
+
|
24
|
+
if (w.opera == "[object Opera]") {
|
25
|
+
d.addEventListener("DOMContentLoaded", f, false);
|
26
|
+
} else { f(); }
|
27
|
+
})(document, window, "yandex_metrika_callbacks");
|
28
|
+
|
29
|
+
noscript
|
30
|
+
div= image_tag "https://mc.yandex.ru/watch/#{counter_id}" style: "position:absolute; left:-9999px;" alt: ""
|
31
|
+
/! Yandex.Metrika counter
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "enjoy_cms_seo"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Enjoy.configure do |config|
|
2
|
+
config.ability_manager_config ||= []
|
3
|
+
config.ability_manager_config << {
|
4
|
+
method: :can,
|
5
|
+
model: Enjoy::Seo::Seo,
|
6
|
+
actions: [:edit]
|
7
|
+
}
|
8
|
+
config.ability_manager_config << {
|
9
|
+
method: :can,
|
10
|
+
model: Enjoy::Seo::SitemapData,
|
11
|
+
actions: [:edit]
|
12
|
+
}
|
13
|
+
|
14
|
+
config.ability_admin_config ||= []
|
15
|
+
config.ability_admin_config << {
|
16
|
+
method: :cannot,
|
17
|
+
model: Enjoy::Seo::Seo,
|
18
|
+
actions: [:new, :create]
|
19
|
+
}
|
20
|
+
config.ability_admin_config << {
|
21
|
+
method: :cannot,
|
22
|
+
model: Enjoy::Seo::SitemapData,
|
23
|
+
actions: [:new, :create]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
Enjoy.rails_admin_configure do |config|
|
28
|
+
if defined?(RailsAdminComments)
|
29
|
+
config.action_visible_for :comments, 'Enjoy::Seo::Seo'
|
30
|
+
config.action_visible_for :comments, 'Enjoy::Seo::SitemapData'
|
31
|
+
config.action_visible_for :model_comments, 'Enjoy::Seo::Seo'
|
32
|
+
config.action_visible_for :model_comments, 'Enjoy::Seo::SitemapData'
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
ru:
|
2
|
+
enjoy:
|
3
|
+
seo:
|
4
|
+
seo: SEO
|
5
|
+
sitemap_data: Карта сайта
|
6
|
+
|
7
|
+
|
8
|
+
mongoid: &mongoid
|
9
|
+
models:
|
10
|
+
enjoy/seo/seo: SEO
|
11
|
+
enjoy/seo/sitemap_data: Карта сайта
|
12
|
+
activerecord:
|
13
|
+
<<: *mongoid
|
14
|
+
|
15
|
+
attributes:
|
16
|
+
enjoy/seo/seo:
|
17
|
+
seoable: Родительский элемент/страница
|
18
|
+
title: Title
|
19
|
+
description: SEO Description
|
20
|
+
keywords: SEO Keywords
|
21
|
+
og_title: Og title
|
22
|
+
og_image: Og image
|
23
|
+
robots: Robots
|
24
|
+
enjoy/seo/sitemap_data:
|
25
|
+
sitemap_data_field: Родительский элемент/страница
|
26
|
+
sitemap_show: Отображать в карте сайта
|
27
|
+
sitemap_lastmod: lastmod
|
28
|
+
sitemap_changefreq: changefreq
|
29
|
+
sitemap_priority: priority
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'enjoy/seo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "enjoy_cms_seo"
|
8
|
+
spec.version = Enjoy::Seo::VERSION
|
9
|
+
spec.authors = ["Alexander Kiseliev"]
|
10
|
+
spec.email = ["dev@enjoycreate.ru"]
|
11
|
+
|
12
|
+
spec.description = %q{enjoy_cms_seo }
|
13
|
+
spec.summary = %q{enjoy_cms_seo}
|
14
|
+
spec.homepage = 'https://github.com/enjoycreative/enjoy_cms_seo'
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
|
33
|
+
spec.add_dependency 'enjoy_cms', "~> 0.4.0.beta1"
|
34
|
+
|
35
|
+
spec.add_dependency "sitemap_generator"
|
36
|
+
spec.add_dependency "rails_admin_sitemap"
|
37
|
+
|
38
|
+
spec.add_dependency "image_optim"
|
39
|
+
spec.add_dependency "paperclip-optimizer"
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
module Admin
|
3
|
+
module Seo
|
4
|
+
def self.config(is_active = true, fields = {})
|
5
|
+
Proc.new {
|
6
|
+
navigation_label 'SEO'
|
7
|
+
field :seoable do
|
8
|
+
read_only true
|
9
|
+
end
|
10
|
+
field :h1, :string do
|
11
|
+
searchable true
|
12
|
+
end
|
13
|
+
field :title, :string do
|
14
|
+
searchable true
|
15
|
+
end
|
16
|
+
field :keywords, :text do
|
17
|
+
searchable true
|
18
|
+
end
|
19
|
+
field :description, :text do
|
20
|
+
searchable true
|
21
|
+
end
|
22
|
+
field :robots, :string
|
23
|
+
|
24
|
+
field :og_title, :string do
|
25
|
+
searchable true
|
26
|
+
end
|
27
|
+
|
28
|
+
if Enjoy::Seo.config.gallery_support
|
29
|
+
field :og_image, :jcrop do
|
30
|
+
jcrop_options :og_image_jcrop_options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
|
35
|
+
|
36
|
+
if block_given?
|
37
|
+
yield self
|
38
|
+
end
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
module Admin
|
3
|
+
module SitemapData
|
4
|
+
def self.config(is_active = false, fields = {})
|
5
|
+
Proc.new {
|
6
|
+
navigation_label 'SEO'
|
7
|
+
label I18n.t('enjoy.seo.sitemap_data')
|
8
|
+
field :sitemap_data_field do
|
9
|
+
read_only true
|
10
|
+
end
|
11
|
+
field :sitemap_show, :toggle
|
12
|
+
field :sitemap_lastmod
|
13
|
+
field :sitemap_changefreq, :enum do
|
14
|
+
enum do
|
15
|
+
Enjoy::Seo::SitemapData::SITEMAP_CHANGEFREQ_ARRAY
|
16
|
+
end
|
17
|
+
end
|
18
|
+
field :sitemap_priority
|
19
|
+
|
20
|
+
Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
|
21
|
+
|
22
|
+
if block_given?
|
23
|
+
yield self
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
def self.configuration
|
3
|
+
@configuration ||= Configuration.new
|
4
|
+
end
|
5
|
+
def self.config
|
6
|
+
@configuration ||= Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.configure
|
10
|
+
yield configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
class Configuration
|
14
|
+
attr_accessor :localize
|
15
|
+
|
16
|
+
attr_accessor :gallery_support
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@localize = Enjoy.config.localize
|
20
|
+
|
21
|
+
@gallery_support = defined?(Enjoy::Gallery)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
module Models
|
3
|
+
module Mongoid
|
4
|
+
module Seo
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
|
8
|
+
if defined?(RailsAdminComments)
|
9
|
+
include RailsAdminComments::Commentable
|
10
|
+
end
|
11
|
+
|
12
|
+
# field :name, type: String, localize: Enjoy::Seo.config.localize
|
13
|
+
field :h1, type: String, localize: Enjoy::Seo.config.localize
|
14
|
+
|
15
|
+
field :title, type: String, localize: Enjoy::Seo.config.localize
|
16
|
+
field :keywords, type: String, localize: Enjoy::Seo.config.localize
|
17
|
+
field :description, type: String, localize: Enjoy::Seo.config.localize
|
18
|
+
field :robots, type: String, localize: Enjoy::Seo.config.localize
|
19
|
+
|
20
|
+
field :og_title, type: String, localize: Enjoy::Seo.config.localize
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
module Models
|
3
|
+
module Mongoid
|
4
|
+
module SitemapData
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
|
9
|
+
if defined?(RailsAdminComments)
|
10
|
+
include RailsAdminComments::Commentable
|
11
|
+
end
|
12
|
+
|
13
|
+
field :sitemap_show, type: Boolean, default: true
|
14
|
+
field :sitemap_lastmod, type: DateTime
|
15
|
+
field :sitemap_changefreq, type: String, default: 'daily'
|
16
|
+
field :sitemap_priority, type: Float
|
17
|
+
|
18
|
+
scope :sitemap_show, -> { where(sitemap_show: true) }
|
19
|
+
scope :for_sitemap, -> { sitemap_show }
|
20
|
+
scope :show_in_sitemap, -> { sitemap_show }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
module Models
|
3
|
+
module Seo
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Enjoy::Model
|
6
|
+
include Enjoy::Enableable
|
7
|
+
if Enjoy::Seo.config.gallery_support
|
8
|
+
include Enjoy::Gallery::Paperclipable
|
9
|
+
end
|
10
|
+
|
11
|
+
include Enjoy::Seo.orm_specific('Seo')
|
12
|
+
|
13
|
+
included do
|
14
|
+
belongs_to :seoable, polymorphic: true
|
15
|
+
|
16
|
+
if Enjoy::Seo.config.gallery_support
|
17
|
+
enjoy_cms_attached_file(:og_image,
|
18
|
+
styles: lambda { |attachment| attachment.instance.og_image_styles }
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
before_save do
|
23
|
+
set_default_seo
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_default_seo
|
28
|
+
_obj = self.seoable
|
29
|
+
if _obj and _obj.set_default_seo?
|
30
|
+
self.h1 = _obj.default_seo_h1 if self.h1.blank?
|
31
|
+
self.title = _obj.default_seo_title if self.title.blank?
|
32
|
+
self.keywords = _obj.default_seo_keywords if self.keywords.blank?
|
33
|
+
self.description = _obj.default_seo_description if self.description.blank?
|
34
|
+
self.title = _obj.default_seo_og_title if self.title.blank?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def og_image_styles
|
39
|
+
{thumb: "800x600>"}
|
40
|
+
end
|
41
|
+
|
42
|
+
def og_image_jcrop_options
|
43
|
+
{}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Enjoy::Seo
|
2
|
+
module Models
|
3
|
+
module SitemapData
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Enjoy::Model
|
6
|
+
include Enjoy::Enableable
|
7
|
+
|
8
|
+
include Enjoy::Seo.orm_specific('SitemapData')
|
9
|
+
|
10
|
+
SITEMAP_CHANGEFREQ_ARRAY = %w(always hourly daily weekly monthly yearly never)
|
11
|
+
|
12
|
+
included do
|
13
|
+
belongs_to :sitemap_data_field, polymorphic: true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
unless defined?(Enjoy) && Enjoy.respond_to?(:orm) && [:active_record, :mongoid].include?(Enjoy.orm)
|
2
|
+
puts "please use enjoy_cms_mongoid or enjoy_cms_activerecord"
|
3
|
+
puts "also: please use enjoy_cms_news_mongoid or enjoy_cms_news_activerecord and not enjoy_cms_news directly"
|
4
|
+
exit 1
|
5
|
+
end
|
6
|
+
|
7
|
+
require "enjoy/seo/version"
|
8
|
+
|
9
|
+
# require 'enjoy_cms'
|
10
|
+
|
11
|
+
require 'enjoy/seo/configuration'
|
12
|
+
require 'enjoy/seo/engine'
|
13
|
+
|
14
|
+
|
15
|
+
module Enjoy::Seo
|
16
|
+
class << self
|
17
|
+
def orm
|
18
|
+
Enjoy.orm
|
19
|
+
end
|
20
|
+
def mongoid?
|
21
|
+
Enjoy::Seo.orm == :mongoid
|
22
|
+
end
|
23
|
+
def active_record?
|
24
|
+
Enjoy::Seo.orm == :active_record
|
25
|
+
end
|
26
|
+
def model_namespace
|
27
|
+
"Enjoy::Seo::Models::#{Enjoy::Seo.orm.to_s.camelize}"
|
28
|
+
end
|
29
|
+
def orm_specific(name)
|
30
|
+
"#{model_namespace}::#{name}".constantize
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
autoload :Admin, 'enjoy/seo/admin'
|
35
|
+
module Admin
|
36
|
+
autoload :SitemapData, 'enjoy/seo/admin/sitemap_data'
|
37
|
+
autoload :Seo, 'enjoy/seo/admin/seo'
|
38
|
+
end
|
39
|
+
|
40
|
+
module Models
|
41
|
+
autoload :SitemapData, 'enjoy/seo/models/sitemap_data'
|
42
|
+
autoload :Seo, 'enjoy/seo/models/seo'
|
43
|
+
|
44
|
+
module Mongoid
|
45
|
+
autoload :SitemapData, 'enjoy/seo/models/mongoid/sitemap_data'
|
46
|
+
autoload :Seo, 'enjoy/seo/models/mongoid/seo'
|
47
|
+
end
|
48
|
+
|
49
|
+
module ActiveRecord
|
50
|
+
autoload :SitemapData, 'enjoy/seo/models/active_record/sitemap_data'
|
51
|
+
autoload :Seo, 'enjoy/seo/models/active_record/seo'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Enjoy::Seo
|
4
|
+
class ConfigGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc 'Enjoy::Seo Config generator'
|
8
|
+
def config
|
9
|
+
template 'enjoy_seo.erb', "config/initializers/enjoy_seo.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/active_record'
|
3
|
+
|
4
|
+
module Enjoy::Seo
|
5
|
+
class MigrationGenerator < Rails::Generators::Base
|
6
|
+
include ActiveRecord::Generators::Migration
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
desc 'Enjoy SEO migration generator'
|
10
|
+
def migration
|
11
|
+
if Enjoy.active_record?
|
12
|
+
%w(seos).each do |table_name|
|
13
|
+
migration_template "migration_#{table_name}.rb", "db/migrate/enjoy_create_#{table_name}.rb"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class EnjoyCreateSeos < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
############## SEO ###################33
|
4
|
+
create_table :enjoy_seo_seos do |t|
|
5
|
+
t.boolean :enabled, default: true, null: false
|
6
|
+
t.integer :seoable_id
|
7
|
+
t.string :seoable_type
|
8
|
+
|
9
|
+
if Enjoy::Seo.config.localize
|
10
|
+
t.column :h1_translations, 'hstore', default: {}
|
11
|
+
t.column :title_translations, 'hstore', default: {}
|
12
|
+
t.column :keywords_translations, 'hstore', default: {}
|
13
|
+
t.column :description_translations, 'hstore', default: {}
|
14
|
+
t.column :og_title_translations, 'hstore', default: {}
|
15
|
+
else
|
16
|
+
t.string :h1
|
17
|
+
t.string :title
|
18
|
+
t.text :keywords
|
19
|
+
t.text :description
|
20
|
+
t.string :og_title
|
21
|
+
end
|
22
|
+
t.string :robots
|
23
|
+
t.attachment :og_image
|
24
|
+
|
25
|
+
t.timestamps
|
26
|
+
end
|
27
|
+
|
28
|
+
add_index :enjoy_seo_seos, [:seoable_id, :seoable_type], unique: true
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
################# SITEMAP #####################
|
33
|
+
create_table :enjoy_seo_sitemap_data do |t|
|
34
|
+
t.boolean :enabled, default: true, null: false
|
35
|
+
t.integer :sitemap_data_field_id
|
36
|
+
t.string :sitemap_data_field_type
|
37
|
+
|
38
|
+
t.boolean :sitemap_show, default: true, null: false
|
39
|
+
t.timestamps :sitemap_lastmod
|
40
|
+
t.string :sitemap_changefreq
|
41
|
+
t.float :sitemap_priority
|
42
|
+
|
43
|
+
t.timestamps
|
44
|
+
end
|
45
|
+
|
46
|
+
add_index :enjoy_seo_sitemap_data, [:sitemap_data_field_id, :sitemap_data_field_type], unique: true
|
47
|
+
end
|
48
|
+
end
|
data/release.sh
ADDED
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: enjoy_cms_seo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0.beta3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Kiseliev
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: enjoy_cms
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.4.0.beta1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.4.0.beta1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sitemap_generator
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails_admin_sitemap
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: image_optim
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: paperclip-optimizer
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: 'enjoy_cms_seo '
|
112
|
+
email:
|
113
|
+
- dev@enjoycreate.ru
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".ruby-gemset"
|
120
|
+
- ".ruby-version"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- app/helpers/enjoy/seo/seo_helper.rb
|
127
|
+
- app/models/concerns/enjoy/seo/decorators/seo.rb
|
128
|
+
- app/models/concerns/enjoy/seo/decorators/sitemap_data.rb
|
129
|
+
- app/models/concerns/enjoy/seo/seoable.rb
|
130
|
+
- app/models/concerns/enjoy/seo/sitemap_data_field.rb
|
131
|
+
- app/models/enjoy/seo/seo.rb
|
132
|
+
- app/models/enjoy/seo/sitemap_data.rb
|
133
|
+
- app/views/blocks/_ga.html.slim
|
134
|
+
- app/views/blocks/_ym.html.slim
|
135
|
+
- bin/console
|
136
|
+
- bin/setup
|
137
|
+
- config/initializers/enjoy_cms_seo.rb
|
138
|
+
- config/locales/ru.enjoy.seo.yml
|
139
|
+
- enjoy_cms_seo.gemspec
|
140
|
+
- lib/enjoy/seo/admin.rb
|
141
|
+
- lib/enjoy/seo/admin/seo.rb
|
142
|
+
- lib/enjoy/seo/admin/sitemap_data.rb
|
143
|
+
- lib/enjoy/seo/configuration.rb
|
144
|
+
- lib/enjoy/seo/engine.rb
|
145
|
+
- lib/enjoy/seo/models/active_record/seo.rb
|
146
|
+
- lib/enjoy/seo/models/active_record/sitemap_data.rb
|
147
|
+
- lib/enjoy/seo/models/mongoid/seo.rb
|
148
|
+
- lib/enjoy/seo/models/mongoid/sitemap_data.rb
|
149
|
+
- lib/enjoy/seo/models/seo.rb
|
150
|
+
- lib/enjoy/seo/models/sitemap_data.rb
|
151
|
+
- lib/enjoy/seo/version.rb
|
152
|
+
- lib/enjoy_cms_seo.rb
|
153
|
+
- lib/generators/enjoy/seo/config/install_generator.rb
|
154
|
+
- lib/generators/enjoy/seo/config/templates/enjoy_seo.erb
|
155
|
+
- lib/generators/enjoy/seo/migrations/migration_generator.rb
|
156
|
+
- lib/generators/enjoy/seo/migrations/templates/migration_seos.rb
|
157
|
+
- release.sh
|
158
|
+
homepage: https://github.com/enjoycreative/enjoy_cms_seo
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
metadata: {}
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">"
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: 1.3.1
|
176
|
+
requirements: []
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 2.5.1
|
179
|
+
signing_key:
|
180
|
+
specification_version: 4
|
181
|
+
summary: enjoy_cms_seo
|
182
|
+
test_files: []
|