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
data/lib/landable/engine.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'rack/cors'
|
2
|
+
require 'active_model_serializers'
|
3
|
+
require 'carrierwave'
|
4
|
+
require 'rake'
|
5
5
|
|
6
6
|
module Landable
|
7
7
|
class Engine < ::Rails::Engine
|
@@ -9,46 +9,46 @@ module Landable
|
|
9
9
|
|
10
10
|
config.generators do |g|
|
11
11
|
g.test_framework :rspec
|
12
|
-
g.fixture_replacement :factory_girl, :
|
12
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
13
13
|
end
|
14
14
|
|
15
|
-
initializer
|
15
|
+
initializer 'landable.enable_cors' do |app|
|
16
16
|
config = Landable.configuration
|
17
17
|
if config.cors.enabled?
|
18
18
|
app.middleware.insert 0, Rack::Cors do
|
19
19
|
allow do
|
20
20
|
origins config.cors.origins
|
21
21
|
resource "#{config.api_namespace}/*",
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
methods: [:get, :post, :put, :patch, :delete],
|
23
|
+
headers: :any,
|
24
|
+
expose: 'X-Landable-Media-Type',
|
25
|
+
credentials: false,
|
26
|
+
max_age: 15.minutes
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
initializer
|
32
|
+
initializer 'landable.json_schema' do |app|
|
33
33
|
if ENV['LANDABLE_VALIDATE_JSON']
|
34
34
|
require 'rack/schema'
|
35
35
|
app.middleware.use Rack::Schema
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
initializer
|
40
|
-
Landable::Seeds.seed(:required)
|
39
|
+
initializer 'landable.seed_required' do |_app|
|
40
|
+
suppress(StandardError) { Landable::Seeds.seed(:required) }
|
41
41
|
end
|
42
42
|
|
43
|
-
initializer
|
44
|
-
Theme.create_from_layouts!
|
43
|
+
initializer 'landable.create_themes' do |_app|
|
44
|
+
suppress(StandardError) { Theme.create_from_layouts! }
|
45
45
|
end
|
46
46
|
|
47
|
-
initializer 'landable.create_templates' do |
|
48
|
-
Template.create_from_partials!
|
47
|
+
initializer 'landable.create_templates' do |_app|
|
48
|
+
suppress(StandardError) { Template.create_from_partials! }
|
49
49
|
end
|
50
50
|
|
51
|
-
initializer
|
51
|
+
initializer 'landable.action_controller' do
|
52
52
|
ActiveSupport.on_load :action_controller do
|
53
53
|
# includes
|
54
54
|
include Landable::Traffic
|
data/lib/landable/error.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
module Landable
|
2
2
|
class Error < StandardError
|
3
|
-
|
4
3
|
STATUS_CODE = 500
|
5
4
|
|
6
|
-
def initialize
|
5
|
+
def initialize(message = nil)
|
7
6
|
message ||= "Status code: #{status_code} (Hint: rescue this in your ApplicationController)"
|
8
7
|
super
|
9
8
|
end
|
@@ -11,6 +10,5 @@ module Landable
|
|
11
10
|
def status_code
|
12
11
|
self.class::STATUS_CODE
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
16
14
|
end
|
data/lib/landable/layout.rb
CHANGED
@@ -14,7 +14,7 @@ module Landable
|
|
14
14
|
path = @file.dup
|
15
15
|
self.class.paths.each { |p| path.sub!(p, '') }
|
16
16
|
|
17
|
-
path.sub!(
|
17
|
+
path.sub!(%r{^\/}, '')
|
18
18
|
|
19
19
|
@path, @extension = path.split('.html.', 2)
|
20
20
|
|
@@ -27,12 +27,12 @@ module Landable
|
|
27
27
|
process unless @processed
|
28
28
|
|
29
29
|
theme = Theme.where(file: @path).first_or_initialize
|
30
|
-
theme.name
|
30
|
+
theme.name ||= @path.gsub('/', ' ').titlecase
|
31
31
|
theme.extension = @extension
|
32
32
|
theme.description = description if theme.description.blank? || theme.description =~ /^Defined in/
|
33
33
|
theme.body = @body
|
34
34
|
theme.editable = false
|
35
|
-
theme.thumbnail_url ||=
|
35
|
+
theme.thumbnail_url ||= 'http://placehold.it/300x200'
|
36
36
|
|
37
37
|
theme.save!
|
38
38
|
|
@@ -40,7 +40,7 @@ module Landable
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def description
|
43
|
-
"Defined in
|
43
|
+
"Defined in #{@path}.html.#{@extension}"
|
44
44
|
end
|
45
45
|
|
46
46
|
class << self
|
@@ -52,8 +52,8 @@ module Landable
|
|
52
52
|
files = []
|
53
53
|
|
54
54
|
paths.map do |path|
|
55
|
-
files << Dir[path +
|
56
|
-
files << Dir[path +
|
55
|
+
files << Dir[path + '/**/[^_]*.html.*']
|
56
|
+
files << Dir[path + '/**/application*']
|
57
57
|
end
|
58
58
|
|
59
59
|
files.flatten.uniq
|
@@ -2,7 +2,6 @@ require 'action_view'
|
|
2
2
|
|
3
3
|
module Landable
|
4
4
|
module Liquid
|
5
|
-
|
6
5
|
class AssetTag < ::Liquid::Tag
|
7
6
|
attr_accessor :tag_name, :asset_name
|
8
7
|
|
@@ -41,11 +40,11 @@ module Landable
|
|
41
40
|
|
42
41
|
def lookup_asset(context, name)
|
43
42
|
assets = context.registers.fetch(:assets) do
|
44
|
-
|
43
|
+
fail(ArgumentError, "`assets' value was never registered with the template")
|
45
44
|
end
|
46
45
|
|
47
46
|
assets.fetch(name) do
|
48
|
-
|
47
|
+
fail(ArgumentError, "No `#{name}' asset available in #{assets.inspect}")
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
@@ -62,7 +61,7 @@ module Landable
|
|
62
61
|
class AssetAttributeTag < AssetTag
|
63
62
|
def render(context)
|
64
63
|
asset = lookup_asset context, asset_name
|
65
|
-
attribute = tag_name.sub
|
64
|
+
attribute = tag_name.sub(/^asset_/, '')
|
66
65
|
|
67
66
|
if attribute == 'url'
|
68
67
|
asset.public_url
|
@@ -71,6 +70,5 @@ module Landable
|
|
71
70
|
end
|
72
71
|
end
|
73
72
|
end
|
74
|
-
|
75
73
|
end
|
76
74
|
end
|
@@ -4,7 +4,6 @@
|
|
4
4
|
|
5
5
|
module Landable
|
6
6
|
module Liquid
|
7
|
-
|
8
7
|
# CategoryProxy gives us these:
|
9
8
|
#
|
10
9
|
# {{ categories.size }}
|
@@ -20,8 +19,7 @@ module Landable
|
|
20
19
|
# {% endfor %}
|
21
20
|
# </ul>
|
22
21
|
class CategoriesDrop < ::Liquid::Drop
|
23
|
-
|
24
|
-
def before_method method_name
|
22
|
+
def before_method(method_name)
|
25
23
|
category_cache[method_name] ||= ::Landable::Category.find_by_slug method_name
|
26
24
|
end
|
27
25
|
|
@@ -29,18 +27,15 @@ module Landable
|
|
29
27
|
@size ||= Category.count
|
30
28
|
end
|
31
29
|
|
32
|
-
def each
|
33
|
-
::Landable::Category.all.each
|
30
|
+
def each(&block)
|
31
|
+
::Landable::Category.all.each(&block)
|
34
32
|
end
|
35
33
|
|
36
|
-
|
37
34
|
protected
|
38
35
|
|
39
36
|
def category_cache
|
40
37
|
@category_cache ||= {}
|
41
38
|
end
|
42
|
-
|
43
39
|
end
|
44
|
-
|
45
40
|
end
|
46
41
|
end
|
data/lib/landable/liquid/tags.rb
CHANGED
@@ -2,14 +2,14 @@ require 'action_view'
|
|
2
2
|
|
3
3
|
module Landable
|
4
4
|
module Liquid
|
5
|
-
|
6
5
|
class Tag < ::Liquid::Tag
|
7
6
|
include ActionView::Helpers::TagHelper
|
8
7
|
|
9
8
|
protected
|
9
|
+
|
10
10
|
def lookup_page(context)
|
11
11
|
context.registers.fetch(:page) do
|
12
|
-
|
12
|
+
fail(ArgumentError, "`page' value was never registered with the template")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -26,9 +26,9 @@ module Landable
|
|
26
26
|
page = lookup_page context
|
27
27
|
tags = page.meta_tags || {}
|
28
28
|
|
29
|
-
tags.map
|
29
|
+
tags.map do |name, value|
|
30
30
|
tag(:meta, name: name, content: value)
|
31
|
-
|
31
|
+
end.join("\n")
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -42,14 +42,14 @@ module Landable
|
|
42
42
|
|
43
43
|
class Head < Tag
|
44
44
|
def render(context)
|
45
|
-
|
45
|
+
lookup_page context
|
46
46
|
|
47
47
|
head = []
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
%w(title_tag meta_tags head_content).each do |tag_name|
|
50
|
+
tag = "Landable::Liquid::#{tag_name.classify}".safe_constantize.new(tag_name, nil, nil)
|
51
|
+
head << tag.render(context) if tag.render(context).present?
|
52
|
+
end
|
53
53
|
|
54
54
|
head.join("\n")
|
55
55
|
end
|
@@ -64,7 +64,7 @@ module Landable
|
|
64
64
|
class TemplateTag < Tag
|
65
65
|
attr_accessor :template_slug
|
66
66
|
|
67
|
-
def initialize(
|
67
|
+
def initialize(_tag, param, _tokens)
|
68
68
|
param_tokens = param.split(/\s+/)
|
69
69
|
@template_slug = param_tokens.shift
|
70
70
|
@variables = Hash[param_tokens.join(' ').scan(/([\w_]+):\s+"([^"]*)"/)]
|
data/lib/landable/migration.rb
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
|
2
|
-
class
|
3
|
-
|
4
|
-
conn
|
5
|
-
|
6
|
-
|
7
|
-
def models
|
8
|
-
@models ||= begin
|
9
|
-
c = Landable.constants.map { |c| "Landable::#{c.to_s}".constantize }
|
10
|
-
c += Landable::Traffic.constants.map { |c| "Landable::Traffic::#{c.to_s}".constantize }
|
11
|
-
c.select { |c| c.kind_of? Class and c.ancestors.include? ActiveRecord::Base }
|
1
|
+
module Landable
|
2
|
+
class Migration < ActiveRecord::Migration
|
3
|
+
class << self
|
4
|
+
def connection_search_path(conn)
|
5
|
+
conn.execute('SHOW SEARCH_PATH')[0]['search_path']
|
12
6
|
end
|
13
|
-
end
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
def models
|
9
|
+
@models ||= begin
|
10
|
+
classes = Landable.constants.map { |c| "Landable::#{c}".constantize }
|
11
|
+
classes += Landable::Traffic.constants.map { |c| "Landable::Traffic::#{c}".constantize }
|
12
|
+
classes.select { |c| c.is_a?(Class) && c.ancestors.include?(ActiveRecord::Base) }
|
13
|
+
end
|
14
|
+
end
|
20
15
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
def clear_cache!
|
17
|
+
models.each(&:reset_primary_key)
|
18
|
+
ActiveRecord::Base.connection.schema_cache.clear!
|
19
|
+
end
|
25
20
|
end
|
26
21
|
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
def exec_migration(conn, direction)
|
23
|
+
# come what may, keep the connection's schema search path intact
|
24
|
+
with_clean_connection(conn) do
|
25
|
+
super
|
26
|
+
end
|
30
27
|
|
28
|
+
# reset a few things, lest we pollute the way for those who follow
|
29
|
+
self.class.clear_cache!
|
30
|
+
end
|
31
31
|
|
32
|
-
|
32
|
+
protected
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def with_clean_connection(conn)
|
35
|
+
original_search_path = self.class.connection_search_path conn
|
36
|
+
yield
|
37
|
+
conn.schema_search_path = original_search_path
|
38
|
+
end
|
38
39
|
end
|
39
|
-
|
40
40
|
end
|
data/lib/landable/mime_types.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Re-register application/json, adding our own vendored mime types as aliases
|
2
2
|
|
3
|
-
# TODO Be more generous about accepting version constraints. Currently,
|
3
|
+
# TODO: Be more generous about accepting version constraints. Currently,
|
4
4
|
# requesting v1.5 when we're running v1.5.2 will return a 406.
|
5
5
|
|
6
6
|
api_mime_types = %W(
|
data/lib/landable/partial.rb
CHANGED
@@ -5,7 +5,7 @@ module Landable
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def process
|
8
|
-
@name = @file.gsub('/',' ').titlecase
|
8
|
+
@name = @file.gsub('/', ' ').titlecase
|
9
9
|
@description = "The Code for this template can be seen at #{@file} in the source code"
|
10
10
|
@slug = @file.gsub(/[^\w]/, '_')
|
11
11
|
|
@@ -22,7 +22,7 @@ module Landable
|
|
22
22
|
template.description = @description
|
23
23
|
template.editable = false
|
24
24
|
template.is_layout = false
|
25
|
-
template.thumbnail_url ||=
|
25
|
+
template.thumbnail_url ||= 'http://placehold.it/300x200'
|
26
26
|
|
27
27
|
# Save!
|
28
28
|
template.save!
|
data/lib/landable/seeds.rb
CHANGED
@@ -2,13 +2,12 @@
|
|
2
2
|
# accessible. Not too thrilled about it; refactor away.
|
3
3
|
module Landable
|
4
4
|
module Seeds
|
5
|
-
|
6
|
-
def self.seed key
|
5
|
+
def self.seed(key)
|
7
6
|
method_key = "seed_#{key}".to_sym
|
8
7
|
if respond_to? method_key
|
9
8
|
send method_key if ActiveRecord::Base.connection.schema_exists? "#{Landable.configuration.database_schema_prefix}landable"
|
10
9
|
else
|
11
|
-
|
10
|
+
fail NotImplementedError, "No seeds for key '#{key}'"
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
@@ -29,7 +28,7 @@ module Landable
|
|
29
28
|
Landable::Theme.where(name: 'Blank').first_or_create!(
|
30
29
|
body: '',
|
31
30
|
description: 'A completely blank theme; only the page body will be rendered.',
|
32
|
-
thumbnail_url: 'http://placehold.it/300x200'
|
31
|
+
thumbnail_url: 'http://placehold.it/300x200'
|
33
32
|
)
|
34
33
|
end
|
35
34
|
end
|
data/lib/landable/traffic.rb
CHANGED
@@ -10,16 +10,14 @@ require 'landable/traffic/event_publisher'
|
|
10
10
|
module Landable
|
11
11
|
module Traffic
|
12
12
|
def track_with_landable!
|
13
|
-
yield
|
13
|
+
yield && return if untracked?
|
14
14
|
|
15
15
|
begin
|
16
16
|
@tracker = Tracker.for self
|
17
17
|
@tracker.track
|
18
18
|
rescue => e
|
19
19
|
Rails.logger.error e
|
20
|
-
if respond_to? :newrelic_notice_error
|
21
|
-
newrelic_notice_error e
|
22
|
-
end
|
20
|
+
newrelic_notice_error e if respond_to? :newrelic_notice_error
|
23
21
|
end
|
24
22
|
|
25
23
|
yield
|
@@ -28,9 +26,7 @@ module Landable
|
|
28
26
|
@tracker.save
|
29
27
|
rescue => e
|
30
28
|
Rails.logger.error e
|
31
|
-
if respond_to? :newrelic_notice_error
|
32
|
-
newrelic_notice_error e
|
33
|
-
end
|
29
|
+
newrelic_notice_error e if respond_to? :newrelic_notice_error
|
34
30
|
end
|
35
31
|
end
|
36
32
|
|
@@ -39,7 +35,7 @@ module Landable
|
|
39
35
|
end
|
40
36
|
|
41
37
|
def untracked_user?
|
42
|
-
Landable.configuration.dnt_enabled && request.headers[
|
38
|
+
Landable.configuration.dnt_enabled && request.headers['DNT'] == '1'
|
43
39
|
end
|
44
40
|
|
45
41
|
def untracked_path?
|