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
@@ -5,8 +5,8 @@ module Landable
|
|
5
5
|
class Error < StandardError; end
|
6
6
|
|
7
7
|
class << self
|
8
|
-
def capture
|
9
|
-
if
|
8
|
+
def capture(url)
|
9
|
+
if !Landable.configuration.publicist_url
|
10
10
|
Rails.logger.warn "Couldn't generate screenshot for #{url}; no Landable.configuration.publicist_url configured"
|
11
11
|
else
|
12
12
|
screenshots_uri = URI(Landable.configuration.publicist_url)
|
@@ -22,11 +22,10 @@ module Landable
|
|
22
22
|
|
23
23
|
file
|
24
24
|
else
|
25
|
-
|
25
|
+
fail Error, "Received #{response.code} back from #{screenshots_uri}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
30
|
end
|
32
31
|
end
|
@@ -1,10 +1,13 @@
|
|
1
1
|
module Landable
|
2
2
|
module TidyService
|
3
|
-
|
4
3
|
class TidyError < StandardError; end
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
class << self
|
6
|
+
attr_accessor :options
|
7
|
+
attr_accessor :liquid_elements
|
8
|
+
end
|
9
|
+
|
10
|
+
@options = [
|
8
11
|
# is what we have
|
9
12
|
'-utf8',
|
10
13
|
|
@@ -31,28 +34,21 @@ module Landable
|
|
31
34
|
|
32
35
|
# silence will fall
|
33
36
|
'--quiet true',
|
34
|
-
'--show-warnings false'
|
37
|
+
'--show-warnings false'
|
35
38
|
]
|
36
39
|
|
37
40
|
# list of liquid tags that also render tags - things that we should
|
38
41
|
# consider to be element-level, and therefore to be tidied along with the
|
39
42
|
# rest of the dom
|
40
|
-
|
41
|
-
@@liquid_elements = [
|
42
|
-
'template',
|
43
|
-
'title_tag',
|
44
|
-
'meta_tags',
|
45
|
-
'img_tag',
|
46
|
-
]
|
47
|
-
|
43
|
+
@liquid_elements = %w(template title_tag meta_tags img_tag)
|
48
44
|
|
49
|
-
def self.call!
|
50
|
-
|
45
|
+
def self.call!(input)
|
46
|
+
call input, raise_on_error: true
|
51
47
|
end
|
52
48
|
|
53
|
-
def self.call
|
54
|
-
|
55
|
-
|
49
|
+
def self.call(input, runtime_options = {})
|
50
|
+
unless tidyable?
|
51
|
+
fail TidyError, 'Your system doesn\'t seem to have tidy installed. Please see https://github.com/w3c/tidy-html5.'
|
56
52
|
end
|
57
53
|
|
58
54
|
# wrapping known liquid in a span to allow tidy to format them nicely
|
@@ -70,8 +66,8 @@ module Landable
|
|
70
66
|
# 2: error
|
71
67
|
# 3: ???
|
72
68
|
# 4: profit
|
73
|
-
if
|
74
|
-
|
69
|
+
if $CHILD_STATUS.exitstatus >= 2 && runtime_options[:raise_on_error]
|
70
|
+
fail TidyError, "Tidy exited with status #{$CHILD_STATUS} - check stderr."
|
75
71
|
end
|
76
72
|
|
77
73
|
# unnwrapping the liquid that we wrapped earlier
|
@@ -82,12 +78,12 @@ module Landable
|
|
82
78
|
end
|
83
79
|
|
84
80
|
def self.tidyable?
|
85
|
-
|
81
|
+
@is_tidyable ||= Kernel.system('which tidy > /dev/null')
|
86
82
|
end
|
87
83
|
|
88
84
|
protected
|
89
85
|
|
90
|
-
def self.wrap_liquid
|
86
|
+
def self.wrap_liquid(input)
|
91
87
|
output = input.dup
|
92
88
|
|
93
89
|
output.scan(/(\s*(\{% *(?:#{liquid_elements.join('|')}) *.*?%})\s*)/).each do |match, liquid|
|
@@ -100,10 +96,10 @@ module Landable
|
|
100
96
|
output
|
101
97
|
end
|
102
98
|
|
103
|
-
def self.unwrap_liquid
|
99
|
+
def self.unwrap_liquid(input)
|
104
100
|
output = input.dup
|
105
101
|
|
106
|
-
output.scan(
|
102
|
+
output.scan(%r{(<div data-liquid="(.*?)"><\/div>)}).each do |match, liquid|
|
107
103
|
# ensure we match utf8 for utf8
|
108
104
|
decoded = Base64.decode64(liquid).force_encoding(match.encoding)
|
109
105
|
output.gsub! match, decoded
|
@@ -112,9 +108,8 @@ module Landable
|
|
112
108
|
output
|
113
109
|
end
|
114
110
|
|
115
|
-
|
116
111
|
class Result < Object
|
117
|
-
def initialize
|
112
|
+
def initialize(source)
|
118
113
|
@source = source
|
119
114
|
end
|
120
115
|
|
@@ -123,33 +118,33 @@ module Landable
|
|
123
118
|
end
|
124
119
|
|
125
120
|
def body
|
126
|
-
|
127
|
-
|
128
|
-
|
121
|
+
match = @source.match(%r{<body(?: [^>]*)?>(.*)<\/body>}m)
|
122
|
+
return unless match
|
123
|
+
deindent match[1]
|
129
124
|
end
|
130
125
|
|
131
126
|
def head
|
132
|
-
|
133
|
-
|
134
|
-
|
127
|
+
match = @source.match(%r{<head>(.*)<\/head>}m)
|
128
|
+
return unless match
|
129
|
+
deindent match[1]
|
135
130
|
end
|
136
131
|
|
137
132
|
def css
|
138
|
-
links = head.try :scan,
|
139
|
-
styles = head.try :scan,
|
133
|
+
links = head.try :scan, %r{<link [^>]*type=['"]text\/css['"][^>]*>}
|
134
|
+
styles = head.try :scan, %r{<style[^>]*>.*?<\/style>}m
|
140
135
|
[links.to_a, styles.to_a].flatten.join("\n\n")
|
141
136
|
end
|
142
137
|
|
143
138
|
protected
|
144
139
|
|
145
|
-
def deindent
|
146
|
-
|
140
|
+
def deindent(string)
|
141
|
+
match = string.match(/^([ \t]*)[^\s]/)
|
142
|
+
if match
|
147
143
|
string.gsub(/^#{match[1]}/, '').strip
|
148
144
|
else
|
149
145
|
string.strip
|
150
146
|
end
|
151
147
|
end
|
152
148
|
end
|
153
|
-
|
154
149
|
end
|
155
|
-
end
|
150
|
+
end
|
@@ -1,13 +1,10 @@
|
|
1
1
|
class UrlValidator < ActiveModel::EachValidator
|
2
|
-
|
3
2
|
def validate_each(record, attribute, value)
|
4
3
|
valid = begin
|
5
|
-
value =~
|
4
|
+
value =~ %r{^[a-z]+\:\/\/} || value =~ %r{^\/}
|
6
5
|
end
|
6
|
+
return if valid
|
7
7
|
|
8
|
-
|
9
|
-
record.errors[attribute] << ("Invalid URL! Make sure it starts with http:// or /")
|
10
|
-
end
|
8
|
+
record.errors[attribute] << ('Invalid URL! Make sure it starts with http:// or /')
|
11
9
|
end
|
12
|
-
|
13
|
-
end
|
10
|
+
end
|
data/config/routes.rb
CHANGED
@@ -4,7 +4,7 @@ Landable::Engine.routes.draw do
|
|
4
4
|
resources :categories, only: [:index, :show]
|
5
5
|
|
6
6
|
resources :directories, only: [:index, :show], constraints: {
|
7
|
-
id:
|
7
|
+
id: %r{[%a-zA-Z0-9\/_.~-]*}
|
8
8
|
}
|
9
9
|
|
10
10
|
resources :assets, only: [:index, :show, :create, :update, :deactivate, :destroy]
|
@@ -50,7 +50,6 @@ Landable::Engine.routes.draw do
|
|
50
50
|
|
51
51
|
resources :access_tokens, only: [:create, :destroy, :show]
|
52
52
|
|
53
|
-
|
54
53
|
# coming soon: screenshots!
|
55
54
|
|
56
55
|
# resources :screenshots, only: [:index, :show, :create] do
|
@@ -69,9 +68,7 @@ Landable::Engine.routes.draw do
|
|
69
68
|
|
70
69
|
get '/sitemap.xml' => 'sitemap#index', as: :sitemap
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
Landable::PageRevision.table_exists? && Landable::PageRevision.where(path: request.path, is_published: true).any?
|
75
|
-
}
|
71
|
+
constraint = ->(request) { Landable::PageRevision.table_exists? && Landable::PageRevision.where(path: request.path, is_published: true).any? }
|
72
|
+
get '*url' => 'pages#show', as: :page, format: false, constraints: constraint
|
76
73
|
end
|
77
74
|
end
|
@@ -3,21 +3,20 @@ class CreateLandableSchema < Landable::Migration
|
|
3
3
|
# This really should not be in this migration, but it's a convenient location
|
4
4
|
# while everything's still under development.
|
5
5
|
#
|
6
|
-
# TODO extract to a separate migration, check if it exists, maybe check if we
|
6
|
+
# TODO: extract to a separate migration, check if it exists, maybe check if we
|
7
7
|
# actually have permission to do it, etc.
|
8
8
|
execute 'CREATE EXTENSION "uuid-ossp";'
|
9
|
-
enable_extension
|
10
|
-
enable_extension
|
11
|
-
enable_extension
|
9
|
+
enable_extension 'uuid-ossp'
|
10
|
+
enable_extension 'hstore'
|
11
|
+
enable_extension 'pg_trgm'
|
12
12
|
|
13
13
|
execute 'ALTER EXTENSION "uuid-ossp" SET SCHEMA "public";'
|
14
14
|
execute "CREATE SCHEMA #{Landable.configuration.database_schema_prefix}landable;"
|
15
15
|
|
16
|
-
|
17
16
|
## status_codes
|
18
17
|
|
19
18
|
create_table "#{Landable.configuration.database_schema_prefix}landable.status_code_categories", id: :uuid, primary_key: :status_code_category_id do |t|
|
20
|
-
t.text
|
19
|
+
t.text :name, null: false
|
21
20
|
end
|
22
21
|
|
23
22
|
execute "CREATE UNIQUE INDEX #{Landable.configuration.database_schema_prefix}landable_status_code_categories__u_name ON #{Landable.configuration.database_schema_prefix}landable.status_code_categories(lower(name))"
|
@@ -25,9 +24,9 @@ class CreateLandableSchema < Landable::Migration
|
|
25
24
|
$$Categories that status codes belong to. Used to affect behavior when viewing a page.$$"
|
26
25
|
|
27
26
|
create_table "#{Landable.configuration.database_schema_prefix}landable.status_codes", id: :uuid, primary_key: :status_code_id do |t|
|
28
|
-
t.uuid
|
29
|
-
t.integer
|
30
|
-
t.text
|
27
|
+
t.uuid :status_code_category_id, null: false
|
28
|
+
t.integer :code, null: false, limit: 2 # Creates as smallint
|
29
|
+
t.text :description, null: false
|
31
30
|
end
|
32
31
|
|
33
32
|
execute "CREATE UNIQUE INDEX #{Landable.configuration.database_schema_prefix}landable_status_codes__u_code ON #{Landable.configuration.database_schema_prefix}landable.status_codes(code)"
|
@@ -35,7 +34,6 @@ class CreateLandableSchema < Landable::Migration
|
|
35
34
|
execute "COMMENT ON TABLE #{Landable.configuration.database_schema_prefix}landable.status_codes IS
|
36
35
|
$$Allowed status codes that pages can be set to.$$"
|
37
36
|
|
38
|
-
|
39
37
|
## themes
|
40
38
|
|
41
39
|
create_table "#{Landable.configuration.database_schema_prefix}landable.themes", id: :uuid, primary_key: :theme_id do |t|
|
@@ -50,7 +48,6 @@ class CreateLandableSchema < Landable::Migration
|
|
50
48
|
execute "COMMENT ON TABLE #{Landable.configuration.database_schema_prefix}landable.themes IS
|
51
49
|
$$Created themes to be consumed by pages. Themes supply formatting (css) rules and can supply header/footer content as well.$$"
|
52
50
|
|
53
|
-
|
54
51
|
## templates
|
55
52
|
|
56
53
|
create_table "#{Landable.configuration.database_schema_prefix}landable.templates", id: :uuid, primary_key: :template_id do |t|
|
@@ -65,28 +62,28 @@ class CreateLandableSchema < Landable::Migration
|
|
65
62
|
|
66
63
|
execute "CREATE UNIQUE INDEX #{Landable.configuration.database_schema_prefix}landable_templates__u_name ON #{Landable.configuration.database_schema_prefix}landable.templates(lower(name))"
|
67
64
|
execute "COMMENT ON TABLE #{Landable.configuration.database_schema_prefix}landable.templates IS
|
68
|
-
$$Created templates to be consumed by pages.
|
69
|
-
A template can supply 'starter' code for a page.
|
65
|
+
$$Created templates to be consumed by pages.
|
66
|
+
A template can supply 'starter' code for a page.
|
70
67
|
A template can also supply code to create elements on a page (sidebars, for example).$$"
|
71
68
|
|
72
69
|
## pages
|
73
70
|
|
74
71
|
create_table "#{Landable.configuration.database_schema_prefix}landable.pages", id: :uuid, primary_key: :page_id do |t|
|
75
|
-
t.uuid
|
76
|
-
t.boolean
|
72
|
+
t.uuid :published_revision_id
|
73
|
+
t.boolean :is_publishable, null: false, default: true
|
77
74
|
|
78
|
-
t.uuid
|
79
|
-
t.uuid
|
80
|
-
t.uuid
|
75
|
+
t.uuid :theme_id
|
76
|
+
t.uuid :category_id
|
77
|
+
t.uuid :status_code_id, null: false
|
81
78
|
|
82
|
-
t.text
|
79
|
+
t.text :path, null: false
|
83
80
|
|
84
|
-
t.text
|
85
|
-
t.text
|
81
|
+
t.text :title
|
82
|
+
t.text :body
|
86
83
|
|
87
|
-
t.text
|
84
|
+
t.text :redirect_url
|
88
85
|
|
89
|
-
t.hstore
|
86
|
+
t.hstore :meta_tags
|
90
87
|
|
91
88
|
t.timestamp :imported_at
|
92
89
|
t.timestamps
|
@@ -123,11 +120,10 @@ class CreateLandableSchema < Landable::Migration
|
|
123
120
|
execute "COMMENT ON TABLE #{Landable.configuration.database_schema_prefix}landable.authors IS
|
124
121
|
$$A list of authors that have accessed the website. Feeds foreign keys so we know which authors have published pages and updated assets.$$"
|
125
122
|
|
126
|
-
|
127
123
|
## access_tokens
|
128
124
|
|
129
125
|
create_table "#{Landable.configuration.database_schema_prefix}landable.access_tokens", id: :uuid, primary_key: :access_token_id do |t|
|
130
|
-
t.uuid
|
126
|
+
t.uuid :author_id, null: false
|
131
127
|
t.timestamp :expires_at, null: false
|
132
128
|
t.timestamps
|
133
129
|
end
|
@@ -137,19 +133,18 @@ class CreateLandableSchema < Landable::Migration
|
|
137
133
|
execute "COMMENT ON TABLE #{Landable.configuration.database_schema_prefix}landable.access_tokens IS
|
138
134
|
$$Access tokens provide authentication information for specific users.$$"
|
139
135
|
|
140
|
-
|
141
136
|
## page_revisions
|
142
137
|
|
143
138
|
create_table "#{Landable.configuration.database_schema_prefix}landable.page_revisions", id: :uuid, primary_key: :page_revision_id do |t|
|
144
|
-
t.integer
|
145
|
-
t.text
|
146
|
-
t.boolean
|
147
|
-
t.boolean
|
139
|
+
t.integer :ordinal
|
140
|
+
t.text :notes
|
141
|
+
t.boolean :is_minor, default: false
|
142
|
+
t.boolean :is_published, default: true
|
148
143
|
|
149
|
-
t.uuid
|
150
|
-
t.uuid
|
144
|
+
t.uuid :page_id, null: false
|
145
|
+
t.uuid :author_id, null: false
|
151
146
|
|
152
|
-
t.text
|
147
|
+
t.text :snapshot_attributes, null: false
|
153
148
|
|
154
149
|
t.timestamps
|
155
150
|
end
|
@@ -159,12 +154,11 @@ class CreateLandableSchema < Landable::Migration
|
|
159
154
|
The attributes of the page at the time of publishing are stored in snapshot_attributes, as essentially a text representation of a hash.
|
160
155
|
The current/active/live revision can be identified by referring to its corresponding PAGES record, OR by looking for the max(ordinal) for a given page_id.$$"
|
161
156
|
|
162
|
-
|
163
157
|
## categories
|
164
158
|
|
165
159
|
create_table "#{Landable.configuration.database_schema_prefix}landable.categories", id: :uuid, primary_key: :category_id do |t|
|
166
|
-
t.text
|
167
|
-
t.text
|
160
|
+
t.text :name
|
161
|
+
t.text :description
|
168
162
|
end
|
169
163
|
|
170
164
|
execute "CREATE UNIQUE INDEX #{Landable.configuration.database_schema_prefix}landable_categories__u_name ON #{Landable.configuration.database_schema_prefix}landable.categories(lower(name))"
|
@@ -172,16 +166,15 @@ class CreateLandableSchema < Landable::Migration
|
|
172
166
|
$$Categories are used to sort pages.
|
173
167
|
Examples could include SEO, PPC.$$"
|
174
168
|
|
175
|
-
|
176
169
|
## assets
|
177
170
|
|
178
171
|
create_table "#{Landable.configuration.database_schema_prefix}landable.assets", id: :uuid, primary_key: :asset_id do |t|
|
179
|
-
t.uuid
|
180
|
-
t.text
|
181
|
-
t.text
|
182
|
-
t.text
|
183
|
-
t.text
|
184
|
-
t.text
|
172
|
+
t.uuid :author_id, null: false
|
173
|
+
t.text :name, null: false
|
174
|
+
t.text :description
|
175
|
+
t.text :data, null: false
|
176
|
+
t.text :md5sum, null: false, length: 32
|
177
|
+
t.text :mime_type, null: false
|
185
178
|
t.integer :file_size
|
186
179
|
t.timestamps
|
187
180
|
end
|
@@ -197,7 +190,6 @@ class CreateLandableSchema < Landable::Migration
|
|
197
190
|
Examples of assets include images (jpg, png, gif) and documents (PDF).
|
198
191
|
data, md5sum, mime_type, file_size are populated via the rails gem CarrierWave when a record is created.$$"
|
199
192
|
|
200
|
-
|
201
193
|
## browsers
|
202
194
|
|
203
195
|
create_table "#{Landable.configuration.database_schema_prefix}landable.browsers", id: :uuid, primary_key: :browser_id do |t|
|
@@ -215,7 +207,6 @@ class CreateLandableSchema < Landable::Migration
|
|
215
207
|
|
216
208
|
execute "CREATE INDEX #{Landable.configuration.database_schema_prefix}landable_screenshots__device_browser_browser_version ON #{Landable.configuration.database_schema_prefix}landable.browsers(device, browser, browser_version)"
|
217
209
|
|
218
|
-
|
219
210
|
## screenshots
|
220
211
|
|
221
212
|
create_table "#{Landable.configuration.database_schema_prefix}landable.screenshots", id: :uuid, primary_key: :screenshot_id do |t|
|
@@ -241,7 +232,6 @@ class CreateLandableSchema < Landable::Migration
|
|
241
232
|
execute "COMMENT ON TABLE #{Landable.configuration.database_schema_prefix}landable.screenshots IS
|
242
233
|
$$Stores saved screenshots (taken of pages) and the URLs to retrieve the actual image.$$"
|
243
234
|
|
244
|
-
|
245
235
|
## asset associations table
|
246
236
|
|
247
237
|
create_table "#{Landable.configuration.database_schema_prefix}landable.page_assets", id: :uuid, primary_key: :page_asset_id do |t|
|
@@ -305,9 +295,9 @@ class CreateLandableSchema < Landable::Migration
|
|
305
295
|
$TRIGGER$
|
306
296
|
LANGUAGE plpgsql;"
|
307
297
|
|
308
|
-
|
309
|
-
|
310
|
-
|
298
|
+
execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__bfr_insert
|
299
|
+
BEFORE INSERT ON #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
300
|
+
FOR EACH ROW EXECUTE PROCEDURE #{Landable.configuration.database_schema_prefix}landable.pages_revision_ordinal();"
|
311
301
|
|
312
302
|
# Trigger disallowing deletes on page_revisions
|
313
303
|
execute "CREATE FUNCTION #{Landable.configuration.database_schema_prefix}landable.tg_disallow()
|
@@ -328,13 +318,12 @@ class CreateLandableSchema < Landable::Migration
|
|
328
318
|
$TRIGGER$
|
329
319
|
LANGUAGE plpgsql;"
|
330
320
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
336
|
-
BEFORE UPDATE OF notes, is_minor, page_id, author_id, created_at, ordinal ON #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
337
|
-
FOR EACH STATEMENT EXECUTE PROCEDURE #{Landable.configuration.database_schema_prefix}landable.tg_disallow();"
|
321
|
+
execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_delete
|
322
|
+
BEFORE DELETE ON #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
323
|
+
FOR EACH STATEMENT EXECUTE PROCEDURE #{Landable.configuration.database_schema_prefix}landable.tg_disallow();"
|
338
324
|
|
325
|
+
execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
326
|
+
BEFORE UPDATE OF notes, is_minor, page_id, author_id, created_at, ordinal ON #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
327
|
+
FOR EACH STATEMENT EXECUTE PROCEDURE #{Landable.configuration.database_schema_prefix}landable.tg_disallow();"
|
339
328
|
end
|
340
329
|
end
|