scrivito_seo_page_extender 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ed2ecbfe3ee81169a8f1cdee0ff37630732abcc
4
+ data.tar.gz: 38e29d9d6c202cd896814e596345cf806099b68e
5
+ SHA512:
6
+ metadata.gz: 3fe5c7ccd6e19be9b8ea1e160819c2f366ffeb2dafd80019a1d349e44620581f1153c72b111d2121ede50eb599b93c47aef9809bb8d9e3f6b8860235ea38df58
7
+ data.tar.gz: befb2f0a6964c1a0fd52ca662044d2f7c0a6abfeacd1c7b0201678c3d4bdde5a07d5908d8b596ecbcdef6d59c9b36c27be9935e7a7476209ad4a356ac06bed98
data/LICENSE ADDED
@@ -0,0 +1,4 @@
1
+ Copyright (c) 2009 - 2014 Infopark AG (http://www.infopark.com)
2
+
3
+ This software can be used and modified under the LGPL-3.0. Please refer to
4
+ http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
@@ -0,0 +1,24 @@
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 = 'ScrivitoSeoPageExtender'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
@@ -0,0 +1,13 @@
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/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -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,15 @@
1
+ module MetaDataExtender
2
+ def self.included(base)
3
+ base.attribute :meta_description, :string
4
+ base.attribute :meta_keywords, :string
5
+ base.attribute :meta_author, :string
6
+ base.attribute :meta_keywords, :string
7
+ base.attribute :meta_publisher, :string
8
+ base.attribute :meta_copyright, :string
9
+
10
+ base.attribute :meta_page_topic, :string
11
+ base.attribute :meta_page_type, :string
12
+ base.attribute :meta_audience, :string
13
+ base.attribute :meta_robots, :enum, values: ["index", "noindex", "nofollow", "all"]
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module OpenGraphExtender
2
+ def self.included(base)
3
+ base.attribute :og_author, :string
4
+ base.attribute :og_creator, :string
5
+ base.attribute :og_description, :string
6
+ base.attribute :og_director, :string
7
+ base.attribute :og_duration, :string
8
+ base.attribute :og_image, :reference
9
+ base.attribute :og_obj_type, :enum, values: ["website", "article", "profile", "video", "book", "other"]
10
+ base.attribute :og_release_date, :date
11
+ base.attribute :og_section, :string
12
+ base.attribute :og_title, :string
13
+ base.attribute :og_url, :string
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ module SitemapExtender
2
+ def self.included(base)
3
+ base.attribute :sitemap_frequency, :enum, values: ["always", "hourly", "daily", "weekly", "monthly", "yearly", "never"]
4
+ base.attribute :sitemap_priority, :enum, values: ["0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0"]
5
+ end
6
+ end
@@ -0,0 +1,41 @@
1
+ module SeoPageExtenderHelper
2
+ def words_density(obj, attribute)
3
+ words = get_words_from_page(obj, attribute).map { |e| e.downcase.gsub(/[^a-z0-9\s]/i, '') }
4
+ without_stop_words = remove_stop_words(words)
5
+ return {
6
+ count: without_stop_words.count,
7
+ density_for_one: density_with_one_word(without_stop_words),
8
+ density_for_two: density_with_n_word(2,without_stop_words),
9
+ density_for_three: density_with_n_word(3,without_stop_words)
10
+ }
11
+ end
12
+
13
+ private
14
+ def get_words_from_page(obj, attribute)
15
+ strip_tags(scrivito_tag(:span, obj, attribute).to_s).split(" ")
16
+ end
17
+
18
+ def calulate_count_of_all_words(words)
19
+ words.each_with_object(Hash.new(0)) {|word,counts| counts[word] += 1 }
20
+ end
21
+
22
+ def remove_stop_words(density)
23
+ density.select {|e| !stop_words_fallback.include? e}
24
+ end
25
+
26
+ def density_with_one_word(words)
27
+ calulate_count_of_all_words(words).sort_by {|word,count| count}.reverse
28
+ end
29
+
30
+ def density_with_n_word(n, words)
31
+ two_words = []
32
+ words[0..-(n+1)].each_with_index do |word, index|
33
+ two_words << words[index..index+n-1].join(" ")
34
+ end
35
+ return calulate_count_of_all_words(two_words).sort_by {|word,count| count}.reverse
36
+ end
37
+
38
+ def stop_words_fallback
39
+ "a,able,about,across,after,all,almost,also,am,among,an,and,any,are,as,at,be,because,been,but,by,can,cannot,could,dear,did,do,does,either,else,ever,every,for,from,get,got,had,has,have,he,her,hers,him,his,how,however,i,if,in,into,is,it,its,just,least,let,like,likely,may,me,might,most,must,my,neither,no,nor,not,of,off,often,on,only,or,other,our,own,rather,said,say,says,she,should,since,so,some,than,that,the,their,them,then,there,these,they,this,tis,to,too,twas,us,wants,was,we,were,what,when,where,which,while,who,whom,why,will,with,would,yet,you,your".split(",")
40
+ end
41
+ end
@@ -0,0 +1,7 @@
1
+ <% if @obj.respond_to?(attribute) && !@obj.send(attribute).blank? %>
2
+ <% if name.include? 'image' %>
3
+ <meta content="<%= @obj.send(attribute).try(:binary_url) %>" name="<%= name %>"/>
4
+ <% else %>
5
+ <meta content="<%= @obj.send(attribute) %>" name="<%= name %>"/>
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= render "seo_page_extender/meta_attribute", attribute: "meta_keywords", name: "keywords" %>
2
+ <%= render "seo_page_extender/meta_attribute", attribute: "meta_description", name: "description" %>
3
+ <%= render "seo_page_extender/meta_attribute", attribute: "meta_robots", name: "robots" %>
4
+ <%= render "seo_page_extender/meta_attribute", attribute: "meta_author", name: "author" %>
5
+
6
+ <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
7
+ <meta content="<%= 'https://#{request.raw_host_with_port + scrivito_path(@obj)}' %>" name="canonical"/>
@@ -0,0 +1,19 @@
1
+ <%= scrivito_details_for 'Keywords' do %>
2
+ <%= scrivito_tag(:div, obj, :meta_keywords, data: {editor: 'scrivito-list-editor', delimiter: ','}) %>
3
+ <% end %>
4
+
5
+ <%= scrivito_details_for 'Description' do %>
6
+ <%= scrivito_tag(:textarea, obj, :meta_description, data: {editor: 'scrivito-textarea-editor'}, style: 'width: 100%; height: 150px' ) %>
7
+ <% end %>
8
+
9
+ <%= scrivito_details_for 'Author' do %>
10
+ <%= scrivito_tag(:div, obj, :meta_author) %>
11
+ <% end %>
12
+
13
+ <%= scrivito_details_for 'Indexing for search engines' do %>
14
+ <%= scrivito_toggle_button_editor(obj, :meta_robots) %>
15
+ <% end %>
16
+
17
+ <%= scrivito_details_for 'Permalink' do %>
18
+ <%= scrivito_tag(:div, obj, :_permalink, data: {autosave: "false"}) %>
19
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_title", name: "og:title" %>
2
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_image", name: "og:image" %>
3
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_url", name: "og:url" %>
4
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_description", name: "og:description" %>
5
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_creator", name: "og:creator" %>
6
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_obj_type", name: "og:type" %>
7
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_director", name: "og:dircetor" %>
8
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_duration", name: "og:duration" %>
9
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_release_date", name: "og:release_date" %>
10
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_author", name: "og:author" %>
11
+ <%= render "seo_page_extender/meta_attribute", attribute: "og_section", name: "og:section" %>
@@ -0,0 +1,43 @@
1
+ <%= scrivito_details_for 'Title of page (Meta title as fallback)' do %>
2
+ <%= scrivito_tag(:div, obj, :og_title) %>
3
+ <% end %>
4
+
5
+ <%= scrivito_details_for 'Type' do %>
6
+ <%= scrivito_toggle_button_editor(obj, :og_obj_type) %>
7
+ <% end %>
8
+
9
+ <%= scrivito_details_for 'Image' do %>
10
+ <%= scrivito_tag(:div, obj, :og_image) %>
11
+ <% end %>
12
+
13
+ <%= scrivito_details_for 'Url' do %>
14
+ <%= scrivito_tag(:div, obj, :og_url) %>
15
+ <% end %>
16
+
17
+ <%= scrivito_details_for 'Description' do %>
18
+ <%= scrivito_tag(:div, obj, :og_description) %>
19
+ <% end %>
20
+
21
+ <%= scrivito_details_for 'Creator' do %>
22
+ <%= scrivito_tag(:div, obj, :og_creator) %>
23
+ <% end %>
24
+
25
+ <%= scrivito_details_for 'Director (For video)' do %>
26
+ <%= scrivito_tag(:div, obj, :og_director) %>
27
+ <% end %>
28
+
29
+ <%= scrivito_details_for 'Duration (For video)' do %>
30
+ <%= scrivito_tag(:div, obj, :og_duration) %>
31
+ <% end %>
32
+
33
+ <%= scrivito_details_for 'Release Date' do %>
34
+ <%= scrivito_tag(:div, obj, :og_release_date) %>
35
+ <% end %>
36
+
37
+ <%= scrivito_details_for 'Author (For book)' do %>
38
+ <%= scrivito_tag(:div, obj, :og_author) %>
39
+ <% end %>
40
+
41
+ <%= scrivito_details_for 'Section' do %>
42
+ <%= scrivito_tag(:div, obj, :og_section) %>
43
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= scrivito_details_for 'Priority for Sitemap' do %>
2
+ <%= scrivito_toggle_button_editor(obj, :sitemap_priority) %>
3
+ <% end %>
4
+
5
+ <%= scrivito_details_for 'Frequency of visits for bots' do %>
6
+ <%= scrivito_toggle_button_editor(obj, :sitemap_frequency) %>
7
+ <% end %>
@@ -0,0 +1,26 @@
1
+ <% words = words_density(obj, attribute) %>
2
+ <h4>
3
+ <%= words[:count] %>good words on this page (words not in stop word list)
4
+ </h4>
5
+ <ul class='tab-list'>
6
+ <li class='active' data-panel-target='#one-word'>
7
+ Single Words
8
+ </li>
9
+ <li data-panel-target='#two-words'>
10
+ Two word phrases
11
+ </li>
12
+ <li data-panel-target='#three-words'>
13
+ Three word phrases
14
+ </li>
15
+ </ul>
16
+ <div class='tab-panels'>
17
+ <div class='tab-panel active' id='one-word'>
18
+ <%= render 'seo_page_extender/word_density_part', list: words[:density_for_one][0..20], words: words %>
19
+ </div>
20
+ <div class='tab-panel' id='two-words'>
21
+ <%= render 'seo_page_extender/word_density_part', list: words[:density_for_two][0..20], words: words %>
22
+ </div>
23
+ <div class='tab-panel' id='three-words'>
24
+ <%= render 'seo_page_extender/word_density_part', list: words[:density_for_three][0..20], words: words %>
25
+ </div>
26
+ </div>
@@ -0,0 +1,22 @@
1
+ <table class="table table-bordered table-striped">
2
+ <thead>
3
+ <tr>
4
+ <th>Word</th>
5
+ <th>Count</th>
6
+ <th>Density</th>
7
+ </tr>
8
+ </thead>
9
+ <% list.each do |word, count| %>
10
+ <tr>
11
+ <td>
12
+ <%= word %>
13
+ </td>
14
+ <td>
15
+ <%= count %>
16
+ </td>
17
+ <td>
18
+ <%= (words[:count] > 0 ? count.to_f * 100 / words[:count].to_f : 0).round(2) %>
19
+ </td>
20
+ </tr>
21
+ <% end %>
22
+ </table>
@@ -0,0 +1,4 @@
1
+ require "scrivito_seo_page_extender/engine"
2
+
3
+ module ScrivitoSeoPageExtender
4
+ end
@@ -0,0 +1,11 @@
1
+ require 'scrivito_advanced_editors'
2
+
3
+ module ScrivitoSeoPageExtender
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace ScrivitoSeoPageExtender
6
+
7
+ initializer "seo_page_extender:seo_page_extender_helper" do
8
+ ActionView::Base.send :include, SeoPageExtenderHelper
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module ScrivitoSeoPageExtender
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :scrivito_seo_page_extender do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrivito_seo_page_extender
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Scrivito
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-21 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: scrivito_sdk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: scrivito_advanced_editors
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A Scrivito Widget to extend your Page with some useful SEO Features,
70
+ Metadata or Open Graph.
71
+ email:
72
+ - support@scrivito.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - LICENSE
78
+ - Rakefile
79
+ - app/assets/javascripts/scrivito_seo_page_extender/application.js
80
+ - app/assets/stylesheets/scrivito_seo_page_extender/application.css
81
+ - app/concerns/meta_data_extender.rb
82
+ - app/concerns/open_graph_extender.rb
83
+ - app/concerns/sitemap_extender.rb
84
+ - app/helper/seo_page_extender_helper.rb
85
+ - app/views/seo_page_extender/_meta_attribute.html.erb
86
+ - app/views/seo_page_extender/_meta_data.html.erb
87
+ - app/views/seo_page_extender/_meta_data_details.html.erb
88
+ - app/views/seo_page_extender/_open_graph.html.erb
89
+ - app/views/seo_page_extender/_open_graph_details.html.erb
90
+ - app/views/seo_page_extender/_sitemap_details.html.erb
91
+ - app/views/seo_page_extender/_word_density.html.erb
92
+ - app/views/seo_page_extender/_word_density_part.html.erb
93
+ - lib/scrivito_seo_page_extender.rb
94
+ - lib/scrivito_seo_page_extender/engine.rb
95
+ - lib/scrivito_seo_page_extender/version.rb
96
+ - lib/tasks/scrivito_seo_page_extender_tasks.rake
97
+ homepage: https://www.scrivito.com
98
+ licenses:
99
+ - LGPL-3.0
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.2.2
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: A Scrivito Widget to extend your Page with some useful SEO Features, Metadata
121
+ or Open Graph.
122
+ test_files: []