zen 0.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. data/.aspell.en.pws +31 -0
  2. data/.gems +1 -1
  3. data/.mailmap +1 -0
  4. data/.travis.yml +13 -7
  5. data/.yardopts +1 -1
  6. data/Rakefile +2 -2
  7. data/guide/changelog.md +23 -5
  8. data/guide/css/common.css +48 -0
  9. data/guide/javascript.md +1 -0
  10. data/guide/javascript/zen_form.md +46 -0
  11. data/guide/zen_compared.md +104 -0
  12. data/lib/zen.rb +21 -12
  13. data/lib/zen/helper/breadcrumb.rb +1 -1
  14. data/lib/zen/helper/message.rb +4 -5
  15. data/lib/zen/language.rb +75 -10
  16. data/lib/zen/markup.rb +20 -8
  17. data/lib/zen/model/init.rb +14 -9
  18. data/lib/zen/model/plugin/events.rb +1 -1
  19. data/lib/zen/package.rb +71 -14
  20. data/lib/zen/package/categories/lib/categories/controller/categories.rb +39 -12
  21. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +26 -5
  22. data/lib/zen/package/categories/lib/categories/helper/category.rb +37 -6
  23. data/lib/zen/package/categories/lib/categories/helper/category_frontend.rb +2 -2
  24. data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +26 -29
  25. data/lib/zen/package/comments/lib/comments.rb +9 -1
  26. data/lib/zen/package/comments/lib/comments/anti_spam.rb +1 -1
  27. data/lib/zen/package/comments/lib/comments/controller/comments.rb +59 -14
  28. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +49 -11
  29. data/lib/zen/package/comments/lib/comments/helper/comment.rb +14 -2
  30. data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +3 -3
  31. data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +1 -1
  32. data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +12 -0
  33. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +24 -6
  34. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +68 -20
  35. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +106 -26
  36. data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +50 -11
  37. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +2 -2
  38. data/lib/zen/package/dashboard/lib/dashboard/controller/dashboard.rb +1 -1
  39. data/lib/zen/package/menu.rb +6 -1
  40. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +44 -9
  41. data/lib/zen/package/menus/lib/menus/controller/menus.rb +53 -13
  42. data/lib/zen/package/menus/lib/menus/helper/menu.rb +30 -4
  43. data/lib/zen/package/menus/lib/menus/model/menu.rb +4 -2
  44. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +48 -9
  45. data/lib/zen/package/sections/lib/sections/controller/sections.rb +77 -21
  46. data/lib/zen/package/sections/lib/sections/helper/section.rb +32 -4
  47. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +1 -1
  48. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +5 -4
  49. data/lib/zen/package/sections/lib/sections/view/admin/sections/form.xhtml +3 -3
  50. data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +1 -1
  51. data/lib/zen/package/settings/lib/settings/blue_form_parameters.rb +2 -2
  52. data/lib/zen/package/settings/lib/settings/controller/settings.rb +60 -15
  53. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +1 -1
  54. data/lib/zen/package/users/lib/users/controller/user_groups.rb +42 -7
  55. data/lib/zen/package/users/lib/users/controller/users.rb +78 -16
  56. data/lib/zen/package/users/lib/users/helper/users.rb +29 -4
  57. data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +2 -2
  58. data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +2 -2
  59. data/lib/zen/public/admin/zen/css/general.css +5 -0
  60. data/lib/zen/public/admin/zen/css/messages.css +1 -0
  61. data/lib/zen/public/admin/zen/css/tables.css +33 -0
  62. data/lib/zen/public/admin/zen/css/tabs.css +8 -0
  63. data/lib/zen/public/admin/zen/js/index.js +21 -2
  64. data/lib/zen/public/admin/zen/js/lib/events.js +45 -0
  65. data/lib/zen/public/admin/zen/js/lib/form.js +229 -0
  66. data/lib/zen/public/admin/zen/js/lib/hash.js +0 -27
  67. data/lib/zen/task/spelling.rake +97 -0
  68. data/lib/zen/task/test.rake +21 -0
  69. data/lib/zen/theme.rb +80 -24
  70. data/lib/zen/validation.rb +1 -1
  71. data/lib/zen/version.rb +1 -1
  72. data/proto/app/config/config.rb.erb +9 -4
  73. data/proto/app/config/middlewares.rb +1 -2
  74. data/spec/README.md +56 -0
  75. data/spec/zen/controller/admin_controller.rb +0 -1
  76. data/spec/zen/controller/preview.rb +0 -1
  77. data/spec/zen/package.rb +32 -0
  78. data/spec/zen/package/categories/controller/categories.rb +7 -0
  79. data/spec/zen/package/categories/controller/category_groups.rb +7 -0
  80. data/spec/zen/package/comments/controller/comments.rb +7 -0
  81. data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +7 -0
  82. data/spec/zen/package/custom_fields/controller/custom_field_types.rb +7 -0
  83. data/spec/zen/package/custom_fields/controller/custom_fields.rb +7 -0
  84. data/spec/zen/package/menus/controller/menu_items.rb +7 -0
  85. data/spec/zen/package/menus/controller/menus.rb +7 -0
  86. data/spec/zen/package/menus/helper/menu_frontend.rb +1 -1
  87. data/spec/zen/package/sections/controller/section_entries.rb +39 -0
  88. data/spec/zen/package/sections/controller/sections.rb +14 -0
  89. data/spec/zen/package/users/controller/user_groups.rb +7 -0
  90. data/spec/zen/package/users/controller/users.rb +7 -0
  91. data/zen.gemspec +6 -5
  92. metadata +142 -40
