pulitzer 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/pulitzer.scss +14 -0
  3. data/app/controllers/pulitzer/content_elements_controller.rb +28 -6
  4. data/app/controllers/pulitzer/posts_controller.rb +1 -1
  5. data/app/controllers/pulitzer/versions_controller.rb +1 -1
  6. data/app/interactions/pulitzer/create_post_content_elements.rb +20 -0
  7. data/app/interactions/pulitzer/create_post_type_content_elements.rb +5 -2
  8. data/app/interactions/pulitzer/create_singleton_post.rb +1 -1
  9. data/app/interactions/pulitzer/update_post_type_content_elements.rb +7 -2
  10. data/app/models/pulitzer/content_element.rb +12 -1
  11. data/app/models/pulitzer/post_type.rb +11 -2
  12. data/app/models/pulitzer/post_type_content_element_type.rb +1 -0
  13. data/app/models/pulitzer/version.rb +8 -0
  14. data/app/views/pulitzer/content_elements/_form.html.erb +0 -1
  15. data/app/views/pulitzer/content_elements/_new.html.erb +25 -0
  16. data/app/views/pulitzer/content_elements/_show.html.erb +10 -1
  17. data/app/views/pulitzer/content_elements/index.html.erb +20 -3
  18. data/app/views/pulitzer/post_types/_form.html.erb +2 -7
  19. data/app/views/pulitzer/post_types/_form_fields.html.erb +5 -0
  20. data/app/views/pulitzer/post_types/_new.html.erb +2 -7
  21. data/app/views/pulitzer/post_types/_show.html.erb +5 -3
  22. data/app/views/pulitzer/shared/_drag_handle.html.erb +5 -0
  23. data/config/routes.rb +5 -1
  24. data/db/migrate/20151113183344_add_post_type_content_element_attributes_to_content_elements.rb +21 -0
  25. data/db/migrate/20151116162508_change_template_to_pulitzer_post_types.rb +11 -0
  26. data/db/migrate/20151118031237_add_kind_to_pulitzer_content_elements.rb +5 -0
  27. data/lib/pulitzer/version.rb +1 -1
  28. data/test/dummy/db/development.sqlite3 +0 -0
  29. data/test/dummy/db/migrate/20151113220908_add_post_type_content_element_attributes_to_content_elements.pulitzer.rb +22 -0
  30. data/test/dummy/db/migrate/20151116162913_change_template_to_pulitzer_post_types.pulitzer.rb +12 -0
  31. data/test/dummy/db/migrate/20151118032759_add_kind_to_pulitzer_content_elements.pulitzer.rb +6 -0
  32. data/test/dummy/db/schema.rb +11 -6
  33. data/test/dummy/log/development.log +59506 -0
  34. data/test/dummy/public/uploads/pulitzer/content_element/image/19/pic05.jpeg +0 -0
  35. data/test/dummy/public/uploads/pulitzer/content_element/image/19/thumb_pic05.jpeg +0 -0
  36. data/test/dummy/public/uploads/pulitzer/content_element/image/3/pic05.jpeg +0 -0
  37. data/test/dummy/public/uploads/pulitzer/content_element/image/3/thumb_pic05.jpeg +0 -0
  38. data/test/dummy/public/uploads/pulitzer/content_element/image/9/pic09.jpeg +0 -0
  39. data/test/dummy/public/uploads/pulitzer/content_element/image/9/thumb_pic09.jpeg +0 -0
  40. data/test/dummy/tmp/cache/assets/development/sass/be077259a59c14e0a5302a785899c0b92a0ab91a/pulitzer.scssc +0 -0
  41. data/test/dummy/tmp/cache/assets/development/sprockets/06862801abb8c401568d01a7b3970906 +0 -0
  42. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  43. data/test/dummy/tmp/cache/assets/development/sprockets/16350d0e2f0ffb7c3b31e13f258e3156 +0 -0
  44. data/test/dummy/tmp/cache/assets/development/sprockets/184aa42aaf70a897286717ad9402c2b6 +0 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  46. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  47. data/test/dummy/tmp/cache/assets/development/sprockets/35abf4d57a1db03bc7222f13bb471ed6 +0 -0
  48. data/test/dummy/tmp/cache/assets/development/sprockets/3b7b7eee503242b1d315d26c7b5cddee +0 -0
  49. data/test/dummy/tmp/cache/assets/development/sprockets/3d7cea3aafdb779f3c95b4622ee7fe69 +0 -0
  50. data/test/dummy/tmp/cache/assets/development/sprockets/441051494a96f6dc5a93d5f1de2509a8 +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/6874b7cce999f4e5a651c0057aa61887 +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/716a56329ace76625a8413db5ce5b9bd +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/7b287d7c33e17041f8f5577f59cc9259 +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/832a1e5e324a689cbe7b649c5b62a2a4 +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/8ad2677bfa97184ea04003bbc872d39f +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/94c7ec6491f0f98ab102d34dda6b2923 +0 -0
  57. data/test/dummy/tmp/cache/assets/development/sprockets/ac2cc187578b49d22d5abf2234f78969 +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/ae53ef709d6f5d0222ec079134304c87 +0 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/c96181a2cb6ed1e5bed0c307492314dd +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/c9fb0a1fca85341be25487d4f49c2919 +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/cf69498eaa29a42d5020469d6ca1ae64 +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/d992a7e563789c6fc0b51e4aaa59ce58 +0 -0
  65. data/test/dummy/tmp/cache/assets/development/sprockets/e820891ae5f960b3ff5216476234fbe2 +0 -0
  66. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/fe22c42cc33c405b1fdc1105e0972a77 +0 -0
  68. metadata +63 -3
  69. data/app/interactions/pulitzer/setup_post_elements.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 390dd38dec3f03235c0f3801eb739c41253ac58e
