seo_pages 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/seo_pages/seo_pages_controller.rb +1 -1
  3. data/app/helpers/seo_pages/application_helper.rb +1 -1
  4. data/app/models/seo_pages/seo_page.rb +27 -0
  5. data/app/views/seo_pages/seo_pages/_form.html.erb +3 -0
  6. data/db/migrate/20130927173154_add_is_regex_to_seo_pages.rb +5 -0
  7. data/lib/seo_pages/version.rb +1 -1
  8. data/test/dummy/app/assets/javascripts/products.js +2 -0
  9. data/test/dummy/app/assets/stylesheets/products.css +4 -0
  10. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  11. data/test/dummy/app/controllers/products_controller.rb +58 -0
  12. data/test/dummy/app/helpers/products_helper.rb +2 -0
  13. data/test/dummy/app/models/product.rb +2 -0
  14. data/test/dummy/app/views/layouts/application.html.erb +1 -1
  15. data/test/dummy/app/views/products/_form.html.erb +21 -0
  16. data/test/dummy/app/views/products/edit.html.erb +6 -0
  17. data/test/dummy/app/views/products/index.html.erb +27 -0
  18. data/test/dummy/app/views/products/new.html.erb +5 -0
  19. data/test/dummy/app/views/products/show.html.erb +9 -0
  20. data/test/dummy/config/routes.rb +2 -0
  21. data/test/dummy/db/migrate/{20130909135320_create_seo_pages_seo_page_defaults.seo_pages.rb → 20130927171428_create_seo_pages_seo_page_defaults.seo_pages.rb} +0 -0
  22. data/test/dummy/db/migrate/{20130909135321_create_seo_pages_seo_pages.seo_pages.rb → 20130927171429_create_seo_pages_seo_pages.seo_pages.rb} +0 -0
  23. data/test/dummy/db/migrate/{20130909135322_create_default_record.seo_pages.rb → 20130927171430_create_default_record.seo_pages.rb} +0 -0
  24. data/test/dummy/db/migrate/20130927171851_create_products.rb +9 -0
  25. data/test/dummy/db/migrate/20130927173450_add_is_regex_to_seo_pages.seo_pages.rb +6 -0
  26. data/test/dummy/db/schema.rb +8 -1
  27. data/test/dummy/db/test.sqlite3 +0 -0
  28. data/test/dummy/test/controllers/products_controller_test.rb +49 -0
  29. data/test/dummy/test/fixtures/products.yml +7 -0
  30. data/test/dummy/test/helpers/products_helper_test.rb +4 -0
  31. data/test/dummy/test/models/product_test.rb +7 -0
  32. data/test/dummy/tmp/cache/assets/development/sprockets/100254abd166c2c45a5851f4ca60e76e +0 -0
  33. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  34. data/test/dummy/tmp/cache/assets/development/sprockets/{5e49a9e50308d9df9c3b978c189e1a95 → 1895131c40748b0414dc4ec32393fc06} +0 -0
  35. data/test/dummy/tmp/cache/assets/development/sprockets/29e6f58c7f81b16f078c14b63ab2164e +0 -0
  36. data/test/dummy/tmp/cache/assets/development/sprockets/2a899d1979e398f21f3393af6cc3da89 +0 -0
  37. data/test/dummy/tmp/cache/assets/development/sprockets/2e06c1d1fa05a4864c17ce06cbb8df6f +0 -0
  38. data/test/dummy/tmp/cache/assets/development/sprockets/2e1453636c7989f68f8ff64a487c74a6 +0 -0
  39. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  40. data/test/dummy/tmp/cache/assets/development/sprockets/31710301f0d68b89727f5de964446610 +0 -0
  41. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  42. data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  43. data/test/dummy/tmp/cache/assets/development/sprockets/3f0a55525ab570339c0fcbfb463fe069 +0 -0
  44. data/test/dummy/tmp/cache/assets/development/sprockets/4f0ccf0eb5b1919093867409e71115ab +0 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  46. data/test/dummy/tmp/cache/assets/development/sprockets/{b64ef79b76b687f0bcd96c61bfcbad04 → 541dd75ce6f1074444b0c96938b27732} +0 -0
  47. data/test/dummy/tmp/cache/assets/development/sprockets/552b4516be6f766a2da35c26be2f1ecf +0 -0
  48. data/test/dummy/tmp/cache/assets/development/sprockets/6025fb186ae1231e67f950857d969e18 +0 -0
  49. data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  50. data/test/dummy/tmp/cache/assets/development/sprockets/8ea40d0224e2d772232dcbfbf0fc3005 +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/{4f86487aa5d289eda467a8c6537a96d7 → 976cd53e8ad83f25733f23f56452eae0} +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/998581655254969187ae9e38e5dfd2bc +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/9d79a842f086f17d3420e5cb88710c10 +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/{111856d8daa1082bf05efab4077547a6 → af7f07d8db8655b7b2c88bb46ca86cbb} +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/b618d1e91e964f790e3ab99ac0f1a717 +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/c6dd8e9ad92af5994abfaafcc6b53e56 +0 -0
  57. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/d3595d230717ab840e8f75b2c4557d46 +0 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/df028ef849d9b6fc8046f3cdbec1784b +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/e26f396103ac57cdf4c55b6b461af9c0 +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/e95e33937352131984bbe9271c9e978d +0 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/fd37851cdd36c36d11d133edab45a370 +0 -0
  65. metadata +200 -139
  66. data/test/dummy/db/development.sqlite3 +0 -0
  67. data/test/dummy/log/development.log +0 -2735
  68. data/test/dummy/tmp/cache/assets/development/sprockets/01fbd25f95749291c3002e82372ce4c7 +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/19dc844a3495c2ebc1346a3a3c12e263 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/2147ddaeafe0b9a21df5d34acc0ddeed +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/2d8705afe57b62d44449d69f4222290f +0 -0
  72. data/test/dummy/tmp/cache/assets/development/sprockets/65009485adc1a6a013669d3dd03bccf2 +0 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/69d9fcd635a8a7e09a3553bb42dcb9fe +0 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/70a21f35131b909ba99755f18f61bc86 +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sprockets/861696f6bec1e79e099c05ac9817ea73 +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/b273afc43ae2c708d583ed1b9ee0dbdf +0 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/b51894bec29fad0fe908ff07013df296 +0 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/d2b80b70d9f90c0787c9cdcfca9a7cc0 +0 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/d85a70becfb7be07108c6a9b1a530599 +0 -0
  80. data/test/dummy/tmp/cache/assets/development/sprockets/dced4195b263fd551435b0ba4c6e1ce6 +0 -0
  81. data/test/dummy/tmp/cache/assets/development/sprockets/e79502ecdcd92526d5d53dde53001f93 +0 -0
  82. data/test/dummy/tmp/pids/server.pid +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0836aa375525e9e6c036877cea72eb9ffb331739
