pageflow 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pageflow might be problematic. Click here for more details.
- checksums.yaml +8 -8
- data/admins/pageflow/accounts.rb +3 -1
- data/admins/pageflow/entry.rb +2 -1
- data/app/assets/javascripts/pageflow/admin.js +1 -0
- data/app/assets/javascripts/pageflow/admin/accounts.js +30 -0
- data/app/assets/javascripts/pageflow/asset_urls.js.erb +2 -2
- data/app/assets/javascripts/pageflow/editor/api.js +136 -0
- data/app/assets/javascripts/pageflow/editor/api/failure.js +54 -0
- data/app/assets/javascripts/pageflow/editor/api/failures.js +47 -0
- data/app/assets/javascripts/pageflow/editor/base.js +8 -0
- data/app/assets/javascripts/pageflow/editor/collections/chapters_collection.js +1 -1
- data/app/assets/javascripts/pageflow/editor/collections/mixins/ordered_collection.js +9 -4
- data/app/assets/javascripts/pageflow/editor/controllers/sidebar_controller.js +9 -10
- data/app/assets/javascripts/pageflow/editor/initializers/additional_initializers.js +8 -0
- data/app/assets/javascripts/pageflow/editor/initializers/boot.js +1 -8
- data/app/assets/javascripts/pageflow/editor/initializers/routing.js +17 -0
- data/app/assets/javascripts/pageflow/editor/initializers/setup_collections.js +5 -5
- data/app/assets/javascripts/pageflow/editor/models/configuration.js +11 -2
- data/app/assets/javascripts/pageflow/editor/models/entry.js +2 -2
- data/app/assets/javascripts/pageflow/editor/models/mixins/retryable.js +2 -2
- data/app/assets/javascripts/pageflow/editor/models/page_configuration_file_selection_handler.js +37 -0
- data/app/assets/javascripts/pageflow/editor/models/theming.js +8 -0
- data/app/assets/javascripts/pageflow/editor/object.js +14 -0
- data/app/assets/javascripts/pageflow/editor/routers/sidebar_router.js +4 -4
- data/app/assets/javascripts/pageflow/editor/templates/edit_entry.jst.ejs +4 -4
- data/app/assets/javascripts/pageflow/editor/templates/notifications.jst.ejs +1 -1
- data/app/assets/javascripts/pageflow/editor/views/back_button_decorator_view.js +3 -2
- data/app/assets/javascripts/pageflow/editor/views/configuration_editors/audio.js +2 -1
- data/app/assets/javascripts/pageflow/editor/views/configuration_editors/video.js +2 -1
- data/app/assets/javascripts/pageflow/editor/views/edit_entry_view.js +23 -11
- data/app/assets/javascripts/pageflow/editor/views/edit_meta_data_view.js +28 -22
- data/app/assets/javascripts/pageflow/editor/views/entry_preview_view.js +5 -1
- data/app/assets/javascripts/pageflow/editor/views/file_item_view.js +3 -2
- data/app/assets/javascripts/pageflow/editor/views/files_view.js +3 -10
- data/app/assets/javascripts/pageflow/editor/views/input_view.js +39 -1
- data/app/assets/javascripts/pageflow/editor/views/inputs/check_box_input_view.js +13 -2
- data/app/assets/javascripts/pageflow/editor/views/inputs/file_input_view.js +9 -4
- data/app/assets/javascripts/pageflow/editor/views/inputs/text_area_input_view.js +14 -1
- data/app/assets/javascripts/pageflow/editor/views/inputs/text_input_view.js +11 -0
- data/app/assets/javascripts/pageflow/editor/views/mixins/failure_indicating_view.js +3 -3
- data/app/assets/javascripts/pageflow/editor/views/notifications_view.js +7 -6
- data/app/assets/javascripts/pageflow/editor/views/page_preview_view.js +2 -1
- data/app/assets/javascripts/pageflow/page_types/audio.js +13 -8
- data/app/assets/javascripts/pageflow/page_types/video.js +9 -5
- data/app/assets/javascripts/pageflow/widgets/navigation.js +3 -2
- data/app/assets/javascripts/pageflow/widgets/player_controls.js +3 -2
- data/app/assets/javascripts/pageflow/widgets/{home_button.js → top_button.js} +4 -4
- data/app/assets/stylesheets/pageflow/editor/back_button_decorator.css.scss +3 -0
- data/app/assets/stylesheets/pageflow/editor/base.css.scss +1 -0
- data/app/assets/stylesheets/pageflow/editor/tabs_view.css.scss +1 -0
- data/app/assets/stylesheets/pageflow/ie9.css.scss +8 -7
- data/app/assets/stylesheets/pageflow/lt_ie9.css.scss +2 -2
- data/app/assets/stylesheets/pageflow/navigation_bar.css.scss +16 -2
- data/app/assets/stylesheets/pageflow/themes/default/anchors.css.scss +0 -3
- data/app/assets/stylesheets/pageflow/themes/default/navigation.css.scss +13 -4
- data/app/controllers/pageflow/entries_controller.rb +4 -9
- data/app/helpers/pageflow/entries_helper.rb +2 -6
- data/app/helpers/pageflow/themes_helper.rb +9 -0
- data/app/helpers/pageflow/themings_helper.rb +11 -0
- data/app/jobs/pageflow/poll_zencoder_job.rb +2 -2
- data/app/models/pageflow/cname_theming_request_scope.rb +7 -0
- data/app/models/pageflow/draft_entry.rb +9 -1
- data/app/models/pageflow/entry.rb +3 -1
- data/app/models/pageflow/home_button.rb +37 -0
- data/app/models/pageflow/published_entry.rb +8 -0
- data/app/models/pageflow/revision.rb +6 -0
- data/app/models/pageflow/theming.rb +3 -0
- data/app/models/pageflow/zencoder_attachment.rb +35 -17
- data/app/views/admin/accounts/_form.html.erb +14 -2
- data/app/views/admin/entries/_attributes_table.html.arb +1 -1
- data/app/views/admin/entries/_links.html.arb +1 -1
- data/app/views/layouts/pageflow/_ie_include_tags.html.erb +4 -4
- data/app/views/pageflow/editor/entries/_analytics.html.erb +1 -0
- data/app/views/pageflow/editor/entries/_entry.json.jbuilder +4 -0
- data/app/views/pageflow/editor/themings/_theming.json.jbuilder +2 -0
- data/app/views/pageflow/entries/_navigation.html.erb +2 -2
- data/app/views/pageflow/entries/edit.html.erb +3 -0
- data/app/views/pageflow/entries/navigation/_bar_top.html.erb +2 -1
- data/app/views/pageflow/entries/navigation/_home_button.html.erb +8 -0
- data/config/initializers/zencoder.rb +11 -1
- data/config/locales/activerecord.de.yml +5 -0
- data/config/locales/editor.de.yml +5 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20140819081454_add_home_url_attributes_to_themings_and_revisions.rb +9 -0
- data/lib/generators/pageflow/seeds/seeds_generator.rb +4 -4
- data/lib/generators/pageflow/seeds/templates/seeds.rb +30 -0
- data/lib/pageflow/configuration.rb +47 -1
- data/lib/pageflow/page_type.rb +25 -0
- data/lib/pageflow/revision_component.rb +39 -0
- data/lib/pageflow/seeds.rb +153 -71
- data/lib/pageflow/theme.rb +7 -2
- data/lib/pageflow/themes.rb +2 -2
- data/lib/pageflow/version.rb +1 -1
- data/lib/pageflow/zencoder_audio_output_definition.rb +3 -3
- data/lib/pageflow/zencoder_output_definition.rb +46 -7
- data/lib/pageflow/zencoder_video_output_definition.rb +51 -35
- data/spec/factories/entries.rb +6 -2
- metadata +687 -668
- data/app/assets/javascripts/pageflow/editor/collections/failed_records_collection.js +0 -18
@@ -95,6 +95,8 @@ de:
|
|
95
95
|
url: "Permalink"
|
96
96
|
account: "Konto"
|
97
97
|
manual_start: "Multimedia Hinweis vor dem Start anzeigen"
|
98
|
+
home_url: "Home-Button URL"
|
99
|
+
home_button_enabled: "Home-Button anzeigen"
|
98
100
|
"pageflow/folder":
|
99
101
|
account: "Konto"
|
100
102
|
name: "Name"
|
@@ -136,6 +138,7 @@ de:
|
|
136
138
|
linked_pages_layout: "Hervorgehobenes Element"
|
137
139
|
hide_title: "Titel ausblenden"
|
138
140
|
text_position: "Textposition"
|
141
|
+
autoplay: "Automatische Wiedergabe"
|
139
142
|
"pageflow/image_file":
|
140
143
|
dimensions: "Maße"
|
141
144
|
"pageflow/video_file":
|
@@ -152,6 +155,8 @@ de:
|
|
152
155
|
imprint_link_url: "Impressum-Link URL"
|
153
156
|
copyright_link_label: "Copyright-Link Text"
|
154
157
|
copyright_link_url: "Copyright-Link URL"
|
158
|
+
home_url: "Redirect URL"
|
159
|
+
home_button_enabled_by_default: "Home-Button in neuen Beiträgen anzeigen"
|
155
160
|
values:
|
156
161
|
"pageflow/page":
|
157
162
|
template:
|
@@ -6,6 +6,7 @@ de:
|
|
6
6
|
files: "Dateien"
|
7
7
|
options: "Optionen"
|
8
8
|
links: "Verweise"
|
9
|
+
widgets: "Erscheinungsbild"
|
9
10
|
screens:
|
10
11
|
ratio16to9: "16:9"
|
11
12
|
ratio4to3: "4:3"
|
@@ -54,5 +55,9 @@ de:
|
|
54
55
|
summary: "Zusammenfassung die an Soziale Netzwerke weitergeben wird."
|
55
56
|
credits: "Text wird zusammen mit dem Impressumsverweis angezeigt."
|
56
57
|
manual_start: "Besucher muss den Start des Beitrags durch einen Klick bestätigen."
|
58
|
+
home_button_enabled: "Link zu einer Übersichtsseite anzeigen."
|
59
|
+
home_button_enabled_disabled: "Diese Funktion steht in diesem Theme nicht zur Verfügung."
|
60
|
+
home_url: "URL der Übersichtseite. Leer lassen, um Standard zu übernehmen."
|
61
|
+
home_url_disabled: "Diese Funktion steht in diesem Theme nicht zur Verfügung."
|
57
62
|
"pageflow/chapter":
|
58
63
|
title: "Wird auf der Übersichtsseite angezeigt."
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddHomeUrlAttributesToThemingsAndRevisions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :pageflow_themings, :home_url, :string, default: '', null: false
|
4
|
+
add_column :pageflow_themings, :home_button_enabled_by_default, :boolean, default: true, null: false
|
5
|
+
|
6
|
+
add_column :pageflow_revisions, :home_url, :string, default: '', null: false
|
7
|
+
add_column :pageflow_revisions, :home_button_enabled, :boolean, default: false, null: false
|
8
|
+
end
|
9
|
+
end
|
@@ -3,10 +3,10 @@ module Pageflow
|
|
3
3
|
class SeedsGenerator < Rails::Generators::Base
|
4
4
|
desc "Requires the pageflow seeds in db/seeds.rb"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
def create_initializer
|
9
|
+
template 'seeds.rb', 'db/seeds.rb'
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
include Pageflow::Seeds
|
2
|
+
|
3
|
+
# Make sure to change the password if you intend to apply this seed to
|
4
|
+
# a production system.
|
5
|
+
default_user_password('!Pass123')
|
6
|
+
|
7
|
+
account(name: 'Pageflow') do |account|
|
8
|
+
entry = sample_entry(account: account, title: 'Example Entry')
|
9
|
+
|
10
|
+
user(account: account,
|
11
|
+
role: 'admin',
|
12
|
+
email: 'admin@example.com',
|
13
|
+
first_name: 'Alice',
|
14
|
+
last_name: 'Adminson')
|
15
|
+
|
16
|
+
user(account: account,
|
17
|
+
role: 'account_manager',
|
18
|
+
email: 'accountmanager@example.com',
|
19
|
+
first_name: 'Alfred',
|
20
|
+
last_name: 'Mc Count')
|
21
|
+
|
22
|
+
user(account: account,
|
23
|
+
email: 'editor@example.com',
|
24
|
+
role: 'editor',
|
25
|
+
first_name: 'Ed',
|
26
|
+
last_name: 'Edison') do |editor|
|
27
|
+
|
28
|
+
membership(user: editor, entry: entry)
|
29
|
+
end
|
30
|
+
end
|
@@ -68,14 +68,34 @@ module Pageflow
|
|
68
68
|
# accessible via one official url.
|
69
69
|
attr_accessor :editor_routing_constraint
|
70
70
|
|
71
|
+
# Either a lambda or an object with a `call` method taking two
|
72
|
+
# parameters: An `ActiveRecord` scope of {Pageflow::Theming} records
|
73
|
+
# and an {ActionDispatch::Request} object. Has to return the scope
|
74
|
+
# in which to find themings.
|
75
|
+
#
|
76
|
+
# Defaults to {CnameThemingRequestScope} which finds themings
|
77
|
+
# based on the request subdomain. Can be used to alter the logic
|
78
|
+
# of finding a theming whose home_url to redirect to when visiting
|
79
|
+
# the public root path.
|
80
|
+
#
|
81
|
+
# Example:
|
82
|
+
#
|
83
|
+
# config.theming_request_scope = lambda do |themings, request|
|
84
|
+
# themings.where(id: Pageflow::Account.find_by_name!(request.subdomain).default_theming_id)
|
85
|
+
# end
|
86
|
+
attr_accessor :theming_request_scope
|
87
|
+
|
71
88
|
# Either a lambda or an object with a `call` method taking two
|
72
89
|
# parameters: An `ActiveRecord` scope of `Pageflow::Entry` records
|
73
90
|
# and an `ActionDispatch::Request` object. Has to return the scope
|
74
91
|
# in which to find entries.
|
75
92
|
#
|
76
|
-
# Used by all public actions that display
|
93
|
+
# Used by all public actions that display entries to restrict the
|
77
94
|
# available entries by hostname or other request attributes.
|
78
95
|
#
|
96
|
+
# Use {#public_entry_url_options} to make sure urls of published
|
97
|
+
# entries conform twith the restrictions.
|
98
|
+
#
|
79
99
|
# Example:
|
80
100
|
#
|
81
101
|
# # Only make entries of one account available under <account.name>.example.com
|
@@ -84,6 +104,20 @@ module Pageflow
|
|
84
104
|
# end
|
85
105
|
attr_accessor :public_entry_request_scope
|
86
106
|
|
107
|
+
# Either a lambda or an object with a `call` method taking a
|
108
|
+
# {Theming} as paramater and returing a hash of options used to
|
109
|
+
# construct the url of a published entry.
|
110
|
+
#
|
111
|
+
# Can be used to change the host of the url under which entries
|
112
|
+
# are available.
|
113
|
+
#
|
114
|
+
# Example:
|
115
|
+
#
|
116
|
+
# config.public_entry_url_options = lambda do |theming|
|
117
|
+
# {host: "#{theming.account.name}.example.com"}
|
118
|
+
# end
|
119
|
+
attr_accessor :public_entry_url_options
|
120
|
+
|
87
121
|
# Submit video/audio encoding jobs only after the user has
|
88
122
|
# explicitly confirmed in the editor. Defaults to false.
|
89
123
|
attr_accessor :confirm_encoding_jobs
|
@@ -100,7 +134,9 @@ module Pageflow
|
|
100
134
|
@quotas = Quotas.new
|
101
135
|
@themes = Themes.new
|
102
136
|
|
137
|
+
@theming_request_scope = CnameThemingRequestScope.new
|
103
138
|
@public_entry_request_scope = lambda { |entries, request| entries }
|
139
|
+
@public_entry_url_options = Pageflow::ThemingsHelper::DEFAULT_PUBLIC_ENTRY_OPTIONS
|
104
140
|
|
105
141
|
@confirm_encoding_jobs = false
|
106
142
|
end
|
@@ -124,5 +160,15 @@ module Pageflow
|
|
124
160
|
def page_type_names
|
125
161
|
page_types.map(&:name)
|
126
162
|
end
|
163
|
+
|
164
|
+
def revision_components
|
165
|
+
page_types.map(&:revision_components).flatten.uniq
|
166
|
+
end
|
167
|
+
|
168
|
+
# @api private
|
169
|
+
def theming_url_options(theming)
|
170
|
+
options = public_entry_url_options
|
171
|
+
options.respond_to?(:call) ? options.call(theming) : options
|
172
|
+
end
|
127
173
|
end
|
128
174
|
end
|
data/lib/pageflow/page_type.rb
CHANGED
@@ -41,6 +41,31 @@ module Pageflow
|
|
41
41
|
[]
|
42
42
|
end
|
43
43
|
|
44
|
+
|
45
|
+
# ActiveRecord models to be copied together with a revision.
|
46
|
+
#
|
47
|
+
# This allows authors of PageTypes to attach models to the Pageflow
|
48
|
+
# revision mechanism.
|
49
|
+
#
|
50
|
+
# Example:
|
51
|
+
# class Rainbow < ActiveRecord::Base
|
52
|
+
# include Pageflow::RevisionComponent
|
53
|
+
#
|
54
|
+
# [...]
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# class RainbowPageType < Pageflow::PageType
|
58
|
+
# name 'rainbow'
|
59
|
+
#
|
60
|
+
# def revision_components
|
61
|
+
# [Rainbow]
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
def revision_components
|
66
|
+
[]
|
67
|
+
end
|
68
|
+
|
44
69
|
# View path of a template containing additional json to pass to
|
45
70
|
# the editor. The data is available in the javascript definition
|
46
71
|
# of the page type's configuration editor. By default nothing is
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Pageflow
|
2
|
+
# RevisionComponent represents a model that is attached to the revision
|
3
|
+
# mechanism of Pageflow.
|
4
|
+
#
|
5
|
+
# In order to be used as a ComponentModel a model is required to
|
6
|
+
# have an integer field `perma_id` and a belongs_to field `revision`.
|
7
|
+
module RevisionComponent
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
belongs_to :revision, class_name: 'Pageflow::Revision'
|
12
|
+
before_save :ensure_perma_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def copy_to(revision)
|
16
|
+
record = dup
|
17
|
+
record.revision = revision
|
18
|
+
record.save!
|
19
|
+
end
|
20
|
+
|
21
|
+
def ensure_perma_id
|
22
|
+
self.perma_id ||= (self.class.maximum(:perma_id) || 0) + 1
|
23
|
+
end
|
24
|
+
|
25
|
+
module ClassMethods
|
26
|
+
def all_for_revision(revision)
|
27
|
+
where(revision_id: revision.id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def from_perma_ids(revision, perma_ids)
|
31
|
+
return [] if revision.blank? || perma_ids.blank?
|
32
|
+
|
33
|
+
perma_ids.map do |perma_id|
|
34
|
+
find_by_revision_id_and_perma_id(revision.id, perma_id)
|
35
|
+
end.compact
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/pageflow/seeds.rb
CHANGED
@@ -1,90 +1,172 @@
|
|
1
|
-
# Require this file in db/seeds.rb to create example records for development mode.
|
2
|
-
|
3
1
|
module Pageflow
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
2
|
+
# Provides a DSL for seeding the database with Pageflow
|
3
|
+
# models. Include this module in your `db/seeds.rb` file.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
#
|
7
|
+
# # db/seeds.rb
|
8
|
+
# include Pageflow::Seeds
|
9
|
+
#
|
10
|
+
# default_password 'supersecret'
|
11
|
+
#
|
12
|
+
# account(name: 'example') do |account|
|
13
|
+
# user(account: account,
|
14
|
+
# email: 'admin@example.com',
|
15
|
+
# role: 'admin',
|
16
|
+
# first_name: 'John',
|
17
|
+
# last_name: 'Doe')
|
18
|
+
# end
|
19
|
+
module Seeds
|
20
|
+
DEFAULT_USER_PASSWORD = '!Pass123'
|
21
|
+
|
22
|
+
# Create an {Account} with a default {Theming} if no account by
|
23
|
+
# that name exists.
|
24
|
+
#
|
25
|
+
# @param [Hash] attributes attributes to override defaults
|
26
|
+
# @option attributes [String] :name required
|
27
|
+
# @yield [account] a block to be called before the account is saved
|
28
|
+
# @return [Account] newly created account
|
29
|
+
def account(attributes, &block)
|
30
|
+
Account.find_or_create_by!(attributes.slice(:name)) do |account|
|
31
|
+
account.attributes = attributes.reverse_merge(name: 'Pageflow')
|
32
|
+
|
33
|
+
build_default_theming_for(account)
|
34
|
+
|
35
|
+
say_creating_account(account)
|
36
|
+
yield(account) if block_given?
|
18
37
|
end
|
19
38
|
end
|
20
39
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
40
|
+
# Build a default {Theming} for an {Account}. To be used inside a
|
41
|
+
# block passed to {#account}.
|
42
|
+
#
|
43
|
+
# @example
|
44
|
+
#
|
45
|
+
# account(name: 'example') do |account|
|
46
|
+
# build_default_theming_for(account) do |theming|
|
47
|
+
# theming.theme_name = 'mdr'
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# @param [Account] account the account to build a default themeing for
|
52
|
+
# @param [Hash] attributes further attributes to override defaults
|
53
|
+
# @yield [theming] a block which is passed the newly built theming
|
54
|
+
# @return [Theming] newly built theming
|
55
|
+
def build_default_theming_for(account, attributes = {}, &block)
|
56
|
+
default_attributes = {
|
57
|
+
theme_name: Pageflow.config.themes.names.first,
|
58
|
+
|
59
|
+
imprint_link_label: 'Impressum',
|
60
|
+
imprint_link_url: 'http://example.com/impressum.html',
|
61
|
+
copyright_link_label: '© Pageflow 2014',
|
62
|
+
copyright_link_url: 'http://www.example.com/copyright.html'
|
63
|
+
}
|
64
|
+
|
65
|
+
account.build_default_theming(default_attributes.merge(attributes), &block)
|
66
|
+
end
|
29
67
|
|
30
|
-
|
31
|
-
|
68
|
+
# Create a {User} if non with the given email exists yet.
|
69
|
+
#
|
70
|
+
# @param [Hash] attributes attributes to override defaults
|
71
|
+
# @option attributes [String] :email required
|
72
|
+
# @yield [user] a block to be called before the user is saved
|
73
|
+
# @return [User] newly created user
|
74
|
+
def user(attributes, &block)
|
75
|
+
default_attributes = {
|
76
|
+
password: default_user_password,
|
77
|
+
first_name: 'Elliot',
|
78
|
+
last_name: 'Example'
|
79
|
+
}
|
80
|
+
|
81
|
+
User.find_or_create_by!(attributes.slice(:email)) do |user|
|
82
|
+
user.attributes = default_attributes.merge(attributes)
|
83
|
+
user.password_confirmation = user.password
|
84
|
+
|
85
|
+
say_creating_user(user)
|
86
|
+
yield(user) if block_given?
|
87
|
+
end
|
88
|
+
end
|
32
89
|
|
33
|
-
|
34
|
-
|
90
|
+
# Set the default password to use for created users. Call before
|
91
|
+
# using {#user}.
|
92
|
+
#
|
93
|
+
# @param [String] password
|
94
|
+
def default_user_password(password = nil)
|
95
|
+
if password
|
96
|
+
@default_user_password = password
|
97
|
+
else
|
98
|
+
@default_user_password || DEFAULT_USER_PASSWORD
|
99
|
+
end
|
100
|
+
end
|
35
101
|
|
36
|
-
|
37
|
-
|
102
|
+
# Create a sample {Entry} with some chapter and pages if no
|
103
|
+
# entry with that title exists in the given account.
|
104
|
+
#
|
105
|
+
# @param [Hash] attributes attributes to override defaults
|
106
|
+
# @option attributes [Account] :account required
|
107
|
+
# @option attributes [title] :title required
|
108
|
+
# @yield [entry] a block to be called before the entry is saved
|
109
|
+
# @return [Entry] newly created entry
|
110
|
+
def sample_entry(attributes)
|
111
|
+
entry = Entry.where(attributes.slice(:account, :title)).first
|
112
|
+
|
113
|
+
if entry.nil?
|
114
|
+
entry = Entry.create!(attributes) do |entry|
|
115
|
+
entry.theming = attributes.fetch(:account).default_theming
|
116
|
+
|
117
|
+
say_creating_entry(entry)
|
118
|
+
yield(entry) if block_given?
|
119
|
+
end
|
120
|
+
|
121
|
+
chapter = entry.draft.chapters.create!(title: 'Kapitel 1')
|
122
|
+
chapter.pages.create!(template: 'background_image')
|
123
|
+
chapter.pages.create!(template: 'background_image')
|
124
|
+
|
125
|
+
chapter = entry.draft.chapters.create!(title: 'Kapitel 2')
|
126
|
+
chapter.pages.create!(template: 'video')
|
127
|
+
end
|
38
128
|
|
39
|
-
|
40
|
-
|
41
|
-
:password => '!Pass123',
|
42
|
-
:first_name => 'Alice',
|
43
|
-
:last_name => 'Adminson',
|
44
|
-
:role => 'admin')
|
45
|
-
|
46
|
-
create_user(:email => 'accountmanager@example.com',
|
47
|
-
:password => '!Pass123',
|
48
|
-
:first_name => 'Alfred',
|
49
|
-
:last_name => 'Mc Count',
|
50
|
-
:role => 'account_manager')
|
51
|
-
|
52
|
-
create_user(:email => 'editor@example.com',
|
53
|
-
:password => '!Pass123',
|
54
|
-
:first_name => 'Ed',
|
55
|
-
:last_name => 'Edison')
|
56
|
-
else
|
57
|
-
puts " Users exist."
|
58
|
-
end
|
129
|
+
entry
|
130
|
+
end
|
59
131
|
|
60
|
-
|
132
|
+
# Create a {Membership} for the given user and entry.
|
133
|
+
#
|
134
|
+
# @param [Hash] attributes attributes to override defaults
|
135
|
+
# @option attributes [User] :user required
|
136
|
+
# @option attributes [Entry] :entry required
|
137
|
+
# @return [Membership] newly created membership
|
138
|
+
def membership(attributes)
|
139
|
+
Membership.find_or_create_by!(attributes) do |membership|
|
140
|
+
say_creating_membership(membership)
|
141
|
+
end
|
142
|
+
end
|
61
143
|
|
62
|
-
|
63
|
-
entry = default_account.entries.create!(:title => 'Fiese Flut', :theming_id => default_account.default_theming.id)
|
144
|
+
private
|
64
145
|
|
65
|
-
|
66
|
-
|
67
|
-
|
146
|
+
def say_creating_account(account)
|
147
|
+
say("\n-- creating account '#{account.name}'\n\n")
|
148
|
+
end
|
68
149
|
|
69
|
-
|
70
|
-
|
150
|
+
def say_creating_user(user)
|
151
|
+
say(<<-END)
|
152
|
+
#{user.role} user:
|
71
153
|
|
72
|
-
|
73
|
-
|
154
|
+
email: #{user.email}
|
155
|
+
password: #{user.password}
|
74
156
|
|
75
|
-
|
157
|
+
END
|
158
|
+
end
|
76
159
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
puts " Created sample membership."
|
81
|
-
end
|
160
|
+
def say_creating_entry(entry)
|
161
|
+
say(" sample entry '#{entry.title}'")
|
162
|
+
end
|
82
163
|
|
83
|
-
|
164
|
+
def say_creating_membership(membership)
|
165
|
+
say(" membership for user '#{membership.user.email}' and entry '#{membership.entry.title}'")
|
166
|
+
end
|
84
167
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
puts " Created sample revision."
|
168
|
+
def say(text)
|
169
|
+
puts(text) unless Rails.env.test?
|
170
|
+
end
|
89
171
|
end
|
90
172
|
end
|