@@ -38,7 +38,7 @@ module Ramaze
38
38
  end
39
39
 
40
40
  ##
41
- # Retrieves all breacrumbs and separates them either by "»" or a
41
+ # Retrieves all breadcrumbs and separates them either by "»" or a
42
42
  # custom element set as the first argument of this method.
43
43
  #
44
44
  # @example
@@ -5,10 +5,9 @@ module Ramaze
5
5
  #:nodoc:
6
6
  module Helper
7
7
  ##
8
- # The Mesage helper is a Ruby implementation of the Codeigniter library
9
- # "Message" (located here: https://github.com/isset/codeigniter-message).
10
- # This helper was taken from another project of mine which can be found here:
11
- # https://github.com/yorickpeterse/stumpert/
8
+ # Helper that wraps around Ramaze's flash helper and provides an easy way of
9
+ # setting messages (errors, informal messages, etc) as well as rendering the
10
+ # required HTML.
12
11
  #
13
12
  # ## Usage
14
13
  #
@@ -52,7 +51,7 @@ module Ramaze
52
51
  gestalt = ::Ramaze::Gestalt.new
53
52
 
54
53
  return if flash[:messages].nil?
55
-
54
+
56
55
  gestalt.div(:id => 'message_container', :class => 'container') do
57
56
  # Render each individual group
58
57
  types.each do |type|
data/lib/zen/language.rb CHANGED
@@ -20,18 +20,55 @@ module Zen
20
20
  #
21
21
  # When adding a language you **must** set the following items:
22
22
  #
23
- # * **name**: the language code as defined in [ISO 639][iso 639]. Examples of
24
- # these codes are "en-GB", "nl", etc. At the moment Zen does not have
25
- # different language files for British English and American English.
26
- # * **title**: the name of the language in a human friendly form. This name
27
- # should be set in the specific language. For example, for Dutch the title
28
- # would be "Nederlands".
23
+ # <table class="table full">
24
+ # <thead>
25
+ # <tr>
26
+ # <th>Attribute</th>
27
+ # <th>Description</th>
28
+ # </tr>
29
+ # </thead>
30
+ # <tbody>
31
+ # <tr>
32
+ # <td>name</td>
33
+ # <td>
34
+ # The language code as defined in
35
+ # <a href="https://en.wikipedia.org/wiki/ISO_639">ISO 369</a>.
36
+ # Examples of these codes are "en-GB", "nl", etc.
37
+ # </td>
38
+ # </tr>
39
+ # <tr>
40
+ # <td>title</td>
41
+ # <td>
42
+ # A human friendly version of the name of the language. This
43
+ # name should be set in the specific language. For example,
44
+ # for Dutch the title should be "Nederlands" instead of
45
+ # "Dutch".
46
+ # </td>
47
+ # </tr>
48
+ # </tbody>
49
+ # </table>
29
50
  #
