pulitzer 0.14.4 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/pulitzer/arrangement_styles_controller.rb +1 -3
  3. data/app/controllers/pulitzer/background_styles_controller.rb +1 -3
  4. data/app/controllers/pulitzer/free_form_section_types_controller.rb +4 -4
  5. data/app/controllers/pulitzer/justification_styles_controller.rb +1 -3
  6. data/app/controllers/pulitzer/partial_types_controller.rb +0 -1
  7. data/app/controllers/pulitzer/post_type_content_element_types_controller.rb +4 -4
  8. data/app/controllers/pulitzer/post_type_versions_controller.rb +54 -0
  9. data/app/controllers/pulitzer/post_types_controller.rb +1 -5
  10. data/app/controllers/pulitzer/posts_controller.rb +3 -3
  11. data/app/controllers/pulitzer/sequence_flow_styles_controller.rb +1 -3
  12. data/app/controllers/pulitzer/versions_controller.rb +8 -2
  13. data/app/helpers/pulitzer/posts_helper.rb +7 -7
  14. data/app/interactions/pulitzer/create_free_form_section_partials.rb +2 -2
  15. data/app/interactions/pulitzer/create_post_type_content_elements.rb +3 -3
  16. data/app/interactions/pulitzer/create_post_type_free_form_sections.rb +3 -3
  17. data/app/interactions/pulitzer/create_singleton_post.rb +6 -6
  18. data/app/interactions/pulitzer/destroy_post_type_content_elements.rb +3 -3
  19. data/app/interactions/pulitzer/destroy_post_type_free_form_sections.rb +3 -3
  20. data/app/interactions/pulitzer/post_type_versions_controller/change_state.rb +15 -0
  21. data/app/interactions/pulitzer/post_type_versions_controller/create.rb +18 -0
  22. data/app/interactions/pulitzer/post_types_controller/create_singleton_post.rb +15 -0
  23. data/app/interactions/pulitzer/post_types_controller/create_template_version.rb +12 -0
  24. data/app/interactions/pulitzer/update_post_type_content_elements.rb +4 -4
  25. data/app/interactions/pulitzer/update_post_type_free_form_sections.rb +3 -3
  26. data/app/interactions/pulitzer/update_singleton_post.rb +6 -4
  27. data/app/models/pulitzer/arrangement_style.rb +1 -1
  28. data/app/models/pulitzer/background_style.rb +1 -1
  29. data/app/models/pulitzer/free_form_section_type.rb +1 -1
  30. data/app/models/pulitzer/justification_style.rb +1 -1
  31. data/app/models/pulitzer/partial.rb +8 -3
  32. data/app/models/pulitzer/post.rb +10 -2
  33. data/app/models/pulitzer/post_type.rb +10 -39
  34. data/app/models/pulitzer/post_type_content_element_type.rb +1 -1
  35. data/app/models/pulitzer/post_type_element.rb +1 -1
  36. data/app/models/pulitzer/post_type_version.rb +84 -0
  37. data/app/models/pulitzer/sequence_flow_style.rb +1 -1
  38. data/app/services/pulitzer/post_type_version/preview.rb +30 -0
  39. data/app/services/pulitzer/post_type_version/publish.rb +38 -0
  40. data/app/services/pulitzer/post_type_version/retire.rb +20 -0
  41. data/app/views/pulitzer/arrangement_styles/_new.html.erb +3 -3
  42. data/app/views/pulitzer/arrangement_styles/_show.html.erb +10 -6
  43. data/app/views/pulitzer/background_styles/_new.html.erb +3 -3
  44. data/app/views/pulitzer/background_styles/_show.html.erb +10 -6
  45. data/app/views/pulitzer/free_form_section_types/_new.html.erb +3 -3
  46. data/app/views/pulitzer/justification_styles/_new.html.erb +3 -3
  47. data/app/views/pulitzer/justification_styles/_show.html.erb +10 -6
  48. data/app/views/pulitzer/partials/_new.html.erb +8 -8
  49. data/app/views/pulitzer/post_type_content_element_types/_form.html.erb +0 -2
  50. data/app/views/pulitzer/post_type_content_element_types/_form_fields.html.erb +2 -2
  51. data/app/views/pulitzer/post_type_content_element_types/_new.html.erb +2 -2
  52. data/app/views/pulitzer/post_type_content_element_types/_show.html.erb +6 -2
  53. data/app/views/pulitzer/post_type_versions/_index.html.erb +15 -0
  54. data/app/views/pulitzer/post_type_versions/_show.html.erb +20 -0
  55. data/app/views/pulitzer/post_type_versions/_show_wrapper.html.erb +3 -0
  56. data/app/views/pulitzer/{post_types → post_type_versions}/_template.html.erb +34 -34
  57. data/app/views/pulitzer/post_types/_show.html.erb +3 -9
  58. data/app/views/pulitzer/post_types/index.html.erb +13 -10
  59. data/app/views/pulitzer/posts/_breadcrumbs.html.erb +4 -0
  60. data/app/views/pulitzer/posts/_edit.html.erb +5 -4
  61. data/app/views/pulitzer/posts/_index.html.erb +3 -3
  62. data/app/views/pulitzer/posts/_new.html.erb +1 -1
  63. data/app/views/pulitzer/posts/_show.html.erb +1 -1
  64. data/app/views/pulitzer/posts/_show_slug.html.erb +1 -1
  65. data/app/views/pulitzer/sequence_flow_styles/_new.html.erb +3 -3
  66. data/app/views/pulitzer/sequence_flow_styles/_show.html.erb +10 -6
  67. data/config/routes.rb +6 -4
  68. data/db/migrate/20170515230633_create_post_type_version.rb +9 -0
  69. data/db/migrate/20170515232938_reconnect_post_type_to_post.rb +13 -0
  70. data/lib/generators/pulitzer/post_type_generator.rb +24 -4
  71. data/lib/pulitzer.rb +1 -0
  72. data/lib/pulitzer/controller_helpers.rb +9 -0
  73. data/lib/pulitzer/version.rb +1 -1
  74. metadata +19 -4
  75. data/app/interactions/pulitzer/destroy_free_form_section_partials.rb +0 -17
