fi_seo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +3 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +6 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +10 -0
  8. data/Gemfile.lock +93 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +309 -0
  11. data/Rakefile +6 -0
  12. data/app/controller/sitemap_controller.rb +58 -0
  13. data/app/views/acts_as_seoable/_view_helper.html.arb +31 -0
  14. data/app/views/google_analytics/_acts_as_seoable.html.erb +9 -0
  15. data/app/views/sitemap/sitemap.xml.erb +1 -0
  16. data/bin/console +14 -0
  17. data/bin/setup +8 -0
  18. data/config/routes.rb +7 -0
  19. data/fi_seo.gemspec +29 -0
  20. data/lib/acts_as_seoable/dynamic_seo.rb +6 -0
  21. data/lib/acts_as_seoable/engine.rb +6 -0
  22. data/lib/acts_as_seoable/google_analytic_seo.rb +5 -0
  23. data/lib/acts_as_seoable/helpers/sitemap_helper.rb +32 -0
  24. data/lib/acts_as_seoable/helpers/static_helper.rb +94 -0
  25. data/lib/acts_as_seoable/sitemap_seo.rb +10 -0
  26. data/lib/acts_as_seoable/static_seo.rb +5 -0
  27. data/lib/acts_as_seoable/version.rb +3 -0
  28. data/lib/fi_seo.rb +205 -0
  29. data/lib/generators/acts_as_seoable/admin/admin_generator.rb +17 -0
  30. data/lib/generators/acts_as_seoable/admin/templates/admin.rb +250 -0
  31. data/lib/generators/acts_as_seoable/admin_view_helper/admin_view_helper_generator.rb +17 -0
  32. data/lib/generators/acts_as_seoable/admin_view_helper/templates/_view_helper.html.arb +31 -0
  33. data/lib/generators/acts_as_seoable/install/install_generator.rb +13 -0
  34. data/lib/generators/acts_as_seoable/install/templates/initializer.rb +20 -0
  35. data/lib/generators/acts_as_seoable/migrate/migrate_generator.rb +22 -0
  36. data/lib/generators/acts_as_seoable/migrate/templates/migration.rb +65 -0
  37. data/screenshots/dynamic-pages-seoable.png +0 -0
  38. data/screenshots/static-pages-seoable-details.png +0 -0
  39. data/screenshots/static-pages-seoable-frontend.png +0 -0
  40. data/screenshots/static-pages-seoable.png +0 -0
  41. metadata +140 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a4b6862bad29b1fb7ce90cab401d565ee92516c9ace05e8ebb9936e317549506
