pulitzer 0.10.3 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9de24ba570441cf00c18e2228d0d611a8e237db
4
- data.tar.gz: 25e968c2433f7e059511b7f45a2d3d0f17331a1c
3
+ metadata.gz: e43f179ef2fe81ffa3ea24617f794319623dcea3
4
+ data.tar.gz: 9992087faafd5ff030059931ae6bf6aa659fb5ee
5
5
  SHA512:
6
- metadata.gz: 53f5e6876d6c7e9d54eaae5a250862f4800bc16edb0297c96a6089b943316f7654ca58ba2f0a6d3bbbe21b9e85cb5fd77b7565ad60aa79199dcb253f9f6d9018
7
- data.tar.gz: f4e9cac1d04b12f7b05609ed22517fb36db42cf47ee81852cbfc026fc8891a54018acaf279d77beb48d6874eee61b42770b1955c26b44d36d75273b5974e417a
6
+ metadata.gz: f3f2f3d97b0286411d7ffd0923a95374938943f1c28dcba8b24d865225df373a732375f146fc0ad0b7e98a8dd41a3673ad66121c3036f29b68b48932b6808e0d
7
+ data.tar.gz: 99eb1abb54a0e793a4afccbada7ebb20ccc09b4b4602b8ff02857276934476f76957b4a48a3825ee9f5f60ba8f80a75216a3a5d5c4bc1876684e072021362589
@@ -3,7 +3,7 @@ class Pulitzer::VersionsController < Pulitzer::ApplicationController
3
3
 
4
4
  def edit
5
5
  if @version.preview?
6
- route = "pulitzer_preview_#{@post.post_type.name.parameterize('_')}_path"
6
+ route = "#{Pulitzer.preview_namespace}_#{@post.post_type.name.parameterize('_')}_path"
7
7
  @preview_path = main_app.public_send(route, @post.slug) if main_app.respond_to?(route)
8
8
  end
9
9
  render_ajax locals: {version: @version}
@@ -8,9 +8,11 @@ class Pulitzer::CreatePostTypeFreeFormSections
8
8
 
9
9
  def call
10
10
  post_type.posts.each do |post|
11
- post.preview_version.free_form_sections.create do |ffs|
12
- ffs.name = ffst.name
13
- ffs.free_form_section_type = ffst
11
+ if post.preview_version
12
+ post.preview_version.free_form_sections.create do |ffs|
13
+ ffs.name = ffst.name
14
+ ffs.free_form_section_type = ffst
15
+ end
14
16
  end
15
17
  end
16
18
  end
@@ -0,0 +1,120 @@
1
+ require 'rails/generators'
2
+
3
+ module Pulitzer
4
+ class PostTypeGenerator < Rails::Generators::Base
5
+ include ActiveSupport::Inflector
6
+
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ argument :post_type_name, required: true,
10
+ desc: "The name of the post type."
11
+
12
+
13
+ def build_post_type_files
14
+ abort("Couldn't find Pulitzer::PostType named #{post_type_name}") unless post_type.is_a? Pulitzer::PostType
15
+ route get_route
16
+ inject_into_file File.join(Rails.root,'config','routes.rb'), after: "namespace :#{Pulitzer.preview_namespace} do\n", force: false do
17
+ "\t\t#{get_route}\n"
18
+ end
19
+
20
+ copy_file "post_view.html.erb", File.join(Rails.root,'app','views',Pulitzer.public_controller,"#{action_name}.html.erb")
21
+
22
+ section_names.each do |section_name|
23
+ inject_into_file File.join(Rails.root,'app','views', Pulitzer.public_controller,"#{action_name}.html.erb"), before: "<%# END Auto-generated by Pulitzer %>", force: false do
24
+ <<-VIEW
25
+ <%= render_cms_section(@post, '#{section_name}') %>
26
+
27
+ VIEW
28
+ end
29
+ end
30
+
31
+ content_element_names.each do |content_element_name|
32
+ inject_into_file File.join(Rails.root,'app','views', Pulitzer.public_controller,"#{action_name}.html.erb"), before: "<%# END Auto-generated by Pulitzer %>", force: false do
33
+ <<-VIEW
34
+ <%= render_cms_element @post.content_element('#{content_element_name}') %>
35
+
36
+ VIEW
37
+ end
38
+ end
39
+
40
+ inject_into_file File.join(Rails.root,'app','controllers', "#{Pulitzer.public_controller}_controller.rb"), after: "#Pulitzer Generated Actions\n", force: false do
41
+ get_controller_action('active')
42
+ end
43
+ inject_into_file File.join(Rails.root,'app','controllers', Pulitzer.preview_namespace, "#{Pulitzer.public_controller}_controller.rb"), after: "#Pulitzer Generated Actions\n", force: false do
44
+ get_controller_action('preview')
45
+ end
46
+ end
47
+
48
+ protected
49
+
50
+ def file_name
51
+ parameterize(post_type_name)
52
+ end
53
+
54
+ def action_name
55
+ file_name.gsub(/-/,'_')
56
+ end
57
+
58
+ def post_type
59
+ Pulitzer::PostType.named(post_type_name)
60
+ end
61
+
62
+ def free_form_section_types
63
+ post_type.free_form_section_types
64
+ end
65
+
66
+ def section_names
67
+ free_form_section_types.map(&:name)
68
+ end
69
+
70
+ def post_type_content_element_types
71
+ post_type.post_type_content_element_types
72
+ end
73
+
74
+ def content_element_names
75
+ post_type_content_element_types.map(&:label)
76
+ end
77
+
78
+ def arity
79
+ return @arity if @arity.present?
80
+ @arity = post_type.plural? ? 'plural' : 'singleton'
81
+ puts "Generating files for a #{arity} post type"
82
+ @arity
83
+ end
84
+
85
+ def get_route
86
+ send "#{arity}_route"
87
+ end
88
+
89
+ def plural_route
90
+ "get '#{file_name}/:slug' => '#{Pulitzer.public_controller}##{action_name}', as: '#{action_name}'"
91
+ end
92
+
93
+ def singleton_route
94
+ "get '#{file_name}' => 'pages##{action_name}', as: '#{action_name}'"
95
+ end
96
+
97
+ def get_controller_action(context)
98
+ send "#{arity}_action", context
99
+ end
100
+
101
+ def plural_action(context)
102
+ <<-CACTION
103
+
104
+ def #{action_name}
105
+ @post = Pulitzer::PostType.named('#{post_type_name}').posts.find_by!(slug: params[:slug]).get_#{context}_version!
106
+ end
107
+ CACTION
108
+ end
109
+
110
+ def singleton_action(context)
111
+ <<-CACTION
112
+
113
+ def #{action_name}
114
+ @post = Pulitzer::PostType.named('#{post_type_name}').singleton_post.get_#{context}_version!
115
+ end
116
+ CACTION
117
+ end
118
+
119
+ end
120
+ end
@@ -0,0 +1,3 @@
1
+ <%# BEGIN Auto-generated by Pulitzer %>
2
+
3
+ <%# END Auto-generated by Pulitzer %>
data/lib/pulitzer.rb CHANGED
@@ -10,7 +10,7 @@ require 'pulitzer/exceptions'
10
10
  module Pulitzer