30
51
  # Optionally you can also set the following attributes:
31
52
  #
32
- # * **rtl**: indicates that the language reads from right to left. When set to
33
- # true the ``<html>`` tag will have an extra ``dir`` attribute so that
34
- # browsers can properly display the text from right to left.
53
+ # <table class="table full">
54
+ # <thead>
55
+ # <tr>
56
+ # <th>Attribute</th>
57
+ # <th>Description</th>
58
+ # </tr>
59
+ # </thead>
60
+ # <tbody>
61
+ # <tr>
62
+ # <td>rtl</td>
63
+ # <td>
64
+ # indicates that the language reads from right to left. When
65
+ # set to true the html tag will have an extra "dir" attribute
66
+ # so that browsers can properly display the text from right to
67
+ # left.
68
+ # </td>
69
+ # </tr>
70
+ # </tbody>
71
+ # </table>
35
72
  #
36
73
  # ## Adding Translations
37
74
  #
@@ -118,7 +155,7 @@ module Zen
118
155
  # namespace).
119
156
  #
120
157
  # In the last case missing language files will be loaded if possible. However,
121
- # it is recommended that you pre-load your language files before starting the
158
+ # it is recommended that you load your language files before starting the
122
159
  # application. By doing this these translations don't have to be loaded during
123
160
  # an HTTP request which could potentially slow down the application.
124
161
  #
@@ -127,6 +164,25 @@ module Zen
127
164
  #
128
165
  # Zen::Language.load('foobar')
129
166
  #
167
+ # Due to the way the language system works it's impossible to load these
168
+ # before {Zen.start} is called. The recommended way of loading a language file
169
+ # is by wrapping it in an event listener for the "post_start" event:
170
+ #
171
+ # Zen::Event.listen :post_start do
172
+ # Zen::Language.load('example')
173
+ # end
174
+ #
175
+ # The reason for this requirement is that language files are stored in a cache
176
+ # (Ramaze::Cache::LRU by default) and this cache isn't set up until
177
+ # {Zen.start} is called.
178
+ #
179
+ # <div class="note todo">
180
+ # <p>
181
+ # This can't be stressed enough: always load language files using the
182
+ # post_start event.
183
+ # </p>
184
+ # </div>
185
+ #
130
186
  # ## Using Translations
131
187
  #
132
188
  # Once the entire process of adding and loading a language file has been
@@ -148,6 +204,15 @@ module Zen
148
204
  # lang('foobar')
149
205
  # lang('foo bar')
150
206
  #
207
+ # <div class="note todo">
208
+ # <p>
209
+ # Because language files aren't loaded until Zen.start is called you
210
+ # should never use or rely on translations before the application has
211
+ # started. Most of the core code works around this by loading
212
+ # translations using blocks whenever they're needed.
213
+ # </p>
214
+ # </div>
215
+ #
151
216
  # [iso 639]: https://en.wikipedia.org/wiki/ISO_639
152
217
  #
153
218
  # @since 0.2
data/lib/zen/markup.rb CHANGED
@@ -11,7 +11,7 @@ module Zen
11
11
  # html = Zen::Markup.convert(:markdown, 'Hello **world**')
12
12
  #
13
13
  # When converting Markdown or Textile Zen will automatically install the
14
- # required gems. For Markdown RDiscount is used, for Textile RedCloth is used.
14
+ # required gems. For Markdown Redcarpet is used, for Textile RedCloth is used.
15
15
  #
