mack 0.6.1.2 → 0.7.0

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 (85) hide show
  1. data/CHANGELOG +49 -3
  2. data/README +4 -4
  3. data/bin/mack +1 -2
  4. data/lib/mack/controller/controller.rb +1 -1
  5. data/lib/mack/controller/cookie_jar.rb +4 -0
  6. data/lib/mack/controller/request.rb +55 -3
  7. data/lib/mack/controller/session.rb +9 -0
  8. data/lib/mack/controller/tell.rb +13 -0
  9. data/lib/mack/core_extensions/kernel.rb +39 -11
  10. data/lib/mack/core_extensions/symbol.rb +107 -0
  11. data/lib/mack/generators/controller_generator/controller_generator.rb +64 -0
  12. data/lib/mack/generators/controller_generator/manifest.yml +18 -0
  13. data/lib/mack/generators/controller_generator/templates/app/controllers/controller.rb.template +7 -0
  14. data/lib/mack/generators/controller_generator/templates/test/controllers/rspec.rb.template +15 -0
  15. data/lib/mack/generators/controller_generator/templates/test/controllers/test_case.rb.template +15 -0
  16. data/lib/mack/generators/controller_helper_generator/controller_helper_generator.rb +16 -0
  17. data/lib/mack/generators/controller_helper_generator/manifest.yml +15 -0
  18. data/lib/mack/generators/controller_helper_generator/templates/app/helpers/controllers/helper.rb.template +7 -0
  19. data/lib/mack/generators/controller_helper_generator/templates/test/helpers/controllers/rspec.rb.template +6 -0
  20. data/lib/mack/generators/controller_helper_generator/templates/test/helpers/controllers/test_case.rb.template +10 -0
  21. data/lib/mack/generators/mack_application_generator/mack_application_generator.rb +1 -0
  22. data/lib/mack/generators/mack_application_generator/manifest.yml +26 -10
  23. data/lib/mack/generators/mack_application_generator/templates/Rakefile.template +1 -1
  24. data/lib/mack/generators/mack_application_generator/templates/app/controllers/default_controller.rb.template +7 -1
  25. data/lib/mack/generators/mack_application_generator/templates/app/helpers/controllers/default_controller_helper.rb.template +1 -1
  26. data/lib/mack/generators/mack_application_generator/templates/app/helpers/views/application_helper.rb.template +3 -0
  27. data/lib/mack/generators/mack_application_generator/templates/app/views/default/index.html.erb.template +60 -2
  28. data/lib/mack/generators/mack_application_generator/templates/app/views/layouts/application.html.erb.template +10 -2
  29. data/lib/mack/generators/mack_application_generator/templates/config/app_config/default.yml.template +21 -0
  30. data/lib/mack/generators/mack_application_generator/templates/config/app_config/development.yml.template +1 -0
  31. data/lib/mack/generators/mack_application_generator/templates/config/app_config/production.yml.template +1 -0
  32. data/lib/mack/generators/mack_application_generator/templates/config/app_config/test.yml.template +1 -0
  33. data/lib/mack/generators/mack_application_generator/templates/config/database.yml.template +24 -0
  34. data/lib/mack/generators/mack_application_generator/templates/config/initializers/inflections.rb.template +13 -0
  35. data/lib/mack/generators/mack_application_generator/templates/config/initializers/mime_types.rb.template +1 -0
  36. data/lib/mack/generators/mack_application_generator/templates/public/stylesheets/scaffold.css.template +125 -29
  37. data/lib/mack/generators/mack_application_generator/templates/test/{functional → controllers}/default_controller_spec.rb.template +2 -0
  38. data/lib/mack/generators/mack_application_generator/templates/test/{functional → controllers}/default_controller_test.rb.template +2 -0
  39. data/lib/mack/generators/mack_application_generator/templates/test/helpers/controllers/default_controller_helper_spec.rb.template +6 -0
  40. data/lib/mack/generators/mack_application_generator/templates/test/helpers/controllers/default_controller_helper_test.rb.template +10 -0
  41. data/lib/mack/generators/mack_application_generator/templates/test/helpers/views/application_helper_spec.rb.template +6 -0
  42. data/lib/mack/generators/mack_application_generator/templates/test/helpers/views/application_helper_test.rb.template +10 -0
  43. data/lib/mack/generators/view_helper_generator/manifest.yml +15 -0
  44. data/lib/mack/generators/view_helper_generator/templates/app/helpers/views/helper.rb.template +7 -0
  45. data/lib/mack/generators/view_helper_generator/templates/test/helpers/views/rspec.rb.template +6 -0
  46. data/lib/mack/generators/view_helper_generator/templates/test/helpers/views/test_case.rb.template +10 -0
  47. data/lib/mack/generators/view_helper_generator/view_helper_generator.rb +16 -0
  48. data/lib/mack/initialization/application.rb +6 -6
  49. data/lib/mack/initialization/configuration.rb +17 -9
  50. data/lib/mack/initialization/helpers.rb +3 -3
  51. data/lib/mack/initialization/logging.rb +30 -20
  52. data/lib/mack/rendering/view_template.rb +1 -0
  53. data/lib/mack/routing/route_map.rb +10 -12
  54. data/lib/mack/routing/urls.rb +0 -40
  55. data/lib/mack/runner.rb +7 -2
  56. data/lib/mack/runner_helpers/request_logger.rb +1 -1
  57. data/lib/mack/runner_helpers/session.rb +13 -6
  58. data/lib/mack/tasks/mack_dump_tasks.rake +1 -8
  59. data/lib/mack/tasks/mack_tasks.rake +1 -1
  60. data/lib/mack/tasks/test_tasks.rake +2 -2
  61. data/lib/mack/testing/file.rb +28 -0
  62. data/lib/mack/testing/helpers.rb +59 -4
  63. data/lib/mack/testing/rspec.rb +19 -7
  64. data/lib/mack/utils/mime_types.yml +1 -0
  65. data/lib/mack/utils/server.rb +1 -1
  66. data/lib/mack/version.rb +3 -0
  67. data/lib/mack/view_helpers/date_time_helpers.rb +106 -0
  68. data/lib/mack/view_helpers/form_helpers.rb +282 -0
  69. data/lib/mack/view_helpers/html_helpers.rb +4 -88
  70. data/lib/mack/view_helpers/link_helpers.rb +171 -0
  71. data/lib/mack/view_helpers/object_helpers.rb +14 -0
  72. data/lib/mack/view_helpers/string_helpers.rb +41 -0
  73. data/lib/mack_app.rb +1 -0
  74. data/lib/mack_core.rb +3 -7
  75. data/lib/mack_tasks.rb +8 -16
  76. metadata +36 -27
  77. data/bin/mack_ring_server +0 -33
  78. data/lib/mack/core_extensions/string.rb +0 -21
  79. data/lib/mack/distributed/errors/errors.rb +0 -27
  80. data/lib/mack/distributed/routing/urls.rb +0 -44
  81. data/lib/mack/distributed/utils/rinda.rb +0 -45
  82. data/lib/mack/initialization/orm_support.rb +0 -20
  83. data/lib/mack/tasks/mack_ring_server_tasks.rake +0 -33
  84. data/lib/mack/utils/crypt/default_worker.rb +0 -28
  85. data/lib/mack/utils/crypt/keeper.rb +0 -46