11
11
  mattr_accessor :base_controller, :metadata_closure, :authentication_closure, :unpublish_authorization,
12
12
  :publish_callback, :tagging_models, :layout, :text_editor_toolbars, :clone_queue, :image_queue, :aws_acl,
13
- :partial_folder, :missing_image_path
13
+ :partial_folder, :missing_image_path, :public_view_dir, :public_controller, :preview_namespace
14
14
 
15
15
  def self.config(options)
16
16
  base_controller_name = options[:base_controller_name]
@@ -23,6 +23,8 @@ module Pulitzer
23
23
  @@tagging_models = options[:tagging_models] || []
24
24
  @@layout = options[:layout] || 'application'
25
25
  @@partial_folder = options[:partial_folder] || 'pulitzer_partials'
26
+ @@preview_namespace = options[:preview_namespace] || 'pulitzer_preview'
27
+ @@public_controller = options[:public_controller] || 'pulitzer'
26
28
  default_text_editor = [{ name: 'None', template: 'pulitzer/text_editors/none', kind: 'TinyMCE'}]
27
29
  user_text_editors = options[:text_editor_toolbars].flatten || nil
28
30
  @@text_editor_toolbars = default_text_editor.push(*user_text_editors).compact
@@ -47,8 +47,8 @@ module Pulitzer
47
47
  element.body.html_safe if element.html
48
48
  end
49
49
 
50
- def render_cms_section(post_type, section_name)
51
- post_type.section(section_name).partials.collect do |partial|
50
+ def render_cms_section(version, section_name)
51
+ version.section(section_name).partials.collect do |partial|
52
52
  render partial: partial.full_view_path, locals: {partial: partial}
53
53
  end.join.html_safe
54
54
  end
@@ -1,3 +1,3 @@
1
1
  module Pulitzer
2
- VERSION = '0.10.3'
2
+ VERSION = '0.11.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.10.3
4
+ version: 0.11.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-04-03 00:00:00.000000000 Z
12
+ date: 2017-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -638,6 +638,9 @@ files:
638
638
  - db/migrate/20160519181030_add_label_to_partial.rb
639
639
  - db/migrate/20160609214139_remove_title_from_content_elements.rb
640
640
  - db/migrate/20160927160910_add_required_to_pulitzer_post_type_content_element_type.rb
641
+ - lib/generators/pulitzer/post_type_generator.rb
642
+ - lib/generators/pulitzer/singleton_type_generator.rb
643
+ - lib/generators/pulitzer/templates/post_view.html.erb
641
644
  - lib/pulitzer.rb
642
645
  - lib/pulitzer/content_element_helper.rb
643
646
  - lib/pulitzer/engine.rb
@@ -1041,7 +1044,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1041
1044
  version: '0'
1042
1045
  requirements: []
1043
1046
  rubyforge_project:
1044
- rubygems_version: 2.5.1
1047
+ rubygems_version: 2.6.11
1045
1048
  signing_key:
1046
1049
  specification_version: 4
1047
1050
  summary: A content management engine for Ruby on Rails.