zen 0.2.4.1 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. data/MANIFEST +42 -33
  2. data/README.md +14 -27
  3. data/ROADMAP.md +20 -2
  4. data/{Thorfile → Rakefile} +2 -3
  5. data/bin/zen +27 -5
  6. data/lib/zen.rb +70 -52
  7. data/lib/zen/asset.rb +258 -0
  8. data/lib/zen/bin/app.rb +42 -0
  9. data/lib/zen/controller/admin_controller.rb +53 -36
  10. data/lib/zen/controller/base_controller.rb +13 -8
  11. data/lib/zen/controller/frontend_controller.rb +4 -3
  12. data/lib/zen/controller/main_controller.rb +17 -33
  13. data/lib/zen/error/validation_error.rb +10 -0
  14. data/lib/zen/ext/string.rb +185 -0
  15. data/lib/zen/helper/acl.rb +120 -92
  16. data/lib/zen/helper/common.rb +1 -3
  17. data/lib/zen/helper/theme.rb +73 -0
  18. data/lib/zen/language.rb +66 -57
  19. data/lib/zen/layout/admin.xhtml +5 -48
  20. data/lib/zen/layout/login.xhtml +4 -44
  21. data/lib/zen/model/methods.rb +1 -1
  22. data/lib/zen/model/settings.rb +0 -3
  23. data/lib/zen/package.rb +101 -83
  24. data/lib/zen/package/base.rb +62 -0
  25. data/lib/zen/package/categories/lib/categories.rb +29 -10
  26. data/lib/zen/package/categories/lib/categories/controller/categories.rb +4 -5
  27. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +4 -5
  28. data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +4 -3
  29. data/lib/zen/package/categories/lib/categories/model/category.rb +2 -2
  30. data/lib/zen/package/categories/lib/categories/model/category_group.rb +3 -3
  31. data/lib/zen/package/categories/lib/categories/plugin/categories.rb +130 -0
  32. data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +1 -1
  33. data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +2 -2
  34. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +11 -6
  35. data/lib/zen/package/comments/lib/comments.rb +23 -13
  36. data/lib/zen/package/comments/lib/comments/controller/comments.rb +4 -5
  37. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +7 -8
  38. data/lib/zen/package/comments/lib/comments/model/comment.rb +4 -4
  39. data/lib/zen/package/comments/lib/comments/plugin/comments.rb +111 -0
  40. data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +2 -2
  41. data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +3 -3
  42. data/lib/zen/package/custom_fields/lib/custom_fields.rb +18 -11
  43. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +4 -5
  44. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +4 -5
  45. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +2 -2
  46. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +3 -3
  47. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +3 -3
  48. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +9 -5
  49. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +1 -1
  50. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +3 -3
  51. data/lib/zen/package/menus/lib/menus.rb +25 -43
  52. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +5 -6
  53. data/lib/zen/package/menus/lib/menus/controller/menus.rb +9 -5
  54. data/lib/zen/package/menus/lib/menus/helper/menu_item.rb +4 -4
  55. data/lib/zen/package/menus/lib/menus/model/menu.rb +2 -2
  56. data/lib/zen/package/menus/lib/menus/model/menu_item.rb +4 -1
  57. data/lib/zen/package/menus/lib/menus/plugin/menus.rb +152 -0
  58. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +1 -1
  59. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +3 -3
  60. data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +7 -7
  61. data/lib/zen/package/sections/lib/sections.rb +32 -16
  62. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +9 -18
  63. data/lib/zen/package/sections/lib/sections/controller/sections.rb +8 -9
  64. data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +1 -1
  65. data/lib/zen/package/sections/lib/sections/model/section.rb +4 -4
  66. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +9 -10
  67. data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +224 -0
  68. data/lib/zen/package/sections/lib/sections/plugin/sections.rb +85 -0
  69. data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +1 -1
  70. data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +9 -5
  71. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +2 -2
  72. data/lib/zen/package/settings/lib/settings.rb +145 -10
  73. data/lib/zen/package/settings/lib/settings/controller/settings.rb +28 -24
  74. data/lib/zen/package/settings/lib/settings/language/en/settings.yml +10 -0
  75. data/lib/zen/package/settings/lib/settings/model/setting.rb +3 -64
  76. data/lib/zen/package/settings/lib/settings/plugin/group_base.rb +40 -0
  77. data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +76 -0
  78. data/lib/zen/package/settings/lib/settings/plugin/settings.rb +236 -0
  79. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +20 -49
  80. data/lib/zen/package/settings/migrations/1295597111_create_schema.rb +0 -12
  81. data/lib/zen/package/settings/migrations/1303196915_settings_plugin.rb +31 -0
  82. data/lib/zen/package/users/lib/users.rb +18 -15
  83. data/lib/zen/package/users/lib/users/controller/access_rules.rb +44 -8
  84. data/lib/zen/package/users/lib/users/controller/user_groups.rb +4 -5
  85. data/lib/zen/package/users/lib/users/controller/users.rb +5 -6
  86. data/lib/zen/package/users/lib/users/language/en/access_rules.yml +11 -9
  87. data/lib/zen/package/users/lib/users/model/access_rule.rb +7 -6
  88. data/lib/zen/package/users/lib/users/model/user.rb +4 -4
  89. data/lib/zen/package/users/lib/users/model/user_group.rb +3 -3
  90. data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +50 -0
  91. data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +32 -29
  92. data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +8 -6
  93. data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +3 -3
  94. data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +2 -2
  95. data/lib/zen/package/users/migrations/1303510943_class_rules.rb +13 -0
  96. data/lib/zen/plugin.rb +110 -104
  97. data/lib/zen/plugin/base.rb +46 -0
  98. data/lib/zen/{liquid/controller_behavior.rb → plugin/controller.rb} +9 -7
  99. data/lib/zen/plugin/helper.rb +47 -0
  100. data/lib/zen/plugin/markup/lib/markup.rb +14 -0
  101. data/lib/zen/plugin/markup/lib/markup/language/en/markup.yml +6 -0
  102. data/lib/zen/plugin/markup/lib/markup/markup.rb +154 -0
  103. data/lib/zen/public/admin/css/forms.css +4 -0
  104. data/lib/zen/public/admin/css/general.css +15 -15
  105. data/lib/zen/public/admin/css/layout.css +10 -10
  106. data/lib/zen/public/admin/css/reset.css +123 -0
  107. data/lib/zen/public/admin/images/icons/accept.png +0 -0
  108. data/lib/zen/public/admin/images/icons/add.png +0 -0
  109. data/lib/zen/public/admin/images/icons/back.png +0 -0
  110. data/lib/zen/public/admin/images/icons/bold.png +0 -0
  111. data/lib/zen/public/admin/images/icons/close.png +0 -0
  112. data/lib/zen/public/admin/images/icons/delete.png +0 -0
  113. data/lib/zen/public/admin/images/icons/edit.png +0 -0
  114. data/lib/zen/public/admin/images/icons/error.png +0 -0
  115. data/lib/zen/public/admin/images/icons/help.png +0 -0
  116. data/lib/zen/public/admin/images/icons/info.png +0 -0
  117. data/lib/zen/public/admin/images/icons/italic.png +0 -0
  118. data/lib/zen/public/admin/images/icons/large/error.png +0 -0
  119. data/lib/zen/public/admin/images/icons/large/notice.png +0 -0
  120. data/lib/zen/public/admin/images/icons/large/success.png +0 -0
  121. data/lib/zen/public/admin/images/icons/link.png +0 -0
  122. data/lib/zen/public/admin/images/icons/logout.png +0 -0
  123. data/lib/zen/public/admin/images/icons/ol.png +0 -0
  124. data/lib/zen/public/admin/images/icons/pdf.png +0 -0
  125. data/lib/zen/public/admin/images/icons/ul.png +0 -0
  126. data/lib/zen/public/admin/images/icons/user.png +0 -0
  127. data/lib/zen/public/admin/images/icons/view.png +0 -0
  128. data/lib/zen/public/admin/js/mootools/core.js +384 -333
  129. data/lib/zen/public/admin/js/mootools/more.js +256 -231
  130. data/lib/zen/public/admin/js/vendor/{datepicker/Picker.Date.js → datepicker.js} +447 -0
  131. data/lib/zen/public/admin/js/vendor/yepnope.js +1 -0
  132. data/lib/zen/public/admin/js/zen/editor/base.js +8 -1
  133. data/lib/zen/public/admin/js/zen/init.js +89 -26
  134. data/lib/zen/public/favicon.ico +0 -0
  135. data/lib/zen/task.rb +7 -0
  136. data/lib/zen/task/build.rake +60 -0
  137. data/lib/zen/task/clean.rake +27 -0
  138. data/lib/zen/task/db.rake +111 -0
  139. data/lib/zen/task/package.rake +67 -0
  140. data/lib/zen/task/plugin.rake +24 -0
  141. data/lib/zen/task/proto.rake +95 -0
  142. data/lib/zen/task/theme.rake +68 -0
  143. data/lib/zen/theme.rb +28 -55
  144. data/lib/zen/theme/base.rb +64 -0
  145. data/lib/zen/validation.rb +149 -0
  146. data/lib/zen/version.rb +1 -1
  147. data/lib/zen/view/bottom.xhtml +6 -0
  148. data/lib/zen/view/main.xhtml +32 -0
  149. data/proto/app/Rakefile +12 -0
  150. data/proto/app/app.rb +6 -6
  151. data/proto/app/config/config.rb +7 -14
  152. data/proto/app/config/database.rb +0 -20
  153. data/proto/app/start.rb +0 -1
  154. data/proto/app/{vendor/themes → task}/.gitkeep +0 -0
  155. data/proto/app/vendor/theme/.gitkeep +0 -0
  156. data/proto/package/lib/package.rb +8 -17
  157. data/proto/package/lib/package/controller/controllers.rb +4 -4
  158. data/proto/package/lib/package/language/en/languages.yml +3 -3
  159. data/proto/package/lib/package/model/model.rb +1 -1
  160. metadata +73 -73
  161. data/lib/zen/bin/base.rb +0 -109
  162. data/lib/zen/helper/asset.rb +0 -106
  163. data/lib/zen/liquid/general.rb +0 -94
  164. data/lib/zen/liquid/redirect.rb +0 -70
  165. data/lib/zen/liquid/strip.rb +0 -60
  166. data/lib/zen/package/categories/lib/categories/liquid/categories.rb +0 -16
  167. data/lib/zen/package/comments/lib/comments/liquid/comment_form.rb +0 -127
  168. data/lib/zen/package/comments/lib/comments/liquid/comments.rb +0 -115
  169. data/lib/zen/package/menus/lib/menus/liquid/menus.rb +0 -152
  170. data/lib/zen/package/sections/lib/sections/liquid/section_entries.rb +0 -228
  171. data/lib/zen/package/sections/lib/sections/liquid/sections.rb +0 -77
  172. data/lib/zen/package/settings/lib/settings/liquid/setting.rb +0 -58
  173. data/lib/zen/package/users/lib/users/liquid/user.rb +0 -77
  174. data/lib/zen/package/users/lib/users/liquid/users.rb +0 -82
  175. data/lib/zen/plugin/markup.rb +0 -30
  176. data/lib/zen/public/admin/css/boilerplate.css +0 -176
  177. data/lib/zen/public/admin/images/general/noise.jpg +0 -0
  178. data/lib/zen/public/admin/js/vendor/datepicker/Picker.Attach.js +0 -137
  179. data/lib/zen/public/admin/js/vendor/datepicker/Picker.js +0 -291
  180. data/lib/zen/public/admin/js/vendor/datepicker/README.md +0 -325
  181. data/lib/zen/public/admin/js/vendor/datepicker/locale.js +0 -16
  182. data/lib/zen/strict_struct.rb +0 -36
  183. data/lib/zen/task/build.rb +0 -123
  184. data/lib/zen/task/clean.rb +0 -46
  185. data/lib/zen/task/db.rb +0 -130
  186. data/lib/zen/task/package.rb +0 -87
  187. data/lib/zen/task/proto.rb +0 -116
  188. data/lib/zen/task/theme.rb +0 -88
  189. data/proto/app/Thorfile +0 -4
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module Comments
3
3
  #:nodoc:
4
- module Controllers
4
+ module Controller
5
5
  ##
6
6
  # Controller used for managing comments. Administrations can't actually
7
7
  # add new comments using the backend controller but can edit or delete them.
@@ -13,11 +13,10 @@ module Comments
13
13
  # @author Yorick Peterse
14
14
  # @since 0.1
15
15
  #
16
- class Comments < Zen::Controllers::AdminController
17
- include ::Comments::Models
16
+ class Comments < Zen::Controller::AdminController
17
+ include ::Comments::Model
18
18
 
19
- map '/admin/comments'
20
- trait :extension_identifier => 'com.zen.comments'
19
+ map('/admin/comments')
21
20
 
22
21
  before_all do
23
22
  csrf_protection(:save, :delete) do
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module Comments
3
3
  #:nodoc:
4
- module Controllers
4
+ module Controller
5
5
  ##
6
6
  # Frontend controller for the comments system used for saving user-submitted comments.
7
7
  # When the anti-spam system is enabled Zen will use Defensio to check if the comment is
@@ -10,11 +10,10 @@ module Comments
10
10
  # @author Yorick Peterse
11
11
  # @since 0.1
12
12
  #
13
- class CommentsForm < Zen::Controllers::FrontendController
14
- include ::Comments::Models
13
+ class CommentsForm < Zen::Controller::FrontendController
14
+ include ::Comments::Model
15
15
 