16
16
  # You may be tempted to call the various methods directly but it is not
17
17
  # recommended to do so. For example, you might have the following code:
@@ -36,12 +36,12 @@ module Zen
36
36
  # Adding a new engine is relatively easy and is done in two steps. First you
37
37
  # should add the name of your engine and it's label to
38
38
  # {Zen::Markup::REGISTERED}. The keys of this hash should be the methods to
39
- # call, teh values will be displayed in various ``<select>`` elements in the
39
+ # call, the values will be displayed in various ``<select>`` elements in the
40
40
  # administration interface.
41
41
  #
42
42
  # Zen::Markup::REGISTERED['my_markup'] = 'My Markup'
43
43
  #
44
- # In this example the label is hardcoded but it's recommended to use
44
+ # In this example the label is hard coded but it's recommended to use
45
45
  # {Zen::Language.lang} instead.
46
46
  #
47
47
  # Once the engine has been added to the list you'll have to add a
@@ -83,6 +83,13 @@ module Zen
83
83
  'html' => 'zen_general.markup.html'
84
84
  }
85
85
 
86
+ # Hash containing the configuration options to use for Redcarpet.
87
+ REDCARPET_OPTIONS = {
88
+ :tables => true,
89
+ :fenced_code_blocks => true,
90
+ :strikethrough => true
91
+ }
92
+
86
93
  class << self
87
94
  include ::Ramaze::Helper::CGI
88
95
 
@@ -123,23 +130,28 @@ module Zen
123
130
  private
124
131
 
125
132
  ##
126
- # Converts the Markdown markup to HTML using RDiscount.
133
+ # Converts the Markdown markup to HTML using Redcarpet.
127
134
  #
128
135
  # @example
129
136
  # Zen::Markup.markdown('Hello **world**')
130
137
  #
131
138
  # @since 0.2.5
132
139
  # @param [String] markup The Markdown string to convert to HTML.
133
- # @return [String] The HTML returned by RDiscount.
140
+ # @return [String] The HTML returned by Redcarpet.
134
141
  #
135
142
  def markdown(markup)
136
- unless Kernel.const_defined?(:RDiscount)
143
+ unless Kernel.const_defined?(:Redcarpet)
137
144
  Ramaze.setup(:verbose => false) do
138
- gem 'rdiscount'
145
+ gem 'redcarpet', ['>= 2.1.1']
139
146
  end
140
147
  end
141
148
 
142
- return RDiscount.new(markup).to_html
149
+ @markdown ||= Redcarpet::Markdown.new(
150
+ Redcarpet::Render::HTML,
151
+ REDCARPET_OPTIONS,
152
+ )
153
+
154
+ return @markdown.render(markup)
143
155
  end
144
156
 
145
157
  ##
@@ -1,5 +1,3 @@
1
- Zen::Language.load('zen_models')
2
-
3
1
  Sequel::Model.strict_param_setting = false
4
2
 
5
3
  Sequel::Model.plugin(:validation_helpers)
@@ -9,6 +7,13 @@ Sequel.extension(:migration)
9
7
  Sequel.extension(:pagination)
10
8
  Sequel.extension(:inflector)
11
9
 
