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
@@ -0,0 +1,258 @@
1
+ require 'ramaze/gestalt'
2
+
3
+ #:nodoc:
4
+ module Zen
5
+ ##
6
+ # The Asset module is a module used to register what Javascript files and stylesheets
7
+ # should be loaded for the current request. This can be very useful if you want to add
8
+ # a widget to all pages or override a certain stylesheet.
9
+ #
10
+ # ## Adding Assets
11
+ #
12
+ # Assets can be added by calling either Zen::Asset.stylesheet or Zen::Asset.javascript.
13
+ # Both take an array of files and a hash with some configuration options, for more info
14
+ # on the exact usage and all the available parameters see the individual methods. Here
15
+ # are a few quick examples of loading files:
16
+ #
17
+ # # Load 3 Javascript files of which 2 will be loaded globally
18
+ # Zen::Asset.javascript(
19
+ # ['mootools/core', 'mootools/more'], :global => true,
20
+ # )
21
+ #
22
+ # Zen::Asset.javascript(['application'], :controller => self)
23
+ #
24
+ # # Do the same with a few stylesheets
25
+ # Zen::Asset.stylesheet(['admin/css/forms'], :global => true)
26
+ # Zen::Asset.stylesheet(['style'], :controller => self)
27
+ #
28
+ # ## Customizing Options
29
+ #
30
+ # This module uses Innate::Optioned to provide a few options that can be changed. The
31
+ # following options are available:
32
+ #
33
+ # * prefix: The global prefix to use for all assets, set to "admin" by default.
34
+ # * javascript_prefix: The prefix to use for all Javascript files on top of the global
35
+ # prefix.
36
+ # * stylesheet_prefix: Similar to the javascript_prefix option but for stylesheets.
37
+ #
38
+ # ## Building Assets
39
+ #
40
+ # Building assets shouldn't be required as Zen already does this but if you happen to
41
+ # need it you can build the files as following:
42
+ #
43
+ # Zen::Asset.build(:stylesheet)
44
+ # Zen::Asset.build(:javascript)
45
+ #
46
+ # ## Controller Usage
47
+ #
48
+ # While this module can be called by any other piece of code the class
49
+ # Zen::Controller::AdminController provides shortcuts to Zen::Asset.javascript and
50
+ # Zen::Asset.stylesheet. These shortcuts work identical but are defined as class methods
51
+ # and thus can be used inside your class declaration:
52
+ #
53
+ # class Something < Zen::Controller::AdminController
54
+ # stylesheet ['reset'], :global => true
55
+ # end
56
+ #
57
+ # @author Yorick Peterse
58
+ # @since 0.2.5
59
+ #
60
+ module Asset
61
+ include ::Innate::Optioned
62
+
63
+ class << self
64
+ include ::Innate::Trinity
65
+ end
66
+
67
+ options.dsl do
68
+ o 'Prefix for both Javascript files and stylesheets', :prefix , 'admin'
69
+ o 'Prefix for Javascript files on top of :prefix' , :javascript_prefix, 'js'
70
+ o 'Prefix for stylesheets on top of :prefix' , :stylesheet_prefix, 'css'
71
+ end
72
+
73
+ ##
74
+ # Hash containing all the global and controller specific stylesheets that have to be
75
+ # loaded when calling build_stylesheets.
76
+ #
77
+ # @author Yorick Peterse
78
+ # @since 0.2.5
79
+ #
80
+ Stylesheets = {
81
+ :global => []
82
+ }
83
+
84
+ ##
85
+ # Hash containing all the global and controller specific stylesheets to load when
86
+ # calling build_javascripts.
87
+ #
88
+ # @author Yorick Peterse
89
+ # @since 0.2.5
90
+ #
91
+ Javascripts = {
92
+ :global => []
93
+ }
94
+
95
+ ##
96
+ # Registers the given Javascripts files so that they're either loaded for the
97
+ # current action or for all actions. Note that the first argument of this method
98
+ # should always be an array.
99
+ #
100
+ # @example
101
+ # # Loads /admin/js/users/access_rules.js for the current action only
102
+ # Zen::Asset.javascript ['users/access_rules']
103
+ #
104
+ # # This would load the file globally
105
+ # Zen::Asset.javascript ['users/access_rules'], :global => true
106
+ #
107
+ # @author Yorick Peterse
108
+ # @since 0.2.5
109
+ # @param [Array] files An array of Javascript files (without their extensions) to
110
+ # load relatively to the root of the application (/).
111
+ # @param [Hash] options A hash containing additional options.
112
+ # @option options [TrueClass] :global When set to true the specified files will be
113
+ # loaded globally rather than just for the current action.
114
+ # @option options [String/Symbol] controller The name of the controller for which
115
+ # the specified files should be loaded.
116
+ #
117
+ def self.javascript(files, options = {})
118
+ options = {
119
+ :prefix => File.join('/', self.options.prefix, self.options.javascript_prefix),
120
+ :type => :javascript
121
+ }.merge(options)
122
+
123
+ process(files, options)
124
+ end
125
+
126
+ ##
127
+ # Registers a number of stylesheets that can either be loaded globally or for the
128
+ # current action.
129
+ #
130
+ # @example
131
+ # Zen::Asset.stylesheet ['foobar/admin_template'], :global => true
132
+ #
133
+ # @author Yorick Peterse
134
+ # @since 0.2.5
135
+ # @param [Array] files A list of stylesheets (without their extensions) to load.
136
+ # @param [Hash] options A hash containing additional options to use.
137
+ # @option options [TrueClass] :global When set to true all the specified stylesheets
138
+ # will be loaded globally rather than just for the current action.
139
+ # @option options [String/Symbol] controller The name of the controller for which
140
+ # the specified files should be loaded.
141
+ #
142
+ def self.stylesheet(files, options = {})
143
+ options = {
144
+ :prefix => File.join('/', self.options.prefix, self.options.stylesheet_prefix),
145
+ :type => :stylesheet
146
+ }.merge(options)
147
+
148
+ process(files, options)
149
+ end
150
+
151
+ ##
152
+ # Builds either all Javascript files or stylesheets. This method will load both the
153
+ # global and action specific files.
154
+ #
155
+ # @example
156
+ # # Build the HTML tags for all stylesheets
157
+ # Zen::Asset.build(:stylesheet)
158
+ #
159
+ # # Build the HTML tags for all Javascript files
160
+ # Zen::Asset.build(:javascript)
161
+ #
162
+ # @author Yorick Peterse
163
+ # @since 0.2.5
164
+ # @param [Symbol] type The type of assets to build.
165
+ # @return [String] The HTML tags for all the assets.
166
+ #
167
+ def self.build(type)
168
+ type = type.to_sym
169
+ attrs = {}
170
+ controller = action.node.to_s.to_sym
171
+ gestalt = Ramaze::Gestalt.new
172
+
173
+ # Set the basic elements of the tag
174
+ if type === :stylesheet
175
+ tag = :link
176
+ value = :href
177
+ attrs[:rel] = 'stylesheet'
178
+ files = Stylesheets
179
+ else
180
+ tag = :script
181
+ value = :src
182
+ files = Javascripts
183
+ end
184
+
185
+ # Get all the files to build
186
+ if !files[controller].nil?
187
+ files = files[:global] + files[controller]
188
+ else
189
+ files = files[:global]
190
+ end
191
+
192
+ # Build the tags
193
+ files.each do |f|
194
+ tag_attrs = {
195
+ value => f
196
+ }.merge(attrs)
197
+
198
+ if type === :javascript
199
+ gestalt.send(tag, '', tag_attrs)
200
+ else
201
+ gestalt.send(tag, tag_attrs)
202
+ end
203
+ end
204
+
205
+ return gestalt.to_s
206
+ end
207
+
208
+ private
209
+
210
+ ##
211
+ # Stores the given files in the correct hash based on the specified options.
212
+ #
213
+ # @example
214
+ # process(['foobar', 'baz'], :global => false, :type => :javascript, :prefix => 'js')
215
+ #
216
+ # @author Yorick Peterse
217
+ # @since 0.2.5
218
+ # @param [Array] files An array of files to load.
219
+ # @param [Hash] options A hash containing all the required options.
220
+ # @option options [TrueClass] :global Specifies that all the files should be loaded
221
+ # globally.
222
+ # @option options [Symbol] :type The type of asset that's loaded, can either be
223
+ # :javascript or :stylesheet.
224
+ # @option options [String] :prefix The prefix to use for all the assets.
225
+ # @option options [TrueClass] :global
226
+ # @option options [Symbol/String] :controller
227
+ #
228
+ def self.process(files, options)
229
+ # Determine whether the files should be loaded globally
230
+ if options.key?(:global) and options[:global] === true
231
+ key = :global
232
+ else
233
+ key = options[:controller].to_s.to_sym
234
+ end
235
+
236
+ # Determine where to save the data
237
+ if options[:type] === :javascript
238
+ save = Javascripts
239
+ ext = '.js'
240
+ else
241
+ save = Stylesheets
242
+ ext = '.css'
243
+ end
244
+
245
+ # Add all the files
246
+ files.each do |f|
247
+ f = f.to_s + ext
248
+ f = File.join(options[:prefix], f)
249
+ save[key] ||= []
250
+
251
+ if !save[key].include?(f)
252
+ save[key].push(f)
253
+ end
254
+ end
255
+ end
256
+
257
+ end
258
+ end
@@ -0,0 +1,42 @@
1
+ require 'fileutils'
2
+
3
+ ##
4
+ # Command that can be used to generate a new application.
5
+ #
6
+ # @author Yorick Peterse
7
+ # @since 0.2.5
8
+ #
9
+ command :app do |cmd|
10
+
11
+ # Set a few details of the command
12
+ cmd.syntax = '$ zen app [NAME]'
13
+ cmd.description = 'Creates a new application powered by Zen.'
14
+
15
+ cmd.option('-f', TrueClass, 'Overwrites any existing application.')
16
+
17
+ # The action to execute when the command is invoked
18
+ cmd.action do |args, opts|
19
+ if args.empty?
20
+ abort 'You need to specify a name for the application.'
21
+ end
22
+
23
+ name = args[0]
24
+ app = File.join('./', name)
25
+ proto = File.expand_path('../../../../proto/app', __FILE__)
26
+
27
+ if File.directory?(app) and !opts.f
28
+ abort "The application #{app} alread exists, use -f to overwrite it."
29
+ else
30
+ FileUtils.rm_rf(app)
31
+ end
32
+
33
+ # Copy the prototype
34
+ begin
35
+ FileUtils.cp_r(proto, app)
36
+ puts "The application has been generated and saved in #{app}"
37
+ rescue => e
38
+ abort "Failed to generate the application: #{e.message}"
39
+ end
40
+ end
41
+
42
+ end
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module Zen
3
3
  #:nodoc:
4
- module Controllers
4
+ module Controller
5
5
  ##
6
6
  # The admin controller is a base controller that should be extended by all controllers
7
7
  # for the backend of Zen. This controller will automatically check to see if the
@@ -15,26 +15,14 @@ module Zen
15
15
  # Users controller, mapped to /admin/users/login. If a user isn't logged in he/she
16
16
  # will be redirected to the login page.
17
17
  #
18
- # ## Helpers
19
- #
20
- # The admin controller loads the following helpers:
21
- #
22
- # * CSRF
23
- # * BlueForm
24
- # * Common
25
- # * Breadcrumb
26
- # * User
27
- # * ACL
28
- # * Asset
29
- #
30
18
  # @author Yorick Peterse
31
19
  # @since 0.1
32
20
  #
33
- class AdminController < Zen::Controllers::BaseController
21
+ class AdminController < Zen::Controller::BaseController
34
22
  layout :admin
35
23
  engine :etanni
36
- helper :blue_form, :common, :breadcrumb, :user, :acl, :asset
37
-
24
+ helper :blue_form, :common, :breadcrumb, :user, :acl
25
+
38
26
  ##
39
27
  # The initialize method is called upon class initalization and is used to process several
40
28
  # items before loading the controller(s) for the current extension.
@@ -44,37 +32,66 @@ module Zen
44
32
  #