16
- map '/comments_form'
17
- trait :extension_identifier => 'com.zen.comments'
16
+ map('/comments-form')
18
17
 
19
18
  before_all do
20
19
  csrf_protection(:save) do
@@ -34,7 +33,7 @@ module Comments
34
33
 
35
34
  comment = Comment.new
36
35
  post = request.params.dup
37
- entry = ::Sections::Models::SectionEntry[h(post['section_entry']).to_i]
36
+ entry = ::Sections::Model::SectionEntry[h(post['section_entry']).to_i]
38
37
 
39
38
  # Remove empty values
40
39
  post.each { |k, v| post.delete(k) if v.empty? }
@@ -82,9 +81,9 @@ module Comments
82
81
  end
83
82
 
84
83
  # Require anti-spam validation?
85
- if session[:settings][:enable_antispam] == '1'
84
+ if ::Zen::Settings[:enable_antispam] == '1'
86
85
  # Validate the comment
87
- api_key = session[:settings][:defensio_key]
86
+ api_key = ::Zen::Settings[:defensio_key]
88
87
 
89
88
  if api_key.nil?
90
89
  flash[:error] = lang('comments.errors.no_api_key')
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module Comments
3
3
  #:nodoc:
4
- module Models
4
+ module Model
5
5
  ##
