push_type_core 0.10.0.beta.3 → 0.10.0.beta.5
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.
- checksums.yaml +4 -4
- data/app/controllers/concerns/push_type/application_controller_methods.rb +2 -0
- data/app/controllers/front_end_controller.rb +26 -12
- data/app/models/push_type/node.rb +11 -1
- data/lib/push_type/core/engine.rb +0 -11
- data/lib/push_type/rails/routes.rb +3 -3
- data/lib/push_type/version.rb +1 -1
- data/test/controllers/front_end_controller_test.rb +19 -0
- data/test/dummy/config/initializers/push_type.rb +1 -1
- data/test/dummy/config/secrets.yml +2 -2
- data/test/dummy/db/migrate/{20161116222801_create_push_type_users.push_type.rb → 20161117154442_create_push_type_users.push_type.rb} +0 -0
- data/test/dummy/db/migrate/{20161116222802_create_push_type_nodes.push_type.rb → 20161117154443_create_push_type_nodes.push_type.rb} +0 -0
- 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
- data/test/dummy/db/migrate/{20161116222804_create_push_type_assets.push_type.rb → 20161117154445_create_push_type_assets.push_type.rb} +0 -0
- 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
- 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
- data/test/dummy/db/schema.rb +1 -1
- data/test/dummy/log/test.log +7667 -7437
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/{tn/tnKqEfyTQNEMuWAhX3xym0TbSoUwIe8XlKbKLmN8oPA.cache → Eq/EqAqaJ_tfMAtqoArQz8TAEgvbpQnvyKDhWfkgsLgDDk.cache} +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/VT/VT0xDh7gu1K3uYidKny01QY0vyaeQDbHoPICVlZmQQc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/YC/YCmmKydZG1FxHcFZiHcaSZhbT44fV2vJglp5i1fOvAc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/{3D/3DiLOA9ufk-bm1-9-hOFWYmGKMgJWxv8xBbSS2pKDN4.cache → pl/plmO1IoJjY_rOEVF1tqlu49tmlR7S7ymF0T7YUqP6Uw.cache} +0 -0
- data/test/dummy/tmp/generators/app/models/home_page.rb +12 -0
- data/test/dummy/tmp/generators/app/views/nodes/home_page.html.erb +13 -0
- data/test/models/push_type/node_test.rb +11 -0
- metadata +22 -22
- data/test/dummy/tmp/generators/config/initializers/push_type.rb +0 -50
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01c112917483c5214c46adac7908e1f325ece658
|
4
|
+
data.tar.gz: 984f05936884a2251f744836be2d47e2e22003d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 757c53adbab7868036862aa189ad61e7162741d4291afa88e7be46774db619b6d25cda0367852601d81907eb4f754a0c9b2a6ea6039f5bd42d5789f9c886fdb0
|
7
|
+
data.tar.gz: a8629fcc234ce54aeba05f52718b06bde6fdf014ed03a357dda81c48f1cfb632205ff8f2d1c605e00459c4906078a5a8009790aefe04c47afecf04cebca33177
|
@@ -2,29 +2,31 @@ class FrontEndController < ApplicationController
|
|
2
2
|
|
3
3
|
include PushType::Filterable
|
4
4
|
|
5
|
-
before_action :load_node,
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
request.fullpath == '/'
|
14
|
+
def preview
|
15
|
+
response.headers['X-Robots-Tag'] = 'none'
|
16
|
+
show
|
16
17
|
end
|
17
18
|
|
18
|
-
|
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
|
-
|
21
|
-
get '*permalink'
|
22
|
-
get '/' => 'front_end#show', as: '
|
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
|
|
data/lib/push_type/version.rb
CHANGED
@@ -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 = '
|
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:
|
14
|
+
secret_key_base: 6e97ea80ddab01674da00aa37e9b31e25a9baf853f8bd0cffbf5112ba33c66fd1be767b6cf5ab8fc59781faa9ec6ebca2d7c9e188bb9f40cc4a88e77d391ec30
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
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.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/dummy/db/schema.rb
CHANGED
@@ -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:
|
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"
|