45
33
  def initialize
46
34
  super
47
-
48
- # Load our CSS and Javascript files
49
- require_css(
50
- 'boilerplate', 'grid', 'layout', 'general', 'forms', 'tables', 'buttons',
51
- 'tabs', 'notifications', 'editor'
52
- )
53
-
54
- require_js('zen/tabs', 'zen/notification', 'zen/modal', 'zen/editor/base',
55
- 'zen/editor/drivers/html', 'zen/editor/drivers/textile', 'zen/editor/drivers/markdown',
56
- 'zen/init'
57
- )
58
-
35
+
59
36
  # Only allow users to access admin/users/login when they aren't logged in
60
37
  if request.env['SCRIPT_NAME'] != 'admin/users/' and request.env['PATH_INFO'] != '/login'
61
38
  redirect '/admin/users/login' unless logged_in?
62
39
  end
63
40
 
64
- # Hash containing all available formats for input fields
65
- @format_hash = {
66
- 'html' => lang('zen_general.special.format_hash.html'),
67
- 'textile' => lang('zen_general.special.format_hash.textile'),
68
- 'markdown' => lang('zen_general.special.format_hash.markdown'),
69
- 'plain' => lang('zen_general.special.format_hash.plain')
70
- }
71
-
72
41
  @boolean_hash = {
73
42
  true => lang('zen_general.special.boolean_hash.true'),
74
43
  false => lang('zen_general.special.boolean_hash.false')
75
44
  }.invert