6
6
  # Model that represents a single comment. This model has the following relations:
7
7
  #
@@ -18,8 +18,8 @@ module Comments
18
18
  class Comment < Sequel::Model
19
19
  include ::Zen::Language
20
20
 
21
- many_to_one :section_entry, :class => "Sections::Models::SectionEntry"
22
- many_to_one :user, :class => "Users::Models::User"
21
+ many_to_one :section_entry, :class => "Sections::Model::SectionEntry"
22
+ many_to_one :user, :class => "Users::Model::User"
23
23
 
24
24
  plugin :timestamps, :create => :created_at, :update => :updated_at
25
25
 
@@ -38,7 +38,7 @@ module Comments
38
38
  # Returns a hash containing all available statuses for each comment.
39
39
  #
40
40
  # @example
41
- # Comments::Models::Comment.status_hash
41
+ # Comments::Model::Comment.status_hash
42
42
  #
43
43
  # @author Yorick Peterse
44
44
  # @since 0.2
@@ -0,0 +1,111 @@
1
+ #:nodoc
2
+ module Comments
3
+ #:nodoc
4
+ module Plugin
5
+ ##
6
+ # The Comments plugin can be used to display a list of comments for a given section
7
+ # entry.
8
+ #
9
+ # ## Usage
10
+ #
11
+ # If we want to retrieve all comments for the entry "hello-world":
12
+ #
13
+ # plugin(:comments, :entry => 'hello-world').each do |comment|
14
+ # comment[:website]
15
+ # end
16
+ #
17
+ # For more information about all available options see
18
+ # Comments::Plugin::Comments#initialize
19
+ #
20
+ # @author Yorick Peterse
21
+ # @since 0.2.5
22
+ #
23
+ class Comments
24
+ include ::Zen::Plugin::Helper
25
+ include ::Sections::Model
26
+ include ::Comments::Model
27
+
28
+ ##
29
+ # Creates a new instance of the plugin and saves the specified configuration options.
30
+ #
31
+ # @author Yorick Peterse
32
+ # @since 0.2.5
33
+ # @param [Hash] options Hash with a set of options that determine how the comments
34
+ # should be retrieved.
35
+ # @option options [String/Integer] :entry The slug or ID of the entry for which to
36
+ # retrieve all comments.
37
+ # @option options [Integer] :limit The maximum amount of comments to retrieve.
38
+ # @option options [Integer] :offset The row offset, useful for pagination systems.
39
+ # @option options [Boolean] :markup When set to true (default) the markup used in
40
+ # each comment will be converted to the appropriate format.
41
+ #
42
+ def initialize(options = {})
43
+ @options = {
44
+ :limit => 20,
45
+ :offset => 0,
46
+ :markup => true,
47
+ :entry => nil
48
+ }.merge(options)
49
+
50
+ # Validate the :entry option
51
+ validate_type(@options[:limit] , :limit , [Integer, Fixnum])
52
+ validate_type(@options[:offset], :offset, [Integer, Fixnum])
53
+ validate_type(@options[:entry] , :entry , [Integer, String, Fixnum])
54
+ validate_type(@options[:markup], :markup, [FalseClass, TrueClass])
55
+ end
56
+
57
+ ##
58
+ # Retrieves all comments based on the options set in the construct. The comments are
59
+ # returned as an array.
60
+ #
61
+ # @author Yorick Peterse
62
+ # @since 0.2.5
63
+ #
64
+ def call
65
+ # Get the section entry
66
+ if @options[:entry].class == String
67
+ entry = SectionEntry[:slug => @options[:entry]]
68
+ else
69
+ entry = SectionEntry[@options[:entry]]
70
+ end
71
+
72
+ # Now that we have the entry and the section we can start retrieving all the
73
+ # comments.
74
+ comments = Comment.filter(:section_entry_id => entry.id)
75
+ .limit(@options[:limit], @options[:offset])
76
+ .all
77
+
78
+ # Don't bother with all code below this if/end if we don't want to convert the
79
+ # markup of each comment.
80
+ if @options[:markup] === false
81
+ return comments
82
+ end
83
+
84
+ # Get the section for the comments. This is required to determine what markup is
85
+ # used for the comments.
86
+ section = entry.section
87
+
88
+ # Convert the markup of each comment and convert each comment to a hash
89
+ comments.each_with_index do |comment, index|
90
+ user = comment.user
91
+ comment = comment.values
92
+ comment[:comment] = plugin(:markup, section.comment_format, comment[:comment])
93
+
94
+ # Conver the userdata to a hash as well
95
+ comment[:user] = {}
96
+
97
+ if !user.nil?
98
+ user.values.each do |k, v|
99
+ comment[:user][k] = v
100
+ end
101
+ end
102
+
103
+ comments[index] = comment
104
+ end
105
+
106
+ return comments
107
+ end
108
+
109
+ end
110
+ end
111
+ end
@@ -5,7 +5,7 @@
5
5
  f.input_hidden(:csrf_token, get_csrf_token)