@@ -0,0 +1,4 @@
1
+ <%= ajax_link "all #{post_type.kind.pluralize} >", post_types_path(post_type_kind: post_type.kind), {}, '[data-tab-id="' + post_type.kind.pluralize + '"]' %>
2
+ <% if Pulitzer.skip_metadata_auth? || self.instance_eval(&Pulitzer.metadata_closure) %>
3
+ <%= ajax_link "template versions for #{post_type.name} >", post_type_versions_path(post_type_id: post_type.id), {}, '[data-tab-id="' + post_type.kind.pluralize + '"]' %>
4
+ <% end %>
@@ -1,7 +1,8 @@
1
- <h1>Editing <%= post.title %></h1>
2
- <div class="pulitzer-row margin-bottom list-item">
3
- <%= link_back_to_posts(post.post_type, "Back to #{post.post_type.name.singularize} Posts", 'Back to post types') %>
4
- </div>
1
+ <%= render partial: '/pulitzer/posts/breadcrumbs', locals: {post_type: post.post_type} %>
2
+ <% if post.plural? %>
3
+ <%= ajax_link "#{post.post_type.name.singularize} Posts >", pulitzer.posts_path(post_type_version_id: post.post_type_version_id), {}, '[data-tab-id="templates"]' %>
4
+ <% end %>
5
+ <h1>Editing <%= post.editor_title %></h1>
5
6
 
6
7
  <div id="<%= dom_id(post, :preview_version)%>">
7
8
  </div>
@@ -1,9 +1,9 @@
1
- <h1><%= @post_type.name.singularize %> Post</h1>
1
+ <%= render partial: '/pulitzer/posts/breadcrumbs', locals: {post_type: @post_type_version.post_type} %>
2
+ <h1><%= @post_type_version.name.singularize %> Post</h1>
2
3
 
3
4
  <div class="pulitzer-row margin-bottom list-item">
4
- <%= link_to "Back to post types", post_types_path %>
5
5
  <br>
