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,109 +0,0 @@
1
- require 'fileutils'
2
- require 'ruby-extensions'
3
-
4
- #:nodoc:
5
- module Zen
6
- #:nodoc:
7
- module Bin
8
- ##
9
- # Main binary class that contains a few methods that can be used
10
- # to generate new applications, extensions and so on.
11
- #
12
- # @author Yorick Peterse
13
- # @since 0.1
14
- #
15
- class Base < Thor
16
-
17
- map ["-v", "--version"] => :version
18
-
19
- # ------------------------------------------------
20
-
21
- desc "app [NAME]", "Creates a new Zen application"
22
- method_option :force, :type => :boolean, :aliases => "-f",
23
- :desc => "Overwrites any existing directories"
24
-
25
- ##
26
- # Creates a new Zen application using a prototype extracted from the
27
- # Rubygem package.
28
- #
29
- # @author Yorick Peterse
30
- # @param [String] name The name of the new application
31
- # @since 0.1
32
- #
33
- def app(name)
34
- # Do we have an application name?
35
- if name.nil?
36
- abort "You need to specify a name for your application"
37
- end
38
-
39
- app = './' + name
40
- proto = __DIR__('../../../proto/app')
41
-
42
- if File.directory?(app) and !options.force?
43
- abort "Application already exists, use -f to overwrite it"
44
- else
45
- FileUtils.rm_rf(app)
46
- end
47
-
48
- # Copy the prototype
49
- begin
50
- FileUtils.cp_r(proto, app)
51
-
52
- puts "Application generated, now do the following:
53
- 1. edit the following configuration files:
54
- * config/database.rb
55
- * config/config.rb
56
- 2. run thor db:migrate to install all extensions and create a default user
57
- 3. have fun!"
58
- rescue => e
59
- abort "Failed to generate the application: #{e}"
60
- end
61
- end
62
-
63
- # ------------------------------------------------
64
-
65
- desc "version", "Shows the current version of Zen"
66
-
67
- ##
68
- # Shows the current version of Zen
69
- #
70
- # @author Yorick Peterse
71
- # @since 0.1
72
- #
73
- def version
74
- puts "Zen v#{Zen::Version}"
75
- end
76
-
77
- # ------------------------------------------------
78
-
79
- ##
80
- # Override the help method provided by Thor
81
- # so we can show our custom banner.
82
- #
83
- # @author Yorick Peterse
84
- # @see Thor.help()
85
- # @since 0.1
86
- #
87
- def help(task = nil, subcommand = false)
88
- if task.nil?
89
- puts "Zen is a modular CMS written using Ramaze.
90
-
91
- Usage:
92
- $ zen [command] [arguments] [flags]
93
-
94
- Example:
95
- $ zen app blog
96
-
97
- Project Details:
98
- * website: http://zen-cms.com/
99
- * github: https://github.com/zen-cms/
100
- * version: v#{Zen::Version}
101
-
102
- "
103
- end
104
-
105
- super(task, subcommand)
106
- end
107
- end
108
- end
109
- end
@@ -1,106 +0,0 @@
1
- require 'ramaze/gestalt'
2
-
3
- #:nodoc:
4
- module Ramaze
5
- #:nodoc:
6
- module Helper
7
- ##
8
- # The Asset helper can be used to load Javascript and CSS files without
9
- # having to embedd them in your views. In order to tell the helper that
10
- # a CSS or Javascript file has to be loaded you'll have to call the
11
- # require_* method. For example, if we want to require a CSS file named
12
- # "reset" we'd do the following:
13
- #
14
- # register_css('reset')
15
- #
16
- # Once you have your files required you can build the HTML by either calling
17
- # build_css or build_js.
18
- #
19
- # @author Yorick Peterse
20
- # @since 0.1
21
- # @todo Add support for compressing Javascript and CSS files.
22
- #
23
- module Asset
24
- @css = []
25
- @js = []
26
-
27
- ##
28
- # Requires a new CSS file.
29
- #
30
- # @author Yorick Peterse
31
- # @param [Symbol] files Paths to the CSS files to require.
32
- # @since 0.1
33
- #
34
- def require_css(*files)
35
- if @css.nil?
36
- @css = []
37
- end
38
-
39
- files.each do |file|
40
- file = file.to_sym
41
-
42
- if !@css.include?(file)
43
- @css.push(file)
44
- end
45
- end
46
- end
47
-
48
- ##
49
- # Requires a new Javascript file.
50
- #
51
- # @author Yorick Peterse
52
- # @param [Symbol] files Paths to the Javascript files to require.
53
- # @since 0.1
54
- #
55
- def require_js(*files)
56
- if @js.nil?
57
- @js = []
58
- end
59
-
60
- files.each do |file|
61
- file = file.to_sym
62
-
63
- if !@js.include?(file)
64
- @js.push(file)
65
- end
66
- end
67
- end
68
-
69
- ##
70
- # Builds the HTML for all CSS tags using Gestalt.
71
- #
72
- # @author Yorick Peterse
73
- # @since 0.1
74
- # @return [String]
75
- #
76
- def build_css
77
- g = Ramaze::Gestalt.new
78
-
79
- @css.each do |css|
80
- css = "/admin/css/#{css}.css"
81
- g.link :rel => "stylesheet", :href => css, :media => "all", :type => "text/css"
82
- end
83
-
84
- return g.to_s
85
- end
86
-
87
- ##
88
- # Builds the HTML for all Javascript tags using Gestalt.
89
- #
90
- # @author Yorick Peterse
91
- # @since 0.1
92
- # @return [String]
93
- #
94
- def build_js
95
- g = Ramaze::Gestalt.new
96
-
97
- @js.each do |js|
98
- js = "/admin/js/#{js}.js"
99
- g.script(:src => js) {}
100
- end
101
-
102
- return g.to_s
103
- end
104
- end
105
- end
106
- end
@@ -1,94 +0,0 @@
1
- #:nodoc:
2
- module Zen
3
- #:nodoc:
4
- module Liquid
5
- ##
6
- # Module that provides several methods that can be used to ease the process of
7
- # creating Liquid tags.
8
- #
9
- # @author Yorick Peterse
10
- # @since 0.1
11
- #
12
- module General
13
- include ::Ramaze::Helper::CGI
14
-
15
- ##
16
- # Parses all additional data specified in the tag open block
17
- # and turns it into a key/value hash. This makes it easier to
18
- # use tags with key/value variables such as the following:
19
- #
20
- # {% my_tag name="yorick" %}
21
- #
22
- # @author Yorick Peterse
23
- # @since 0.1
24
- # @param [String] string the raw string specified after the tag name.
25
- # @return [Hash] A key/value hash of all specified arguments.
26
- #
27
- def parse_key_values(string)
28
- key_values = {}
29
-
30
- # Thanks to Michael Trommer (https://github.com/entropie) for coming up with
31
- # this way of parsing the key/value string.
32
- string.split(/["']([^"]*)["']|\s/).reject{ |s| s.empty? }.each_slice(2) do |key, val|
33
- key_values[ key[0..-2].to_s ] = val
34
- end
35
-
36
- # Returns the data in the format of {'key' => 'value'}
37
- return key_values
38
- end
39
-
40
- ##
41
- # Merges the values in the given context with the hash. This means that if the
42
- # Liquid context has a key that matches a value in the hash that key's value
43
- # will become the value of the key in the hash. Confused? Assume our context has
44
- # a key of "username" which is set to "YorickPeterse". If our hash had a key
45
- # who's value is "username" that value would be replaced with "YorickPeterse".
46
- #
47
- # If context was a hash (it's an object) this would result in something like the
48
- # following:
49
- #
50
- # context = {'username' => 'YorickPeterse'}
51
- # hash = {'selected_user' => 'username'}
52
- #
53
- # merge_context(hash, context) # => {'selected_user' => 'YorickPeterse'}
54
- #
55
- # This method will also automatically escape all variables using the h() method
56
- # so you don't have to worry about nasty input.
57
- #
58
- # @author Yorick Peterse
59
- # @since 0.2a
60
- # @param [Hash] hash The input hash that may contain Liquid variables
61
- # @param [Liquid::Context] context The Liquid context from which to extract any
62
- # variables set in the hash.
63
- # @return [Hash] The merged hash.
64
- #
65
- def merge_context(hash, context)
66
- if hash.class != Hash
67
- raise(
68
- TypeError,
69
- "The first argument of this method should be a hash instead of \"#{hash.class}\""
70
- )
71
- end
72
-
73
- hash.each do |k, v|
74
- v = v.to_s
75
-
76
- # Check if the Liquid context has a matching key and extract the value of that key
77
- # if this is the case.
78
- if context.respond_to?('key?')
79
- if context.key?(v)
80
- hash[k] = h(context[v])
81
- end
82
- else
83
- if context.has_key?(v)
84
- hash[k] = h(context[v])
85
- end
86
- end
87
- end
88
-
89
- return hash
90
- end
91
-
92
- end
93
- end
94
- end
@@ -1,70 +0,0 @@
1
- #:nodoc:
2
- module Zen
3
- #:nodoc:
4
- module Liquid
5
- ##
6
- # The Redirect tag can be used to redirect a user from one URL to another.
7
- #
8
- # @example
9
- # {% redirect "blog/index" %}
10
- #
11
- # Optionally you can redirect a user to a 404 page by doing the following:
12
- #
13
- # {% redirect "404" %}
14
- #
15
- # This will render the 404 template but without changing the current URL.
16
- #
17
- # @author Yorick Peterse
18
- # @since 0.1
19
- #
20
- class Redirect < ::Liquid::Tag
21
- include ::Ramaze::Helper::Redirect
22
- include ::Zen::Liquid::ControllerBehavior
23
- include ::Ramaze::Helper::Render
24
-
25
- ##
26
- # Creates a new instance of this tag by passing the tag name, arguments and HTML
27
- # tokens to the construct.
28
- #
29
- # @author Yorick Peterse
30
- # @since 0.1
31
- # @param [String] tag_name The name of the tag that was called.
32
- # @param [String] arguments All additional arguments passed as a string.
33
- # @param [String] tokens All tokens (HTML mostly) inside the tag block.
34
- #
35
- def initialize(tag_name = 'redirect', arguments = '', tokens = '')
36
- super
37
-
38
- @url = arguments.gsub('"', '').gsub("'", '').strip
39
- end
40
-
41
- ##
42
- # Redirects the user to a certain page based on the arguments specified in the
43
- # constructor method.
44
- #
45
- # @author Yorick Peterse
46
- # @since 0.1
47
- # @param [Object] context The current Liquid context
48
- #
49
- def render(context)
50
- if @url.nil? or @url.empty?
51
- raise(ArgumentError, "You need to specify a URL in order to redirect a user")
52
- end
53
-
54
- # 404 URLs are treated differently than other URLs
55
- if @url == '404'
56
- theme = ::Zen::Package[session[:settings][:theme]]
57
- not_found = theme.directory + "/templates/404.liquid"
58
-
59
- if File.exist?(not_found)
60
- respond(action.instance.render_file(not_found), 404)
61
- else
62
- respond("The requested page could not be found", 404)
63
- end
64
- else
65
- redirect(@url)
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,60 +0,0 @@
1
- #:nodoc:
2
- module Zen
3
- #:nodoc:
4
- module Liquid
5
- ##
6
- # Tag block that can be used to strip leading and trailing characters from
7
- # the text inside of the block. This tag can be extremely useful when you're
8
- # displaying elements seperated by a comma and want to remove the last comma.
9
- #
10
- # @example
11
- # {% strip end=", " %}
12
- # Hello, world,
13
- # {% endstrip %}
14
- #
15
- # This tag has the following options:
16
- #
17
- # * start
18
- # * end
19
- #
20
- # @author Yorick Peterse
21
- # @since 0.1
22
- #
23
- class Strip < ::Liquid::Block
24
- include ::Zen::Liquid::General
25
-
26
- ##
27
- # Creates a new instance of the block and passes the tag name,
28
- # all additional arguments and the HTML to the constructor method.
29
- #
30
- # @author Yorick Peterse
31
- # @param [String] tag_name The name of the tag that was called.
32
- # @param [String] arguments All additional arguments passed as a string.
33
- # @param [String] html The HTML inside the block.
34
- # @since 0.1
35
- #
36
- def initialize(tag_name = 'strip', arguments = '', html = '')
37
- super
38
-
39
- @arguments = {'start' => '', 'end' => ''}
40
- @arguments = @arguments.merge(parse_key_values(arguments))
41
- end
42
-
43
- ##
44
- # Renders the tag block. We'll retrieve the content inside the block,
45
- # trim it and return it.
46
- #
47
- # @author Yorick Peterse
48
- # @since 0.1
49
- # @param [Object] context The Liquid context for the current tag
50
- #
51
- def render context
52
- html = super
53
- html = html.join
54
- html = html.gsub(/^#{@arguments['start']}/, '').gsub(/#{@arguments['end']}$/, '')
55
-
56
- return html
57
- end
58
- end
59
- end
60
- end
@@ -1,16 +0,0 @@
1
- #:nodoc:
2
- module Categories
3
- #:nodoc:
4
- module Liquid
5
- ##
6
- #
7
- #
8
- # @author Yorick Peterse
9
- # @since 0.2
10
- # @todo Create this tag you lazy bum!
11
- #
12
- class Categories < ::Liquid::Block
13
-
14
- end
15
- end
16
- end