mizugumo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/.document +5 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +30 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +87 -0
  6. data/Rakefile +70 -0
  7. data/VERSION +1 -0
  8. data/lib/generators/mizugumo/install/install_generator.rb +59 -0
  9. data/lib/generators/mizugumo/install/templates/images/ui/spinner.gif +0 -0
  10. data/lib/generators/mizugumo/install/templates/javascripts/jquery-1.4.2.js +6240 -0
  11. data/lib/generators/mizugumo/install/templates/javascripts/jquery.ninja_script.js +997 -0
  12. data/lib/generators/mizugumo/install/templates/stylesheets/mizugumo.css +46 -0
  13. data/lib/generators/mizugumo/install/templates/stylesheets/sass/mizugumo.sass +48 -0
  14. data/lib/generators/rails/mizugumo/erb_generator.rb +21 -0
  15. data/lib/generators/rails/mizugumo/haml_generator.rb +21 -0
  16. data/lib/generators/rails/mizugumo/scaffold_controller_generator.rb +26 -0
  17. data/lib/generators/rails/mizugumo/templates/_form.html.erb +23 -0
  18. data/lib/generators/rails/mizugumo/templates/_form.html.haml +21 -0
  19. data/lib/generators/rails/mizugumo/templates/_row.html.erb +9 -0
  20. data/lib/generators/rails/mizugumo/templates/_row.html.haml +7 -0
  21. data/lib/generators/rails/mizugumo/templates/controller.rb +93 -0
  22. data/lib/generators/rails/mizugumo/templates/create.js.erb +2 -0
  23. data/lib/generators/rails/mizugumo/templates/destroy.js.erb +1 -0
  24. data/lib/generators/rails/mizugumo/templates/edit.html.erb +6 -0
  25. data/lib/generators/rails/mizugumo/templates/edit.html.haml +7 -0
  26. data/lib/generators/rails/mizugumo/templates/edit.js.erb +4 -0
  27. data/lib/generators/rails/mizugumo/templates/index.html.erb +18 -0
  28. data/lib/generators/rails/mizugumo/templates/index.html.haml +13 -0
  29. data/lib/generators/rails/mizugumo/templates/new.html.erb +5 -0
  30. data/lib/generators/rails/mizugumo/templates/new.html.haml +5 -0
  31. data/lib/generators/rails/mizugumo/templates/new.js.erb +2 -0
  32. data/lib/generators/rails/mizugumo/templates/show.html.erb +10 -0
  33. data/lib/generators/rails/mizugumo/templates/show.html.haml +9 -0
  34. data/lib/generators/rails/mizugumo/templates/update.js.erb +4 -0
  35. data/lib/generators/rails/mizugumo/view_generator.rb +44 -0
  36. data/lib/mizugumo.rb +13 -0
  37. data/lib/mizugumo_link_helper.rb +58 -0
  38. data/spec/spec_helper.rb +0 -0
  39. metadata +165 -0
