mizugumo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +30 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +87 -0
- data/Rakefile +70 -0
- data/VERSION +1 -0
- data/lib/generators/mizugumo/install/install_generator.rb +59 -0
- data/lib/generators/mizugumo/install/templates/images/ui/spinner.gif +0 -0
- data/lib/generators/mizugumo/install/templates/javascripts/jquery-1.4.2.js +6240 -0
- data/lib/generators/mizugumo/install/templates/javascripts/jquery.ninja_script.js +997 -0
- data/lib/generators/mizugumo/install/templates/stylesheets/mizugumo.css +46 -0
- data/lib/generators/mizugumo/install/templates/stylesheets/sass/mizugumo.sass +48 -0
- data/lib/generators/rails/mizugumo/erb_generator.rb +21 -0
- data/lib/generators/rails/mizugumo/haml_generator.rb +21 -0
- data/lib/generators/rails/mizugumo/scaffold_controller_generator.rb +26 -0
- data/lib/generators/rails/mizugumo/templates/_form.html.erb +23 -0
- data/lib/generators/rails/mizugumo/templates/_form.html.haml +21 -0
- data/lib/generators/rails/mizugumo/templates/_row.html.erb +9 -0
- data/lib/generators/rails/mizugumo/templates/_row.html.haml +7 -0
- data/lib/generators/rails/mizugumo/templates/controller.rb +93 -0
- data/lib/generators/rails/mizugumo/templates/create.js.erb +2 -0
- data/lib/generators/rails/mizugumo/templates/destroy.js.erb +1 -0
- data/lib/generators/rails/mizugumo/templates/edit.html.erb +6 -0
- data/lib/generators/rails/mizugumo/templates/edit.html.haml +7 -0
- data/lib/generators/rails/mizugumo/templates/edit.js.erb +4 -0
- data/lib/generators/rails/mizugumo/templates/index.html.erb +18 -0
- data/lib/generators/rails/mizugumo/templates/index.html.haml +13 -0
- data/lib/generators/rails/mizugumo/templates/new.html.erb +5 -0
- data/lib/generators/rails/mizugumo/templates/new.html.haml +5 -0
- data/lib/generators/rails/mizugumo/templates/new.js.erb +2 -0
- data/lib/generators/rails/mizugumo/templates/show.html.erb +10 -0
- data/lib/generators/rails/mizugumo/templates/show.html.haml +9 -0
- data/lib/generators/rails/mizugumo/templates/update.js.erb +4 -0
- data/lib/generators/rails/mizugumo/view_generator.rb +44 -0
- data/lib/mizugumo.rb +13 -0
- data/lib/mizugumo_link_helper.rb +58 -0
- data/spec/spec_helper.rb +0 -0
- metadata +165 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
.ninja.busy {
|
2
|
+
background-color: white;
|
3
|
+
background-image: url("/images/ui/spinner.gif");
|
4
|
+
background-position: center center;
|
5
|
+
background-repeat: no-repeat;
|
6
|
+
opacity: 0.75;
|
7
|
+
filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=75)"; }
|
8
|
+
|
9
|
+
form {
|
10
|
+
margin: 1em 0;
|
11
|
+
padding: 1em;
|
12
|
+
border: 1px solid gray;
|
13
|
+
background: #eeeeee; }
|
14
|
+
form label {
|
15
|
+
display: block;
|
16
|
+
width: 8em;
|
17
|
+
float: left; }
|
18
|
+
form .field {
|
19
|
+
clear: all; }
|
20
|
+
|
21
|
+
form.mizugumo_graceful_form {
|
22
|
+
margin: 0;
|
23
|
+
padding: 0;
|
24
|
+
border: 0;
|
25
|
+
background: transparent; }
|
26
|
+
|
27
|
+
table.scaffold, table.scaffold td, table.scaffold th {
|
28
|
+
border-collapse: collapse;
|
29
|
+
border: 1px solid black; }
|
30
|
+
table.scaffold td, table.scaffold th, table.scaffold td td, table.scaffold td th, table.scaffold th td, table.scaffold th th {
|
31
|
+
padding: 0.5em; }
|
32
|
+
|
33
|
+
form.mizugumo_graceful_form {
|
34
|
+
margin: 0;
|
35
|
+
padding: 0;
|
36
|
+
border: 0;
|
37
|
+
background: transparent; }
|
38
|
+
|
39
|
+
.being_edited {
|
40
|
+
color: #cccccc;
|
41
|
+
font-style: italic;
|
42
|
+
background: #dddddd;
|
43
|
+
text-shadow: #999999 0 0 4px; }
|
44
|
+
.being_edited a, .being_edited a:visited {
|
45
|
+
color: #ccccdd;
|
46
|
+
text-shadow: #aaaacc 0 0 4px; }
|
@@ -0,0 +1,48 @@
|
|
1
|
+
.ninja.busy
|
2
|
+
:background-color white
|
3
|
+
:background-image url("/images/ui/spinner.gif")
|
4
|
+
:background-position center center
|
5
|
+
:background-repeat no-repeat
|
6
|
+
:opacity 0.75
|
7
|
+
:filter 'progid:DXImageTransform.Microsoft.Alpha(opacity=75)'
|
8
|
+
|
9
|
+
form
|
10
|
+
:margin 1em 0
|
11
|
+
:padding 1em
|
12
|
+
:border 1px solid gray
|
13
|
+
:background #eee
|
14
|
+
label
|
15
|
+
:display block
|
16
|
+
:width 8em
|
17
|
+
:float left
|
18
|
+
.field
|
19
|
+
:clear all
|
20
|
+
form.mizugumo_graceful_form
|
21
|
+
:margin 0
|
22
|
+
:padding 0
|
23
|
+
:border 0
|
24
|
+
:background transparent
|
25
|
+
|
26
|
+
table.scaffold, table.scaffold td, table.scaffold th
|
27
|
+
:border-collapse collapse
|
28
|
+
:border 1px solid black
|
29
|
+
|
30
|
+
td, th
|
31
|
+
:padding .5em
|
32
|
+
|
33
|
+
|
34
|
+
form.mizugumo_graceful_form
|
35
|
+
:margin 0
|
36
|
+
:padding 0
|
37
|
+
:border 0
|
38
|
+
:background transparent
|
39
|
+
|
40
|
+
.being_edited
|
41
|
+
:color #ccc
|
42
|
+
:font-style italic
|
43
|
+
:background #ddd
|
44
|
+
:text-shadow #999 0 0 4px
|
45
|
+
|
46
|
+
a, a:visited
|
47
|
+
:color #ccd
|
48
|
+
:text-shadow #aac 0 0 4px
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails/generators/resource_helpers'
|
2
|
+
require 'generators/rails/mizugumo/view_generator'
|
3
|
+
|
4
|
+
module Mizugumo
|
5
|
+
class ErbGenerator < ViewGenerator
|
6
|
+
include ::Rails::Generators::ResourceHelpers
|
7
|
+
|
8
|
+
self.namespace("rails:mizugumo:erb")
|
9
|
+
source_root File.dirname(__FILE__) + '/templates'
|
10
|
+
|
11
|
+
def copy_html_view_files
|
12
|
+
HTML_VIEWS.each do |view|
|
13
|
+
filename = "#{view}.html.erb"
|
14
|
+
template filename, File.join("app/views", controller_file_path, filename)
|
15
|
+
end
|
16
|
+
filename = "_#{singular_table_name}.html.erb"
|
17
|
+
template "_row.html.erb", File.join("app/views", controller_file_path, filename)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails/generators/resource_helpers'
|
2
|
+
require 'generators/rails/mizugumo/view_generator'
|
3
|
+
|
4
|
+
module Mizugumo
|
5
|
+
class HamlGenerator < ViewGenerator
|
6
|
+
include ::Rails::Generators::ResourceHelpers
|
7
|
+
|
8
|
+
self.namespace("rails:mizugumo:haml")
|
9
|
+
source_root File.dirname(__FILE__) + '/templates'
|
10
|
+
|
11
|
+
def copy_html_view_files
|
12
|
+
HTML_VIEWS.each do |view|
|
13
|
+
filename = "#{view}.html.haml"
|
14
|
+
template filename, File.join("app/views", controller_file_path, filename)
|
15
|
+
end
|
16
|
+
filename = "_#{singular_table_name}.html.haml"
|
17
|
+
template "_row.html.haml", File.join("app/views", controller_file_path, filename)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails/generators/resource_helpers'
|
2
|
+
|
3
|
+
module Mizugumo
|
4
|
+
class ScaffoldControllerGenerator < Rails::Generators::NamedBase
|
5
|
+
include Rails::Generators::ResourceHelpers
|
6
|
+
self.namespace('rails:mizugumo:scaffold_controller')
|
7
|
+
|
8
|
+
source_root File.dirname(__FILE__) + '/templates'
|
9
|
+
|
10
|
+
check_class_collision :suffix => "Controller"
|
11
|
+
|
12
|
+
class_option :orm, :banner => "NAME", :type => :string, :required => true,
|
13
|
+
:desc => "ORM to generate the controller for"
|
14
|
+
|
15
|
+
def create_controller_files
|
16
|
+
template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
hook_for :template_engine, :test_framework, :in => :rails, :as => :scaffold
|
20
|
+
|
21
|
+
# Invoke the helper using the controller name (pluralized)
|
22
|
+
hook_for :helper, :in => :rails, :as => :scaffold do |invoked|
|
23
|
+
invoke invoked, [ controller_name ]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%%= form_for(@<%= singular_table_name %>) do |f| %>
|
2
|
+
<%% if @<%= singular_table_name %>.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%%= msg %></li>
|
9
|
+
<%% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<%% end %>
|
13
|
+
|
14
|
+
<% for attribute in attributes -%>
|
15
|
+
<div class="field">
|
16
|
+
<%%= f.label :<%= attribute.name %> %><br />
|
17
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
18
|
+
</div>
|
19
|
+
<% end -%>
|
20
|
+
<div class="actions">
|
21
|
+
<%%= f.submit %>
|
22
|
+
</div>
|
23
|
+
<%% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
- @<%= singular_table_name %> ||= <%= class_name %>.new
|
2
|
+
= form_for(@<%= singular_table_name %>) do |f|
|
3
|
+
|
4
|
+
- if @<%= singular_table_name %>.errors.any?
|
5
|
+
#error_explanation
|
6
|
+
%h2
|
7
|
+
= pluralize(@<%= singular_table_name %>.errors.count, "error")
|
8
|
+
prohibited this <%= singular_table_name %> from being saved:
|
9
|
+
|
10
|
+
%ul
|
11
|
+
- @<%= singular_table_name %>.errors.full_messages.each do |msg|
|
12
|
+
%li= msg
|
13
|
+
|
14
|
+
<% for attribute in attributes -%>
|
15
|
+
.field
|
16
|
+
= f.label :<%= attribute.name %>
|
17
|
+
%br
|
18
|
+
= f.<%= attribute.field_type %> :<%= attribute.name %>
|
19
|
+
<% end -%>
|
20
|
+
.actions
|
21
|
+
= f.submit
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%%= content_tag_for :tr, <%= singular_table_name %> do %>
|
2
|
+
<% for attribute in attributes -%>
|
3
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
4
|
+
<% end -%>
|
5
|
+
<td><%%= link_to 'Show', <%= singular_table_name %> %></td>
|
6
|
+
<td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>), :class => 'edit_<%= singular_table_name %>' %></td>
|
7
|
+
<td><%%= link_to 'Delete', <%= singular_table_name %>, :confirm => 'Are you sure?', :method => :delete, :class => 'delete_<%= singular_table_name %>' %></td>
|
8
|
+
</tr>
|
9
|
+
<%% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
= content_tag_for :tr, <%= singular_table_name %> do
|
2
|
+
<% for attribute in attributes -%>
|
3
|
+
%td= <%= singular_table_name %>.<%= attribute.name %>
|
4
|
+
<% end -%>
|
5
|
+
%td= link_to 'Show', <%= singular_table_name %>
|
6
|
+
%td= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>), :class => "edit_<%= singular_table_name %>"
|
7
|
+
%td= link_to 'Delete', <%= singular_table_name %>, :confirm => 'Are you sure?', :method => :delete, :class => "delete_<%= singular_table_name %>"
|
@@ -0,0 +1,93 @@
|
|
1
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
+
# GET <%= route_url %>
|
3
|
+
# GET <%= route_url %>.xml
|
4
|
+
def index
|
5
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.xml { render :xml => @<%= plural_table_name %> }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET <%= route_url %>/1
|
14
|
+
# GET <%= route_url %>/1.xml
|
15
|
+
def show
|
16
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
17
|
+
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # show.html.erb
|
20
|
+
format.xml { render :xml => @<%= singular_table_name %> }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET <%= route_url %>/new
|
25
|
+
# GET <%= route_url %>/new.xml
|
26
|
+
def new
|
27
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # new.html.erb
|
31
|
+
format.xml { render :xml => @<%= singular_table_name %> }
|
32
|
+
format.js
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET <%= route_url %>/1/edit
|
37
|
+
def edit
|
38
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
39
|
+
respond_to do |format|
|
40
|
+
format.html
|
41
|
+
format.js
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# POST <%= route_url %>
|
46
|
+
# POST <%= route_url %>.xml
|
47
|
+
def create
|
48
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "params[:#{singular_table_name}]") %>
|
49
|
+
|
50
|
+
respond_to do |format|
|
51
|
+
if @<%= orm_instance.save %>
|
52
|
+
format.html { redirect_to(@<%= singular_table_name %>, :notice => '<%= human_name %> was successfully created.') }
|
53
|
+
format.xml { render :xml => @<%= singular_table_name %>, :status => :created, :location => @<%= singular_table_name %> }
|
54
|
+
format.js
|
55
|
+
else
|
56
|
+
format.html { render :action => "new" }
|
57
|
+
format.xml { render :xml => @<%= orm_instance.errors %>, :status => :unprocessable_entity }
|
58
|
+
format.js { render :action => "new" }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# PUT <%= route_url %>/1
|
64
|
+
# PUT <%= route_url %>/1.xml
|
65
|
+
def update
|
66
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
67
|
+
|
68
|
+
respond_to do |format|
|
69
|
+
if @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %>
|
70
|
+
format.html { redirect_to(@<%= singular_table_name %>, :notice => '<%= human_name %> was successfully updated.') }
|
71
|
+
format.xml { head :ok }
|
72
|
+
format.js
|
73
|
+
else
|
74
|
+
format.html { render :action => "edit" }
|
75
|
+
format.xml { render :xml => @<%= orm_instance.errors %>, :status => :unprocessable_entity }
|
76
|
+
format.js { render :action => "edit" }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# DELETE <%= route_url %>/1
|
82
|
+
# DELETE <%= route_url %>/1.xml
|
83
|
+
def destroy
|
84
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
85
|
+
@<%= orm_instance.destroy %>
|
86
|
+
|
87
|
+
respond_to do |format|
|
88
|
+
format.html { redirect_to(<%= index_helper %>_url) }
|
89
|
+
format.xml { head :ok }
|
90
|
+
format.js
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$("#<%%= dom_id(@<%= singular_table_name %>) %>").remove()
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<h1>Listing <%= plural_table_name.humanize %></h1>
|
2
|
+
|
3
|
+
<div id="<%= plural_table_name %>">
|
4
|
+
<table class="scaffold">
|
5
|
+
<tr>
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
<th><%= attribute.human_name %></th>
|
8
|
+
<% end -%>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
<%%= render @<%= plural_table_name %> %>
|
14
|
+
</table>
|
15
|
+
|
16
|
+
<%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path, :class => 'new_<%= singular_table_name %>' %>
|
17
|
+
|
18
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%h1 List of <%= plural_table_name %>
|
2
|
+
|
3
|
+
#<%= plural_table_name %>
|
4
|
+
%table.scaffold
|
5
|
+
%tr
|
6
|
+
<% for attribute in attributes -%>
|
7
|
+
%th <%= attribute.human_name %>
|
8
|
+
<% end -%>
|
9
|
+
%th{:colspan => 3}
|
10
|
+
=render @<%= plural_table_name %>
|
11
|
+
|
12
|
+
= link_to 'New <%= class_name %>', new_<%= singular_table_name %>_path, :class => 'new_<%= singular_table_name %>'
|
13
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% for attribute in attributes -%>
|
2
|
+
<p>
|
3
|
+
<b><%= attribute.human_name %>:</b>
|
4
|
+
<%%= @<%= singular_table_name %>.<%= attribute.name %> %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
|
10
|
+
<%%= link_to 'Back', <%= index_helper %>_path %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% for attribute in attributes -%>
|
2
|
+
%p
|
3
|
+
%b <%= attribute.human_name %>:
|
4
|
+
= @<%= singular_table_name %>.<%= attribute.name %>
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
|
8
|
+
|
|
9
|
+
= link_to 'Back', <%= plural_table_name %>_path
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rails/generators/resource_helpers'
|
2
|
+
|
3
|
+
module Mizugumo
|
4
|
+
class ViewGenerator < Rails::Generators::NamedBase
|
5
|
+
include ::Rails::Generators::ResourceHelpers
|
6
|
+
|
7
|
+
source_root File.dirname(__FILE__) + '/templates'
|
8
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
9
|
+
check_class_collision :suffix => "Controller"
|
10
|
+
|
11
|
+
class_option :orm, :banner => "NAME", :type => :string, :required => true,
|
12
|
+
:desc => "ORM to generate the controller for"
|
13
|
+
|
14
|
+
JS_VIEWS = %w(create destroy edit new update)
|
15
|
+
HTML_VIEWS = %w(index edit show new _form)
|
16
|
+
|
17
|
+
def create_root_folder
|
18
|
+
empty_directory File.join("app/views", controller_file_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def copy_js_files
|
22
|
+
JS_VIEWS.each do |view|
|
23
|
+
filename = "#{view}.js.erb"
|
24
|
+
template filename, File.join("app/views", controller_file_path, filename)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_javascript
|
29
|
+
file = File.join("public", "javascripts", "application.js")
|
30
|
+
append_to_file(file) do
|
31
|
+
<<ADDITIONAL_JS
|
32
|
+
Ninja.behavior({
|
33
|
+
// Generated by the mizugumo scaffold
|
34
|
+
// AJAX behavior for edit, new, and delete actions; applies to both forms and links
|
35
|
+
'.new_#{singular_table_name}': Ninja.submitsAsAjax,
|
36
|
+
'.edit_#{singular_table_name}': Ninja.submitsAsAjax,
|
37
|
+
'.delete_#{singular_table_name}': Ninja.submitsAsAjax
|
38
|
+
})
|
39
|
+
ADDITIONAL_JS
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|