4
- data.tar.gz: 1fd803867d5524865bef3833777579bf9887cec3
3
+ metadata.gz: 083afe98d92c2c4a03ba25db1dfc51d609c2adf9
4
+ data.tar.gz: 1f6dcb3ca972f13845ebd6dba8fd9fe205fb095d
5
5
  SHA512:
6
- metadata.gz: 9c963a61bf13d85a28a9bf10ce9a284dd728e741ee936536a99fc72140401d65acda774e1cc9f2838f7a3fecd1cabe77b22fe24ea127924cdac5ae356eb05687
7
- data.tar.gz: ebae1a5d79899103f5c59972b42db14b125fce9e0a1e0a721858b4e2f8568c9163f07ddadf088d365f868194b3e21f38571188888c55d8061be8253c6dbc39cf
6
+ metadata.gz: fb982e6957535b3e9f437f41ae61d28198dcc64a9faf3945d78899172ef9f4aa86a21834c765cd47c7a0e0e561a4b22a905904ee3e284e5c926383bca0fdd9b8
7
+ data.tar.gz: 5403da8e53bf5b63a7fd7c6ae579559bd9d80e72f3fa1bf4a6ddefe0bddc0dc6d87e66ee6abf521a5664fb92610f40f1a44ec01046540409e1a4c2ac2167d9e4
@@ -57,7 +57,7 @@ module SeoPages
57
57
 
