kms_seo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +41 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/kms_seo/application.js +15 -0
- data/app/assets/javascripts/kms_seo/application/controllers/redirects_controller.coffee.erb +31 -0
- data/app/assets/javascripts/kms_seo/application/routes.coffee.erb +17 -0
- data/app/assets/javascripts/templates/pages/seo.html.slim +14 -0
- data/app/assets/javascripts/templates/redirects/index.html.slim +30 -0
- data/app/assets/stylesheets/kms_seo/application.css +15 -0
- data/app/controllers/kms/pages_controller_decorator.rb +3 -0
- data/app/controllers/kms/public/pages_controller_decorator.rb +17 -0
- data/app/controllers/kms/public/sitemaps_controller.rb +21 -0
- data/app/controllers/kms/seo/redirects_controller.rb +39 -0
- data/app/helpers/kms_seo/application_helper.rb +4 -0
- data/app/models/kms/redirect.rb +4 -0
- data/app/serializers/kms/redirect_serializer.rb +5 -0
- data/app/views/kms/public/sitemaps/show.xml.builder +31 -0
- data/app/views/layouts/kms_seo/application.html.erb +14 -0
- data/config/initializers/externals.rb +10 -0
- data/config/initializers/form_customizations.rb +1 -0
- data/config/initializers/resources.rb +1 -0
- data/config/locales/en.yml +18 -0
- data/config/locales/ru.yml +18 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20150727192219_add_seo_fields_to_pages.rb +7 -0
- data/db/migrate/20150903135219_create_redirects.rb +10 -0
- data/lib/generators/kms_seo/install/install_generator.rb +15 -0
- data/lib/kms/drops/seo_wrapper_drop.rb +5 -0
- data/lib/kms/seo/engine.rb +14 -0
- data/lib/kms/seo/version.rb +5 -0
- data/lib/kms/seo_wrapper.rb +25 -0
- data/lib/kms_seo.rb +6 -0
- data/lib/tasks/kms_seo_tasks.rake +4 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/kms_seo_test.rb +7 -0
- data/test/test_helper.rb +19 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cee0939b2b5f7825c1bc2469f783ded0e11bedbb
|
4
|
+
data.tar.gz: bf2fc6ba9f87140f3373307d6b699f070045f120
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b996a6b7bf18f46a92aee0723dde9378bd8479b3c4b3e1aa4633a5f4e88f021393dc76cd0a5c63b49ea40628eea328355aac9eb1ed377de8a0a70710b1a7e548
|
7
|
+
data.tar.gz: 2bf53cdacad8c9e533a11b227410ebc404198cc59d56e906d913aeec71573648a352e6737000ecc9922eaeba35931d7a6ef5b85f66808f68d75ef6bae944bf67
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Igor Petrov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
## KMS SEO
|
2
|
+
|
3
|
+
Adds SEO support to KMS: meta tags fields for Pages, sitemap.xml generating, redirects, special {{ seo }} variable.
|
4
|
+
|
5
|
+
Use "seo" object for accessing SEO settings for page or object.
|
6
|
+
|
7
|
+
<title>{{ seo.title }}</title>
|
8
|
+
<meta name="keywords" content="{{ seo.keywords }}">
|
9
|
+
<meta name="description" content="{{ seo.description }}">
|
10
|
+
|
11
|
+
Also, this adds sitemap generation support (at /sitemap.xml)
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
1. Add to Gemfile
|
16
|
+
|
17
|
+
gem "kms_seo"
|
18
|
+
# or for edge version:
|
19
|
+
gem "kms_seo", github: "webgradus/kms_seo"
|
20
|
+
|
21
|
+
2. Run generator:
|
22
|
+
|
23
|
+
bundle exec rails g kms_seo:install
|
24
|
+
|
25
|
+
3. Copy migrations:
|
26
|
+
|
27
|
+
bundle exec rails kms_seo:install:migrations
|
28
|
+
|
29
|
+
4. Migrate:
|
30
|
+
|
31
|
+
bundle exec rails db:migrate
|
32
|
+
|
33
|
+
5. Recompile assets (if on production):
|
34
|
+
|
35
|
+
bundle exec rails assets:precompile
|
36
|
+
|
37
|
+
6. Restart KMS instance
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Please follow [CONTRIBUTING.md](CONTRIBUTING.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
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 = 'KmsSeo'
|
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("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require "kms_seo/application/routes"
|
14
|
+
//= require_tree "../templates"
|
15
|
+
//= require_tree "./application/controllers"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
RedirectsController = ($scope, $state, Restangular, $stateParams) ->
|
2
|
+
$scope.store = Restangular.all('redirects')
|
3
|
+
|
4
|
+
$scope.store.getList().then (redirects)->
|
5
|
+
$scope.redirects = redirects
|
6
|
+
|
7
|
+
$scope.addRedirect = ->
|
8
|
+
$scope.redirects.unshift
|
9
|
+
source: ''
|
10
|
+
destination: ''
|
11
|
+
|
12
|
+
$scope.save = (data, redirect)->
|
13
|
+
redirect.source = data.source
|
14
|
+
redirect.destination = data.destination
|
15
|
+
if redirect.id?
|
16
|
+
redirect.put()
|
17
|
+
else
|
18
|
+
restangularizedRedirect = Restangular.restangularizeElement(null, redirect, 'redirects')
|
19
|
+
restangularizedRedirect.save()
|
20
|
+
|
21
|
+
$scope.destroy = (redirect)->
|
22
|
+
if redirect.id?
|
23
|
+
restangularizedRedirect = Restangular.restangularizeElement(null, redirect, 'redirects')
|
24
|
+
return unless confirm('<%= I18n.t(:are_you_sure) %>')
|
25
|
+
restangularizedRedirect.remove().then ->
|
26
|
+
$scope.redirects = _.without($scope.redirects, redirect)
|
27
|
+
else
|
28
|
+
$scope.redirects = _.without($scope.redirects, redirect)
|
29
|
+
|
30
|
+
angular.module('KMS')
|
31
|
+
.controller('RedirectsController', ['$scope', '$state', 'Restangular', '$stateParams', RedirectsController])
|
@@ -0,0 +1,17 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
angular.module('KMS').config ['$stateProvider', '$urlRouterProvider', ($stateProvider, $urlRouterProvider) ->
|
4
|
+
|
5
|
+
# Application routes
|
6
|
+
$stateProvider
|
7
|
+
.state('redirects', {
|
8
|
+
url: '/kms/redirects',
|
9
|
+
views:
|
10
|
+
"header":
|
11
|
+
template: "<%= Kms::Redirect.model_name.human(count: 1.1) %>"
|
12
|
+
"@":
|
13
|
+
controller: 'RedirectsController',
|
14
|
+
controllerAs: 'redirects',
|
15
|
+
templateUrl: 'redirects/index.html',
|
16
|
+
})
|
17
|
+
]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
accordion close-others="true"
|
2
|
+
accordion-group is-open="status.open"
|
3
|
+
accordion-heading
|
4
|
+
i.pull-left.glyphicon ng-class="{'glyphicon-chevron-down': status.open, 'glyphicon-chevron-right': !status.open}"
|
5
|
+
| SEO
|
6
|
+
.form-group
|
7
|
+
label for="seo_title" = Kms::Page.human_attribute_name(:seo_title)
|
8
|
+
input#seo_title.form-control type="text" ng-model="page.seo_title"
|
9
|
+
.form-group
|
10
|
+
label for="seo_keywords" = Kms::Page.human_attribute_name(:seo_keywords)
|
11
|
+
input#seo_keywords.form-control type="text" ng-model="page.seo_keywords"
|
12
|
+
.form-group
|
13
|
+
label for="seo_description" = Kms::Page.human_attribute_name(:seo_description)
|
14
|
+
input#seo_description.form-control type="text" ng-model="page.seo_description"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
.row
|
2
|
+
.col-lg-12
|
3
|
+
.widget
|
4
|
+
.widget-header
|
5
|
+
i.fa.fa-list
|
6
|
+
= Kms::Redirect.model_name.human(count: 1.1)
|
7
|
+
a.btn.btn-sm.btn-primary.pull-right ng-click="addRedirect()"
|
8
|
+
= I18n.t("add_redirect")
|
9
|
+
.widget-body.no-padding
|
10
|
+
.table-responsive
|
11
|
+
table.table
|
12
|
+
tbody
|
13
|
+
tr ng-repeat="redirect in redirects"
|
14
|
+
td style="width: 40%"
|
15
|
+
span editable-text="redirect.source" e-name="source" e-form="editRedirectForm" e-required=""
|
16
|
+
| {{ redirect.source || '#{Kms::Redirect.human_attribute_name(:source)}' }}
|
17
|
+
td style="width: 40%"
|
18
|
+
span editable-text="redirect.destination" e-name="destination" e-form="editRedirectForm" e-required=""
|
19
|
+
| {{ redirect.destination || '#{Kms::Redirect.human_attribute_name(:destination)}' }}
|
20
|
+
td
|
21
|
+
form.form-buttons.form-inline.pull-right editable-form="" name="editRedirectForm" ng-show="editRedirectForm.$visible" onbeforesave="save($data, redirect)"
|
22
|
+
button.btn.btn-primary ng-disabled="editRedirectForm.$waiting" type="submit"
|
23
|
+
span class="glyphicon glyphicon-ok"
|
24
|
+
button.btn.btn-default ng-click="editRedirectForm.$cancel()" ng-disabled="editRedirectForm.$waiting" type="button"
|
25
|
+
span class="glyphicon glyphicon-remove"
|
26
|
+
.btn-group.pull-right ng-show="!editRedirectForm.$visible"
|
27
|
+
a.btn.btn-sm.btn-info ng-click="editRedirectForm.$show()"
|
28
|
+
i.fa.fa-pencil
|
29
|
+
a.btn.btn-sm.btn-danger ng-click="destroy(redirect)"
|
30
|
+
i.fa.fa-times
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Kms::Public::PagesController.class_eval do
|
2
|
+
protected
|
3
|
+
|
4
|
+
def eval_externals
|
5
|
+
@externals = Hash[Kms::ExternalsRegistry.externals.map { |k, v| [k, v.call(request, self)] }]
|
6
|
+
@page = @externals[:page].source
|
7
|
+
@template = @page.template
|
8
|
+
rescue ActiveRecord::RecordNotFound
|
9
|
+
# try to find with first "/" character or without it
|
10
|
+
redirect = Kms::Redirect.where("source in (?)", [request.fullpath, request.fullpath.sub('/', '')]).first
|
11
|
+
if redirect
|
12
|
+
redirect_to URI.join(main_app.root_url, redirect.destination).to_s, status: :moved_permanently
|
13
|
+
else
|
14
|
+
render file: "#{Rails.root}/public/404.html", layout: false, status: :not_found unless redirect
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Kms
|
2
|
+
module Public
|
3
|
+
class SitemapsController < ActionController::Base
|
4
|
+
respond_to :xml
|
5
|
+
helper_method :site_url, :public_page_url
|
6
|
+
|
7
|
+
def show
|
8
|
+
@pages = Kms::Page.published
|
9
|
+
respond_with @pages
|
10
|
+
end
|
11
|
+
|
12
|
+
def site_url
|
13
|
+
'http://' + request.host_with_port
|
14
|
+
end
|
15
|
+
|
16
|
+
def public_page_url(page)
|
17
|
+
File.join(site_url, page.respond_to?(:permalink) ? page.permalink : page.fullpath)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Kms
|
2
|
+
module Seo
|
3
|
+
class RedirectsController < ApplicationController
|
4
|
+
def index
|
5
|
+
render json: Redirect.all, root: false
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
@redirect = Redirect.new(redirect_params)
|
10
|
+
if @redirect.save
|
11
|
+
render json: @redirect, root: false
|
12
|
+
else
|
13
|
+
render json: @redirect.to_json(methods: :errors), status: :unprocessable_entity
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def update
|
18
|
+
@redirect = Redirect.find(params[:id])
|
19
|
+
if @redirect.update(redirect_params)
|
20
|
+
render json: @redirect, root: false
|
21
|
+
else
|
22
|
+
render json: @redirect.to_json(methods: :errors), status: :unprocessable_entity
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def destroy
|
27
|
+
@redirect = Redirect.find(params[:id])
|
28
|
+
@redirect.destroy
|
29
|
+
render json: @redirect, root: false
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def redirect_params
|
35
|
+
params.require(:redirect).permit!
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
xml.instruct!
|
2
|
+
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
|
3
|
+
|
4
|
+
xml.url do
|
5
|
+
xml.loc site_url
|
6
|
+
xml.priority 1.0
|
7
|
+
end
|
8
|
+
|
9
|
+
@pages.each do |page|
|
10
|
+
unless page.index?
|
11
|
+
if page.templatable?
|
12
|
+
page.fetch_items.each do |c|
|
13
|
+
if c.slug.present?
|
14
|
+
xml.url do
|
15
|
+
xml.loc public_page_url(c)
|
16
|
+
xml.lastmod c.updated_at.to_date.to_s('%Y-%m-%d')
|
17
|
+
xml.priority 0.9
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
else
|
22
|
+
xml.url do
|
23
|
+
xml.loc public_page_url(page)
|
24
|
+
xml.lastmod page.updated_at.to_date.to_s('%Y-%m-%d')
|
25
|
+
xml.priority 0.9
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>KmsSeo</title>
|
5
|
+
<%= stylesheet_link_tag "kms_seo/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "kms_seo/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Kms::ExternalsRegistry.register(:seo) do |request, controller|
|
2
|
+
page = Kms::ExternalsRegistry.externals[:page].call(request, controller)
|
3
|
+
return nil unless page
|
4
|
+
if page.source.templatable?
|
5
|
+
item = page.source.fetch_item!(File.basename(request.params[:path]))
|
6
|
+
Kms::SeoWrapper.new(item).to_drop
|
7
|
+
else
|
8
|
+
Kms::SeoWrapper.new(page.source).to_drop
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Kms::FormCustomizationService.register_templates(Kms::Page, 'seo')
|
@@ -0,0 +1 @@
|
|
1
|
+
Kms::ResourceService.register(:seo, Kms::Redirect, 'fa-arrow-right')
|
@@ -0,0 +1,18 @@
|
|
1
|
+
en:
|
2
|
+
seo: "SEO"
|
3
|
+
add_redirect: "Add Redirect"
|
4
|
+
activerecord:
|
5
|
+
models:
|
6
|
+
kms/redirect:
|
7
|
+
one: "Redirect"
|
8
|
+
few: "Redirects"
|
9
|
+
many: "Redirects"
|
10
|
+
other: "Redirects"
|
11
|
+
attributes:
|
12
|
+
kms/page:
|
13
|
+
seo_title: "Meta Title"
|
14
|
+
seo_keywords: "Meta Keywords"
|
15
|
+
seo_description: "Meta Description"
|
16
|
+
kms/redirect:
|
17
|
+
source: "Source/From"
|
18
|
+
destination: "Destination/To"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
ru:
|
2
|
+
seo: "SEO"
|
3
|
+
add_redirect: "Добавить редирект"
|
4
|
+
activerecord:
|
5
|
+
models:
|
6
|
+
kms/redirect:
|
7
|
+
one: "Редирект"
|
8
|
+
few: "Редиректа"
|
9
|
+
many: "Редиректов"
|
10
|
+
other: "Редиректы"
|
11
|
+
attributes:
|
12
|
+
kms/page:
|
13
|
+
seo_title: "Meta Title"
|
14
|
+
seo_keywords: "Meta Keywords"
|
15
|
+
seo_description: "Meta Description"
|
16
|
+
kms/redirect:
|
17
|
+
source: "Откуда"
|
18
|
+
destination: "Куда"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module KmsSeo
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../../../../../', __FILE__)
|
4
|
+
|
5
|
+
def insert_engine_routes
|
6
|
+
route %(
|
7
|
+
mount Kms::Seo::Engine => '/kms'
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
def insert_javascript
|
12
|
+
append_file "app/assets/javascripts/application.js", "//= require kms_seo/application\n"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Kms
|
2
|
+
module Seo
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
engine_name 'kms_seo'
|
5
|
+
isolate_namespace Kms::Seo
|
6
|
+
config.eager_load_paths += Dir["#{config.root}/lib/**/"]
|
7
|
+
config.to_prepare do
|
8
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../../app/**/*_decorator*.rb")) do |c|
|
9
|
+
require_dependency(c)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SEO Wrapper for page or entry
|
2
|
+
module Kms
|
3
|
+
class SeoWrapper
|
4
|
+
include Liquor::Dropable
|
5
|
+
|
6
|
+
def initialize(seo_context)
|
7
|
+
@seo_context = seo_context
|
8
|
+
end
|
9
|
+
|
10
|
+
def title
|
11
|
+
return nil unless @seo_context.respond_to?(:seo_title)
|
12
|
+
@seo_context.seo_title
|
13
|
+
end
|
14
|
+
|
15
|
+
def keywords
|
16
|
+
return nil unless @seo_context.respond_to?(:seo_keywords)
|
17
|
+
@seo_context.seo_keywords
|
18
|
+
end
|
19
|
+
|
20
|
+
def description
|
21
|
+
return nil unless @seo_context.respond_to?(:seo_description)
|
22
|
+
@seo_context.seo_description
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/kms_seo.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
5
|
+
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
6
|
+
ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
|
7
|
+
require "rails/test_help"
|
8
|
+
|
9
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
10
|
+
# to be shown.
|
11
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
12
|
+
|
13
|
+
# Load support files
|
14
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
15
|
+
|
16
|
+
# Load fixtures from the engine
|
17
|
+
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
18
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kms_seo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Petrov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-29 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: 5.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kms
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Adds SEO support to KMS
|
56
|
+
email:
|
57
|
+
- garik.piton@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- app/assets/javascripts/kms_seo/application.js
|
66
|
+
- app/assets/javascripts/kms_seo/application/controllers/redirects_controller.coffee.erb
|
67
|
+
- app/assets/javascripts/kms_seo/application/routes.coffee.erb
|
68
|
+
- app/assets/javascripts/templates/pages/seo.html.slim
|
69
|
+
- app/assets/javascripts/templates/redirects/index.html.slim
|
70
|
+
- app/assets/stylesheets/kms_seo/application.css
|
71
|
+
- app/controllers/kms/pages_controller_decorator.rb
|
72
|
+
- app/controllers/kms/public/pages_controller_decorator.rb
|
73
|
+
- app/controllers/kms/public/sitemaps_controller.rb
|
74
|
+
- app/controllers/kms/seo/redirects_controller.rb
|
75
|
+
- app/helpers/kms_seo/application_helper.rb
|
76
|
+
- app/models/kms/redirect.rb
|
77
|
+
- app/serializers/kms/redirect_serializer.rb
|
78
|
+
- app/views/kms/public/sitemaps/show.xml.builder
|
79
|
+
- app/views/layouts/kms_seo/application.html.erb
|
80
|
+
- config/initializers/externals.rb
|
81
|
+
- config/initializers/form_customizations.rb
|
82
|
+
- config/initializers/resources.rb
|
83
|
+
- config/locales/en.yml
|
84
|
+
- config/locales/ru.yml
|
85
|
+
- config/routes.rb
|
86
|
+
- db/migrate/20150727192219_add_seo_fields_to_pages.rb
|
87
|
+
- db/migrate/20150903135219_create_redirects.rb
|
88
|
+
- lib/generators/kms_seo/install/install_generator.rb
|
89
|
+
- lib/kms/drops/seo_wrapper_drop.rb
|
90
|
+
- lib/kms/seo/engine.rb
|
91
|
+
- lib/kms/seo/version.rb
|
92
|
+
- lib/kms/seo_wrapper.rb
|
93
|
+
- lib/kms_seo.rb
|
94
|
+
- lib/tasks/kms_seo_tasks.rake
|
95
|
+
- test/integration/navigation_test.rb
|
96
|
+
- test/kms_seo_test.rb
|
97
|
+
- test/test_helper.rb
|
98
|
+
homepage: http://webgradus.ru
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.5.1
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Adds SEO support to KMS
|
122
|
+
test_files:
|
123
|
+
- test/integration/navigation_test.rb
|
124
|
+
- test/kms_seo_test.rb
|
125
|
+
- test/test_helper.rb
|