6
6
  f.input_hidden(:id , @comment.id)
7
7
 
8
- if !@comment.user_id
8
+ if !@comment.user
9
9
  name = @comment.name
10
10
  website = @comment.website
11
11
  email = @comment.email
@@ -37,7 +37,7 @@
37
37
  f.select(
38
38
  lang('comments.labels.status'),
39
39
  :status,
40
- :values => Comments::Models::Comment.status_hash,
40
+ :values => Comments::Model::Comment.status_hash,
41
41
  :selected => @comment.status,
42
42
  :size => 1
43
43
  )
@@ -38,7 +38,7 @@
38
38
  <td>
39
39
  #{anchor_to(
40
40
  "#{comment.comment[0, 15]}...",
41
- Comments::Controllers::Comments.r(:edit, comment.id)
41
+ Comments::Controller::Comments.r(:edit, comment.id)
42
42
  )}
43
43
  </td>
44
44
  <?r else ?>
@@ -46,9 +46,9 @@
46
46
  <?r end ?>
47
47
 
48
48
  <td>#{comment.section_entry.title}</td>
49
- <td>#{Comments::Models::Comment.status_hash[comment.status]}</td>
49
+ <td>#{Comments::Model::Comment.status_hash[comment.status]}</td>
50
50
 
51
- <?r if !comment.user_id ?>
51
+ <?r if !comment.user ?>
52
52
  <td>#{comment.name}</td>
