push_type_core 0.10.0.beta.3 → 0.10.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/push_type/application_controller_methods.rb +2 -0
  3. data/app/controllers/front_end_controller.rb +26 -12
  4. data/app/models/push_type/node.rb +11 -1
  5. data/lib/push_type/core/engine.rb +0 -11
  6. data/lib/push_type/rails/routes.rb +3 -3
  7. data/lib/push_type/version.rb +1 -1
  8. data/test/controllers/front_end_controller_test.rb +19 -0
  9. data/test/dummy/config/initializers/push_type.rb +1 -1
  10. data/test/dummy/config/secrets.yml +2 -2
  11. data/test/dummy/db/migrate/{20161116222801_create_push_type_users.push_type.rb → 20161117154442_create_push_type_users.push_type.rb} +0 -0
  12. data/test/dummy/db/migrate/{20161116222802_create_push_type_nodes.push_type.rb → 20161117154443_create_push_type_nodes.push_type.rb} +0 -0
  13. data/test/dummy/db/migrate/{20161116222803_create_push_type_node_hierarchies.push_type.rb → 20161117154444_create_push_type_node_hierarchies.push_type.rb} +0 -0
  14. data/test/dummy/db/migrate/{20161116222804_create_push_type_assets.push_type.rb → 20161117154445_create_push_type_assets.push_type.rb} +0 -0
  15. data/test/dummy/db/migrate/{20161116222805_add_field_store_default_values.push_type.rb → 20161117154446_add_field_store_default_values.push_type.rb} +0 -0
  16. data/test/dummy/db/migrate/{20161116222806_drop_legacy_push_type_taxonomies.push_type.rb → 20161117154447_drop_legacy_push_type_taxonomies.push_type.rb} +0 -0
  17. data/test/dummy/db/schema.rb +1 -1
  18. data/test/dummy/log/test.log +7667 -7437
  19. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{tn/tnKqEfyTQNEMuWAhX3xym0TbSoUwIe8XlKbKLmN8oPA.cache → Eq/EqAqaJ_tfMAtqoArQz8TAEgvbpQnvyKDhWfkgsLgDDk.cache} +0 -0
  20. data/test/dummy/tmp/cache/assets/sprockets/v3.0/VT/VT0xDh7gu1K3uYidKny01QY0vyaeQDbHoPICVlZmQQc.cache +0 -0
  21. data/test/dummy/tmp/cache/assets/sprockets/v3.0/YC/YCmmKydZG1FxHcFZiHcaSZhbT44fV2vJglp5i1fOvAc.cache +0 -0
  22. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{3D/3DiLOA9ufk-bm1-9-hOFWYmGKMgJWxv8xBbSS2pKDN4.cache → pl/plmO1IoJjY_rOEVF1tqlu49tmlR7S7ymF0T7YUqP6Uw.cache} +0 -0
  23. data/test/dummy/tmp/generators/app/models/home_page.rb +12 -0
  24. data/test/dummy/tmp/generators/app/views/nodes/home_page.html.erb +13 -0
  25. data/test/models/push_type/node_test.rb +11 -0
  26. metadata +22 -22
  27. data/test/dummy/tmp/generators/config/initializers/push_type.rb +0 -50
  28. data/test/dummy/tmp/generators/config/routes.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fd6cd0064cd63d1dd950087f1ac29d726f4c008
4
- data.tar.gz: 7f4324b860c06b86ca5544bbe74483228e9109ce
3
+ metadata.gz: 01c112917483c5214c46adac7908e1f325ece658
4
+ data.tar.gz: 984f05936884a2251f744836be2d47e2e22003d6
5
5
  SHA512:
