equipment 0.1.0 → 1.4.84

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGES +9 -0
  2. data/LICENSE +340 -0
  3. data/README +29 -12
  4. data/Rakefile +157 -0
  5. data/TODO +14 -0
  6. data/doc/structure.dia +0 -0
  7. data/doc/structure.png +0 -0
  8. data/lib/camping_ext.rb +72 -0
  9. data/lib/equipment.rb +39 -116
  10. data/lib/ext.rb +33 -0
  11. data/lib/ext/active_record.rb +146 -0
  12. data/lib/ext/basic_auth.rb +15 -15
  13. data/lib/ext/controls.rb +16 -14
  14. data/lib/ext/flash.rb +35 -17
  15. data/lib/ext/form_helpers.rb +46 -0
  16. data/lib/ext/forward.rb +44 -15
  17. data/lib/ext/js_helpers.rb +66 -19
  18. data/lib/ext/logging.rb +61 -0
  19. data/lib/ext/mount.rb +33 -27
  20. data/lib/ext/negociate_content.rb +90 -0
  21. data/lib/ext/og.rb +18 -10
  22. data/lib/ext/og_scaffold.rb +5 -8
  23. data/lib/ext/resource.rb +127 -0
  24. data/lib/ext/security.rb +66 -31
  25. data/lib/ext/sendfile.rb +3 -4
  26. data/lib/ext/settings.rb +243 -0
  27. data/lib/ext/template_view.rb +9 -37
  28. data/lib/ext/use_helper.rb +6 -10
  29. data/lib/ext/view.rb +98 -0
  30. data/lib/ext/view_slot.rb +60 -0
  31. data/lib/mimetype_ext.rb +12 -0
  32. data/lib/more/typecast.rb +288 -0
  33. data/lib/ruby_ext.rb +126 -0
  34. data/share/js/date_ext.js +234 -0
  35. data/share/js/es-confirm.js +23 -0
  36. data/share/js/event-selector.js +145 -0
  37. data/share/js/jquery.js +1793 -0
  38. data/share/js/prototype.js +2012 -0
  39. metadata +50 -35
  40. data/ProjectInfo +0 -55
  41. data/examples/basicauthtest.rb +0 -59
  42. data/examples/erubytest.rb +0 -36
  43. data/examples/flashtest.rb +0 -46
  44. data/examples/index.erb +0 -9
  45. data/examples/mounttest.rb +0 -34
  46. data/examples/ogtest.rb +0 -41
  47. data/examples/patchestest.rb +0 -40
  48. data/examples/sendfiletest.rb +0 -29
  49. data/lib/ext/forms.rb +0 -22
  50. data/lib/ext/patches.rb +0 -130
  51. data/lib/ext/ressource.rb +0 -88
