mack 0.5.0 → 0.5.5

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 (56) hide show
  1. data/CHANGELOG +19 -0
  2. data/bin/mack +3 -2
  3. data/bin/mack_ring_server +19 -1
  4. data/lib/{sea_level/controller_base.rb → controller/base.rb} +87 -128
  5. data/lib/{sea_level → controller}/cookie_jar.rb +3 -3
  6. data/lib/{sea_level → controller}/filter.rb +0 -0
  7. data/lib/{sea_level → controller}/request.rb +0 -0
  8. data/lib/{sea_level → controller}/response.rb +0 -0
  9. data/lib/{sea_level → controller}/session.rb +0 -0
  10. data/lib/{sea_level → controller}/uploaded_file.rb +0 -0
  11. data/lib/distributed/routing/urls.rb +1 -1
  12. data/lib/distributed/utils/rinda.rb +1 -1
  13. data/lib/errors/errors.rb +6 -4
  14. data/lib/generators/mack_application_generator/templates/config/initializers/mime_types.rb.template +3 -0
  15. data/lib/generators/mack_application_generator/templates/public/favicon.ico.template +0 -0
  16. data/lib/initialization/configuration.rb +2 -1
  17. data/lib/initialization/console.rb +2 -2
  18. data/lib/initialization/{initializers/logging.rb → logging.rb} +0 -0
  19. data/lib/initialization/{initializers/orm_support.rb → orm_support.rb} +0 -0
  20. data/lib/initialization/{initializers/plugins.rb → plugins.rb} +0 -0
  21. data/lib/mack.rb +107 -131
  22. data/lib/mack_tasks.rb +1 -1
  23. data/lib/rendering/engine/base.rb +26 -0
  24. data/lib/rendering/engine/builder.rb +30 -0
  25. data/lib/rendering/engine/erubis.rb +67 -0
  26. data/lib/rendering/engine/haml.rb +18 -0
  27. data/lib/rendering/engine/markaby.rb +27 -0
  28. data/lib/rendering/engine/registry.rb +48 -0
  29. data/lib/rendering/type/action.rb +37 -0
  30. data/lib/rendering/type/base.rb +59 -0
  31. data/lib/rendering/type/file_base.rb +32 -0
  32. data/lib/rendering/type/inline.rb +26 -0
  33. data/lib/rendering/type/layout.rb +26 -0
  34. data/lib/rendering/type/partial.rb +40 -0
  35. data/lib/rendering/type/public.rb +29 -0
  36. data/lib/rendering/type/template.rb +22 -0
  37. data/lib/rendering/type/text.rb +17 -0
  38. data/lib/rendering/type/url.rb +120 -0
  39. data/lib/rendering/type/xml.rb +34 -0
  40. data/lib/rendering/view_template.rb +168 -0
  41. data/lib/routing/route_map.rb +20 -11
  42. data/lib/runner.rb +137 -0
  43. data/lib/utils/mime_types.rb +56 -0
  44. data/lib/utils/mime_types.yml +449 -0
  45. data/lib/{sea_level/helpers/view_helpers → view_helpers}/html_helpers.rb +0 -0
  46. data/lib/{sea_level/helpers/view_helpers → view_helpers}/string_helpers.rb +0 -0
  47. metadata +58 -29
  48. data/lib/initialization/initializer.rb +0 -110
  49. data/lib/rendering/base.rb +0 -62
  50. data/lib/rendering/classes/action.rb +0 -26
  51. data/lib/rendering/classes/partial.rb +0 -12
  52. data/lib/rendering/classes/public.rb +0 -13
  53. data/lib/rendering/classes/text.rb +0 -12
  54. data/lib/rendering/classes/url.rb +0 -59
  55. data/lib/rendering/classes/xml.rb +0 -24
  56. data/lib/sea_level/view_binder.rb +0 -88