4
+ data.tar.gz: 82faae7924d91bbf8e63071fb6b75e3dd0403c3ac854df138eb374a635de7bbf
5
+ SHA512:
6
+ metadata.gz: a239940436fe911a43d9e90fdbe740ae0799bd5b5e242e88af7c931e6872ae9d87ae085913d11003e69704ab666810a262b92afbb5e4ea599066ae2a93d62a64
7
+ data.tar.gz: 277b06536793f9f15cb35cae8ad76ce162596c852e834459f6be49ffa9a552fd0ca39caf8b1bc75d522678266c3919bb87f073dd81bb1eedbf345a8eea933836
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # Remove .idea files from project (specified for JetBrains RubyMine)
11
+ .idea/
12
+ *.iml
13
+
14
+ # rspec failure tracking
15
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.3
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5.3
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fi_seo.gemspec
4
+ gemspec
5
+
6
+ gem 'rake', '~> 12.0'
7
+ gem 'rspec', '~> 3.0'
8
+ gem 'meta-tags', '~> 2.13'
9
+ gem 'activerecord','~> 5.0', '>= 5.0.0.1'
10
+ gem 'xml-sitemap', '~> 1.3', '>= 1.3.3'
data/Gemfile.lock ADDED
@@ -0,0 +1,93 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fi_seo (0.1.0)
5
+ activerecord (~> 5.0, >= 5.0.0.1)
6
+ meta-tags (~> 2.13)
7
+ xml-sitemap (~> 1.3, >= 1.3.3)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (5.2.4.2)
13
+ actionview (= 5.2.4.2)
14
+ activesupport (= 5.2.4.2)
15
+ rack (~> 2.0, >= 2.0.8)
16
+ rack-test (>= 0.6.3)
17
+ rails-dom-testing (~> 2.0)
18
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
19
+ actionview (5.2.4.2)
20
+ activesupport (= 5.2.4.2)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.4)
23
+ rails-dom-testing (~> 2.0)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
25
+ activemodel (5.2.4.2)
26
+ activesupport (= 5.2.4.2)
27
+ activerecord (5.2.4.2)
28
+ activemodel (= 5.2.4.2)
29
+ activesupport (= 5.2.4.2)
30
+ arel (>= 9.0)
31
+ activesupport (5.2.4.2)
32
+ concurrent-ruby (~> 1.0, >= 1.0.2)
33
+ i18n (>= 0.7, < 2)
34
+ minitest (~> 5.1)
35
+ tzinfo (~> 1.1)
36
+ arel (9.0.0)
37
+ builder (3.2.4)
38
+ concurrent-ruby (1.1.6)
39
+ crass (1.0.6)
40
+ diff-lcs (1.3)
41
+ erubi (1.9.0)
42
+ i18n (1.8.2)
43
+ concurrent-ruby (~> 1.0)
44
+ loofah (2.4.0)
45
+ crass (~> 1.0.2)
46
+ nokogiri (>= 1.5.9)
47
+ meta-tags (2.13.0)
48
+ actionpack (>= 3.2.0, < 6.1)
49
+ mini_portile2 (2.4.0)
50
+ minitest (5.14.0)
51
+ nokogiri (1.10.9)
52
+ mini_portile2 (~> 2.4.0)
53
+ rack (2.2.2)
54
+ rack-test (1.1.0)
55
+ rack (>= 1.0, < 3)
56
+ rails-dom-testing (2.0.3)
57
+ activesupport (>= 4.2.0)
58
+ nokogiri (>= 1.6)
59
+ rails-html-sanitizer (1.3.0)
60
+ loofah (~> 2.3)
61
+ rake (12.3.3)
62
+ rspec (3.9.0)
63
+ rspec-core (~> 3.9.0)
64
+ rspec-expectations (~> 3.9.0)
65
+ rspec-mocks (~> 3.9.0)
66
+ rspec-core (3.9.1)
67
+ rspec-support (~> 3.9.1)
68
+ rspec-expectations (3.9.1)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.9.0)
71
+ rspec-mocks (3.9.1)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.9.0)
74
+ rspec-support (3.9.2)
75
+ thread_safe (0.3.6)
76
+ tzinfo (1.2.6)
77
+ thread_safe (~> 0.1)
78
+ xml-sitemap (1.3.3)
79
+ builder (>= 2.0)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ activerecord (~> 5.0, >= 5.0.0.1)
86
+ fi_seo!
87
+ meta-tags (~> 2.13)
88
+ rake (~> 12.0)
89
+ rspec (~> 3.0)
90
+ xml-sitemap (~> 1.3, >= 1.3.3)
91
+
92
+ BUNDLED WITH
93
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 TODO: Write your name
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,309 @@
1
+ # FiSeo
2
+
3
+ This gem provides a easier solution to search engine optimization(SEO) in a ruby project. This will give you the seo capabilities to your static pages and dynamic pages alike with few lines of code.
4
+ Also site maps are essential to the SEO of your web application. So this gem gives that capabilities with a feature to integrate google analytics.
5
+
6
+ This gem currently integrate with the Active Admin for management of the gem. Dynamic pages and other settings also include with the integration.
7
+
8
+
9
+ ## Goals
10
+
11
+ 1. To give ability to easily integrate seo solution with your application.
12
+ 2. Give most popular seo strategies in a compact package.
13
+ 3. To reduce the development time by substantial amount.
14
+
15
+ ## Dependencies
16
+
17
+ This gem depend on:
18
+ * activerecord
19
+ * meta-tags
20
+ * xml-sitemap
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'fi_seo'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ $ bundle install
33
+
34
+ After updating your bundle, run the migration as follows:
35
+
36
+ $ acts_as_seoable:migrate
37
+ $ rails db:migrate
38
+
39
+ ## Usage
40
+
41
+ First, add this code to your main layout:
42
+
43
+ ```erbruby
44
+ # application.html.erb
45
+
46
+ <head>
47
+ <%= display_meta_tags site: 'My website' %>
48
+ </head>
49
+ ```
50
+ ### Options
51
+ These options can be used in the both static pages and dynamic pages. For examples please refer each usage guides.
52
+
53
+ | Option | Description |
54
+ | -------------- | ----------- |
55
+ | `:separator` | text used to separate website name from page title |
56
+ | `:lowercase` | when true, the page name will be lowercase |
57
+ | `:reverse` | when true, the page and site names will be reversed |
58
+ | `:noindex` | add noindex meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
59
+ | `:index` | add index meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
60
+ | `:nofollow` | add nofollow meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
61
+ | `:follow` | add follow meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
62
+ | `:noarchive` | add noarchive meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
63
+ | `:canonical` | add canonical link tag |
64
+
65
+ ### Static Pages
66
+
67
+ For static pages you need to configure routes as follows:
68
+ ```ruby
69
+ # routes.rb
70
+
71
+ root 'pages#home', defaults: { acts_as_seoable: true }
72
+ ```
73
+
74
+ In routes you need to add defaults arguments to a static page.
75
+ You also can set act_as_seoable to false as well. But any other value used will also be considered as a false hence will not be a seoable route.
76
+
77
+ If you ran the server after this you would not see any different. Because we need to render the meta tags to the page. See following example for that:
78
+ ```ruby
79
+ # some_controller.rb
80
+
81
+ def home
82
+ set_meta_tags FiSeo.create_static_meta_tags(controller_name, action_name, social:%i[facebook twitter])
83
+ end
84
+ ```
85
+
86
+ If you want to include any above mention options to meta tags You do that as follows:
87
+
88
+ ```ruby
89
+ # some_controller.rb
90
+
91
+ def home
92
+ set_meta_tags FiSeo.create_static_meta_tags(controller_name, action_name, social:%i[facebook twitter], lowercase: true, noindex: true)
93
+ end
94
+ ```
95
+
96
+ If the few action in a same controller with static pages use this instead:
97
+
98
+ ```ruby
99
+ # application_controller.rb
100
+
101
+ def static_meta_tag_creation
102
+ set_meta_tags FiSeo.create_static_meta_tags(controller_name, action_name)
103
+ end
104
+
105
+ # any_controller
106
+
107
+ before_action :static_meta_tag_creation
108
+ ```
109
+
110
+ Note: You can use any method name for before action method
111
+
112
+ ### Dynamic Pages
113
+
114
+ For dynamic seoable pages you need to configure model as follows:
115
+ ```ruby
116
+ # model.rb
117
+
118
+ acts_as_seoable :title, :description, :keywords
119
+ ```
120
+
121
+ If the model has attributes for that you need to use for the seoable attributes you can add as above. You can also build and set by method as well.
122
+ ```ruby
123
+ # model.rb
124
+
125
+ acts_as_seoable :title_seoable, :description, :keywords
126
+
127
+ def title_seoable
128
+ "#{self.name}#{self.id}"
129
+ end
130
+ ```
131
+ when you create a new record from this model the gem will create a corresponding seoable record as well. Above values will be set as default values.
132
+
133
+
134
+ For dynamic records you can have option set for the model.
135
+
136
+ And here are a few examples to give you ideas.
137
+
138
+ ```ruby
139
+ # model.rb
140
+
141
+ acts_as_seoable :title, :description, :keywords, social: [:facebook, :twitter], noindex: true
142
+
143
+ # model.rb
144
+
145
+ acts_as_seoable :title, :description, :keywords, social: [:facebook, :twitter], lowercase: true
146
+ ```
147
+
148
+ For social tags default they are empty. It can be set by the model as follows:
149
+
150
+ ```ruby
151
+ # model.rb
152
+
153
+ def facebook_tags
154
+ {
155
+ title: 'title',
156
+ type: 'type',
157
+ url: 'url',
158
+ image: 'image_url',
159
+ description: 'description'
160
+ }
161
+ end
162
+
163
+ def twitter_tags
164
+ {
165
+ title: 'title',
166
+ card: 'card',
167
+ site: 'site_url',
168
+ image: 'image_url',
169
+ description: 'description'
170
+ }
171
+ end
172
+ ```
173
+
174
+ ### Sitemap
175
+
176
+ For sitemap you need to configure as follows:
177
+ ```ruby
178
+ # routes.rb
179
+
180
+ root 'pages#home', defaults: { sitemap: true, static: true }
181
+ ```
182
+ For static pages in the sitemap you must user static as true in the route. Otherwise this route will considered as dynamic route.
183
+
184
+ After that restart you server and you will able to see your sitemap at the path of:
185
+
186
+ your_address/sitemap.xml
187
+
188
+ ### Google Analytics
189
+
190
+ First, add this code to your main layout:
191
+
192
+ ```erb
193
+ # application.html.erb
194
+
195
+ <head>
196
+ <%= render 'google_analytics/acts_as_seoable' %>
197
+ </head>
198
+ ```
199
+
200
+ Then you can edit the analytic Id from the backend.
201
+
202
+ ### Generators
203
+
204
+ There are few initializers and generators for this gem to help you to configure the behavior of the gem.
205
+ #### Migration
206
+
207
+ Before using the gem you need to migrate the tables for gem to databalse. To get the migration run the following code:
208
+ ```bash
209
+ $ acts_as_seoable:migrate
210
+ ```
211
+ #### Gem Initializer
212
+ This initializer will give ability to set few social configuration and website name for seo and few other things.
213
+ Run the following code for to create initializer:
214
+ ```bash
215
+ $ acts_as_seoable:install
216
+ ```
217
+ #### Active Admin Page
218
+ *Only if you are using active admin*
219
+
220
+ To add SEO data to active admin you need to run following code. This will generate a admin page:
221
+ ```bash
222
+ $ acts_as_seoable:admin
223
+ ```
224
+
225
+ #### Active Admin View Helper
226
+ *Only if you are using active admin*
227
+
228
+ To add active admin view helper you need to run following code. This will generate a **arb** file to add dynamic pages show and edit action:
229
+ ```bash
230
+ $ acts_as_seoable:admin_view_helper
231
+ ```
232
+
233
+ ### Active Admin
234
+
235
+ This gem is fully compatible with the active admin gem. To use run generator command to get a active admin page for all of data this gem has to offer.
236
+ Then you can configure it to your likings.
237
+
238
+ Special feature of this is you are able to add dynamic records that are **seoable** can be edited of viewed. For example if a model seoable configured
239
+ you can add to following code view data in active admin.
240
+
241
+ ```erbruby
242
+ # app/admin/user.rb
243
+
244
+ show do |user|
245
+ render partial: 'acts_as_seoable/view_helper', locals: { seoable: user, action: 'show' }
246
+ end
247
+ ```
248
+
249
+ You must add action and seoable variables as locals to work. action can has either **show** or **edit** variables.
250
+
251
+ To edit seo variables from active admin first you need to allow params to permit by the active admin. Then you can edit view helper to edit values.
252
+
253
+ ```erbruby
254
+ # app/admin/user.rb
255
+
256
+ permit_params: dynamic_seos: [:title, :description, :keywords]
257
+ ```
258
+ Then:
259
+ ```erbruby
260
+ # app/admin/user.rb
261
+
262
+ form do |f|
263
+ if f.object.dynamic_seo.present?
264
+ render partial: 'acts_as_seoable/view_helper', locals: { seoable: f, action: 'edit '}
265
+ end
266
+ end
267
+ ```
268
+
269
+ ### Screenshots
270
+
271
+ ![activeadmin-dynamic-seoable](./screenshots/dynamic-pages-seoable.png)
272
+
273
+ Above image show how active admin backend let you configure the dynamic **seoable** records. To achieve this please
274
+ follow dynamic pages active admin guidelines.
275
+
276
+ ![activeadmin-static-seoable](./screenshots/static-pages-seoable.png)
277
+
278
+ Above image show how the static routes can be configured using active admin generator. It will capture the routes and show
279
+ it in here to edit.
280
+
281
+ ![activeadmin-static-seoable-frontend](./screenshots/static-pages-seoable-details.png)
282
+
283
+ Above image show how the meta details has been configured from the backend using active admin for a static route.
284
+ These details will appear in the frontend (inside the head tag).
285
+
286
+ ![activeadmin-static-seoable-frontend](./screenshots/static-pages-seoable-frontend.png)
287
+
288
+ Above image show how the meta tags has been rendered inside the head tag for a static page.
289
+ These can be changed by active admin or your backend itself.
290
+
291
+ ## ToDo Features
292
+
293
+
294
+ ## Getting Help
295
+
296
+ Got a bug and you're not sure? You're sure you have a bug, but don't know what to do next? In any case, let us know about it! The best place for letting the Contributes know about bugs or problems you're having is on the page at GitHub.
297
+
298
+ ## Contributing
299
+
300
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fi_seo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/fi_seo/blob/master/CODE_OF_CONDUCT.md).
301
+
302
+
303
+ ## License
304
+
305
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
306
+
307
+ ## Code of Conduct
308
+
309
+ Everyone interacting in the FiSeo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fi_seo/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,58 @@
1
+ require 'xml-sitemap'
2
+ require 'acts_as_seoable/helpers/sitemap_helper'
3
+
4
+ class SitemapController < ApplicationController
5
+ extend ActionDispatch::Routing::UrlFor
6
+
7
+ def sitemap
8
+ FiSeo::create_sitemap_seo_records
9
+ class_names = ActiveRecord::Base.connection.tables.map do |model|
10
+ model
11
+ end
12
+
13
+ domain = 'www.domain.com'
14
+ domain = FiSeo.initialized_config.sitemap_host_url if FiSeo.initialized_config.sitemap_host_url.present?
15
+
16
+ @map = XmlSitemap::Map.new(domain) do |m|
17
+ SitemapSeo.where(status: true).each do |site_map_seo|
18
+ action = site_map_seo.sitemap_action
19
+ controller = site_map_seo.sitemap_controller
20
+ priority = site_map_seo.priority
21
+ period = site_map_seo.period
22
+ static = site_map_seo.static
23
+
24
+ if SitemapSeo.periods[period.to_sym] == 0
25
+ period_string = 'none'
26
+ period_sym = period_string.to_sym
27
+ else
28
+ period_sym = period.to_sym
29
+ end
30
+
31
+ if class_names.include? controller.pluralize
32
+ p = controller.capitalize.singularize.camelize
33
+ if Object.const_defined?(p) && (%w[destroy update create index new].exclude? action) && p.constantize.any? && !static
34
+ p.constantize.all.each do |record|
35
+ if (%w[new create index].include? action)
36
+ m.add(url_for(controller: controller, action: action, only_path: true),
37
+ priority: priority, updated: Date.today, period: period_sym)
38
+ else
39
+ m.add(url_for(controller: controller, action: action, id: record.id, only_path: true),
40
+ priority: priority, updated: Date.today, period: period_sym)
41
+ end
42
+ end
43
+ elsif %w[destroy update create].exclude? action
44
+ m.add(url_for(controller: controller, action: action, only_path: true),
45
+ priority: priority, updated: Date.today, period: period_sym)
46
+ end
47
+ elsif %w[destroy update create].exclude? action
48
+ m.add(url_for(controller: controller, action: action, only_path: true),
49
+ priority: priority, updated: Date.today, period: period_sym)
50
+ end
51
+ end
52
+ end
53
+
54
+ respond_to do |format|
55
+ format.xml
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,31 @@
1
+ if defined?(seoable)
2
+ unless seoable.nil?
3
+ if action.to_s == 'show' && seoable.present? && seoable.dynamic_seo.present?
4
+ panel 'Dynamic SEO Information' do
5
+ attributes_table_for seoable.dynamic_seo do
6
+ row 'Title' do
7
+ seoable.dynamic_seo.title
8
+ end
9
+ row 'Description' do
10
+ seoable.dynamic_seo.description
11
+ end
12
+ row 'Keywords' do
13
+ seoable.dynamic_seo.keywords
14
+ end
15
+ end
16
+ end
17
+ elsif action.to_s == 'edit' && seoable.object.dynamic_seo.present?
18
+ seoable.inputs 'Dynamic SEO Information', for: [:dynamic_seo, seoable.object.dynamic_seo] do |dynamic_seo|
19
+ dynamic_seo.input :title
20
+ dynamic_seo.input :description
21
+ dynamic_seo.input :keywords
22
+ end
23
+ elsif action.to_s == 'new'
24
+ seoable.inputs 'Dynamic SEO Information', for: [:dynamic_seo, seoable.object.dynamic_seo || DynamicSeo.new] do |dynamic_seo|
25
+ dynamic_seo.input :title
26
+ dynamic_seo.input :description
27
+ dynamic_seo.input :keywords
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ <script>
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','https://www.google-analytics.com/analytics.js','ga');
6
+
7
+ ga('create', '<%= GoogleAnalyticSeo.first.content %>', 'none');
8
+ ga('send', 'pageview');
9
+ </script>
@@ -0,0 +1 @@
1
+ <%= @map.render.html_safe %>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fi_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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here