53
53
  <td>#{comment.email}</td>
54
54
  <td>#{comment.website}</td>
@@ -1,23 +1,30 @@
1
+ require __DIR__('custom_fields/model/custom_field')
2
+ require __DIR__('custom_fields/model/custom_field_group')
3
+ require __DIR__('custom_fields/model/custom_field_value')
4
+ require __DIR__('custom_fields/controller/custom_field_groups')
5
+ require __DIR__('custom_fields/controller/custom_fields')
1
6
 
2
- # Load all the classes such as controllers, models and so on.
3
- require __DIR__ 'custom_fields/model/custom_field'
4
- require __DIR__ 'custom_fields/model/custom_field_group'
5
- require __DIR__ 'custom_fields/model/custom_field_value'
6
-
7
- require __DIR__ 'custom_fields/controller/custom_field_groups'
8
- require __DIR__ 'custom_fields/controller/custom_fields'
7
+ Zen::Language.options.paths.push(__DIR__('custom_fields'))
8
+ Zen::Language.load('custom_fields')
9
+ Zen::Language.load('custom_field_groups')
9
10
 
10
11
  Zen::Package.add do |p|
11
- p.name = 'Custom Fields'
12
+ p.name = 'custom_fields'
12
13
  p.author = 'Yorick Peterse'
13
14
  p.url = 'http://yorickpeterse.com/'
14
- p.about = "The Custom Fields module is used to manage, how original, custom fields and custom field groups."
15
- p.identifier = 'com.zen.custom_fields'
15
+ p.about = "The Custom Fields module is used to manage custom fields and custom
16
+ field groups."
17
+
16
18
  p.directory = __DIR__('custom_fields')
17
19
  p.migration_dir = __DIR__('../migrations')
18
20
 
19
21
  p.menu = [{
20
- :title => "Custom Fields",
22
+ :title => lang('custom_fields.titles.index'),
21
23
  :url => "admin/custom-field-groups"
22
24
  }]
25
+
26
+ p.controllers = {
27
+ lang('custom_fields.titles.index') => CustomFields::Controller::CustomFields,
28
+ lang('custom_field_groups.titles.index') => CustomFields::Controller::CustomFieldGroups
29
+ }
23
30
  end
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module CustomFields
3
3
  #:nodoc:
4
- module Controllers
4
+ module Controller
5
5
  ##
6
6
  # Controller for managing custom field groups. These groups are used
7
7
  # to organize individual fields into a larger group which in turn will
@@ -10,11 +10,10 @@ module CustomFields
10
10
  # @author Yorick Peterse
11
11
  # @since 0.1
12
12
  #
13
- class CustomFieldGroups < Zen::Controllers::AdminController
14
- include ::CustomFields::Models
13
+ class CustomFieldGroups < Zen::Controller::AdminController
14
+ include ::CustomFields::Model
15
15
 
16
- map '/admin/custom-field-groups'
17
- trait :extension_identifier => 'com.zen.custom_fields'
16
+ map('/admin/custom-field-groups')
18
17
 
19
18
  before_all do
20
19
  csrf_protection(:save, :delete) do
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module CustomFields
3
3
  #:nodoc:
4
- module Controllers
4
+ module Controller
5
5
  ##
6
6
  # Controller for managing custom fields. Custom fields are one of
7
7
  # the most important elements in Zen. Custom fields can be used to
@@ -12,11 +12,10 @@ module CustomFields
12
12
  # @author Yorick Peterse
13
13
  # @since 0.1
14
14
  #
15
- class CustomFields < Zen::Controllers::AdminController
16
- include ::CustomFields::Models
15
+ class CustomFields < Zen::Controller::AdminController
16
+ include ::CustomFields::Model
17
17
 
18
- map '/admin/custom-fields'
19
- trait :extension_identifier => 'com.zen.custom_fields'
18
+ map('/admin/custom-fields')
20
19
 
21
20
  before_all do
22
21
  csrf_protection(:save, :delete) do
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module CustomFields
3
3
  #:nodoc:
4
- module Models
4
+ module Model
5
5
  ##
6
6
  # Model that represents a single custom field. This model has the following