@@ -1,24 +0,0 @@
1
- module Mack
2
- module Rendering
3
- # Used when someone calls render(:xml => "rss_feed")
4
- class Xml < Base
5
-
6
- def render
7
- begin
8
- # Try to render the action:
9
- return render_file(options[:xml], options.merge(:format => :xml, :ext => ".xml.erb"))
10
- rescue Errno::ENOENT => e
11
- begin
12
- # If the action doesn't exist on disk, try to render it from the public directory:
13
- t = render_file(options[:xml], {:dir => Mack::Configuration.public_directory, :ext => ".xml.erb", :layout => false}.merge(options.merge(:format => :xml)))
14
- return t
15
- rescue Errno::ENOENT => ex
16
- end
17
- # Raise the original exception because something bad has happened!
18
- raise e
19
- end
20
- end
21
-
22
- end
23
- end
24
- end
@@ -1,88 +0,0 @@
1
- # This class is used to do all the view level bindings.
2
- # It allows for seperation between the controller and the view levels.
3
- class Mack::ViewBinder
4
-
5
- attr_accessor :controller # Allows access to the controller.
6
- attr_accessor :options # Allows access to any options passed into the Binder.
7
-
8
- def initialize(cont, opts = {})
9
- self.controller = cont
10
- self.options = {:locals => {}}.merge(opts)
11
- transfer_vars(@controller)
12
- @xml_output = ""
13
- @xml = Builder::XmlMarkup.new(:target => @xml_output, :indent => 1)
14
- end
15
-
16
- # If a method can not be found then the :locals key of
17
- # the options is used to find the variable.
18
- def method_missing(sym, *args)
19
- self.options[:locals][sym]
20
- end
21
-
22
- # Maps to the controller's param method. See also Mack::Controller::Base params.
23
- def params(key)
24
- self.controller.params(key)
25
- end
26
-
27
- def xml
28
- @xml
29
- end
30
-
31
- # Handles rendering calls both in the controller and in the view.
32
- # For full details of render examples see Mack::Controller::Base render.
33
- # Although the examples there are all in controllers, they idea is still
34
- # the same for views.
35
- #
36
- # Examples in the view:
37
- # <%= render(:text => "Hello") %>
38
- # <%= render(:action => "show") %>
39
- # <%= render(:partial => :latest_news) %>
40
- # <%= render(:url => "http://www.mackframework.com") %>
41
- def render(options = {})
42
- app_config.mack.rendering_systems.each do |render_option|
43
- if options[render_option]
44
- begin
45
- rc = "Mack::Rendering::#{render_option.to_s.camelcase}".constantize.new(self, options)
46
- rescue Exception => e
47
- raise Mack::Errors::UnknownRenderOption.new(options)
48
- end
49
- return rc.render
50
- end
51
- end
52
- raise Mack::Errors::UnknownRenderOption.new(options)
53
- end
54
-
55
- def run(io)
56
- # TODO: find a nicer way of doing this:
57
- if ((controller.params(:format).to_sym == :xml) || options[:format] == :xml) && (options[:action] || options[:xml])
58
- return eval(io, binding)
59
- else
60
- return Erubis::Eruby.new(io).result(binding)
61
- end
62
- end
63
-
64
- def concat(txt, b)
65
- eval( "_buf", b) << txt
66
- end
67
-
68
- private
69
-
70
- # Transfer instance variables from the controller to the view.
71
- def transfer_vars(x)
72
- x.instance_variables.each do |v|
73
- self.instance_variable_set(v, x.instance_variable_get(v))
74
- end
75
- end
76
-
77
- class << self
78
-
79
- # Creates a Mack::ViewBinder and then passes the io through Erubis::Eruby
80
- # and returns a String. The io can be either an IO object or a String.
81
- def render(io, controller, options = {})
82
- vb = Mack::ViewBinder.new(controller, options)
83
- vb.run(io)
84
- end
85
-
86
- end
87
-
88
- end