6
- metadata.gz: 4d6b466d5f153fd3175aaa49d8730a4dd72e4d9936d69ceef3da9283570859f57d26dec1e801a0870ae28698efd0c49a9d7f9baff867364f19c5b781f78ce451
7
- data.tar.gz: fce3f8f57b3a02994a556a3dae73b6ecaec3c9206ca314ff1f12d013bc9e49a7e9e71c5e252d0b26204187c526681d01554e5ec96714ca0930062a292107004c
6
+ metadata.gz: 757c53adbab7868036862aa189ad61e7162741d4291afa88e7be46774db619b6d25cda0367852601d81907eb4f754a0c9b2a6ea6039f5bd42d5789f9c886fdb0
7
+ data.tar.gz: a8629fcc234ce54aeba05f52718b06bde6fdf014ed03a357dda81c48f1cfb632205ff8f2d1c605e00459c4906078a5a8009790aefe04c47afecf04cebca33177
@@ -8,6 +8,8 @@ module PushType
8
8
 
9
9
  included do
10
10
  class_attribute *FILTERS
11
+ helper PushType::MediaUrlHelper
12
+ helper PushType::NodeUrlHelper
11
13
  end
12
14
 
13
15
  protected
@@ -2,29 +2,31 @@ class FrontEndController < ApplicationController
2
2
 
3
3
  include PushType::Filterable
4
4
 
5
- before_action :load_node, only: :show
5
+ before_action :load_node, only: :show
6
+ before_action :load_preview_node, only: :preview
7
+ before_action :build_presenter
6
8
  node_filters
7
9
 
8
10
  def show
9
11
  render *@node.template_args
10
12
  end
11
13
 
12
- private
13
-
14
- def root_path?
15
- request.fullpath == '/'
14
+ def preview
15
+ response.headers['X-Robots-Tag'] = 'none'
16
+ show
16
17
  end
17
18
 
18
- def raise_404
19
- if root_path?
20
- render template: 'push_type/setup', layout: nil, status: 404
21
- else
22
- raise ActiveRecord::RecordNotFound
23
- end
24
- end
19
+ private
25
20
 
26
21
  def load_node
27
22
  @node = PushType::Node.exposed.published.find_by_path permalink_path
23
+ end
24
+
25
+ def load_preview_node
26
+ @node = PushType::Node.exposed.find_by_base64_id params[:id]
27
+ end
28
+
29
+ def build_presenter
28
30
  if @node
29
31
  instance_variable_set "@#{ @node.type.underscore }", @node.present!(view_context)
30
32
  else
@@ -32,4 +34,16 @@ class FrontEndController < ApplicationController
32
34
  end
33
35
  end
34
36
 
37
+ def root_path?
38
+ request.fullpath == main_app.home_node_path
39
+ end
40
+
41
+ def raise_404
42
+ if root_path?
43
+ render template: 'push_type/setup', layout: nil, status: 404
44
+ else
45
+ raise ActiveRecord::RecordNotFound
46
+ end
47
+ end
48
+
35
49
  end
@@ -17,9 +17,19 @@ module PushType
17
17
  validates :title, presence: true
18
18
  validates :slug, presence: true, uniqueness: { scope: :parent_id }
19
19
 
20
+ def self.find_by_base64_id(secret)
21
+ find Base64.urlsafe_decode64(secret)
22
+ rescue ArgumentError
23
+ raise ActiveRecord::RecordNotFound
24
+ end
25
+
26
+ def base64_id
27
+ Base64.urlsafe_encode64 id.to_s
28
+ end
29
+
20
30
  def permalink
21
31
  @permalink ||= self_and_ancestors.map(&:slug).reverse.join('/')
22
- end
32
+ end
23
33
 
24
34
  def orphan?
25
35
  parent && parent.trashed?
@@ -30,17 +30,6 @@ module PushType
30
30
  end
31
31
  end
32
32
 
33
- initializer 'push_type.url_helpers' do
34
- ActiveSupport.on_load :action_controller do
35
- helper PushType::MediaUrlHelper
36
- helper PushType::NodeUrlHelper
37
- end
38
- ActiveSupport.on_load :action_view do
39
- include PushType::MediaUrlHelper
40
- include PushType::NodeUrlHelper
41
- end
42
- end
43
-
44
33
  initializer 'push_type.menu_helpers' do