58
58
  # Only allow a trusted parameter "white list" through.
59
59
  def seo_page_params
60
- params.require(:seo_page).permit(:url_identifier, :page_title, :meta_keywords, :meta_description)
60
+ params.require(:seo_page).permit(:url_identifier, :is_regex, :page_title, :meta_keywords, :meta_description)
61
61
  end
62
62
  end
63
63
  end
@@ -2,7 +2,7 @@ module SeoPages
2
2
  module ApplicationHelper
3
3
  def seo_data
4
4
  @seo_default ||= SeoPages::SeoPageDefault.first
5
- @seo = SeoPages::SeoPage.where(url_identifier: request.fullpath).first || SeoPages::SeoPage.new
5
+ @seo = SeoPages::SeoPage.find_by_url(request.fullpath) || SeoPages::SeoPage.new
6
6
 
7
7
  @seo.page_title ||= @seo_default.page_title
8
8
  @seo.meta_keywords ||= @seo_default.meta_keywords
@@ -1,5 +1,32 @@
1
1
  module SeoPages
2
2
  class SeoPage < ActiveRecord::Base
3
3
  validates :url_identifier, uniqueness: true
4
+
5
+ scope :regex, -> { where(is_regex: true)}
6
+ scope :non_regex, -> { where(is_regex: false)}
7
+
8
+ @@regex = {}
9
+
10
+ def self.find_by_url(url)
11
+ exact_match(url) || regex_match(url)
12
+ end
13
+
14
+ def self.exact_match(url)
15
+ non_regex.where(url_identifier: url).first
16
+ end
17
+
18
+ def self.regex_match(url)
19
+ regex.to_a.find do |seo|
20
+ get_regex(seo.url_identifier) =~ url
21
+ end
22
+ end
23
+
24
+ def self.get_regex(url)
25
+ if @@regex[url].nil?
26
+ @@regex[url] = Regexp.new(url)
27
+ else
28
+ @@regex[url]
29
+ end
30
+ end
4
31
  end
5
32
  end
@@ -17,6 +17,9 @@
17
17
  <div class="field">
18
18
  <%= f.label :url_identifier %><br>
19
19
  <%= f.text_field :url_identifier %>
20
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
21
+ <%= f.check_box :is_regex %>
22
+ <%= f.label "Regular Expression?" %>
20
23
  </div>
21
24
 
22
25
  <div class="field">
@@ -0,0 +1,5 @@
1
+ class AddIsRegexToSeoPages < ActiveRecord::Migration
2
+ def change
3
+ add_column :seo_pages_seo_pages, :is_regex, :boolean
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module SeoPages
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,58 @@
1
+ class ProductsController < ApplicationController
2
+ before_action :set_product, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /products
5
+ def index
6
+ @products = Product.all
7
+ end
8
+
9
+ # GET /products/1
10
+ def show
11
+ end
12
+
13
+ # GET /products/new
14
+ def new
15
+ @product = Product.new
16
+ end
17
+
18
+ # GET /products/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /products
23
+ def create
24
+ @product = Product.new(product_params)
25
+
26
+ if @product.save
27
+ redirect_to @product, notice: 'Product was successfully created.'
28
+ else
29
+ render action: 'new'
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /products/1
34
+ def update
35
+ if @product.update(product_params)
36
+ redirect_to @product, notice: 'Product was successfully updated.'
37
+ else
38
+ render action: 'edit'
39
+ end
40
+ end
41
+
42
+ # DELETE /products/1
43
+ def destroy
44
+ @product.destroy
45
+ redirect_to products_url, notice: 'Product was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_product
51
+ @product = Product.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def product_params
56
+ params.require(:product).permit(:name)
57
+ end
58
+ end
@@ -0,0 +1,2 @@
1
+ module ProductsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class Product < ActiveRecord::Base
2
+ end
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title><%= seo_page %></title>
4
+ <%= seo_page %>
5
5
  <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