@@ -1,22 +0,0 @@
1
- require 'equipment'
2
- require 'ext/controls'
3
-
4
- module Ext
5
- # Not implemented yet
6
- module Forms
7
- extend Equipment
8
- depends_on Controls
9
-
10
- module Helpers
11
- def form_for(xy)
12
- end
13
- end
14
-
15
- module Mab
16
- def form(*a, &b)
17
- super
18
- end
19
- end
20
-
21
- end
22
- end
@@ -1,130 +0,0 @@
1
- require 'equipment'
2
- require 'ext/app_util'
3
-
4
- module Ext
5
-
6
- # Fixes some Camping defaults.
7
- #
8
- # == Dependencies
9
- #
10
- # * Equipment
11
- # * AppUtil
12
- #
13
- module Patches
14
- extend Equipment
15
- depends_on AppUtil
16
-
17
- # Removes method_missing, it makes things too complicated and debug
18
- # unclear.
19
- #
20
- # Redefines the D method
21
- def self.equip(app)
22
- super
23
-
24
- =begin
25
- # remove method_missing, it makes things too complicated
26
- if app::Base.method_defined? :method_missing
27
- app::Base.send :undef_method, :method_missing
28
- end
29
- =end
30
-
31
- =begin # not needed in 1.5
32
- app::Controllers.module_eval do
33
- # New D method which uses respond_to? instead of kind_of?(R)
34
- def self.D(path)
35
- puts "REQUEST: #{path}" if $DBG
36
- constants.inject(nil) do |d,c|
37
- k = const_get(c)
38
- k.meta_def(:urls){["/#{c.downcase}"]}unless k.respond_to? :urls
39
- d||([k, $~[1..-1]] if k.urls.find { |x| path =~ /^#{x}\/?$/ })
40
- end||[self::NotFound, [path]]
41
- end
42
- end
43
- =end
44
-
45
- # app::Controllers::NotFound.send :include, app::C, app::Base, app::Models
46
- # app::Controllers::ServerError.send :include, app::C, app::Base, app::Models
47
- end
48
- module Base
49
-
50
- # = Re-defined render
51
- #
52
- # The method_missing method is great but it ties the system too much to
53
- # markaby. It makes also harder to debunk wrong methods since the call-
54
- # stack is longer. Finally, it encourages to put the view in the
55
- # controller, which is considered bad in MVC style (that's what ppl say)
56
- #
57
- # Render is a method that gets the view and puts a layout around it if
58
- # found.
59
- #
60
- # Layout was renamed to _layout because it is a partial. Also partials
61
- # don't use the layout feature (so layout doesn't have a layout)
62
- def render(m, *a, &b)
63
- str = view(m, *a, &b)
64
- # allow content-negotiation
65
- if m.to_s[0] != ?_ and has_view? :_layout
66
- str = view(:_layout) { str }
67
- end
68
- str
69
- end
70
-
71
- # Temporary there until markaview is restored or replaced in
72
- # camping-unabridged.
73
- def markaview(m,*a,&b)
74
- h=markaby
75
- h.send m,*a,&b
76
- h.to_s
77
- end
78
-
79
- # Useful if you want to implement your own view
80
- alias :view :markaview
81
-
82
- # Shortcut.
83
- #
84
- # This is useful if you want to implement your own view lookup
85
- # (cf. TemplateView, ErubisView)
86
- def has_view?(v)
87
- /text\/html|\*\/\*/ =~ (env.HTTP_ACCEPT || '*/*') and
88
- app::Views.method_defined? v # this is specific to markaby
89
- end
90
- end
91
-
92
- =begin
93
- module Controllers
94
- # Changed usage of markaby template after removing method_missing.
95
- class NotFound
96
- def self.urls; [] end # do not serve urls directly
97
- def get(p); r(404, app::Mab.new { h1 "Camping Problem!"; h2 "#{p} not found"}) end
98
- end
99
-
100
- class ServerError
101
- def self.urls; [] end # do not serve urls directly
102
- def get(k,m,e)
103
- r(500, app::Mab.new do
104
- h1 "Camping Problem!"
105
- # if $DBG
106
- h2 "#{k}.#{m}"
107
- h3 "#{e.class} #{e.message}:"
108
- ul { e.backtrace.each { |bt| li bt } }
109
- # end
110
- end.to_s
111
- )
112
- end
113
- end
114
- end
115
- =end
116
-
117
- =begin
118
- module CClassMethods
119
- # Does noting. Allows calling super to chain initialization processes
120
- # without having to check for NoMethodError.
121
- def create
122
- super
123
- rescue NoMethodError, ArgumentError
124
- end
125
- end
126
- =end
127
-
128
- end
129
- end
130
-
@@ -1,88 +0,0 @@
1
- require 'equipment'
2
-
3
- module Ext
4
- # Unfinished work.
5
- #
6
- # I'm currently implementing a Controller that works like rail's
7
- # ActiveRessouce.
8
- #
9
- # == Dependencies
10
- #
11
- # * None
12
- #
13
- module Ressource
14
- class RestController
15
- class << self
16
- attr_accessor :model, :path
17
-
18
- def urls
19
- @__urls ||= [
20
- # POST GET POST POST
21
- "#{path}/(create)", "#{path}/(show)/(\d+)", "#{path}/(update)/(\d+)", "#{path}/(destroy)/(\d+)",
22
- "#{path}/(\d+)", "#{path}", # POST,GET,PUT,DELETE : rest methods
23
- "#{path};(\w+)", "#{path}/(\d+);(\w+)" # POST,GET : forms
24
- ]
25
- end
26
- end
27
-
28
- # GET method dispatching
29
- def get(action, id)
30
- if action.to_i > 0 #/id , /id;actions
31
- id = 'show' unless id
32
- send(id, action)
33
- elsif id #/show/id
34
- show(id)
35
- else # ;actions
36
- action = 'index' if action.empty?
37
- send(action)
38
- end
39
- end
40
-
41
- # POST method dispatching
42
- def post(action, id)
43
- if action.to_i > 0
44
- id = id ? "_#{id}" : 'update'
45
- send(id, action)
46
- elsif id
47
- send(action, id)
48
- elsif action=='create'
49
- create
50
- else
51
- send("_#{action}")
52
- end
53
- end
54
-
55
- def put(id); update(id); end
56
- def delete(id); destroy(id); end
57
-
58
- ### CRUD operations ###
59
-
60
- def create # POST
61
- end
62
-
63
- def show(id) # GET
64
- end
65
-
66
- def update(id) # PUT
67
- redirect R(self, :show, id)
68
- end
69
-
70
- def destroy(id) # DELETE
71
- redirect R(self, :index)
72
- end
73
-
74
- ### Pages ###
75
-
76
- def index
77
- end
78
-
79
- def new
80
- end
81
-
82
- def edit
83
- end
84
- end
85
-
86
- end
87
- end
88
-