4
- data.tar.gz: d5abe8e354d0d7799ef8f877bee732cf181c0e1e
3
+ metadata.gz: d1a21389d2d52313083f4e7d7ea067ac90ae0dab
4
+ data.tar.gz: 52b6aa62689710bdd817773fdb4384aa18c3d8d7
5
5
  SHA512:
6
- metadata.gz: 13325afd994d30604ee3199fa24a4b4cd417f63379ac50177834b3fbe98d880b1fe1eec3215a7bfb869f1f7543fdaf7a626439297c6080dafbed7450989d551b
7
- data.tar.gz: 7aeabb4cbf40a7c17815d930787870647d00389e0d2d4fbe0ac420d8f05ea593c0d038b3c9a9b435ba3a486989533e0edd1014e2d9a209900fa887284372f589
6
+ metadata.gz: cc2ee6693517dcf76fe0ec32f6f090e5fef6b71bfdeb663bfc68f1078164e5f17856202b2057a9ac276d51be45af18e7d0171c4411104dcd11bb03de1af23b4a
7
+ data.tar.gz: 71c364ad79775cca1f5141bc79a2e0d40eb7c9dad265b77f4173727b1964ae867b7c8223bf6a22373d3bc552defefdb5078170da249c6ce7f5af02fa5cb28c8b
@@ -159,3 +159,17 @@ textarea {
159
159
  .wysihtml5-sandbox {
160
160
  width: 100% !important;
161
161
  }
162
+
163
+ .drag_handle {
164
+ margin-top: 6px;
165
+ width: 12px;
166
+ height: 9px;
167
+ .drag_handle_indent {
168
+ width: 100%;
169
+ height: 2px;
170
+ margin-bottom: 1px;
171
+ background-color: #e6e6e6;
172
+ border-top: 1px solid #636564;
173
+ border-left: 1px solid #636564;
174
+ }
175
+ }
@@ -1,11 +1,24 @@
1
1
  class Pulitzer::ContentElementsController < Pulitzer::ApplicationController
2
- before_filter :get_content_element, only: [:show, :edit, :update]
2
+ before_filter :set_content_element, only: [:show, :edit, :update]
3
3
 
4
4
  def index
5
- @post = Pulitzer::Post.find(params[:post_id])
6
- @content_elements = @post.preview_version.content_elements
7
- route = "pulitzer_preview_#{@post.title.parameterize('_')}_path"
8
- @preview_path = main_app.public_send(route) if main_app.respond_to?(route)
5
+ @post = Pulitzer::Post.find(params[:post_id])
6
+ @content_elements = @post.preview_version.template_content_elements
7
+ @free_form_content_elements = @post.preview_version.free_form_content_elements
8
+ route = "pulitzer_preview_#{@post.title.parameterize('_')}_path"
9
+ @preview_path = main_app.public_send(route) if main_app.respond_to?(route)
10
+ end
11
+
12
+ def new
13
+ @version = Pulitzer::Version.find params[:version_id]
14
+ @content_element = @version.content_elements.build
15
+ render partial: 'new', locals: { content_element: @content_element, version: @version }
16
+ end
17
+
18
+ def create
19
+ @version = Pulitzer::Version.find content_element_params[:version_id]
20
+ @content_element = @version.content_elements.create content_element_params
21
+ render partial: 'show_wrapper', locals: { content_element: @content_element }
9
22
  end
10
23
 
11
24
  def show
@@ -21,13 +34,22 @@ class Pulitzer::ContentElementsController < Pulitzer::ApplicationController
21
34
  render partial: 'show', locals: { content_element: @content_element }
22
35
  end
23
36
 
37
+ def update_all
38
+ content_elements = Pulitzer::ContentElement.find params[:content_element]
39
+ content_elements.each do |ce|
40
+ new_sort_order = params[:content_element].index(ce.id.to_s)
41
+ ce.update_attribute(:sort_order, new_sort_order)
42
+ end
43
+ render nothing: true
44
+ end
45
+
24
46
  protected
25
47
 
26
48
  def content_element_params
27
49
  params[:content_element].permit!
28
50
  end
29
51
 
30
- def get_content_element
52
+ def set_content_element
31
53
  @content_element = Pulitzer::ContentElement.find(params[:id])
32
54
  end
33
55
  end
@@ -13,7 +13,7 @@ class Pulitzer::PostsController < Pulitzer::ApplicationController
13
13
 
14
14
  def create
15
15
  @post = Pulitzer::Post.create(post_params)
16
- Pulitzer::SetupPostElements.new(@post).call if @post
16
+ Pulitzer::CreatePostContentElements.new(@post).call if @post
17
17
  render partial: 'show_wrapper', locals: { post: @post }
18
18
  end
19
19
 
@@ -8,7 +8,7 @@ class Pulitzer::VersionsController < Pulitzer::ApplicationController
8
8
  if @active_version
9
9
  Pulitzer::CloneVersion.new(@active_version, new_version).call
10
10
  else
11
- Pulitzer::SetupPostElements.new(@post).call
11
+ Pulitzer::CreatePostContentElements.new(@post).call
12
12
  end
13
13
  redirect_to post_content_elements_path(@post), notice: "Post #{@status}"
14
14
  end
@@ -0,0 +1,20 @@
1
+ class Pulitzer::CreatePostContentElements
2
+ attr_accessor :post
3
+
4
+ def initialize(post)
5
+ self.post = post
6
+ end
7
+
8
+ def call
9
+ post.post_type_content_element_types.each do |cet|
10
+ post.preview_version.content_elements.create do |ce|
11
+ ce.label = cet.label
12
+ ce.height = cet.height
13
+ ce.width = cet.width
14
+ ce.text_editor = cet.text_editor
15
+ ce.content_element_type = cet.content_element_type
16
+ ce.post_type_content_element_type = cet
17
+ end
18
+ end
19
+ end
20
+ end
@@ -9,8 +9,11 @@ class Pulitzer::CreatePostTypeContentElements
9
9
  def call
10
10
  post_type.posts.each do |post|
11
11
  post.preview_version.content_elements.create do |ce|
12
- ce.label = ptcet.label
13
- ce.content_element_type = ptcet.content_element_type
12
+ ce.label = ptcet.label
13
+ ce.height = ptcet.height
14
+ ce.width = ptcet.width
15
+ ce.text_editor = ptcet.text_editor
16
+ ce.content_element_type = ptcet.content_element_type
14
17
  ce.post_type_content_element_type = ptcet
15
18
  end
16
19
  end
@@ -9,7 +9,7 @@ class Pulitzer::CreateSingletonPost
9
9
  def call
10
10
  if post_type.singular? && !post_type.singleton_post?
11
11
  singleton_post = post_type.posts.create(title: title)
12
- Pulitzer::SetupPostElements.new(singleton_post).call
12
+ Pulitzer::CreatePostContentElements.new(singleton_post).call
13
13
  end
14
14
  end
15
15
  end
@@ -9,8 +9,13 @@ class Pulitzer::UpdatePostTypeContentElements
9
9
 
10
10
  def call
11
11
  post_type.posts.each do |post|
12
- post.preview_version.content_elements.where(label: old_label).each do |ce|
13
- ce.update(label: ptcet.label, content_element_type: ptcet.content_element_type, post_type_content_element_type: ptcet)
12
+ post.preview_version.content_elements.where(label: old_label).each do |content_element|
13
+ content_element.update(label: ptcet.label,
14
+ height: ptcet.height,
15
+ width: ptcet.width,
16
+ text_editor: ptcet.text_editor,
17
+ content_element_type: ptcet.content_element_type,
18
+ post_type_content_element_type: ptcet)
14
19
  end
15
20
  end
16
21
  end
@@ -1,13 +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
  belongs_to :version
5
7
  belongs_to :content_element_type
6
8
  belongs_to :post_type_content_element_type
7
9
  delegate :type, :text_type?, :image_type?, :video_type?, to: :content_element_type
8
- delegate :height, :width, :text_editor, to: :post_type_content_element_type
9
10
  delegate :post, to: :version
11
+
12
+ before_save :handle_sort_order
13
+
10
14
  default_scope { order(id: :asc) }
15
+ scope :free_form, -> { unscoped.where(kind: kinds[:free_form]).order(sort_order: :asc) }
11
16
 
12
17
  def video_link
13
18
  if video_type? && !body.nil?
@@ -36,5 +41,11 @@ private
36
41
  end
37
42
  end
38
43
 
44
+ def handle_sort_order
45
+ if new_record? && sort_order.nil? && free_form?
46
+ self.sort_order = version.free_form_content_elements.maximum(:sort_order).to_i + 1
47
+ end
48
+ end
49
+
39
50
  end
40
51
  end
@@ -1,10 +1,15 @@
1
1
  class Pulitzer::PostType < ActiveRecord::Base
2
+ enum kind: [ :template, :free_form, :hybrid ]
2
3
  has_many :posts, dependent: :destroy
3
4
  has_many :post_type_content_element_types, dependent: :destroy
4
5
  has_many :content_element_types, through: :post_type_content_element_types
5
6
 
6
7
  validates :name, presence: true
7
8
 
9
+ def self.named(label)
10
+ self.find_by(name: label)
11
+ end
12
+
8
13
  def singular?
9
14
  !plural
10
15
  end
@@ -17,7 +22,11 @@ class Pulitzer::PostType < ActiveRecord::Base
17
22
  !!singleton_post
18
23
  end
19
24
 
20
- def self.named(label)
21
- self.find_by(name: label)
25
+ def allow_template?
26
+ template? || hybrid?
27
+ end
28
+
29
+ def allow_free_form?
30
+ free_form? || hybrid?
22
31
  end
23
32
  end
@@ -2,6 +2,7 @@ module Pulitzer
2
2
  class PostTypeContentElementType < ActiveRecord::Base
3
3
  belongs_to :post_type
4
4
  belongs_to :content_element_type
5
+ has_one :content_element
5
6
  delegate :type, :image_type?, to: :content_element_type
6
7
 
7
8
  default_scope { order(id: :asc) }
@@ -8,5 +8,13 @@ module Pulitzer
8
8
  def content_element(label)
9
9
  self.content_elements.find_by(label: label)
10
10
  end
11
+
12
+ def template_content_elements
13
+ content_elements.template
14
+ end
15
+
16
+ def free_form_content_elements
17
+ content_elements.free_form
18
+ end
11
19
  end
12
20
  end
@@ -1,6 +1,5 @@
1
1
  <%= form_for content_element, html: ajax_form_hash(dom_target(content_element)), multipart: true,
2
2
  data: { server_endpoint: content_element_path(content_element) } do |f| %>
3
- <%= f.label content_element.label %>
4
3
  <%= f.text_field :title, placeholder: 'Title' %>
5
4
  <%= render partial: "#{content_element.type}_fields", locals: { f: f, content_element: content_element } %>
6
5
  <%= submit_tag "Update" %>
@@ -0,0 +1,25 @@
1
+ <%= form_for content_element, html: ajax_form_hash("#version_content_element_container_#{dom_id(version)}", insert_method: 'append', sub_class: "AddALineForm", container: "#new_version_content_element_#{dom_id(version)}") do |f| %>
2
+ <%= f.collection_select :content_element_type_id, Pulitzer::ContentElementType.all, :id, :name, {},
3
+ { data: { "revealer" => true, "sub-type" => "FormFieldRevealer", "revealer-children-id" => dom_id(version, :revealer) }} %>
4
+
5
+ <div data-revealer-target="<%= dom_id(version, :revealer) %>"></div>
6
+
7
+ <div data-revealer_id="<%= dom_id(version, :revealer) %>" data-revealer-triggers="['<%= Pulitzer::ContentElementType.find_by(name: 'Image').id %>']">
8
+ <%= f.label :height %>
9
+ <%= f.text_field :height, placeholder: 'Height' %>
10
+ <%= f.label :width %>
11
+ <%= f.text_field :width, placeholder: 'Width' %>
12
+ </div>
13
+
14
+ <div data-revealer_id="<%= dom_id(version, :revealer) %>" data-revealer-triggers="['<%= Pulitzer::ContentElementType.find_by(name: 'Text').id %>']">
15
+ <%= f.label :text_editor, "Text editor" %>
16
+ <%= f.select :text_editor, Pulitzer.text_editor_toolbars.map { |t| t[:name] } %>
17
+ </div>
18
+
19
+ <%= f.hidden_field :version_id %>
20
+ <%= f.hidden_field :kind, value: :free_form %>
21
+
22
+ <%= submit_tag "Create" %>
23
+ <%= link_to('Cancel', '#', :class => 'button',
24
+ data: { emptier: true, target: "#new_version_content_element_#{dom_id(version)}" } ) %>
25
+ <% end %>
@@ -1,6 +1,15 @@
1
+ <% if content_element.free_form? %>
2
+ <div class="pulitzer-row">
3
+ <div class="pulitzer-span right">
4
+ <%= render partial: '/pulitzer/shared/drag_handle' %>
5
+ </div>
6
+ </div>
7
+ <% end %>
1
8
  <div class="pulitzer-row">
2
9
  <ul class="list">
3
- <li><h2><%= content_element.label %></h2></li>
10
+ <% if content_element.free_form? %>
11
+ <li><h2><%= content_element.label %></h2></li>
12
+ <% end %>
4
13
  <li><%= render_element(content_element) %></li>
5
14
  <li><%= ajax_link "Edit", edit_post_content_element_path(content_element.post, content_element), {}, dom_target(content_element) %></li>
6
15
  </ul>
@@ -4,17 +4,34 @@
4
4
  <%= link_back_to_posts(@post.post_type, "Back to #{@post.post_type.name.singularize} Posts", 'Back to post types') %>
5
5
  </div>
6
6
 
7
+ <% if @post.post_type.allow_free_form? %>
8
+ <div class="pulitzer-row margin-bottom list-item">
9
+ <%= ajax_link "add a new content element for #{@post.title}", new_content_element_path(version_id: @post.preview_version), {}, "#new_version_content_element_#{dom_id(@post.preview_version)}" %>
10
+ <div id="new_version_content_element_<%= dom_id(@post.preview_version) %>"></div>
11
+ </div>
12
+ <% end %>
13
+
7
14
  <div class="pulitzer-row margin-bottom list-item">
8
15
  <h2>Tags</h2>
9
-
10
16
  <% Pulitzer::Post::TAG_MODELS.each do |tag_model| %>
11
17
  <%= render partial: 'pulitzer/post_tags/show_wrapper', locals: { post: @post, tag_model: tag_model } %>
12
18
  <% end %>
19
+ </div>
13
20
 
21
+ <div class="pulitzer-row margin-bottom list-item">
22
+ <h2>Template content elements</h2>
23
+ <% @content_elements.each do |content_element| %>
24
+ <%= render partial: 'show_wrapper', locals: { content_element: content_element } %>
25
+ <% end %>
14
26
  </div>
15
27
 
16
- <% @content_elements.each do |content_element| %>
17
- <%= render partial: 'show_wrapper', locals: {content_element: content_element } %>
28
+ <% if @post.post_type.allow_free_form? %>
29
+ <h2>Free form content elements</h2>
30
+ <div class="pulitzer-row margin-bottom list-item" id="version_content_element_container_<%= dom_id(@post.preview_version) %>" id="content_element_list" data-sorter href="<%= update_all_content_elements_path %>">
31
+ <% @free_form_content_elements.each do |content_element| %>
32
+ <%= render partial: 'show_wrapper', locals: { content_element: content_element } %>
33
+ <% end %>
34
+ </div>
18
35
  <% end %>
19
36
 
20
37
  <div class="pulitzer-row">
@@ -1,11 +1,6 @@
1
1
  <%= form_for post_type, html: ajax_form_hash(dom_target(post_type)) do |f| %>
2
- <%= f.label :name %>
3
- <%= f.text_field :name %>
4
- <%= f.label :plural %>
5
- <%= f.check_box :plural %>
6
- <%= f.label :template %>
7
- <%= f.check_box :template %>
8
- <%= f.submit "Update post type" %>
2
+ <%= render partial: 'form_fields', locals: { f: f } %>
3
+ <%= f.submit "Update" %>
9
4
  <%= link_to('Cancel', post_type_path(post_type), :class => 'button',
10
5
  data: { ajax_link: true, ajax_target: dom_target(post_type) } ) %>
11
6
  <% end %>
@@ -0,0 +1,5 @@
1
+ <%= f.label :name %>
2
+ <%= f.text_field :name %>
3
+ <%= f.label :plural %>
4
+ <%= f.check_box :plural %>
5
+ <%= f.select :kind, Pulitzer::PostType.kinds.keys.map { |m| [m.humanize, m] } %>
@@ -1,11 +1,6 @@
1
1
  <%= form_for post_type, html: ajax_form_hash('#post_types_container', insert_method: 'append', sub_class: "AddALineForm", container: '#new_post_type') do |f| %>
2
- <%= f.label :name %>
3
- <%= f.text_field :name %>
4
- <%= f.label :plural %>
5
- <%= f.check_box :plural %>
6
- <%= f.label :template %>
7
- <%= f.check_box :template %>
8
- <%= f.submit %>
2
+ <%= render partial: 'form_fields', locals: { f: f } %>
3
+ <%= f.submit "Create" %>
9
4
  <%= link_to('Cancel', '#', :class => 'button',
10
5
  data: { emptier: true, target: '#new_post_type' } ) %>
11
6
  <% end %>
@@ -2,9 +2,11 @@
2
2
  <ul class="inline-list">
3
3
  <li><%= post_type.name %></li>
4
4
  <li><%= link_to_posts(post_type, 'Index', 'Manage') %></li>
5
- <li <%= expander("post_type_content_element_types_#{dom_id(post_type)}") %>>
6
- <%= link_to "Template", '#', class: 'toggle-post-type-content-elements', data: { post_types: post_type.id } %>
7
- </li>
5
+ <% if post_type.allow_template? %>
6
+ <li <%= expander("post_type_content_element_types_#{dom_id(post_type)}") %>>
7
+ <%= link_to "Template", '#', class: 'toggle-post-type-content-elements', data: { post_types: post_type.id } %>
8
+ </li>
9
+ <% end %>
8
10
  <li>
9
11
  <% if Pulitzer.skip_metadata_auth? || self.instance_eval(&Pulitzer.metadata_closure) %>
10
12
  <%= ajax_link "Details", edit_post_type_path(post_type), {}, dom_target(post_type) %>
@@ -0,0 +1,5 @@
1
+ <div class="drag_handle" data-drag-handle>
2
+ <div class="drag_handle_indent"></div>
3
+ <div class="drag_handle_indent"></div>
4
+ <div class="drag_handle_indent"></div>
5
+ </div>
data/config/routes.rb CHANGED
@@ -3,7 +3,11 @@ Pulitzer::Engine.routes.draw do
3
3
  resources :content_elements
4
4
  resources :post_tags
5
5
  end
6
- resources :content_elements
6
+ resources :content_elements do
7
+ collection do
8
+ patch :update_all
9
+ end
10
+ end
7
11
  resources :post_types
8
12
  resources :versions
9
13
  resources :content_element_types
@@ -0,0 +1,21 @@
1
+ class AddPostTypeContentElementAttributesToContentElements < ActiveRecord::Migration
2
+ def up
3
+ add_column :pulitzer_content_elements, :text_editor, :string
4
+ add_column :pulitzer_content_elements, :height, :integer, default: 100
5
+ add_column :pulitzer_content_elements, :width, :integer, default: 100
6
+ add_column :pulitzer_content_elements, :sort_order, :integer
7
+ Pulitzer::ContentElement.reset_column_information
8
+ Pulitzer::ContentElement.find_each do |ce|
9
+ if ptce = ce.post_type_content_element_type
10
+ ce.update(text_editor: ptce.text_editor, height: ptce.height, width: ptce.width)
11
+ end
12
+ end
13
+ end
14
+
15
+ def down
16
+ remove_column :pulitzer_content_elements, :text_editor
17
+ remove_column :pulitzer_content_elements, :height
18
+ remove_column :pulitzer_content_elements, :width
19
+ remove_column :pulitzer_content_elements, :sort_order
20
+ end
21
+ end