10
+ Zen::Event.listen :post_start do
11
+ Zen::Language.load('zen_models')
12
+ end
13
+
14
+ # Note that the values for the :message keys should always be wrapped in
15
+ # lambdas. Doing so means the call to lang() won't be executed until it is
16
+ # actually needed.
12
17
  Sequel::Plugins::ValidationHelpers::DEFAULT_OPTIONS.merge!(
13
18
  {
14
19
  :exact_length => {
@@ -16,7 +21,7 @@ Sequel::Plugins::ValidationHelpers::DEFAULT_OPTIONS.merge!(
16
21
  },
17
22
 
18
23
  :format => {
19
- :message => lang('zen_models.format')
24
+ :message => lambda { lang('zen_models.format') }
20
25
  },
21
26
 
22
27
  :includes => {
@@ -25,12 +30,12 @@ Sequel::Plugins::ValidationHelpers::DEFAULT_OPTIONS.merge!(
25
30
  },
26
31
 
27
32
  :integer => {
28
- :message => lang('zen_models.integer'),
33
+ :message => lambda { lang('zen_models.integer') },
29
34
  :allow_nil => true
30
35
  },
31
36
 
32
37
  :length_range => {
33
- :message => lang('zen_models.length_range')
38
+ :message => lambda { lang('zen_models.length_range') }
34
39
  },
35
40
 
36
41
  :max_length => {
@@ -43,11 +48,11 @@ Sequel::Plugins::ValidationHelpers::DEFAULT_OPTIONS.merge!(
43
48
  },
44
49
 
45
50
  :not_string => {
46
- :message => lang('zen_models.not_string')
51
+ :message => lambda { lang('zen_models.not_string') }
47
52
  },
48
53
 
49
54
  :numeric => {
50
- :message => lang('zen_models.numeric')
55
+ :message => lambda { lang('zen_models.numeric') }
51
56
  },
52
57
 
53
58
  :type => {
@@ -55,10 +60,10 @@ Sequel::Plugins::ValidationHelpers::DEFAULT_OPTIONS.merge!(
55
60
  },
56
61
 
57
62
  :presence => {
58
- :message => lang('zen_models.presence')
63
+ :message => lambda { lang('zen_models.presence') }
59
64
  },
60
65
 
61
66
  :unique => {
62
- :message => lang('zen_models.unique')
67
+ :message => lambda { lang('zen_models.unique') }
63
68
  }
64
69
  })
@@ -70,7 +70,7 @@ module Sequel
70
70
 
71
71
  ##
72
72
  # Module containing the methods and attributes to make available on
73
- # instance leve.
73
+ # instance level.
74
74
  #
75
75
  # @since 06-02-2012
76
76
  #
data/lib/zen/package.rb CHANGED
@@ -19,17 +19,55 @@ module Zen
19
19
  #
20
20
  # When adding a package you must **always** set the following attributes:
21
21
  #
22
- # * name: the name of the package, should be a symbol
23
- # * title: the title of the package. This should be a language key such as
24
- # "users.titles.index" as this allows users to view the package name in
25
- # their chosen language.
26
- # * author: the name of the package's author.
27
- # * about: a description of the package, just like the title attribute this
28
- # should be a language key, "users.description" is an example of such a key.
29
- # * root: the root directory of the package, this path should point to the
30
- # directory containing your ``helper/`` and ``language/`` directories as
31
- # well as any ``public/`` directories.
32
- # * An innstance of OpenStruct that can be used for storing custom data.
22
+ # <table class="table full">
23
+ # <thead>
24
+ # <tr>
25
+ # <th>Attribute</th>
26
+ # <th>Description</th>
27
+ # </tr>
28
+ # </thead>
29
+ # <tbody>
30
+ # <tr>
31
+ # <td>name</td>
32
+ # <td>The name of the package, should be a symbol.</td>
33
+ # </tr>
34
+ # <tr>
35
+ # <td>title</td>
36
+ # <td>
37
+ # The title of the package. This should be a language key such
38
+ # as "users.titles.index' as it allows users to view the
39
+ # package name in their chosen language.
40
+ # </td>
41
+ # </tr>
42
+ # <tr>
43
+ # <td>author</td>
44
+ # <td>The name of the package's author.</td>
45
+ # </tr>
46
+ # <tr>
47
+ # <td>about</td>
48
+ # <td>
49
+ # A description of the package. Just like the title attribute
50
+ # this should be a language key.
51
+ # </td>
52
+ # </tr>
53
+ # <tr>
54
+ # <td>root</td>
55
+ # <td>
56
+ # The root directory of the package. This path should point to
57
+ # the directory containing your helper, language and other
58
+ # directories.
59
+ # </td>
60
+ # </tr>
61
+ # <tr>
62
+ # <td>env</td>
63
+ # <td>
64
+ # A special object (an instance of OpenStruct) that can be
65
+ # used for storing arbitrary data that might be needed by
66
+ # the package.
67
+ # </td>
68
+ # </tr>
69
+ # </tbody>
70
+ # </table>
33
71
  #
34
72
  # Setting these (and other) attributes is very easy:
35
73
  #
@@ -43,8 +81,27 @@ module Zen
43
81
  # Besides the required attributes listed above you can also set the following
44
82
  # ones:
45
83
  #
46
- # * url: a URL that points to the website of the package.
47
- # * migrations: a directory containing all Sequel migrations.
84
+ # <table class="table full">
85
+ # <thead>
86
+ # <tr>
87
+ # <th>Attribute</th>
88
+ # <th>Description</th>
89
+ # </tr>
90
+ # </thead>
91
+ # <tbody>
92
+ # <tr>
93
+ # <td>url</td>
94
+ # <td>A URL that points to the website of the package author.</td>
95
+ # </tr>
96
+ # <tr>
97
+ # <td>migrations</td>
98
+ # <td>
99
+ # A directory containing the Sequel migrations for the
100
+ # package.
101
+ # </td>
102
+ # </tr>
103
+ # </tbody>
104
+ # </table>
48
105
  #
49
106
  # ## Package Structure
50
107
  #
@@ -95,7 +152,7 @@ module Zen
95
152
  # Permissions allow you to restrict access to certain actions to specific
96
153
  # users/user groups. A permission can be added by calling ``permission()`` on
97
154
  # the object passed to the block. Again the title of the permission should be
98
- # a langauge key so it can be displayed in a custom language:
155
+ # a language key so it can be displayed in a custom language:
99
156
  #
100
157
  # Zen::Package.add do |p|
101
158
  # p.permission(:show_some_package, 'packages.titles.index')
@@ -27,18 +27,45 @@ module Categories
27
27
  #
28
28
  # In this form you can specify the following fields:
29
29
  #
30
- # * **Name** (required): the name of the category. This name can be anything
31
- # and there's no restriction to it's format. An example of such a name
32
- # would be "Code" or "Products".
33
- # * **Slug**: a URL friendly version of a category name. If no slug is
34
- # specified one will be generated based on the category name.
35
- # * **Parent**: the name of the parent category.
36
- # * **Description**: a description of the category. While not required it
37
- # can help you remember what the category is meant for in case the name
38
- # doesn't already make this clear enough.
39
- #
40
- # Note that both the name of a category and it's slug can not be longer than
41
- # 255 characters.
30
+ # <table class="table full">
31
+ # <thead>
32
+ # <tr>
33
+ # <th class="field_name">Field</th>
34
+ # <th>Required</th>
35
+ # <th>Maximum Length</th>
36
+ # <th>Description</th>
37
+ # </tr>
38
+ # </thead>
39
+ # <tbody>
40
+ # <tr>
41
+ # <td>Name</td>
42
+ # <td>Yes</td>
43
+ # <td>255</td>
44
+ # <td>The name of the category.</td>
45
+ # </tr>
46
+ # <tr>
47
+ # <td>Slug</td>
48
+ # <td>No</td>
49
+ # <td>255</td>
50
+ # <td>
51
+ # A URL friendly version of the name. If no custom slug is
52
+ # given one will be generated automatically.
53
+ # </td>
54
+ # </tr>
55
+ # <tr>
56
+ # <td>Parent</td>
57
+ # <td>No</td>
58
+ # <td></td>
59
+ # <td>The parent category.</td>
60
+ # </tr>
61
+ # <tr>
62
+ # <td>Description</td>
63
+ # <td>No</td>
64
+ # <td>Unlimited</td>
65
+ # <td>A short description of the category.</td>
66
+ # </tr>
67
+ # </tbody>
68
+ # </table>
42
69
  #
43
70
  # ## Used Permissions
44
71
  #