6
  <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
7
  <%= csrf_meta_tags %>
@@ -0,0 +1,21 @@
1
+ <%= form_for(@product) do |f| %>
2
+ <% if @product.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@product.errors.count, "error") %> prohibited this product from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @product.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing product</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @product %> |
6
+ <%= link_to 'Back', products_path %>
@@ -0,0 +1,27 @@
1
+ <h1>Listing products</h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>Name</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <% @products.each do |product| %>
15
+ <tr>
16
+ <td><%= product.name %></td>
17
+ <td><%= link_to 'Show', product %></td>
18
+ <td><%= link_to 'Edit', edit_product_path(product) %></td>
19
+ <td><%= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } %></td>
20
+ </tr>
21
+ <% end %>
22
+ </tbody>
23
+ </table>
24
+
25
+ <br>
26
+
27
+ <%= link_to 'New Product', new_product_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New product</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', products_path %>
@@ -0,0 +1,9 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @product.name %>
6
+ </p>
7
+
8
+ <%= link_to 'Edit', edit_product_path(@product) %> |
9
+ <%= link_to 'Back', products_path %>
@@ -1,4 +1,6 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
+ resources :products
4
+
3
5
  mount SeoPages::Engine => "/seo_pages"
4
6
  end
@@ -0,0 +1,9 @@
1
+ class CreateProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :products do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ # This migration comes from seo_pages (originally 20130927173154)
2
+ class AddIsRegexToSeoPages < ActiveRecord::Migration
3
+ def change
4
+ add_column :seo_pages_seo_pages, :is_regex, :boolean
5
+ end
6
+ end
@@ -11,7 +11,13 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20130909135322) do
14
+ ActiveRecord::Schema.define(version: 20130927173450) do
15
+
16
+ create_table "products", force: true do |t|
17
+ t.string "name"
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
+ end
15
21
 
16
22
  create_table "seo_pages_seo_page_defaults", force: true do |t|
17
23
  t.string "page_title"
@@ -28,6 +34,7 @@ ActiveRecord::Schema.define(version: 20130909135322) do
28
34
  t.string "meta_description"
29
35
  t.datetime "created_at"
30
36
  t.datetime "updated_at"
37
+ t.boolean "is_regex"
31
38
  end
32
39
 
33
40
  end
File without changes
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class ProductsControllerTest < ActionController::TestCase
4
+ setup do
5
+ @product = products(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:products)
12
+ end
13
+
14
+ test "should get new" do
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ test "should create product" do
20
+ assert_difference('Product.count') do
21
+ post :create, product: { name: @product.name }
22
+ end
23
+
24
+ assert_redirected_to product_path(assigns(:product))
25
+ end
26
+
27
+ test "should show product" do
28
+ get :show, id: @product
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ get :edit, id: @product
34
+ assert_response :success
35
+ end
36
+
37
+ test "should update product" do
38
+ patch :update, id: @product, product: { name: @product.name }
39
+ assert_redirected_to product_path(assigns(:product))
40
+ end
41
+
42
+ test "should destroy product" do
43
+ assert_difference('Product.count', -1) do
44
+ delete :destroy, id: @product
45
+ end
46
+
47
+ assert_redirected_to products_path
48
+ end
49
+ end
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ name: MyString
5
+
6
+ two:
7
+ name: MyString
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class ProductsHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ProductTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end