6
- <%= ajax_link "Add a new #{@post_type.name.singularize} Post", new_post_path(post_type_id: params[:post_type_id]), {}, '#new_post' %>
6
+ <%= ajax_link "Add a new #{@post_type_version.name.singularize} Post", new_post_path(post_type_version_id: params[:post_type_version_id]), {}, '#new_post' %>
7
7
  <div id="new_post"></div>
8
8
  </div>
9
9
 
@@ -1,7 +1,7 @@
1
1
  <%= form_for post, html: ajax_form_hash('#posts_container', insert_method: 'prepend', sub_class: "AddALineForm", container: '#new_post') do |f| %>
2
2
  <%= f.label :title %>
3
3
  <%= f.text_field :title %>
4
- <%= f.hidden_field :post_type_id %>
4
+ <%= f.hidden_field :post_type_version_id %>
5
5
  <%= f.submit %>
6
6
  <%= link_to('Cancel', '#', :class => 'button',
7
7
  data: { emptier: true, target: '#new_post' } ) %>
@@ -7,7 +7,7 @@
7
7
  <%= ajax_link "Edit post name", edit_title_post_path(post), {}, dom_target(post) %>
8
8
  </li>
9
9
  <li>
10
- <%= link_to 'Edit content', edit_post_path(post) %>
10
+ <%= ajax_link 'Edit content', edit_post_path(post), {}, '[data-tab-id="templates"]' %>
11
11
  </li>
12
12
  </ul>
13
13
  </div>
@@ -1,7 +1,7 @@
1
1
  <div class="pulitzer-row">
2
2
  <ul class="list">
3
3
  <li><%= post.slug %></li>
4
- <% unless post.post_type.singleton_post? %>
4
+ <% unless post.post_type_version.singleton_post? %>
5
5
  <li><%= ajax_link "Edit", edit_slug_post_path(post, version_id: version), {}, dom_target(post) %></li>
6
6
  <% end %>
7
7
  </ul>
@@ -1,12 +1,12 @@
1
1
  <div class="pulitzer-row">
2
- <%= form_for sequence_flow_style, html: ajax_form_hash(dom_target(sequence_flow_style.post_type, :sequence_flow_styles_container), insert_method: 'append', reset_on_success: true) do |f| %>
3
- <%= f.hidden_field :post_type_id %>
2
+ <%= form_for sequence_flow_style, html: ajax_form_hash(dom_target(sequence_flow_style.post_type_version, :sequence_flow_styles_container), insert_method: 'append', reset_on_success: true) do |f| %>
3
+ <%= f.hidden_field :post_type_version_id %>
4
4
  <%= render partial: 'form_fields', locals: { f: f, sequence_flow_style: sequence_flow_style } %>
5
5
  <div class="pulitzer-span ten-percent">
6
6
  <%= f.submit "Create", data: {disable_with: false} %>
7
7
  </div>
8
8
  <div class="pulitzer-span ten-percent">
9
- <a class="button" data-emptier="true" data-target="<%= dom_target(sequence_flow_style.post_type, :new_sequence_flow_style) %>">Close</a>
9
+ <a class="button" data-emptier="true" data-target="<%= dom_target(sequence_flow_style.post_type_version, :new_sequence_flow_style) %>">Close</a>
10
10
  </div>
11
11
  <% end %>
12
12
  </div>
@@ -1,10 +1,14 @@
1
1
  <div class="pulitzer-row">
2
2
  <div class="pulitzer-span one-fifth"><%= sequence_flow_style.display_name %></div>
3
3
  <div class="pulitzer-span one-fifth"><%= sequence_flow_style.css_class_name %></div>