@@ -2,59 +2,6 @@ module Mack
2
2
  module ViewHelpers # :nodoc:
3
3
  module HtmlHelpers
4
4
 
5
- # This is just an alias to
6
- #
7
- # Examples:
8
- # <%= link_to("http://www.mackframework.com") %> # => <a href="http://www.mackframework.com">http://www.mackframework.com</a>
9
- # <%= link_to("Mack", "http://www.mackframework.com") %> # => <a href="http://www.mackframework.com">Mack</a>
10
- # <%= link_to("Mack", "http://www.mackframework.com", :target => "_blank") %> # => <a href="http://www.mackframework.com" target="_blank">Mack</a>
11
- # <%= link_to("Mack", "http://www.mackframework.com", :target => "_blank", :rel => :nofollow) %> # => <a href="http://www.mackframework.com" target="_blank" rel="nofollow">Mack</a>
12
- # If you pass in :method as an option it will be a JavaScript form that will post to the specified link with the
13
- # methd specified.
14
- # <%= link_to("Mack", "http://www.mackframework.com", :method => :delete) %>
15
- # If you use the :method option you can also pass in a :confirm option. The :confirm option will generate a
16
- # javascript confirmation window. If 'OK' is selected the the form will submit. If 'cancel' is selected, then
17
- # nothing will happen. This is extremely useful for 'delete' type of links.
18
- # <%= link_to("Mack", "http://www.mackframework.com", :method => :delete, :confirm => "Are you sure?") %>
19
- def link_to(link_text, url = link_text, html_options = {})
20
- options = {:href => url}.merge(html_options)
21
- a(link_text, options)
22
- end
23
-
24
- # Used in views to create href links. It takes link_text, url, and a Hash that gets added
25
- # to the href as options.
26
- #
27
- # Examples:
28
- # a("http://www.mackframework.com") # => <a href="http://www.mackframework.com">http://www.mackframework.com</a>
29
- # a("Mack", :href => "http://www.mackframework.com") # => <a href="http://www.mackframework.com">Mack</a>
30
- # a("Mack", :href => "http://www.mackframework.com", :target => "_blank") # => <a href="http://www.mackframework.com" target="_blank">Mack</a>
31
- # a("Mack", :href => "http://www.mackframework.com", :target => "_blank", :rel => :nofollow) # => <a href="http://www.mackframework.com" target="_blank" rel="nofollow">Mack</a>
32
- # If you pass in :method as an option it will be a JavaScript form that will post to the specified link with the
33
- # methd specified.
34
- # a("Mack", :href => "http://www.mackframework.com", :method => :delete)
35
- # If you use the :method option you can also pass in a :confirm option. The :confirm option will generate a
36
- # javascript confirmation window. If 'OK' is selected the the form will submit. If 'cancel' is selected, then
37
- # nothing will happen. This is extremely useful for 'delete' type of links.
38
- # a("Mack", :href => "http://www.mackframework.com", :method => :delete, :confirm => "Are you sure?")
39
- def a(link_text, options = {})
40
- options = {:href => link_text}.merge(options)
41
- if options[:method]
42
- meth = nil
43
- confirm = nil
44
-
45
- meth = %{var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', '_method'); s.setAttribute('value', '#{options[:method]}'); f.appendChild(s);f.submit()}
46
- options.delete(:method)
47
-
48
- if options[:confirm]
49
- confirm = %{if (confirm('#{options[:confirm]}'))}
50
- options.delete(:confirm)
51
- end
52
-
53
- options[:onclick] = (confirm ? (confirm + " { ") : "") << meth << (confirm ? (" } ") : "") << ";return false;"
54
- end
55
- content_tag(:a, options, link_text)
56
- end
57
-
58
5
  # Builds an HTML tag.
59
6
  #
60
7
  # Examples:
@@ -64,7 +11,7 @@ module Mack
64
11
  if block_given?
65
12
  concat("<#{tag}#{build_options(options)}>\n", block.binding)
66
13
  yield
67
- concat("</#{tag}>", block.binding)
14
+ concat("\n</#{tag}>", block.binding)
68
15
  else
69
16
  "<#{tag}#{build_options(options)}>#{content}</#{tag}>"
70
17
  end
@@ -84,48 +31,17 @@ module Mack
84
31
  non_content_tag(:img, {:src => image_src}.merge(options))
85
32
  end
86
33
 
87
- # Builds an HTML submit tag
88
- def submit_tag(value = "Submit", options = {})
89
- non_content_tag(:input, {:type => :submit, :value => value}.merge(options))
90
- end
91
-
92
- # Wraps an image tag with a link tag.
93
- #
94
- # Examples:
95
- # <%= link_image_to("/images/foo.jpg", "#" %> # => <a href="#"><img src="/images/foo.jpg"></a>
96
- def link_image_to(image_url, url, image_options = {}, html_options = {})
97
- link_to(img(image_url, image_options), url, html_options)
98
- end
99
-
100
34
  # Example:
101
35
  # <%= rss_tag(posts_index_url(:format => :xml)) %>
102
36
  def rss_tag(url)
103
37
  "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"#{url}\">"
104
38
  end
105
39
 
106
- def form(action, options = {}, &block)
107
- options = {:method => :post, :action => action}.merge(options)
108
- if options[:id]
109
- options = {:class => options[:id]}.merge(options)
110
- end
111
- if options[:multipart]
112
- options = {:enctype => "multipart/form-data"}.merge(options)
113
- options.delete(:multipart)
114
- end
115
- meth = nil
116
- unless options[:method] == :get || options[:method] == :post
117
- meth = "<input name=\"_method\" type=\"hidden\" value=\"#{options[:method]}\" />\n"
118
- options[:method] = :post
119
- end
120
- concat("<form#{build_options(options)}>\n", block.binding)
121
- concat(meth, block.binding) unless meth.blank?
122
- yield
123
- concat("</form>", block.binding)
124
- # content_tag(:form, options, &block)
125
- end
126
-
127
40
  private
128
41
  def build_options(options)
42
+ if options[:disabled]
43
+ options[:disabled] = :disabled
44
+ end
129
45
  opts = ""
130
46
  unless options.empty?
131
47
  opts = " " << options.join("%s=\"%s\"", " ")
@@ -0,0 +1,171 @@
1
+ module Mack
2
+ module ViewHelpers # :nodoc:
3
+ module LinkHelpers
4
+
5
+ # Generates a javascript popup window. It will create the javascript needed for the window,
6
+ # as well as the href to call it.
7
+ #
8
+ # Example:
9
+ # popup('click here', 'http://www.example.com', {:toolbar => :yes, :name => :example_window}, {:alt => 'hello'}) # =>
10
+ # <script>
11
+ # function popup_r8b3edqgpbhm3zkthlgp(u) {
12
+ # window.open(u, 'example_window', "height=400,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=yes,width=500");
13
+ # }
14
+ # </script>
15
+ # <a alt="hello" href="javascript:popup_r8b3edqgpbhm3zkthlgp('http://www.example.com')">click here</a>
16
+ def popup(link_text, url = link_text, popup_options = {}, html_options = {})
17
+ m = String.randomize(20).downcase
18
+ popup_options = {:menubar => :no, :width => 500, :height => 400, :toolbar => :no, :scrollbars => :yes, :resizable => :yes, :titlebar => :no, :status => :no, :location => :no, :name => m}.merge(popup_options)
19
+ window_name = popup_options[:name]
20
+ popup_options.delete(:name)
21
+ %{
22
+ <script>
23
+ function popup_#{m}(u) {
24
+ window.open(u, '#{window_name}', "#{popup_options.join("%s=%s", ",")}");
25
+ }
26
+ </script>
27
+ #{link_to(link_text, "javascript:popup_#{m}('#{url}')", html_options)}
28
+ }.strip
29
+ end
30
+
31
+ # This is just an alias to the a method
32
+ #
33
+ # Examples:
34
+ # <%= link_to("http://www.mackframework.com") %> # => <a href="http://www.mackframework.com">http://www.mackframework.com</a>
35
+ # <%= link_to("Mack", "http://www.mackframework.com") %> # => <a href="http://www.mackframework.com">Mack</a>
36
+ # <%= link_to("Mack", "http://www.mackframework.com", :target => "_blank") %> # => <a href="http://www.mackframework.com" target="_blank">Mack</a>
37
+ # <%= link_to("Mack", "http://www.mackframework.com", :target => "_blank", :rel => :nofollow) %> # => <a href="http://www.mackframework.com" target="_blank" rel="nofollow">Mack</a>
38
+ # If you pass in :method as an option it will be a JavaScript form that will post to the specified link with the
39
+ # methd specified.
40
+ # <%= link_to("Mack", "http://www.mackframework.com", :method => :delete) %>
41
+ # If you use the :method option you can also pass in a :confirm option. The :confirm option will generate a
42
+ # javascript confirmation window. If 'OK' is selected the the form will submit. If 'cancel' is selected, then
43
+ # nothing will happen. This is extremely useful for 'delete' type of links.
44
+ # <%= link_to("Mack", "http://www.mackframework.com", :method => :delete, :confirm => "Are you sure?") %>
45
+ def link_to(link_text, url = link_text, html_options = {})
46
+ options = {:href => url}.merge(html_options)
47
+ a(link_text, options)
48
+ end
49
+
50
+ # Used in views to create href links. It takes link_text, url, and a Hash that gets added
51
+ # to the href as options.
52
+ #
53
+ # Examples:
54
+ # a("http://www.mackframework.com") # => <a href="http://www.mackframework.com">http://www.mackframework.com</a>
55
+ # a("Mack", :href => "http://www.mackframework.com") # => <a href="http://www.mackframework.com">Mack</a>
56
+ # a("Mack", :href => "http://www.mackframework.com", :target => "_blank") # => <a href="http://www.mackframework.com" target="_blank">Mack</a>
57
+ # a("Mack", :href => "http://www.mackframework.com", :target => "_blank", :rel => :nofollow) # => <a href="http://www.mackframework.com" target="_blank" rel="nofollow">Mack</a>
58
+ # If you pass in :method as an option it will be a JavaScript form that will post to the specified link with the
59
+ # methd specified.
60
+ # a("Mack", :href => "http://www.mackframework.com", :method => :delete)
61
+ # If you use the :method option you can also pass in a :confirm option. The :confirm option will generate a
62
+ # javascript confirmation window. If 'OK' is selected the the form will submit. If 'cancel' is selected, then
63
+ # nothing will happen. This is extremely useful for 'delete' type of links.
64
+ # a("Mack", :href => "http://www.mackframework.com", :method => :delete, :confirm => "Are you sure?")
65
+ def a(link_text, options = {})
66
+ options = {:href => link_text}.merge(options)
67
+ if options[:method]
68
+ meth = nil
69
+ confirm = nil
70
+
71
+ meth = %{var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', '_method'); s.setAttribute('value', '#{options[:method]}'); f.appendChild(s);f.submit()}
72
+ options.delete(:method)
73
+
74
+ if options[:confirm]
75
+ confirm = %{if (confirm('#{options[:confirm]}'))}
76
+ options.delete(:confirm)
77
+ end
78
+
79
+ options[:onclick] = (confirm ? (confirm + " { ") : "") << meth << (confirm ? (" } ") : "") << ";return false;"
80
+ end
81
+ content_tag(:a, options, link_text)
82
+ end
83
+
84
+ # Wraps an image tag with a link tag.
85
+ #
86
+ # Examples:
87
+ # <%= link_image_to("/images/foo.jpg", "#" %> # => <a href="#"><img src="/images/foo.jpg"></a>
88
+ def link_image_to(image_url, url, image_options = {}, html_options = {})
89
+ link_to(img(image_url, image_options), url, html_options)
90
+ end
91
+
92
+ # Builds a mailto href. By default it will generate
93
+ # JavaScript to help prevent phishing. To turn this off
94
+ # pass in the option :format => :plain
95
+ #
96
+ # mail_to("Saul Frami", "frami.saul@klocko.ca") # =>
97
+ # <script>document.write(String.fromCharCode(60,97,32,104,114,101,
98
+ # 102,61,34,109,97,105,108,116,111,58,102,114,97,109,105,46,115,97,117,
99
+ # 108,64,107,108,111,99,107,111,46,99,97,34,62,83,97,117,108,32,70,114,97,109,105,60,47,97,62));</script>
100
+ def mail_to(text, email_address = nil, options = {})
101
+ email_address = text if email_address.blank?
102
+ options = {:format => :js}.merge(options)
103
+ format = options[:format]
104
+ options - [:format]
105
+ link = link_to(text, "mailto:#{email_address}", options)
106
+ if format == :js
107
+ y = ''
108
+ link.size.times {y << 'a'}
109
+ js_link = "<script>"
110
+ c_code = []
111
+ link.each_byte {|c| c_code << c}
112
+ js_link << "document.write(String.fromCharCode(#{c_code.join(",")}));"
113
+ js_link << "</script>"
114
+ return js_link
115
+ else
116
+ return link
117
+ end
118
+ end
119
+
120
+ #
121
+ # Generate Javascript tag (<javascript src="/javascripts/foo.js?1241225" type="text/javascript" />)
122
+ #
123
+ # If distributed_site_domain is specified, it will be used.
124
+ #
125
+ def javascript(files, options = {})
126
+ files = [files].flatten
127
+ options = {:type => "text/javascript"}.merge(options)
128
+
129
+ link = ""
130
+ files.each do |name|
131
+ file_name = !name.to_s.end_with?(".js") ? "#{name}.js" : "#{name}"
132
+ link += "<javascript src=\"#{get_resource_root}/javascripts/#{file_name}?#{Time.now.to_i}\" type=\"#{options[:type]}\" />\n"
133
+ end
134
+ return link
135
+ end
136
+
137
+ #
138
+ # Generate Stylesheet tag
139
+ # If distributed_site_domain is specified, then it will use it as the host of the css file
140
+ # example:
141
+ # stylesheet("foo") => <link href="/stylesheets/scaffold.css" media="screen" rel="stylesheet" type="text/css" />
142
+ #
143
+ # distributed_site_domain is set to 'http://localhost:3001'
144
+ # then, stylesheet("foo") will generate
145
+ # <link href="http://localhost:3001/stylesheets/scaffold.css" media="screen" rel="stylesheet" type="text/css" />
146
+ #
147
+ # Supported options are: :media, :rel, and :type
148
+ #
149
+ def stylesheet(files, options = {})
150
+ files = [files].flatten
151
+ options = {:media => 'screen', :rel => 'stylesheet', :type => 'text/css'}.merge(options)
152
+
153
+ link = ""
154
+ files.each do |name|
155
+ file_name = !name.to_s.end_with?(".css") ? "#{name}.css" : "#{name}"
156
+ link += "<link href=\"#{get_resource_root}/stylesheets/#{file_name}\" media=\"#{options[:media]}\" rel=\"#{options[:rel]}\" type=\"#{options[:type]}\" />\n"
157
+ end
158
+
159
+ return link
160
+ end
161
+
162
+ private
163
+ def get_resource_root
164
+ path = ""
165
+ path = "#{app_config.mack.distributed_site_domain}" if app_config.mack.distributed_site_domain
166
+ return path
167
+ end
168
+
169
+ end # LinkHelpers
170
+ end # ViewHelpers
171
+ end # Mack
@@ -0,0 +1,14 @@
1
+ module Mack
2
+ module ViewHelpers # :nodoc:
3
+ module ObjectHelpers
4
+
5
+ # Useful for debugging objects in views. Just pass it an object
6
+ # and will grap the pretty print of the inspect and wrap it in
7
+ # HTML pre tags.
8
+ def debug(obj)
9
+ "<pre>#{pp_to_s(obj)}</pre>"
10
+ end
11
+
12
+ end # ObjectHelpers
13
+ end # ViewHelpers
14
+ end # Mack
@@ -17,6 +17,47 @@ module Mack
17
17
  end
18
18
  end
19
19
 
20
+ # Applies a simple HTML formatting scheme to the text. It first wraps the
21
+ # whole string in a p tag. Then it converts any double carriage returns to
22
+ # new p tags, and any single break tags to br tags.
23
+ #
24
+ # Examples:
25
+ # simple_format("hello\n\ngoodbye\nhello, goodbye") # => "<p>hello</p>\n\n<p>goodbye\n<br />\nhello, goodbye</p>"
26
+ def simple_format(text, options = {})
27
+ if options.empty?
28
+ p = "<p>"
29
+ else
30
+ p = "<p #{options.join("%s=\"%s\"", " ")}>"
31
+ end
32
+ x = text.to_s.dup
33
+ x.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
34
+ x.gsub!(/\n\n+/, "</p>\n\n#{p}") # 2+ newline -> paragraph
35
+ x.gsub!(/([^\n]\n)(?=[^\n])/, "\\1<br />\n") # 1 newline -> br
36
+ "#{p}#{x}</p>"
37
+ end
38
+
39
+ # By this will convert all '<' tags to &lt;. You can specify specific tags
40
+ # with the :tags => [...] option.
41
+ #
42
+ # Examples:
43
+ # sanitize_html("<script>foo;</script>hello <b>mark</b>") # => "&lt;script>foo;&lt;/script>hello &lt;b>mark&lt;/b>"
44
+ # sanitize_html("<script>foo;</script>hello <b>mark</b>", :tags => :script) # => "&lt;script>foo;&lt;/script>hello <b>mark</b>"
45
+ # sanitize_html("< script>foo;</ script>hello <b>mark</b>", :tags => :script) # => "&lt;script>foo;&lt;/script>hello <b>mark</b>"
46
+ def sanitize_html(html, options = {})
47
+ h = html.to_s.dup
48
+ unless options[:tags]
49
+ return h.gsub("<", "&lt;")
50
+ else
51
+ [options[:tags]].flatten.each do |tag|
52
+ h.gsub!(/<\s*#{tag}/i, "&lt;#{tag}")
53
+ h.gsub!(/<\/\s*#{tag}/i, "&lt;/#{tag}")
54
+ end
55
+ return h
56
+ end
57
+ end
58
+
59
+ alias_method :s, :sanitize_html
60
+
20
61
  end # StringHelpers
21
62
  end # ViewHelpers
22
63
  end # Mack
@@ -8,6 +8,7 @@ unless Mack::Configuration.initialized_application
8
8
 
9
9
  Mack.logger.debug "Starting application in #{Mack.env} mode."
10
10
  Mack.logger.debug "Mack root: #{Mack.root}"
11
+ Mack.logger.debug "Mack version: #{Mack::VERSION}"
11
12
 
12
13
  require File.join(fl, "initialization", "application.rb")
13
14
 
@@ -6,7 +6,6 @@ require 'application_configuration'
6
6
  require 'cachetastic'
7
7
  require 'fileutils'
8
8
  require 'log4r'
9
- require 'crypt/rijndael'
10
9
  require 'singleton'
11
10
  require 'uri'
12
11
  require 'drb'
@@ -19,10 +18,9 @@ require 'genosaurus'
19
18
  require 'net/http'
20
19
  require 'pp'
21
20
  require 'test/unit'
22
- require 'redgreen'
23
21
 
24
22
  fl = File.join(File.dirname(__FILE__), "mack")
25
-
23
+ require File.join(fl, "version")
26
24
  require File.join(fl, "initialization", "configuration.rb")
27
25
 
28
26
  unless Mack::Configuration.initialized_core
@@ -31,7 +29,7 @@ unless Mack::Configuration.initialized_core
31
29
  require File.join(fl, "initialization", "logging.rb")
32
30
 
33
31
 
34
- Mack.logger.debug "Initializing core classes..."
32
+ Mack.logger.debug "Initializing core classes..." unless app_config.log.disable_initialization_logging
35
33
  # Require all the necessary files to make Mack actually work!
36
34
  lib_dirs = ["errors", "core_extensions", "utils", "runner_helpers", "routing", "view_helpers", "rendering", "controller", "tasks", "initialization/server", "generators", "distributed"]
37
35
  lib_dirs << "testing"# if Mack.env == "test"
@@ -44,9 +42,7 @@ unless Mack::Configuration.initialized_core
44
42
 
45
43
  require File.join(fl, "runner")
46
44
 
47
- require File.join(fl, "initialization", "orm_support.rb")
48
-
49
45
  Mack::Configuration.initialized_core = true if Mack::Configuration.initialized_core.nil?
50
46
 
51
- Mack.logger.debug "Initialization of Mack Core finished."
47
+ Mack.logger.debug "Initialization of Mack Core finished." unless app_config.log.disable_initialization_logging
52
48
  end
@@ -2,27 +2,19 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
  require 'rubygems'
5
+ require 'mack-facets'
5
6
  require 'application_configuration'
6
7
 
7
8
  require File.join(File.dirname(__FILE__), "mack", "initialization", "configuration.rb")
8
9
 
9
10
  require File.join(File.dirname(__FILE__), 'mack_core')
10
- require File.join(Mack.root, "config", "initializers", "gems.rb")
11
- Mack::Utils::GemManager.instance.do_requires
12
-
13
- orm = app_config.orm
14
- unless orm.nil?
15
- Mack.logger.warn %{
16
- Please note that setting up orm in app_config has been deprecated, and will not be supported in future mack releases.
17
- Here's how to update your existing application:
18
- 1. Remove the line:
19
- orm: data_mapper
20
- from the app_config/default.yml file
21
- 2. In gem.rb, add the following line in the require_gems block:
22
- gem.add "mack-data_mapper", :libs => "mack-data_mapper"
23
- ** if you use active record, then change it to mack-active_record instead of mack-data_mapper
24
- }
25
- require "mack-#{orm}_tasks"
11
+ gems_rb = File.join(Mack.root, "config", "initializers", "gems.rb")
12
+ if File.exists?(gems_rb)
13
+ begin
14
+ require File.join(Mack.root, "config", "initializers", "gems.rb")
15
+ Mack::Utils::GemManager.instance.do_requires
16
+ rescue Gem::LoadError
17
+ end
26
18
  end
27
19
 
28
20
  # Requires all rake tasks that ship with the Mack framework.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-29 00:00:00 -04:00
12
+ date: 2008-08-25 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - "="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.1.2
33
+ version: 0.7.0
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: application_configuration
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - "="
42
42
  - !ruby/object:Gem::Version
43
- version: 1.5.3
43
+ version: 1.5.2
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: cachetastic
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - "="
52
52
  - !ruby/object:Gem::Version
53
- version: 1.7.4
53
+ version: 1.7.3
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: log4r
@@ -82,16 +82,6 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: 2.1.2
84
84
  version:
85
- - !ruby/object:Gem::Dependency
86
- name: crypt
87
- type: :runtime
88
- version_requirement:
89
- version_requirements: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - "="
92
- - !ruby/object:Gem::Version
93
- version: 1.1.4
94
- version:
95
85
  - !ruby/object:Gem::Dependency
96
86
  name: daemons
97
87
  type: :runtime
@@ -120,7 +110,7 @@ dependencies:
120
110
  requirements:
121
111
  - - "="
122
112
  - !ruby/object:Gem::Version
123
- version: 1.2.1
113
+ version: 1.2.2
124
114
  version:
125
115
  - !ruby/object:Gem::Dependency
126
116
  name: rcov
@@ -156,7 +146,6 @@ description: Mack is a powerful, yet simple, web application framework. It take
156
146
  email: mark@mackframework.com
157
147
  executables:
158
148
  - mack
159
- - mack_ring_server
160
149
  extensions: []
161
150
 
162
151
  extra_rdoc_files:
@@ -171,13 +160,21 @@ files:
171
160
  - lib/mack/controller/request.rb
172
161
  - lib/mack/controller/response.rb
173
162
  - lib/mack/controller/session.rb
163
+ - lib/mack/controller/tell.rb
174
164
  - lib/mack/controller/uploaded_file.rb
175
165
  - lib/mack/core_extensions/kernel.rb
176
- - lib/mack/core_extensions/string.rb
177
- - lib/mack/distributed/errors/errors.rb
178
- - lib/mack/distributed/routing/urls.rb
179
- - lib/mack/distributed/utils/rinda.rb
166
+ - lib/mack/core_extensions/symbol.rb
180
167
  - lib/mack/errors/errors.rb
168
+ - lib/mack/generators/controller_generator/controller_generator.rb
169
+ - lib/mack/generators/controller_generator/manifest.yml
170
+ - lib/mack/generators/controller_generator/templates/app/controllers/controller.rb.template
171
+ - lib/mack/generators/controller_generator/templates/test/controllers/rspec.rb.template
172
+ - lib/mack/generators/controller_generator/templates/test/controllers/test_case.rb.template
173
+ - lib/mack/generators/controller_helper_generator/controller_helper_generator.rb
174
+ - lib/mack/generators/controller_helper_generator/manifest.yml
175
+ - lib/mack/generators/controller_helper_generator/templates/app/helpers/controllers/helper.rb.template
176
+ - lib/mack/generators/controller_helper_generator/templates/test/helpers/controllers/rspec.rb.template
177
+ - lib/mack/generators/controller_helper_generator/templates/test/helpers/controllers/test_case.rb.template
181
178
  - lib/mack/generators/mack_application_generator/mack_application_generator.rb
182
179
  - lib/mack/generators/mack_application_generator/manifest.yml
183
180
  - lib/mack/generators/mack_application_generator/templates/app/controllers/default_controller.rb.template
@@ -191,13 +188,18 @@ files:
191
188
  - lib/mack/generators/mack_application_generator/templates/config/app_config/test.yml.template
192
189
  - lib/mack/generators/mack_application_generator/templates/config/database.yml.template
193
190
  - lib/mack/generators/mack_application_generator/templates/config/initializers/gems.rb.template
191
+ - lib/mack/generators/mack_application_generator/templates/config/initializers/inflections.rb.template
194
192
  - lib/mack/generators/mack_application_generator/templates/config/initializers/mime_types.rb.template
195
193
  - lib/mack/generators/mack_application_generator/templates/config/routes.rb.template
196
194
  - lib/mack/generators/mack_application_generator/templates/public/favicon.ico.template
197
195
  - lib/mack/generators/mack_application_generator/templates/public/stylesheets/scaffold.css.template
198
196
  - lib/mack/generators/mack_application_generator/templates/Rakefile.template
199
- - lib/mack/generators/mack_application_generator/templates/test/functional/default_controller_spec.rb.template
200
- - lib/mack/generators/mack_application_generator/templates/test/functional/default_controller_test.rb.template
197
+ - lib/mack/generators/mack_application_generator/templates/test/controllers/default_controller_spec.rb.template
198
+ - lib/mack/generators/mack_application_generator/templates/test/controllers/default_controller_test.rb.template
199
+ - lib/mack/generators/mack_application_generator/templates/test/helpers/controllers/default_controller_helper_spec.rb.template
200
+ - lib/mack/generators/mack_application_generator/templates/test/helpers/controllers/default_controller_helper_test.rb.template
201
+ - lib/mack/generators/mack_application_generator/templates/test/helpers/views/application_helper_spec.rb.template
202
+ - lib/mack/generators/mack_application_generator/templates/test/helpers/views/application_helper_test.rb.template
201
203
  - lib/mack/generators/mack_application_generator/templates/test/spec.opts.template
202
204
  - lib/mack/generators/mack_application_generator/templates/test/spec_helper.rb.template
203
205
  - lib/mack/generators/mack_application_generator/templates/test/test_helper.rb.template
@@ -206,12 +208,16 @@ files:
206
208
  - lib/mack/generators/plugin_generator/templates/vendor/plugins/%=@plugin_name%/init.rb.template
207
209
  - lib/mack/generators/plugin_generator/templates/vendor/plugins/%=@plugin_name%/lib/%=@plugin_name%.rb.template
208
210
  - lib/mack/generators/plugin_generator/templates/vendor/plugins/%=@plugin_name%/lib/tasks/%=@plugin_name%_tasks.rake.template
211
+ - lib/mack/generators/view_helper_generator/manifest.yml
212
+ - lib/mack/generators/view_helper_generator/templates/app/helpers/views/helper.rb.template
213
+ - lib/mack/generators/view_helper_generator/templates/test/helpers/views/rspec.rb.template
214
+ - lib/mack/generators/view_helper_generator/templates/test/helpers/views/test_case.rb.template
215
+ - lib/mack/generators/view_helper_generator/view_helper_generator.rb
209
216
  - lib/mack/initialization/application.rb
210
217
  - lib/mack/initialization/configuration.rb
211
218
  - lib/mack/initialization/console.rb
212
219
  - lib/mack/initialization/helpers.rb
213
220
  - lib/mack/initialization/logging.rb
214
- - lib/mack/initialization/orm_support.rb
215
221
  - lib/mack/initialization/plugins.rb
216
222
  - lib/mack/initialization/server/simple_server.rb
217
223
  - lib/mack/rendering/engine/base.rb
@@ -242,7 +248,6 @@ files:
242
248
  - lib/mack/tasks/generator_tasks.rake
243
249
  - lib/mack/tasks/log_tasks.rake
244
250
  - lib/mack/tasks/mack_dump_tasks.rake
245
- - lib/mack/tasks/mack_ring_server_tasks.rake
246
251
  - lib/mack/tasks/mack_server_tasks.rake
247
252
  - lib/mack/tasks/mack_tasks.rake
248
253
  - lib/mack/tasks/mack_update_tasks.rake
@@ -250,20 +255,24 @@ files:
250
255
  - lib/mack/tasks/rake_rules.rake
251
256
  - lib/mack/tasks/test_tasks.rake
252
257
  - lib/mack/tasks/tmp_tasks.rake
258
+ - lib/mack/testing/file.rb
253
259
  - lib/mack/testing/helpers.rb
254
260
  - lib/mack/testing/response.rb
255
261
  - lib/mack/testing/rspec.rb
256
262
  - lib/mack/testing/test_assertions.rb
257
263
  - lib/mack/testing/test_case.rb
258
264
  - lib/mack/utils/ansi/ansi_color.rb
259
- - lib/mack/utils/crypt/default_worker.rb
260
- - lib/mack/utils/crypt/keeper.rb
261
265
  - lib/mack/utils/gem_manager.rb
262
266
  - lib/mack/utils/mime_types.rb
263
267
  - lib/mack/utils/mime_types.yml
264
268
  - lib/mack/utils/server.rb
269
+ - lib/mack/version.rb
265
270
  - lib/mack/view_helpers/all_helpers.rb
271
+ - lib/mack/view_helpers/date_time_helpers.rb
272
+ - lib/mack/view_helpers/form_helpers.rb
266
273
  - lib/mack/view_helpers/html_helpers.rb
274
+ - lib/mack/view_helpers/link_helpers.rb
275
+ - lib/mack/view_helpers/object_helpers.rb
267
276
  - lib/mack/view_helpers/string_helpers.rb
268
277
  - lib/mack.rb
269
278
  - lib/mack_app.rb