landable 1.13.1 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +281 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +3 -4
- data/README.md +2 -0
- data/Rakefile +6 -3
- data/app/controllers/concerns/landable/variables_concern.rb +9 -9
- data/app/controllers/landable/api/access_tokens_controller.rb +7 -8
- data/app/controllers/landable/api/assets_controller.rb +29 -26
- data/app/controllers/landable/api/audits_controller.rb +6 -5
- data/app/controllers/landable/api/configurations_controller.rb +1 -1
- data/app/controllers/landable/api/directories_controller.rb +2 -2
- data/app/controllers/landable/api/page_revisions_controller.rb +2 -4
- data/app/controllers/landable/api/pages_controller.rb +39 -40
- data/app/controllers/landable/api/template_revisions_controller.rb +1 -2
- data/app/controllers/landable/api/templates_controller.rb +15 -14
- data/app/controllers/landable/api/themes_controller.rb +15 -14
- data/app/controllers/landable/api_controller.rb +10 -11
- data/app/controllers/landable/public/pages_controller.rb +2 -2
- data/app/controllers/landable/public/preview/page_revisions_controller.rb +2 -2
- data/app/controllers/landable/public/preview/pages_controller.rb +1 -1
- data/app/controllers/landable/public/sitemap_controller.rb +2 -2
- data/app/decorators/landable/page_decorator.rb +3 -3
- data/app/helpers/landable/pages_helper.rb +2 -2
- data/app/helpers/landable/traffic_helper.rb +2 -4
- data/app/models/concerns/landable/has_assets.rb +6 -9
- data/app/models/concerns/landable/has_templates.rb +6 -7
- data/app/models/concerns/landable/librarian.rb +5 -5
- data/app/models/concerns/landable/table_name.rb +2 -2
- data/app/models/landable/access_token.rb +1 -1
- data/app/models/landable/asset.rb +8 -8
- data/app/models/landable/asset_search_engine.rb +7 -8
- data/app/models/landable/author.rb +2 -1
- data/app/models/landable/category.rb +1 -3
- data/app/models/landable/directory.rb +2 -2
- data/app/models/landable/page.rb +44 -50
- data/app/models/landable/page_revision.rb +27 -41
- data/app/models/landable/page_search_engine.rb +5 -6
- data/app/models/landable/search_engine.rb +2 -2
- data/app/models/landable/template.rb +9 -11
- data/app/models/landable/template_revision.rb +4 -14
- data/app/models/landable/theme.rb +1 -1
- data/app/models/landable/traffic/attribution.rb +3 -1
- data/app/models/landable/traffic/page_view.rb +1 -1
- data/app/models/landable/traffic/user_agent.rb +1 -1
- data/app/models/landable/traffic/visit.rb +1 -1
- data/app/responders/landable/api_responder.rb +5 -3
- data/app/responders/landable/page_render_responder.rb +1 -1
- data/app/serializers/landable/asset_serializer.rb +1 -1
- data/app/serializers/landable/audit_serializer.rb +2 -3
- data/app/serializers/landable/directory_serializer.rb +2 -2
- data/app/serializers/landable/page_revision_serializer.rb +0 -1
- data/app/serializers/landable/page_serializer.rb +5 -5
- data/app/serializers/landable/template_serializer.rb +2 -2
- data/app/services/landable/authentication_service.rb +1 -1
- data/app/services/landable/registration_service.rb +3 -2
- data/app/services/landable/render_service.rb +16 -18
- data/app/services/landable/screenshot_service.rb +3 -4
- data/app/services/landable/tidy_service.rb +32 -37
- data/app/validators/path_validator.rb +1 -3
- data/app/validators/url_validator.rb +4 -7
- data/config/routes.rb +3 -6
- data/db/migrate/20130510221424_create_landable_schema.rb +45 -56
- data/db/migrate/20130909182713_landable_pages__add_updated_by.rb +2 -2
- data/db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb +9 -12
- data/db/migrate/20131002220041_file_based_themes.rb +3 -3
- data/db/migrate/20131008164204_create_head_tag_on_page.rb +4 -4
- data/db/migrate/20131008193544_drop_status_codes_model.rb +1 -2
- data/db/migrate/20131028145652_add_traffic_schema.rb +5 -5
- data/db/migrate/20131101213623_add_dnt_column_to_visits.rb +1 -1
- data/db/migrate/20131106185946_add_index_on_page_revisions_path.rb +1 -1
- data/db/migrate/20131106193021_page_revisisons__path_status_code_index.rb +1 -1
- data/db/migrate/20131121150902_add_attribution_id_to_unique_index.rb +2 -2
- data/db/migrate/20131216214027_drop_browser_screenshot_tables.rb +3 -3
- data/db/migrate/20140128170659_file_backed_templates.rb +1 -1
- data/db/migrate/20140205193757_fix_status_codes.rb +3 -3
- data/db/migrate/20140220170324_add_slug_to_categories.rb +1 -1
- data/db/migrate/20140224205516_rename_traffic_schema.rb +7 -9
- data/db/migrate/20140509190128_create_template_revisions.rb +13 -15
- data/db/migrate/20140509192856_create_audits.rb +3 -3
- data/db/migrate/20140602213937_path_response_time_view.rb +20 -19
- data/features/step_definitions/asset_steps.rb +10 -12
- data/features/step_definitions/core_api_steps.rb +29 -27
- data/features/step_definitions/factory_steps.rb +16 -16
- data/features/step_definitions/html_steps.rb +1 -1
- data/features/step_definitions/liquid_steps.rb +8 -8
- data/features/step_definitions/theme_steps.rb +4 -4
- data/features/support/env.rb +5 -5
- data/landable.gemspec +2 -2
- data/lib/generators/landable/landable_generator.rb +2 -2
- data/lib/generators/templates/landable.rb +1 -1
- data/lib/landable.rb +7 -7
- data/lib/landable/configuration.rb +10 -19
- data/lib/landable/engine.rb +19 -19
- data/lib/landable/error.rb +1 -3
- data/lib/landable/layout.rb +6 -6
- data/lib/landable/liquid/asset_tags.rb +3 -5
- data/lib/landable/liquid/drops.rb +3 -8
- data/lib/landable/liquid/filters.rb +1 -3
- data/lib/landable/liquid/tags.rb +10 -10
- data/lib/landable/migration.rb +30 -30
- data/lib/landable/mime_types.rb +1 -1
- data/lib/landable/partial.rb +2 -2
- data/lib/landable/seeds.rb +3 -4
- data/lib/landable/traffic.rb +4 -8
- data/lib/landable/traffic/tracker.rb +48 -43
- data/lib/landable/traffic/user_tracker.rb +15 -10
- data/lib/landable/version.rb +1 -1
- data/lib/schema_moves.rb +15 -16
- data/lib/tasks/landable/cucumber.rake +46 -47
- data/lib/tasks/landable/data.rake +13 -14
- data/lib/tasks/landable/pgtap.rake +12 -18
- data/lib/tasks/landable/seed.rake +4 -4
- data/spec/concerns/landable/has_assets_spec.rb +15 -19
- data/spec/concerns/landable/has_templates_spec.rb +10 -13
- data/spec/concerns/landable/librarian.rb +4 -4
- data/spec/concerns/landable/table_name_spec.rb +3 -5
- data/spec/concerns/landable/traffic/table_name_spec.rb +2 -4
- data/spec/controllers/concerns/landable/variables_concern_spec.rb +11 -10
- data/spec/controllers/landable/api/assets_controller_spec.rb +15 -14
- data/spec/controllers/landable/api/audits_controller_spec.rb +104 -102
- data/spec/controllers/landable/api/categories_controller_spec.rb +36 -34
- data/spec/controllers/landable/api/configuration_controller_spec.rb +14 -12
- data/spec/controllers/landable/api/directories_controller_spec.rb +52 -50
- data/spec/controllers/landable/api/page_revisions_controller_spec.rb +20 -18
- data/spec/controllers/landable/api/pages_controller_spec.rb +204 -203
- data/spec/controllers/landable/api/template_revisions_controller_spec.rb +20 -18
- data/spec/controllers/landable/api/templates_controller_spec.rb +39 -37
- data/spec/controllers/landable/api_controller_spec.rb +24 -26
- data/spec/controllers/public/preview/page_revisions_controller_spec.rb +36 -34
- data/spec/controllers/public/preview/pages_controller_spec.rb +32 -30
- data/spec/controllers/public/sitemap_controller_spec.rb +19 -17
- data/spec/decorators/page_decorator_spec.rb +9 -9
- data/spec/dummy/app/helpers/application_helper.rb +1 -1
- data/spec/dummy/config/application.rb +5 -6
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/landable.rb +7 -6
- data/spec/factories/asset.rb +1 -1
- data/spec/factories/audit.rb +1 -1
- data/spec/factories/authors.rb +1 -1
- data/spec/factories/category.rb +1 -1
- data/spec/factories/pages.rb +4 -4
- data/spec/factories/template.rb +3 -3
- data/spec/factories/theme.rb +2 -2
- data/spec/helpers/pages_helper_spec.rb +5 -5
- data/spec/lib/landable/configuration_spec.rb +2 -4
- data/spec/lib/landable/event_publisher_spec.rb +1 -3
- data/spec/lib/landable/layout_spec.rb +4 -4
- data/spec/lib/landable/liquid_spec.rb +12 -14
- data/spec/lib/landable/migration_spec.rb +4 -4
- data/spec/lib/landable/partial_spec.rb +18 -18
- data/spec/lib/landable/tracking_spec.rb +27 -29
- data/spec/lib/landable/traffic_spec.rb +29 -33
- data/spec/models/landable/access_token_spec.rb +1 -1
- data/spec/models/landable/asset_spec.rb +9 -11
- data/spec/models/landable/directory_spec.rb +7 -7
- data/spec/models/landable/page/errors_spec.rb +1 -3
- data/spec/models/landable/page_revision_spec.rb +23 -24
- data/spec/models/landable/page_spec.rb +41 -42
- data/spec/models/landable/template_revision_spec.rb +3 -3
- data/spec/models/landable/template_spec.rb +11 -11
- data/spec/models/landable/theme_spec.rb +2 -2
- data/spec/models/landable/traffic/referer_spec.rb +3 -3
- data/spec/responders/page_render_responder_spec.rb +0 -2
- data/spec/routing/public_page_route_spec.rb +4 -5
- data/spec/services/landable/authentication_service_spec.rb +7 -7
- data/spec/services/landable/render_service_spec.rb +8 -8
- data/spec/services/landable/screenshot_service_spec.rb +3 -3
- data/spec/services/landable/tidy_service_spec.rb +20 -20
- data/spec/spec_helper.rb +3 -3
- data/spec/support/behaviors.rb +4 -4
- data/spec/support/helpers.rb +1 -1
- metadata +86 -35
- checksums.yaml +0 -7
@@ -6,21 +6,10 @@ module Landable
|
|
6
6
|
include Landable::HasAssets
|
7
7
|
include Landable::TableName
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
'deleted_at',
|
14
|
-
'updated_at',
|
15
|
-
'published_revision_id',
|
16
|
-
'is_publishable',
|
17
|
-
'updated_by_author_id',
|
18
|
-
'lock_version',
|
19
|
-
'audit_flags',
|
20
|
-
'page_name'
|
21
|
-
]
|
22
|
-
|
23
|
-
cattr_accessor :ignored_page_attributes
|
9
|
+
class << self
|
10
|
+
attr_accessor :ignored_page_attributes
|
11
|
+
end
|
12
|
+
@ignored_page_attributes = %w(page_id imported_at created_at deleted_at updated_at published_revision_id is_publishable updated_by_author_id lock_version audit_flags page_name)
|
24
13
|
|
25
14
|
belongs_to :author
|
26
15
|
belongs_to :page, inverse_of: :revisions
|
@@ -46,17 +35,17 @@ module Landable
|
|
46
35
|
end
|
47
36
|
|
48
37
|
def snapshot
|
49
|
-
Page.new(title:
|
38
|
+
Page.new(title: title,
|
50
39
|
meta_tags: page.meta_tags,
|
51
40
|
head_content: page.head_content,
|
52
|
-
body:
|
53
|
-
path:
|
54
|
-
redirect_url:
|
55
|
-
status_code:
|
56
|
-
theme_id:
|
57
|
-
category_id:
|
58
|
-
abstract:
|
59
|
-
hero_asset_id:
|
41
|
+
body: body,
|
42
|
+
path: path,
|
43
|
+
redirect_url: redirect_url,
|
44
|
+
status_code: status_code,
|
45
|
+
theme_id: theme_id,
|
46
|
+
category_id: category_id,
|
47
|
+
abstract: abstract,
|
48
|
+
hero_asset_id: hero_asset_id)
|
60
49
|
end
|
61
50
|
|
62
51
|
def publish!
|
@@ -69,18 +58,18 @@ module Landable
|
|
69
58
|
|
70
59
|
def republish!(options)
|
71
60
|
unpublish!
|
72
|
-
PageRevision.create!(page_id:
|
73
|
-
title:
|
61
|
+
PageRevision.create!(page_id: page_id,
|
62
|
+
title: title,
|
74
63
|
meta_tags: page.meta_tags,
|
75
64
|
head_content: page.head_content,
|
76
|
-
body:
|
77
|
-
path:
|
78
|
-
redirect_url:
|
79
|
-
status_code:
|
80
|
-
theme_id:
|
81
|
-
category_id:
|
82
|
-
abstract:
|
83
|
-
hero_asset_id:
|
65
|
+
body: body,
|
66
|
+
path: path,
|
67
|
+
redirect_url: redirect_url,
|
68
|
+
status_code: status_code,
|
69
|
+
theme_id: theme_id,
|
70
|
+
category_id: category_id,
|
71
|
+
abstract: abstract,
|
72
|
+
hero_asset_id: hero_asset_id,
|
84
73
|
notes: "Publishing update for template #{options[:template]}: #{options[:notes]}",
|
85
74
|
is_minor: options[:is_minor],
|
86
75
|
author_id: options[:author_id],
|
@@ -88,12 +77,10 @@ module Landable
|
|
88
77
|
end
|
89
78
|
|
90
79
|
def preview_url
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
nil
|
96
|
-
end
|
80
|
+
public_preview_page_revision_url(self, host: Landable.configuration.public_host)
|
81
|
+
rescue ArgumentError
|
82
|
+
Rails.logger.warn "Failed to generate preview url for page revision #{id} - missing Landable.configuration.public_host"
|
83
|
+
nil
|
97
84
|
end
|
98
85
|
|
99
86
|
def preview_path
|
@@ -135,5 +122,4 @@ module Landable
|
|
135
122
|
end
|
136
123
|
end
|
137
124
|
end
|
138
|
-
|
139
125
|
end
|
@@ -8,13 +8,12 @@ module Landable
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def filter_by!(filters)
|
11
|
-
|
12
|
-
|
13
|
-
end
|
11
|
+
ids = as_array(filters[:ids])
|
12
|
+
@scope = @scope.where(page_id: ids) if ids
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
path = filters[:path].presence
|
15
|
+
return unless path
|
16
|
+
@scope = @scope.with_fuzzy_path(path)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -6,32 +6,31 @@ module Landable
|
|
6
6
|
# attributes
|
7
7
|
attr_accessor :temp_author
|
8
8
|
|
9
|
-
validates_presence_of
|
9
|
+
validates_presence_of :name, :slug, :description
|
10
10
|
validates_uniqueness_of :name, case_sensitive: false
|
11
11
|
validates_uniqueness_of :slug, case_sensitive: false
|
12
12
|
|
13
13
|
before_save :slug_has_no_spaces
|
14
14
|
|
15
|
-
|
16
15
|
belongs_to :published_revision, class_name: 'Landable::TemplateRevision'
|
17
|
-
has_many
|
18
|
-
has_many
|
16
|
+
has_many :audits, class_name: 'Landable::Audit', as: :auditable
|
17
|
+
has_many :revisions, class_name: 'Landable::TemplateRevision'
|
19
18
|
|
20
19
|
has_and_belongs_to_many :pages, join_table: Page.templates_join_table_name
|
21
20
|
|
22
21
|
delegate :count, to: :pages, prefix: true # Returns how many Pages a Template lives in!
|
23
22
|
|
24
|
-
before_save
|
23
|
+
before_save lambda { |template|
|
25
24
|
template.is_publishable = true unless template.published_revision_id_changed?
|
26
25
|
}
|
27
26
|
|
28
27
|
def deactivate
|
29
|
-
publish!(author_id: temp_author.id, notes:
|
28
|
+
publish!(author_id: temp_author.id, notes: 'This template has been trashed')
|
30
29
|
|
31
30
|
super
|
32
31
|
end
|
33
32
|
|
34
|
-
def name=
|
33
|
+
def name=(val)
|
35
34
|
self[:name] = val
|
36
35
|
self[:slug] ||= (val && val.underscore.gsub(/[^\w_]/, '_').gsub(/_{2,}/, '_'))
|
37
36
|
end
|
@@ -52,7 +51,7 @@ module Landable
|
|
52
51
|
end
|
53
52
|
|
54
53
|
def republish_associated_pages(options)
|
55
|
-
options[:template] =
|
54
|
+
options[:template] = name
|
56
55
|
pages.each do |page|
|
57
56
|
page.republish!(options) if page.published?
|
58
57
|
end
|
@@ -68,9 +67,8 @@ module Landable
|
|
68
67
|
end
|
69
68
|
|
70
69
|
def slug_has_no_spaces
|
71
|
-
|
72
|
-
|
73
|
-
end
|
70
|
+
return unless slug =~ /\s/ # check if whitespace
|
71
|
+
self.slug = slug.underscore.gsub(/[^\w_]/, '_').gsub(/_{2,}/, '_')
|
74
72
|
end
|
75
73
|
|
76
74
|
class << self
|
@@ -2,20 +2,10 @@ module Landable
|
|
2
2
|
class TemplateRevision < ActiveRecord::Base
|
3
3
|
include Landable::TableName
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
'published_revision_id',
|
10
|
-
'file',
|
11
|
-
'thumbnail_url',
|
12
|
-
'is_layout',
|
13
|
-
'is_publishable',
|
14
|
-
'audit_flags',
|
15
|
-
'deleted_at'
|
16
|
-
]
|
17
|
-
|
18
|
-
cattr_accessor :ignored_template_attributes
|
5
|
+
@ignored_template_attributes = %w(editable created_at updated_at published_revision_id file thumbnail_url is_layout is_publishable audit_flags deleted_at)
|
6
|
+
class << self
|
7
|
+
attr_accessor :ignored_template_attributes
|
8
|
+
end
|
19
9
|
|
20
10
|
belongs_to :template, inverse_of: :revisions
|
21
11
|
belongs_to :author
|
@@ -3,7 +3,7 @@ module Landable
|
|
3
3
|
class Attribution < ActiveRecord::Base
|
4
4
|
include Landable::TableName
|
5
5
|
|
6
|
-
KEYS = %w
|
6
|
+
KEYS = %w(ad_type ad_group bid_match_type campaign content creative device_type experiment keyword match_type medium network placement position search_term source target)
|
7
7
|
|
8
8
|
self.record_timestamps = false
|
9
9
|
|
@@ -28,6 +28,8 @@ module Landable
|
|
28
28
|
|
29
29
|
def lookup(parameters)
|
30
30
|
where(transform(parameters)).first_or_create
|
31
|
+
rescue ActiveRecord::RecordNotUnique
|
32
|
+
retry
|
31
33
|
end
|
32
34
|
|
33
35
|
def digest(parameters)
|
@@ -4,7 +4,7 @@ module Landable
|
|
4
4
|
include Landable::TableName
|
5
5
|
self.record_timestamps = false
|
6
6
|
|
7
|
-
lookup_by
|
7
|
+
lookup_by :user_agent, cache: 50, find_or_create: true
|
8
8
|
|
9
9
|
lookup_for :user_agent_type, class_name: UserAgentType
|
10
10
|
lookup_for :device, class_name: Device
|
@@ -3,12 +3,14 @@ module Landable
|
|
3
3
|
def to_format
|
4
4
|
controller.response.headers['X-Landable-Media-Type'] = api_media_type
|
5
5
|
|
6
|
-
|
6
|
+
serializer = resource_serializer
|
7
|
+
if serializer
|
7
8
|
options[collection_resource? ? :each_serializer : :serializer] = serializer
|
8
9
|
controller.response.headers['X-Landable-Serializer'] = serializer.name if leaky?
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
+
schema = json_schema
|
13
|
+
if leaky? && format == :json && schema
|
12
14
|
key = collection_resource? ? resource_name.pluralize : resource_name
|
13
15
|
link = "<#{schema}>; rel=\"describedby\"; anchor=\"#/#{key}\""
|
14
16
|
link = "#{link}; collection=\"collection\"" if collection_resource?
|
@@ -32,7 +34,7 @@ module Landable
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def collection_resource?
|
35
|
-
Array
|
37
|
+
resource.is_a?(Array) || resource.is_a?(ActiveRecord::Relation)
|
36
38
|
end
|
37
39
|
|
38
40
|
def json_schema
|
@@ -4,9 +4,8 @@ module Landable
|
|
4
4
|
attributes :auditable_type, :auditable_id, :created_at
|
5
5
|
|
6
6
|
def auditable_type
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
return unless object.auditable_type.present?
|
8
|
+
object.auditable_type.underscore.gsub(%r{^landable\/}, '')
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
@@ -2,7 +2,7 @@ module Landable
|
|
2
2
|
class DirectorySerializer < ActiveModel::Serializer
|
3
3
|
attributes :id, :path
|
4
4
|
|
5
|
-
has_many
|
6
|
-
has_many
|
5
|
+
has_many :subdirectories, embed: :ids, embed_key: :path
|
6
|
+
has_many :pages, embed: :ids
|
7
7
|
end
|
8
8
|
end
|
@@ -10,11 +10,11 @@ module Landable
|
|
10
10
|
attributes :lock_version
|
11
11
|
attributes :deleted_at
|
12
12
|
|
13
|
-
embed
|
14
|
-
has_one
|
15
|
-
has_one
|
16
|
-
has_one
|
17
|
-
has_one
|
13
|
+
embed :ids
|
14
|
+
has_one :theme
|
15
|
+
has_one :published_revision
|
16
|
+
has_one :category
|
17
|
+
has_one :updated_by_author, root: :authors, include: true, serializer: AuthorSerializer
|
18
18
|
|
19
19
|
def category
|
20
20
|
object.category || Landable::Category.where(name: 'Uncategorized').first
|
@@ -1,9 +1,10 @@
|
|
1
|
-
require_dependency
|
1
|
+
require_dependency 'landable/author'
|
2
2
|
|
3
3
|
module Landable
|
4
4
|
class RegistrationService
|
5
5
|
def self.call(attributes)
|
6
|
-
|
6
|
+
author = Author.where(username: attributes[:username]).first
|
7
|
+
if author
|
7
8
|
author
|
8
9
|
else
|
9
10
|
Author.create!(attributes.slice(:username, :email, :first_name, :last_name))
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# TODO Handle layouts-as-themes here
|
1
|
+
# TODO: Handle layouts-as-themes here
|
2
2
|
|
3
3
|
require_dependency 'landable/liquid'
|
4
4
|
|
@@ -19,16 +19,16 @@ module Landable
|
|
19
19
|
variables ||= {}
|
20
20
|
|
21
21
|
content = render_template(page.body, variables, registers: {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
page: page,
|
23
|
+
assets: assets_for_page,
|
24
|
+
responder: options[:responder]
|
25
|
+
})
|
26
26
|
|
27
27
|
if layout?
|
28
|
-
content = render_template(theme.body, {'body' => content}, registers: {
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
content = render_template(theme.body, { 'body' => content }, registers: {
|
29
|
+
page: page,
|
30
|
+
assets: assets_for_theme
|
31
|
+
})
|
32
32
|
end
|
33
33
|
|
34
34
|
# not completely happy about this
|
@@ -37,16 +37,14 @@ module Landable
|
|
37
37
|
# fancy!
|
38
38
|
preview_template = File.open(Landable::Engine.root.join('app', 'views', 'templates', 'preview.liquid')).read
|
39
39
|
|
40
|
-
content = render_template(preview_template,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
'redirect_url' => page.redirect_url,
|
46
|
-
})
|
40
|
+
content = render_template(preview_template, 'content' => content,
|
41
|
+
'is_redirect' => page.redirect?,
|
42
|
+
'is_html' => page.html?,
|
43
|
+
'status_code' => page.status_code,
|
44
|
+
'redirect_url' => page.redirect_url)
|
47
45
|
else
|
48
46
|
# non-html stuff just gets rendered as plaintext for a preview
|
49
|
-
content = '<pre>' + CGI
|
47
|
+
content = '<pre>' + CGI.escapeHTML(content) + '</pre>'
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
@@ -77,7 +75,7 @@ module Landable
|
|
77
75
|
@assets_for_theme ||= theme ? theme.assets_as_hash : {}
|
78
76
|
end
|
79
77
|
|
80
|
-
def render_template
|
78
|
+
def render_template(template, variables = {}, liquid_options = {})
|
81
79
|
variables['categories'] = Liquid::CategoriesDrop.new
|
82
80
|
|
83
81
|
parse(template).render!(variables, liquid_options)
|