45
+ end
46
+
47
+ ##
48
+ # Shortcut for Zen::Asset.stylesheet.
49
+ #
50
+ # @author Yorick Peterse
51
+ # @see Zen::Asset.stylesheet
52
+ # @since 0.2.5
53
+ #
54
+ def self.stylesheet(files, options = {})
55
+ options = {
56
+ :controller => self
57
+ }.merge(options)
76
58
 
59
+ ::Zen::Asset.stylesheet(files, options)
77
60
  end
61
+
62
+ ##
63
+ # Shortcut for Zen::Asset.javascript.
64
+ #
65
+ # @author Yorick Peterse
66
+ # @see Zen::Asset.javascript
67
+ # @since 0.2.5
68
+ #
69
+ def self.javascript(files, options = {})
70
+ options = {
71
+ :controller => self
72
+ }.merge(options)
73
+
74
+ ::Zen::Asset.javascript(files, options)
75
+ end
76
+
77
+ # Load all stylesheets globally
78
+ stylesheet(
79
+ [
80
+ 'reset', 'grid', 'layout', 'general', 'forms', 'tables', 'buttons',
81
+ 'notifications'
82
+ ],
83
+ :global => true
84
+ )
85
+
86
+ # Load all global javascript files
87
+ javascript(
88
+ [
89
+ 'mootools/core', 'mootools/more', 'vendor/yepnope', 'zen/notification',
90
+ 'zen/init',
91
+ ],
92
+ :global => true
93
+ )
94
+
78
95
  end
79
96
  end
80
97
  end
@@ -1,7 +1,7 @@
1
1
  #:nodoc:
2
2
  module Zen
3
3
  #:nodoc:
4
- module Controllers
4
+ module Controller
5
5
  ##
6
6
  # The BaseController is extended by both the FrontendController and the
7
7
  # BackendController. This controller is mostly used to set and retrieve data that's
@@ -24,15 +24,20 @@ module Zen
24
24
  #
25
25
  def initialize
26
26
  super
27
-
28
- # Get all settings
29
- if !@settings
30
- @settings = ::Settings::Models::Setting.get_settings
27
+
28
+ # Store the settings data if this is the first time we're loading the controller
29
+ if ::Zen::Settings.empty?
30
+ ::Settings::Model::Setting.get_settings.each do |k, v|
31
+ ::Zen::Settings[k] = v
32
+ end
31
33
  end
32
-
34
+
33
35
  # Override the language
34
- ::Zen::Language.options.language = @settings[:language]
35
- ::Zen::Language.load('zen_general')
36
+ if ::Zen::Settings[:language] != ::Zen::Language.options.language
37
+ # Reload the language pack
38
+ ::Zen::Language.options.language = ::Zen::Settings[:language]
39
+ ::Zen::Language.load('zen_general')
40
+ end
36
41
  end
37
42
  end
38
43
  end