4
- <div class="pulitzer-span ten-percent">
5
- <%= ajax_link "Edit", edit_sequence_flow_style_path(sequence_flow_style), {}, dom_target(sequence_flow_style) %>
6
- </div>
7
- <div class="pulitzer-span ten-percent">
8
- <%= ajax_delete 'Delete', sequence_flow_style_path(sequence_flow_style), {}, dom_target(sequence_flow_style) %>
9
- </div>
4
+ <% if sequence_flow_style.post_type_version.locked? %>
5
+ <div class="pulitzer-span one-fifth">live</div>
6
+ <% else %>
7
+ <div class="pulitzer-span ten-percent">
8
+ <%= ajax_link "Edit", edit_sequence_flow_style_path(sequence_flow_style), {}, dom_target(sequence_flow_style) %>
9
+ </div>
10
+ <div class="pulitzer-span ten-percent">
11
+ <%= ajax_delete 'Delete', sequence_flow_style_path(sequence_flow_style), {}, dom_target(sequence_flow_style) %>
12
+ </div>
13
+ <% end %>
10
14
  </div>
data/config/routes.rb CHANGED
@@ -19,15 +19,17 @@ Pulitzer::Engine.routes.draw do
19
19
  end
20
20
 
21
21
  resources :tags
22
- resources :custom_option_lists
23
- resources :custom_options
24
-
25
- resources :post_types do
22
+ resources :post_types
23
+ resources :post_type_versions do
26
24
  member do
27
25
  get :template
26
+ patch :change_state
28
27
  end
29
28
  end
30
29
 
30
+ resources :custom_option_lists
31
+ resources :custom_options
32
+
31
33
  resources :versions
32
34
  resources :content_element_types
33
35
  resources :post_type_content_element_types
@@ -0,0 +1,9 @@
1
+ class CreatePostTypeVersion < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :pulitzer_post_type_versions do |t|
4
+ t.references :pulitzer_post_type, index: true
5
+ t.integer :version_number, default: 1, null: false
6
+ t.string :status, default: 'preview', null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class ReconnectPostTypeToPost < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :pulitzer_posts, :post_type_version_id, :integer
4
+ Pulitzer::Post.reset_column_information
5
+ Pulitzer::PostType.all.each do |pt|
6
+ ptv = pt.published_type_version
7
+ ptv ||= pt.post_type_versions.create(status: 'active')
8
+ Pulitzer::Post.where(post_type_id: pt.id).update_all post_type_version_id: ptv.id
9
+ end
10
+ remove_column :pulitzer_posts, :post_type_id
11
+ add_index :pulitzer_posts, :post_type_version_id
12
+ end
13
+ end
@@ -74,6 +74,11 @@ module Pulitzer
74
74
  empty_directory partial_path
75
75
  layouts.each do |layout_name|
76
76
  copy_file "post_view.html.erb", layout_path(layout_name)
77
+ inject_into_file layout_path(layout_name), before: "<%# END Auto-generated by Pulitzer %>", force: false do
78
+ <<-BEGIN_COMMENT
79
+ <!-- BEGIN #{layout_short_path} -->
80
+ BEGIN_COMMENT
81
+ end
77
82
  content_element_names.each do |content_element_name|
78
83
  inject_into_file layout_path(layout_name), before: "<%# END Auto-generated by Pulitzer %>", force: false do
79
84
  <<-VIEW
@@ -82,6 +87,11 @@ module Pulitzer
82
87
  VIEW
83
88
  end
84
89
  end
90
+ inject_into_file layout_path(layout_name), before: "<%# END Auto-generated by Pulitzer %>", force: false do
91
+ <<-BEGIN_COMMENT
92
+ <!-- END #{layout_short_path} -->
93
+ BEGIN_COMMENT
94
+ end
85
95
  end
86
96
  end
87
97
 
@@ -97,6 +107,10 @@ module Pulitzer
97
107
  File.join(Rails.root,'app','views', Pulitzer.public_controller, "#{action_name}.html.erb")
98
108
  end
99
109
 
110
+ def layout_short_path(layout_name)
111
+ File.join(action_name, "_#{layout_name}.html.erb")
112
+ end
113
+
100
114
  def layout_path(layout_name)
101
115
  File.join(Rails.root,'app','views', Pulitzer.partial_folder, action_name, "_#{layout_name}.html.erb")
102
116
  end
@@ -163,19 +177,25 @@ module Pulitzer
163
177
  end
164
178
 
165
179
  def plural_action(context)