45
34
  ActiveSupport.on_load :action_view do
46
35
  include PushType::MenuBuilder::Helpers
@@ -17,9 +17,9 @@ module ActionDispatch::Routing
17
17
  asset.media params[:style]
18
18
  }, as: 'media'
19
19
 
20
- # A catch-all root for the nodes
21
- get '*permalink' => 'front_end#show', as: 'node'
22
- get '/' => 'front_end#show', as: 'home', permalink: PushType.config.home_slug if PushType.config.home_slug.present?
20
+ get '/node/preview/:id' => 'front_end#preview', as: 'preview_node'
21
+ get '*permalink' => 'front_end#show', as: 'node'
22
+ get '/' => 'front_end#show', as: 'home_node', permalink: PushType.config.home_slug if PushType.config.home_slug.present?
23
23
  end
24
24
  end
25
25
 
@@ -1,3 +1,3 @@
1
1
  module PushType
2
- VERSION = '0.10.0.beta.3'
2
+ VERSION = '0.10.0.beta.5'
3
3
  end
@@ -27,6 +27,25 @@ class FrontEndControllerTest < ActionController::TestCase
27
27
  end
28
28
  end
29
29
 
30
+ describe 'GET #preview' do
31
+ let(:page) { Page.create FactoryGirl.attributes_for(:node, type: 'Page') }
32
+ let(:id) { page.base64_id }
33
+ let(:action!) { get :preview, params: { id: id } }
34
+
35
+ describe 'when node does not exist' do
36
+ let(:id) { 'abcefg12345' }
37
+ it { proc { action! }.must_raise ActiveRecord::RecordNotFound }
38
+ end
39
+ describe 'when node not published' do
40
+ before { action! }
41
+ it { response.must_render_template 'nodes/page' }
42
+ it { response.headers.must_include 'X-Robots-Tag' }
43
+ it { response.headers['X-Robots-Tag'].must_equal 'none' }
44
+ it { assigns[:node].must_equal page }
45
+ it { assigns[:page].must_equal page }
46
+ end
47
+ end
48
+
30
49
  describe 'node filters' do
31
50
 
32
51
  ApplicationController.module_eval do
@@ -45,6 +45,6 @@ PushType.setup do |config|
45
45
  # secret_access_key: ENV['SECRET_ACCESS_KEY_ID']
46
46
  # }
47
47
 
48
- # config.dragonfly_secret = 'db0e7c33e8b359951d22f8e750068f5c5896b6adfa07cbb839b895550378c153'
48
+ # config.dragonfly_secret = '4c23a3d0cfad7fc78e7ade796a3df4a5dc6e412b000e922098d44bd017991386'
49
49
 
50
50
  end
@@ -11,10 +11,10 @@
11
11
  # if you're sharing your code publicly.
12
12
 
13
13
  development:
14
- secret_key_base: a3f3c85b457a43f7bc749ac36a23dfbe8c276f37e549629681d926ddc777a60b1de8b51423b7eeb88d83cf12899d57df2874e8764ff2658f1b4c25ef71d1e5c2
14
+ secret_key_base: 6e97ea80ddab01674da00aa37e9b31e25a9baf853f8bd0cffbf5112ba33c66fd1be767b6cf5ab8fc59781faa9ec6ebca2d7c9e188bb9f40cc4a88e77d391ec30
15
15
 
16
16
  test:
17
- secret_key_base: 733f6bf04272401ea3a441bf8371d6075c2a60649e4b9360bdd7c6130bc0d262b40adf47d0176794d8404c08badc03339b814841f132c92e06285db7583746c9
17
+ secret_key_base: e8c528eb48d3d486b52671932881ba94aa5e867f4c017624f58a75e9f3e6d10cf9e3d12858a5f7aca48f122021a3191b1322d67641e183b60cb9c66c68318ff2
18
18
 
19
19
  # Do not keep production secrets in the repository,
20
20
  # instead read values from the environment.
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20161116222806) do
13
+ ActiveRecord::Schema.define(version: 20161117154447) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"