pulitzer 0.13.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/pulitzer.scss +28 -2
- data/app/controllers/pulitzer/content_elements_controller.rb +6 -2
- data/app/controllers/pulitzer/custom_option_lists_controller.rb +55 -0
- data/app/controllers/pulitzer/custom_options_controller.rb +55 -0
- data/app/controllers/pulitzer/partial_types_controller.rb +0 -11
- data/app/controllers/pulitzer/posts_controller.rb +5 -6
- data/app/controllers/pulitzer/styles_controller.rb +42 -0
- data/app/helpers/pulitzer/posts_helper.rb +15 -4
- data/app/interactions/pulitzer/content_elements_controller/update.rb +21 -0
- data/app/models/pulitzer/content_element.rb +63 -8
- data/app/models/pulitzer/content_element_type.rb +6 -1
- data/app/models/pulitzer/custom_option.rb +6 -0
- data/app/models/pulitzer/custom_option_list.rb +10 -0
- data/app/models/pulitzer/post_type_content_element_type.rb +58 -2
- data/app/models/pulitzer/style.rb +11 -0
- data/app/views/pulitzer/content_elements/_clickable_fields.html.erb +31 -0
- data/app/views/pulitzer/content_elements/_form.html.erb +1 -3
- data/app/views/pulitzer/content_elements/_partial_index.html.erb +1 -1
- data/app/views/pulitzer/content_elements/_show.html.erb +11 -20
- data/app/views/pulitzer/custom_option_lists/_edit.html.erb +10 -0
- data/app/views/pulitzer/custom_option_lists/_index.html.erb +12 -0
- data/app/views/pulitzer/custom_option_lists/_new.html.erb +9 -0
- data/app/views/pulitzer/custom_option_lists/_show.html.erb +11 -0
- data/app/views/pulitzer/custom_option_lists/_show_wrapper.html.erb +3 -0
- data/app/views/pulitzer/custom_options/_edit.html.erb +10 -0
- data/app/views/pulitzer/custom_options/_fields.html.erb +2 -0
- data/app/views/pulitzer/custom_options/_index.html.erb +20 -0
- data/app/views/pulitzer/custom_options/_new.html.erb +10 -0
- data/app/views/pulitzer/custom_options/_show.html.erb +5 -0
- data/app/views/pulitzer/custom_options/_show_wrapper.html.erb +3 -0
- data/app/views/pulitzer/free_form_section_types/_show_wrapper.html.erb +1 -1
- data/app/views/pulitzer/partial_types/_index.html.erb +1 -1
- data/app/views/pulitzer/partials/_index.html.erb +4 -4
- data/app/views/pulitzer/partials/_new.html.erb +1 -1
- data/app/views/pulitzer/post_type_content_element_types/_form_fields.html.erb +4 -0
- data/app/views/pulitzer/post_type_content_element_types/_show.html.erb +13 -5
- data/app/views/pulitzer/post_types/_template.html.erb +5 -4
- data/app/views/pulitzer/post_types/index.html.erb +26 -12
- data/app/views/pulitzer/posts/{index.html.erb → _index.html.erb} +0 -0
- data/app/views/pulitzer/styles/_index.html.erb +10 -0
- data/app/views/pulitzer/styles/_new.html.erb +29 -0
- data/app/views/pulitzer/styles/_show.html.erb +15 -0
- data/app/views/pulitzer/styles/_show_wrapper.html.erb +3 -0
- data/config/routes.rb +4 -0
- data/lib/pulitzer/content_element_helper.rb +22 -4
- data/lib/pulitzer/version.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +16 -0
- data/spec/dummy/app/controllers/pages_controller.rb +7 -0
- data/spec/dummy/app/controllers/pulitzer_preview/pages_controller.rb +16 -0
- data/spec/dummy/app/views/pages/welcome.html.erb +27 -0
- data/spec/dummy/app/views/pulitzer/welcome.html.erb +27 -0
- data/spec/dummy/config/initializers/zz_pulitzer.rb +1 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +198 -0
- data/spec/dummy/log/test.log +1733 -0
- metadata +34 -6
- data/app/interactions/pulitzer/update_free_form_section_partials.rb +0 -18
- data/app/models/pulitzer/layout.rb +0 -11
- data/app/views/pulitzer/partial_types/_form.html.erb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e01e95cdb9ec9d3fbb0f484ab7263519409140c
|
4
|
+
data.tar.gz: 18fcb0fecbab662836112e3ec7a155c8129fa2d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f048a22b01c550868720e74b75e6c53dd22eec334bdd99bac68481c3c0caee046d384611bb793ec9771585b26b33c52d0f2f430c33bb44b69c2e5f46f7cca5f
|
7
|
+
data.tar.gz: d220bf23ba6638104df2cd56bd75f31c46ac8b94ac229b487c8fe26c578b2e67f2b7ce2d83d3027e860d2a51a63345bc922ad09f537dc2f22e79f3d260900bc5
|
@@ -65,6 +65,9 @@ body {
|
|
65
65
|
&.margin-bottom {
|
66
66
|
margin-bottom: 1.4em;
|
67
67
|
}
|
68
|
+
&.margin-top {
|
69
|
+
margin-top: 1.4em;
|
70
|
+
}
|
68
71
|
&.margin-left {
|
69
72
|
margin-left: 1.4em;
|
70
73
|
}
|
@@ -185,6 +188,18 @@ body {
|
|
185
188
|
&.empty {
|
186
189
|
background-color: #eee;
|
187
190
|
}
|
191
|
+
&.five-percent {
|
192
|
+
width: 5%;
|
193
|
+
&.margin {
|
194
|
+
width: 3%;
|
195
|
+
margin-right: 2%;
|
196
|
+
}
|
197
|
+
@media screen and (max-width: 480px) {
|
198
|
+
width: 100%;
|
199
|
+
margin-right: none;
|
200
|
+
margin-left: none;
|
201
|
+
}
|
202
|
+
}
|
188
203
|
&.ten-percent {
|
189
204
|
width: 10%;
|
190
205
|
&.margin {
|
@@ -257,9 +272,20 @@ body {
|
|
257
272
|
margin-left: none;
|
258
273
|
}
|
259
274
|
}
|
275
|
+
&.ninety-percent {
|
276
|
+
width: 90%;
|
277
|
+
&.margin{
|
278
|
+
width: 88%;
|
279
|
+
margin-right: 2%;
|
280
|
+
}
|
281
|
+
@media screen and (max-width: 480px) {
|
282
|
+
width: 100%;
|
283
|
+
margin-right: none;
|
284
|
+
margin-left: none;
|
285
|
+
}
|
286
|
+
}
|
260
287
|
input[type="submit"] {
|
261
|
-
margin: 0
|
262
|
-
width: 85%;
|
288
|
+
margin: 0;
|
263
289
|
}
|
264
290
|
|
265
291
|
input[type="text"], select {
|
@@ -10,8 +10,12 @@ class Pulitzer::ContentElementsController < Pulitzer::ApplicationController
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def update
|
13
|
-
@content_element
|
14
|
-
|
13
|
+
Update.new(@content_element, content_element_params).call
|
14
|
+
if @content_element.errors.empty?
|
15
|
+
render partial: 'show', locals: { content_element: @content_element }
|
16
|
+
else
|
17
|
+
render partial: 'form', locals: { content_element: @content_element }, status: :conflict
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
def update_all
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Pulitzer
|
2
|
+
class CustomOptionListsController < ApplicationController
|
3
|
+
before_action :get_custom_option_list, except: [:index,:new, :create]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@custom_option_lists = CustomOptionList.all
|
7
|
+
render_ajax
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
@custom_option_list = CustomOptionList.new(custom_option_list_params)
|
12
|
+
render_ajax locals: { custom_option_list: @custom_option_list }
|
13
|
+
end
|
14
|
+
|
15
|
+
def edit
|
16
|
+
render_ajax locals: { custom_option_list: @custom_option_list }
|
17
|
+
end
|
18
|
+
|
19
|
+
def show
|
20
|
+
render_ajax locals: { custom_option_list: @custom_option_list }
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
@custom_option_list = CustomOptionList.new(custom_option_list_params)
|
25
|
+
if @custom_option_list.save
|
26
|
+
render partial: 'show_wrapper', locals: { custom_option_list: @custom_option_list }
|
27
|
+
else
|
28
|
+
render partial: 'new', locals: { custom_option_list: @custom_option_list }, status: 409
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
if @custom_option_list.update_attributes(custom_option_list_params)
|
34
|
+
render partial: 'show', locals: { custom_option_list: @custom_option_list }
|
35
|
+
else
|
36
|
+
render partial: 'edit', locals: { custom_option_list: @custom_option_list }, status: 409
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
@custom_option_list.destroy
|
42
|
+
head :ok
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def custom_option_list_params
|
48
|
+
params[:custom_option_list].permit!
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_custom_option_list
|
52
|
+
@custom_option_list = CustomOptionList.find(params[:id])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Pulitzer
|
2
|
+
class CustomOptionsController < ApplicationController
|
3
|
+
before_action :get_custom_option, except: [:index, :new, :create]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@custom_options = CustomOption.all
|
7
|
+
render_ajax
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
@custom_option = CustomOption.new(custom_option_params)
|
12
|
+
render_ajax locals: { custom_option: @custom_option }
|
13
|
+
end
|
14
|
+
|
15
|
+
def edit
|
16
|
+
render_ajax locals: { custom_option: @custom_option }
|
17
|
+
end
|
18
|
+
|
19
|
+
def show
|
20
|
+
render_ajax locals: { custom_option: @custom_option }
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
@custom_option = CustomOption.new(custom_option_params)
|
25
|
+
if @custom_option.save
|
26
|
+
render partial: 'show_wrapper', locals: { custom_option: @custom_option }
|
27
|
+
else
|
28
|
+
render partial: 'new', locals: { custom_option: @custom_option }, status: 409
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
if @custom_option.update_attributes(custom_option_params)
|
34
|
+
render partial: 'show', locals: { custom_option: @custom_option }
|
35
|
+
else
|
36
|
+
render partial: 'edit', locals: { custom_option: @custom_option }, status: 409
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
@custom_option.destroy
|
42
|
+
head :ok
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def custom_option_params
|
48
|
+
params[:custom_option].permit!
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_custom_option
|
52
|
+
@custom_option = CustomOption.find(params[:id])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -28,17 +28,6 @@ class Pulitzer::PartialTypesController < Pulitzer::ApplicationController
|
|
28
28
|
render partial: 'show', locals: { partial_type: @partial_type }
|
29
29
|
end
|
30
30
|
|
31
|
-
def edit
|
32
|
-
render partial: 'form', locals: { partial_type: @partial_type }
|
33
|
-
end
|
34
|
-
|
35
|
-
def update
|
36
|
-
old_label = @partial_type.label
|
37
|
-
@partial_type.update_attributes(partial_type_params)
|
38
|
-
Pulitzer::UpdateFreeFormSectionPartials.new(@partial_type, old_label).call
|
39
|
-
render partial: 'show', locals: { partial_type: @partial_type }
|
40
|
-
end
|
41
|
-
|
42
31
|
def destroy
|
43
32
|
Pulitzer::DestroyFreeFormSectionPartials.new(@partial_type).call
|
44
33
|
@partial_type.destroy
|
@@ -6,11 +6,12 @@ class Pulitzer::PostsController < Pulitzer::ApplicationController
|
|
6
6
|
def index
|
7
7
|
@post_type = Pulitzer::PostType.find params[:post_type_id]
|
8
8
|
@posts = Pulitzer::Post.where(post_type: @post_type).order(id: :desc)
|
9
|
+
render_ajax
|
9
10
|
end
|
10
11
|
|
11
12
|
def new
|
12
13
|
@post = Pulitzer::Post.new(post_type_id: params[:post_type_id])
|
13
|
-
|
14
|
+
render_ajax locals: { post: @post }
|
14
15
|
end
|
15
16
|
|
16
17
|
def create
|
@@ -20,17 +21,15 @@ class Pulitzer::PostsController < Pulitzer::ApplicationController
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def show
|
23
|
-
|
24
|
+
render_ajax locals: { post: @post }
|
24
25
|
end
|
25
26
|
|
26
27
|
def edit
|
27
|
-
|
28
|
-
render partial: 'edit', locals: { post: @post }
|
29
|
-
end
|
28
|
+
render_ajax locals: { post: @post }
|
30
29
|
end
|
31
30
|
|
32
31
|
def edit_title
|
33
|
-
|
32
|
+
render partial: 'form', locals: { post: @post }
|
34
33
|
end
|
35
34
|
|
36
35
|
def update
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Pulitzer::StylesController < Pulitzer::ApplicationController
|
2
|
+
before_action :get_style, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
def index
|
5
|
+
@ptcet = Pulitzer::PostTypeContentElementType.find(params[:post_type_content_element_type_id])
|
6
|
+
render partial: 'index', locals: { ptcet: @ptcet }
|
7
|
+
end
|
8
|
+
|
9
|
+
def new
|
10
|
+
@style = Pulitzer::Style.new(style_params)
|
11
|
+
render partial: 'new', locals: { ptcet: @ptcet, style: @style }
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@style = Pulitzer::Style.create(style_params)
|
16
|
+
if @style.errors.empty?
|
17
|
+
render partial: 'show_wrapper', locals: { style: @style }
|
18
|
+
else
|
19
|
+
render partial: 'new', locals: { style: @style }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def show
|
24
|
+
render partial: 'show', locals: { style: @style }
|
25
|
+
end
|
26
|
+
|
27
|
+
def destroy
|
28
|
+
@style.destroy
|
29
|
+
head :ok
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def get_style
|
35
|
+
@style = Pulitzer::Style.find(params[:id])
|
36
|
+
end
|
37
|
+
|
38
|
+
def style_params
|
39
|
+
params[:style].permit!
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -3,17 +3,17 @@ module Pulitzer
|
|
3
3
|
|
4
4
|
def link_to_posts(post_type, plural_label, singular_label)
|
5
5
|
if post_type.plural?
|
6
|
-
|
6
|
+
ajax_link plural_label, posts_path(post_type_id: post_type.id), {}, '[data-tab-id="templates"]'
|
7
7
|
else
|
8
|
-
|
8
|
+
ajax_link singular_label, edit_post_path(post_type.singleton_post), {}, '[data-tab-id="templates"]'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def link_back_to_posts(post_type, plural_label, singular_label)
|
13
13
|
if post_type.plural?
|
14
|
-
|
14
|
+
ajax_link plural_label, pulitzer.posts_path(post_type_id: post_type.id), {}, '[data-tab-id="templates"]'
|
15
15
|
else
|
16
|
-
|
16
|
+
ajax_link singular_label, pulitzer.post_types_path, {}, '[data-tab-id="templates"]'
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -21,11 +21,22 @@ module Pulitzer
|
|
21
21
|
content_tag(:iframe, nil, src: element.video_link) if element.video_link
|
22
22
|
end
|
23
23
|
|
24
|
+
def render_clickable(element)
|
25
|
+
content_tag(:span, 'clickabe text: '.html_safe, class: 'pulitzer-span heading') +
|
26
|
+
content_tag(:span, element.title, class: 'pulitzer-span margin') +
|
27
|
+
content_tag(:span, 'action: '.html_safe, class: 'pulitzer-span heading') +
|
28
|
+
content_tag(:span, element.content_display, class: 'pulitzer-span margin') +
|
29
|
+
content_tag(:span, 'style: '.html_safe, class: 'pulitzer-span heading') +
|
30
|
+
content_tag(:span, element.style_display, class: 'pulitzer-span margin')
|
31
|
+
end
|
32
|
+
|
24
33
|
def render_element(element)
|
25
34
|
if element.image_type?
|
26
35
|
image_tag(element.image_url(:thumb)) if element.image?
|
27
36
|
elsif element.video_type?
|
28
37
|
render_video(element)
|
38
|
+
elsif element.clickable_type?
|
39
|
+
render_clickable(element)
|
29
40
|
else
|
30
41
|
element.body.html_safe if element.body
|
31
42
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Pulitzer::ContentElementsController::Update
|
2
|
+
|
3
|
+
def initialize(content_element, params)
|
4
|
+
@content_element, @params = content_element, params.to_h.to_hash.symbolize_keys
|
5
|
+
end
|
6
|
+
|
7
|
+
def call
|
8
|
+
prune_params
|
9
|
+
@content_element.update @params
|
10
|
+
end
|
11
|
+
|
12
|
+
def prune_params
|
13
|
+
clickable_kind = @params.delete :clickable_kind
|
14
|
+
custom_option_list = GlobalID::Locator.locate(clickable_kind)
|
15
|
+
if custom_option_list.present?
|
16
|
+
@params[:body] = nil
|
17
|
+
else
|
18
|
+
@params[:custom_option_id] = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,14 +1,18 @@
|
|
1
1
|
module Pulitzer
|
2
2
|
class ContentElement < ActiveRecord::Base
|
3
3
|
mount_uploader :image, Pulitzer::ImageUploader
|
4
|
-
enum kind: [ :template, :free_form ]
|
5
4
|
|
6
5
|
# Associations
|
7
6
|
belongs_to :version
|
8
7
|
belongs_to :content_element_type
|
9
8
|
belongs_to :post_type_content_element_type
|
10
|
-
|
11
|
-
|
9
|
+
belongs_to :style
|
10
|
+
belongs_to :custom_option
|
11
|
+
|
12
|
+
delegate :type, :text_type?, :image_type?, :video_type?, :clickable_type?, to: :content_element_type
|
13
|
+
delegate :required?, :sort_order, :custom_option_list, :custom_options, :any_clickable_kind?,
|
14
|
+
:url_clickable_kind?, :clickable_kinds, :custom_clickable_kinds,
|
15
|
+
to: :post_type_content_element_type, allow_nil: true
|
12
16
|
delegate :post, to: :version
|
13
17
|
|
14
18
|
attr_accessor :version_unavailable, :ensure_unique
|
@@ -21,7 +25,6 @@ module Pulitzer
|
|
21
25
|
|
22
26
|
# Scopes
|
23
27
|
default_scope { order(id: :asc) }
|
24
|
-
scope :free_form, -> { where(kind: kinds[:free_form]).reorder(sort_order: :asc) }
|
25
28
|
scope :required, -> { joins(:post_type_content_element_type).where(pulitzer_post_type_content_element_types: { required: true}) }
|
26
29
|
|
27
30
|
# def reprocess_versions
|
@@ -44,11 +47,63 @@ module Pulitzer
|
|
44
47
|
end
|
45
48
|
|
46
49
|
def empty_body?
|
47
|
-
|
50
|
+
!has_content?
|
48
51
|
end
|
49
52
|
|
50
53
|
def has_content?
|
51
|
-
image_type?
|
54
|
+
if image_type?
|
55
|
+
image?
|
56
|
+
elsif custom_type?
|
57
|
+
custom_content.present?
|
58
|
+
else
|
59
|
+
body.present?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def custom_content
|
64
|
+
custom_option.value
|
65
|
+
end
|
66
|
+
|
67
|
+
def custom_display
|
68
|
+
"#{custom_option.display} #{custom_option.custom_option_list.name.singularize}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def content
|
72
|
+
if custom_type?
|
73
|
+
custom_content
|
74
|
+
else
|
75
|
+
body
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def content_display
|
80
|
+
if custom_type?
|
81
|
+
custom_display
|
82
|
+
else
|
83
|
+
body
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def custom_type?
|
88
|
+
custom_option.present?
|
89
|
+
end
|
90
|
+
|
91
|
+
def clickable_kind
|
92
|
+
if custom_type?
|
93
|
+
custom_option.custom_option_list
|
94
|
+
elsif body.present?
|
95
|
+
Pulitzer::PostTypeContentElementType.url_clickable
|
96
|
+
else
|
97
|
+
Pulitzer::PostTypeContentElementType.any_clickable
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def style_options
|
102
|
+
post_type_content_element_type.styles
|
103
|
+
end
|
104
|
+
|
105
|
+
def style_display
|
106
|
+
style.display_name
|
52
107
|
end
|
53
108
|
|
54
109
|
def clone_me
|
@@ -97,8 +152,8 @@ private
|
|
97
152
|
end
|
98
153
|
|
99
154
|
def handle_sort_order
|
100
|
-
if new_record? && sort_order.nil? &&
|
101
|
-
self.sort_order = version.
|
155
|
+
if new_record? && sort_order.nil? && version.present?
|
156
|
+
self.sort_order = version.content_elements.maximum(:sort_order).to_i + 1
|
102
157
|
end
|
103
158
|
end
|
104
159
|
|