@@ -0,0 +1,13 @@
1
+ module Mizugumo
2
+ class Railtie < Rails::Railtie
3
+ require 'mizugumo_link_helper'
4
+
5
+ ActionController::Base.helper(MizugumoLinkHelper)
6
+
7
+ generators do
8
+ require 'generators/rails/mizugumo/scaffold_controller_generator'
9
+ require 'generators/rails/mizugumo/erb_generator'
10
+ require 'generators/mizugumo/install/install_generator'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,58 @@
1
+
2
+ module MizugumoLinkHelper
3
+ include ActionView::Helpers::UrlHelper
4
+
5
+ # Redefined link_to to provide Mizugumo-style
6
+ # graceful degradation. If a :method option
7
+ # was provided, this replaces the link with a form
8
+ # and specifies a class so that MizugumoScript will
9
+ # convert it to the expected link on Javascript-enabled
10
+ # browsers.
11
+ def link_to(*args, &block)
12
+ if block_given?
13
+ options = args[0] || {}
14
+ html_options = args[1]
15
+ else
16
+ options = args[1] || {}
17
+ html_options = args[2]
18
+ end
19
+
20
+ if html_options and html_options[:method]
21
+ degradable_form_for_link(*args, &block)
22
+ else
23
+ super(*args, &block)
24
+ end
25
+ end
26
+
27
+ def degradable_form_for_link(*args, &block)
28
+ if block_given?
29
+ return degradable_form_for_link(capture(&block), *args)
30
+ else
31
+ contents = args.shift
32
+ if contents =~ /<img.+src=['"](\S+?)['"]/
33
+ submit_element = image_submit_tag($1)
34
+ title = "block was passed"
35
+ else
36
+ title = contents
37
+ submit_element = submit_tag(title)
38
+ end
39
+ end
40
+ options = args[0] || {}
41
+ html_options = args[1]
42
+ action = url_for(options)
43
+ # debugger
44
+ method = html_options[:method]
45
+
46
+ cssclass = [ 'mizugumo_graceful_form' ]
47
+ cssclass << html_options[:class] unless html_options[:class].blank?
48
+ html_options = convert_options_to_data_attributes(options, html_options)
49
+ html_options.merge!({:action => action, :method => :post, :title => title, :class => cssclass})
50
+ html_options.delete('rel')
51
+
52
+ content_tag(:form, html_options) do
53
+ hidden_field_tag("_method", method) +
54
+ hidden_field_tag("authenticity_token", session[:_csrf_token]) +
55
+ submit_element
56
+ end
57
+ end
58
+ end
File without changes
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mizugumo
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Evan Dorn
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-25 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 1
32
+ - 5
33
+ version: "1.5"
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 23
45
+ segments:
46
+ - 1
47
+ - 0
48
+ - 0
49
+ version: 1.0.0
50
+ type: :development
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: jeweler
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 7
61
+ segments:
62
+ - 1
63
+ - 5
64
+ - 2
65
+ version: 1.5.2
66
+ type: :development
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: rcov
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ type: :development
81
+ version_requirements: *id004
82
+ description: Seamless UJS for Rails using NinjaScript
83
+ email: evan@lrdesign.com
84
+ executables: []
85
+
86
+ extensions: []
87
+
88
+ extra_rdoc_files:
89
+ - LICENSE.txt
90
+ - README.rdoc
91
+ files:
92
+ - .document
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.rdoc
97
+ - Rakefile
98
+ - VERSION
99
+ - lib/generators/mizugumo/install/install_generator.rb
100
+ - lib/generators/mizugumo/install/templates/images/ui/spinner.gif
101
+ - lib/generators/mizugumo/install/templates/javascripts/jquery-1.4.2.js
102
+ - lib/generators/mizugumo/install/templates/javascripts/jquery.ninja_script.js
103
+ - lib/generators/mizugumo/install/templates/stylesheets/mizugumo.css
104
+ - lib/generators/mizugumo/install/templates/stylesheets/sass/mizugumo.sass
105
+ - lib/generators/rails/mizugumo/erb_generator.rb
106
+ - lib/generators/rails/mizugumo/haml_generator.rb
107
+ - lib/generators/rails/mizugumo/scaffold_controller_generator.rb
108
+ - lib/generators/rails/mizugumo/templates/_form.html.erb
109
+ - lib/generators/rails/mizugumo/templates/_form.html.haml
110
+ - lib/generators/rails/mizugumo/templates/_row.html.erb
111
+ - lib/generators/rails/mizugumo/templates/_row.html.haml
112
+ - lib/generators/rails/mizugumo/templates/controller.rb
113
+ - lib/generators/rails/mizugumo/templates/create.js.erb
114
+ - lib/generators/rails/mizugumo/templates/destroy.js.erb
115
+ - lib/generators/rails/mizugumo/templates/edit.html.erb
116
+ - lib/generators/rails/mizugumo/templates/edit.html.haml
117
+ - lib/generators/rails/mizugumo/templates/edit.js.erb
118
+ - lib/generators/rails/mizugumo/templates/index.html.erb
119
+ - lib/generators/rails/mizugumo/templates/index.html.haml
120
+ - lib/generators/rails/mizugumo/templates/new.html.erb
121
+ - lib/generators/rails/mizugumo/templates/new.html.haml
122
+ - lib/generators/rails/mizugumo/templates/new.js.erb
123
+ - lib/generators/rails/mizugumo/templates/show.html.erb
124
+ - lib/generators/rails/mizugumo/templates/show.html.haml
125
+ - lib/generators/rails/mizugumo/templates/update.js.erb
126
+ - lib/generators/rails/mizugumo/view_generator.rb
127
+ - lib/mizugumo.rb
128
+ - lib/mizugumo_link_helper.rb
129
+ - spec/spec_helper.rb
130
+ has_rdoc: true
131
+ homepage: http://github.com/IdahoEv/mizugumo
132
+ licenses:
133
+ - MIT
134
+ post_install_message:
135
+ rdoc_options: []
136
+
137
+ require_paths:
138
+ - lib/
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ hash: 3
145
+ segments:
146
+ - 0
147
+ version: "0"
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ hash: 3
154
+ segments:
155
+ - 0
156
+ version: "0"
157
+ requirements: []
158
+
159
+ rubyforge_project:
160
+ rubygems_version: 1.4.2
161
+ signing_key:
162
+ specification_version: 3
163
+ summary: Seamless UJS for Rails using NinjaScript
164
+ test_files: []
165
+