166
- <<-CACTION
180
+ <<-PACTION
167
181
 
168
182
  def #{action_name}
169
- @post = Pulitzer::PostType.named('#{post_type_name}').posts.find_by!(slug: params[:slug]).get_#{context}_version!
183
+ @post_type_version = Pulitzer::PostType.named('#{post_type_name}').published_type_version
184
+ version_number = @post_type_version.version_number
185
+ @post = @post_type_version.posts.find_by!(slug: params[:slug]).get_#{context}_version!
186
+ render template: pulitzer_view_path(version_number)
170
187
  end
171
- CACTION
188
+ PACTION
172
189
  end
173
190
 
174
191
  def singleton_action(context)
175
192
  <<-CACTION
176
193
 
177
194
  def #{action_name}
178
- @post = Pulitzer::PostType.named('#{post_type_name}').singleton_post.get_#{context}_version!
195
+ @post_type_version = Pulitzer::PostType.named('#{post_type_name}').published_type_version
196
+ version_number = @post_type_version.version_number
197
+ @post = @post_type_version.singleton_post.get_#{context}_version!
198
+ render template: pulitzer_view_path(version_number)
179
199
  end
180
200
  CACTION
181
201
  end
data/lib/pulitzer.rb CHANGED
@@ -6,6 +6,7 @@ require 'friendly_id'
6
6
  require 'select2-rails'
7
7
  require 'pulitzer/engine'
8
8
  require 'pulitzer/exceptions'
9
+ require 'pulitzer/controller_helpers'
9
10
 
10
11
  module Pulitzer
11
12
  mattr_accessor :base_controller, :metadata_closure, :authentication_closure, :unpublish_authorization,
@@ -0,0 +1,9 @@
1
+ module Pulitzer
2
+ module ControllerHelpers
3
+ def pulitzer_view_path(version_number)
4
+ File.join Pulitzer.public_controller,
5
+ action_name,
6
+ "v_#{version_number.to_s}.html.erb"
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Pulitzer
2
- VERSION = '0.14.4'
2
+ VERSION = '0.15.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulitzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-06-05 00:00:00.000000000 Z
12
+ date: 2017-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -511,6 +511,7 @@ files:
511
511
  - app/controllers/pulitzer/partials_controller.rb
512
512
  - app/controllers/pulitzer/post_tags_controller.rb
513
513
  - app/controllers/pulitzer/post_type_content_element_types_controller.rb
514
+ - app/controllers/pulitzer/post_type_versions_controller.rb
514
515
  - app/controllers/pulitzer/post_types_controller.rb
515
516
  - app/controllers/pulitzer/posts_controller.rb
516
517
  - app/controllers/pulitzer/sequence_flow_styles_controller.rb
@@ -528,9 +529,12 @@ files:
528
529
  - app/interactions/pulitzer/create_post_type_content_elements.rb
529
530
  - app/interactions/pulitzer/create_post_type_free_form_sections.rb
530
531
  - app/interactions/pulitzer/create_singleton_post.rb
531
- - app/interactions/pulitzer/destroy_free_form_section_partials.rb
532
532
  - app/interactions/pulitzer/destroy_post_type_content_elements.rb
533
533
  - app/interactions/pulitzer/destroy_post_type_free_form_sections.rb
534
+ - app/interactions/pulitzer/post_type_versions_controller/change_state.rb
535
+ - app/interactions/pulitzer/post_type_versions_controller/create.rb
536
+ - app/interactions/pulitzer/post_types_controller/create_singleton_post.rb
537
+ - app/interactions/pulitzer/post_types_controller/create_template_version.rb
534
538
  - app/interactions/pulitzer/update_content_element.rb
535
539
  - app/interactions/pulitzer/update_post_type_content_elements.rb
536
540
  - app/interactions/pulitzer/update_post_type_free_form_sections.rb
@@ -554,10 +558,14 @@ files:
554
558
  - app/models/pulitzer/post_type.rb
555
559
  - app/models/pulitzer/post_type_content_element_type.rb
556
560
  - app/models/pulitzer/post_type_element.rb