7
7
  # relations:
@@ -21,7 +21,7 @@ module CustomFields
21
21
  class CustomField < Sequel::Model
22
22
  one_to_many(
23
23
  :custom_field_values,
24
- :class => "CustomFields::Models::CustomFieldValue"
24
+ :class => "CustomFields::Model::CustomFieldValue"
25
25
  )
26
26
 
27
27
  plugin :sluggable, :source => :name, :freeze => false
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module CustomFields
3
3
  #:nodoc:
4
- module Models
4
+ module Model
5
5
  ##
6
6
  # Model that represents a single custom field group. This model has
7
7
  # the following relations:
@@ -18,13 +18,13 @@ module CustomFields
18
18
  class CustomFieldGroup < Sequel::Model
19
19
  one_to_many(
20
20
  :custom_fields,
21
- :class => "CustomFields::Models::CustomField",
21
+ :class => "CustomFields::Model::CustomField",
22
22
  :order => :sort_order
23
23
  )
24
24
 
25
25
  many_to_many(
26
26
  :sections,
27
- :class => "Sections::Models::Section"
27
+ :class => "Sections::Model::Section"
28
28
  )
29
29
 
30
30
  ##
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module CustomFields
3
3
  #:nodoc:
4
- module Models
4
+ module Model
5
5
  ##
6
6
  # Model that represents a single custom field value. This model
7
7
  # has the following relations:
@@ -15,8 +15,8 @@ module CustomFields
15
15
  # @since 0.1
16
16
  #
17
17
  class CustomFieldValue < Sequel::Model
18
- many_to_one(:custom_field , :class => "CustomFields::Models::CustomField")
19
- many_to_one(:section_entry, :class => "Sections::Models::SectionEntry")
18
+ many_to_one(:custom_field , :class => "CustomFields::Model::CustomField")
19
+ many_to_one(:section_entry, :class => "Sections::Model::SectionEntry")
20
20
 
21
21
  ##
22
22
  # Hook that is executed before saving a field's value. This hook is used to clean
@@ -21,7 +21,9 @@
21
21
  <th>#{lang('custom_field_groups.labels.name')}</th>
22
22
  <th>#{lang('custom_field_groups.labels.sections')}</th>
23
23
 
24
- <?r if user_authorized?([:create]) ?>
24
+ <?r if user_authorized?(
25
+ [:read], true, 'CustomFields::Controller::CustomFields'
26
+ ) ?>
25
27
  <th></th>
26
28
  <?r end ?>
27
29
  </tr>
@@ -41,7 +43,7 @@
41
43
  <td>
42
44
  #{anchor_to(
43
45
  group.name,
44
- CustomFields::Controllers::CustomFieldGroups.r(:edit, group.id),
46
+ CustomFields::Controller::CustomFieldGroups.r(:edit, group.id),
45
47
  :title => group.name
46
48
  )}
47
49
  </td>
@@ -58,11 +60,13 @@
58
60
  <?r end ?>
59
61
  </td>
60
62
 
61
- <?r if user_authorized?([:create]) ?>
63
+ <?r if user_authorized?(
64
+ [:read], true, 'CustomFields::Controller::CustomFields'
65
+ ) ?>
62
66
  <td>
63
67
  #{anchor_to(
64
68
  lang('custom_field_groups.labels.manage_fields'),
65
- CustomFields::Controllers::CustomFields.r(:index, group.id)
69
+ CustomFields::Controller::CustomFields.r(:index, group.id)
66
70
  )}
67
71
  </td>
68
72
  <?r end ?>
@@ -84,7 +88,7 @@
84
88
  <div class="button">
85
89
  #{anchor_to(
86
90
  lang('custom_field_groups.buttons.new'),
87
- CustomFields::Controllers::CustomFieldGroups.r(:new)
91
+ CustomFields::Controller::CustomFieldGroups.r(:new)
88
92
  )}
89
93
  </div>
90
94
  <?r end ?>
@@ -45,7 +45,7 @@ form_for(
45
45
  f.select(
46
46
  lang('custom_fields.labels.format'),
47
47
  :format,
48
- :values => @format_hash,
48
+ :values => Zen::Plugin::Markup::Engines,
49
49
  :size => 1,
50
50
  :selected => @custom_field.format
51
51
  )