561
+ - app/models/pulitzer/post_type_version.rb
557
562
  - app/models/pulitzer/sequence_flow_style.rb
558
563
  - app/models/pulitzer/style.rb
559
564
  - app/models/pulitzer/tag.rb
560
565
  - app/models/pulitzer/version.rb
566
+ - app/services/pulitzer/post_type_version/preview.rb
567
+ - app/services/pulitzer/post_type_version/publish.rb
568
+ - app/services/pulitzer/post_type_version/retire.rb
561
569
  - app/uploaders/pulitzer/base_uploader.rb
562
570
  - app/uploaders/pulitzer/image_uploader.rb
563
571
  - app/validators/pulitzer/content_element_validator.rb
@@ -622,14 +630,18 @@ files:
622
630
  - app/views/pulitzer/post_type_content_element_types/_new.html.erb
623
631
  - app/views/pulitzer/post_type_content_element_types/_show.html.erb
624
632
  - app/views/pulitzer/post_type_content_element_types/_show_wrapper.html.erb
633
+ - app/views/pulitzer/post_type_versions/_index.html.erb
634
+ - app/views/pulitzer/post_type_versions/_show.html.erb
635
+ - app/views/pulitzer/post_type_versions/_show_wrapper.html.erb
636
+ - app/views/pulitzer/post_type_versions/_template.html.erb
625
637
  - app/views/pulitzer/post_types/_form.html.erb
626
638
  - app/views/pulitzer/post_types/_form_fields.html.erb
627
639
  - app/views/pulitzer/post_types/_index.html.erb
628
640
  - app/views/pulitzer/post_types/_new.html.erb
629
641
  - app/views/pulitzer/post_types/_show.html.erb
630
642
  - app/views/pulitzer/post_types/_show_wrapper.html.erb
631
- - app/views/pulitzer/post_types/_template.html.erb
632
643
  - app/views/pulitzer/post_types/index.html.erb
644
+ - app/views/pulitzer/posts/_breadcrumbs.html.erb
633
645
  - app/views/pulitzer/posts/_edit.html.erb
634
646
  - app/views/pulitzer/posts/_form.html.erb
635
647
  - app/views/pulitzer/posts/_form_slug.html.erb
@@ -695,6 +707,8 @@ files:
695
707
  - db/migrate/20160927160910_add_required_to_pulitzer_post_type_content_element_type.rb
696
708
  - db/migrate/20170502210827_add_sort_to_post_elements.rb
697
709
  - db/migrate/20170508145431_create_pulitzer_partial_types.rb
710
+ - db/migrate/20170515230633_create_post_type_version.rb
711
+ - db/migrate/20170515232938_reconnect_post_type_to_post.rb
698
712
  - db/migrate/20170518142411_create_pulitzer_background_classes.rb
699
713
  - db/migrate/20170518144418_create_pulitzer_justification_classes.rb
700
714
  - db/migrate/20170518144449_create_pulitzer_sequence_flow_classes.rb
@@ -711,6 +725,7 @@ files:
711
725
  - lib/generators/pulitzer/templates/post_view.html.erb
712
726
  - lib/pulitzer.rb
713
727
  - lib/pulitzer/content_element_helper.rb
728
+ - lib/pulitzer/controller_helpers.rb
714
729
  - lib/pulitzer/engine.rb
715
730
  - lib/pulitzer/exceptions.rb
716
731
  - lib/pulitzer/version.rb
@@ -1,17 +0,0 @@
1
- class Pulitzer::DestroyFreeFormSectionPartials
2
-
3
- def initialize(partial_type)
4
- @partial_type = partial_type
5
- end
6
-
7
- def call
8
- free_form_section_type = @partial_type.free_form_section_type
9
- post_type = free_form_section_type.post_type
10
- post_type.posts.each do |post|
11
- if post.preview_version
12
- free_form_section = post.preview_version.free_form_sections.find_by(name: free_form_section_type.name)
13
- partial = free_form_section.partials.find_by(label: @partial_type.label)&.destroy
14
- end
15
- end
16
- end
17
- end