masterview 0.0.2
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.
- data/CHANGELOG +1 -0
- data/MIT-LICENSE +20 -0
- data/README +574 -0
- data/Rakefile +149 -0
- data/generators/masterview/USAGE +32 -0
- data/generators/masterview/masterview_generator.rb +277 -0
- data/generators/masterview/templates/controller.rb +50 -0
- data/generators/masterview/templates/fields_scaffold.rhtml +1 -0
- data/generators/masterview/templates/form_scaffold.rhtml +3 -0
- data/generators/masterview/templates/functional_test.rb +83 -0
- data/generators/masterview/templates/helper.rb +2 -0
- data/generators/masterview/templates/layout.rhtml +11 -0
- data/generators/masterview/templates/list_head_scaffold.rhtml +4 -0
- data/generators/masterview/templates/list_line_scaffold.rhtml +6 -0
- data/generators/masterview/templates/masterview.rhtml +182 -0
- data/generators/masterview/templates/mvpreview.js +31 -0
- data/generators/masterview/templates/semantic.cache +84 -0
- data/generators/masterview/templates/show_scaffold.rhtml +3 -0
- data/generators/masterview/templates/style.css +61 -0
- data/generators/masterview_gem_plugin/masterview_gem_plugin_generator.rb +21 -0
- data/generators/masterview_gem_plugin/templates/init.rb +43 -0
- data/init.rb +43 -0
- data/lib/masterview/directive_base.rb +163 -0
- data/lib/masterview/directive_helpers.rb +176 -0
- data/lib/masterview/directives/block.rb +30 -0
- data/lib/masterview/directives/content.rb +10 -0
- data/lib/masterview/directives/else.rb +25 -0
- data/lib/masterview/directives/elsif.rb +26 -0
- data/lib/masterview/directives/form.rb +19 -0
- data/lib/masterview/directives/global_inline_erb.rb +39 -0
- data/lib/masterview/directives/hidden_field.rb +31 -0
- data/lib/masterview/directives/if.rb +24 -0
- data/lib/masterview/directives/insert_generated_comment.rb +30 -0
- data/lib/masterview/directives/javascript_include.rb +15 -0
- data/lib/masterview/directives/link_to.rb +17 -0
- data/lib/masterview/directives/link_to_if.rb +21 -0
- data/lib/masterview/directives/link_to_remote.rb +17 -0
- data/lib/masterview/directives/password_field.rb +33 -0
- data/lib/masterview/directives/preview.rb +10 -0
- data/lib/masterview/directives/replace.rb +18 -0
- data/lib/masterview/directives/stylesheet_link.rb +14 -0
- data/lib/masterview/directives/submit.rb +14 -0
- data/lib/masterview/directives/testfilter.rb +55 -0
- data/lib/masterview/directives/text_area.rb +34 -0
- data/lib/masterview/directives/text_field.rb +33 -0
- data/lib/masterview/extras/rails_init.rb +67 -0
- data/lib/masterview/extras/watcher.rb +30 -0
- data/lib/masterview/masterview_version.rb +9 -0
- data/lib/masterview/parser.rb +585 -0
- data/lib/masterview/plugin_load_tracking.rb +41 -0
- data/lib/masterview/runtime_helpers.rb +9 -0
- data/lib/masterview/string_extensions.rb +15 -0
- data/lib/masterview.rb +130 -0
- data/test/block_test.rb +47 -0
- data/test/content_test.rb +26 -0
- data/test/else_test.rb +31 -0
- data/test/elsif_test.rb +31 -0
- data/test/example_test.rb +11 -0
- data/test/filter_helpers_test.rb +142 -0
- data/test/form_test.rb +66 -0
- data/test/global_inline_erb_test.rb +30 -0
- data/test/hidden_field_test.rb +62 -0
- data/test/if_test.rb +23 -0
- data/test/javascript_include_test.rb +26 -0
- data/test/link_to_if_test.rb +27 -0
- data/test/link_to_test.rb +52 -0
- data/test/parser_test.rb +166 -0
- data/test/password_field_test.rb +89 -0
- data/test/replace_test.rb +27 -0
- data/test/run_parser_test.rb +27 -0
- data/test/stylesheet_link_test.rb +26 -0
- data/test/submit_test.rb +54 -0
- data/test/template_file_watcher_test.rb +50 -0
- data/test/template_test.rb +181 -0
- data/test/test_helper.rb +24 -0
- data/test/text_area_test.rb +81 -0
- data/test/text_field_test.rb +89 -0
- metadata +136 -0
@@ -0,0 +1,182 @@
|
|
1
|
+
<html mv:generate="layouts/<%= singular_name %>.rhtml">
|
2
|
+
<head>
|
3
|
+
<title><%= controller_class_name %>: {{{= controller.action_name }}}</title>
|
4
|
+
<link rel="stylesheet" type="text/css" href="../../../public/stylesheets/scaffold.css" mv:stylesheet_link="scaffold"/>
|
5
|
+
<script type="text/javascript" src="../../../public/javascripts/prototype.js" mv:javascript_include=":defaults"></script>
|
6
|
+
<script type="text/javascript" src="../../../public/javascripts/effects.js" mv:replace=""></script>
|
7
|
+
<script type="text/javascript" src="../../../public/javascripts/dragdrop.js" mv:replace=""></script>
|
8
|
+
<script type="text/javascript" src="../../../public/javascripts/controls.js" mv:replace=""></script>
|
9
|
+
<script type="text/javascript" src="../../../public/javascripts/application.js" mv:replace=""></script>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<div class="messages" mv:if="@flash[:notice]" mv:content="@flash[:notice]">
|
14
|
+
messages
|
15
|
+
</div>
|
16
|
+
|
17
|
+
|
18
|
+
<div id="<%= singular_name %>_content" mv:replace="@content_for_layout">
|
19
|
+
<div id="<%= singular_name %>_new" mv:generate="<%= singular_name %>/new.rhtml" mv:preview="showOne">
|
20
|
+
<div class="<%= singular_name %>_new sidebar">
|
21
|
+
<h1>Tasks:</h1>
|
22
|
+
<ul>
|
23
|
+
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
24
|
+
</ul>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class="<%= singular_name %>_new content">
|
28
|
+
<h1><%= plural_name.capitalize %></h1>
|
29
|
+
|
30
|
+
<form mv:form=":action => 'new'">
|
31
|
+
|
32
|
+
<div class="form">
|
33
|
+
<h2>Creating <%= singular_name %></h2>
|
34
|
+
|
35
|
+
<div id="<%= singular_name %>_form" mv:gen_render=":partial => '<%= singular_name %>/form'">
|
36
|
+
<div class="error_messages" mv:replace="error_messages_for :<%= singular_name %>">
|
37
|
+
error messages
|
38
|
+
</div>
|
39
|
+
<br/>
|
40
|
+
<%= form_inclusion %>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<br/>
|
46
|
+
<div class="<%= singular_name %>_new operations">
|
47
|
+
<input type="submit" value="OK" class="primary" mv:submit="" onclick="javascript:mvpreview.showOneSection('<%= singular_name %>_list');return false;"/>
|
48
|
+
<input type="button" value="Cancel" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" />
|
49
|
+
</div>
|
50
|
+
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="<%= singular_name %>_edit" mv:generate="<%= singular_name %>/edit.rhtml" mv:preview="showOne">
|
59
|
+
<div class="<%= singular_name %>_edit sidebar">
|
60
|
+
<h1>Tasks:</h1>
|
61
|
+
<ul>
|
62
|
+
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
63
|
+
</ul>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div class="<%= singular_name %>_edit content">
|
67
|
+
<h1><%= plural_name.capitalize %></h1>
|
68
|
+
|
69
|
+
<form mv:form=":action => 'edit', :id => @<%=singular_name%>.id">
|
70
|
+
|
71
|
+
<div class="form">
|
72
|
+
<h2>Editing <%= singular_name %></h2>
|
73
|
+
<div mv:replace="render :partial => 'form'" mv:preview="copyOf:<%= singular_name %>_form">
|
74
|
+
copyOf:<%= singular_name %>_form
|
75
|
+
</div>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
<br/>
|
79
|
+
<div class="<%= singular_name %>_edit operations">
|
80
|
+
<input type="submit" value="OK" class="primary" mv:submit="" onclick="javascript:mvpreview.showOneSection('<%= singular_name %>_list');return false;"/>
|
81
|
+
<input type="button" value="Cancel" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" /> </div>
|
82
|
+
|
83
|
+
</form>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<div id="<%= singular_name %>_list" mv:generate="<%= singular_name %>/list.rhtml" mv:preview="showOne">
|
90
|
+
<div class="<%= singular_name %>_list sidebar">
|
91
|
+
<h1>Tasks:</h1>
|
92
|
+
<ul>
|
93
|
+
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_new');" mv:link_to=":action => 'new<%= suffix %>'">Create new <%= singular_name %></a></li>
|
94
|
+
</ul>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<div class="<%= singular_name %>_list content">
|
98
|
+
<h1><%= plural_name.capitalize %></h1>
|
99
|
+
|
100
|
+
<div class="list">
|
101
|
+
<table border="1" class="<%= singular_name %>_list_table" cellpadding="5">
|
102
|
+
<tr>
|
103
|
+
<%= list_head_inclusion %>
|
104
|
+
</tr>
|
105
|
+
<tr mv:gen_render=":partial => '<%= singular_name %>/<%= singular_name %>', :collection => @<%= plural_name %>">
|
106
|
+
<%= list_line_inclusion %>
|
107
|
+
</tr>
|
108
|
+
</table>
|
109
|
+
|
110
|
+
<a mv:if="@<%= singular_name %>_pages.current.previous" mv:link_to=":page => @<%= singular_name %>_pages.current.previous">Previous page</a>
|
111
|
+
<a mv:if="@<%= singular_name %>_pages.current.next" mv:link_to=":page => @<%= singular_name %>_pages.current.next">Next page</a>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<div id="<%= singular_name %>_show" mv:generate="<%= singular_name %>/show.rhtml" mv:preview="showOne">
|
120
|
+
<div class="<%= singular_name %>_show sidebar">
|
121
|
+
<h1>Tasks:</h1>
|
122
|
+
<ul>
|
123
|
+
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
124
|
+
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_edit');" mv:link_to=":action => 'edit<%= suffix %>', :id => @<%= singular_name %>.id">Edit this <%= singular_name %></a></li>
|
125
|
+
</ul>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
<div class="<%= singular_name %>_show content">
|
129
|
+
<h1><%= plural_name.capitalize %></h1>
|
130
|
+
|
131
|
+
<div id="<%= singular_name %>_show_partial" class="form" mv:gen_render=":partial => '<%= singular_name %>/show'">
|
132
|
+
<%= show_inclusion %>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
</div>
|
136
|
+
</div>
|
137
|
+
|
138
|
+
<div id="<%= singular_name %>_destroy" mv:generate="<%= singular_name %>/destroy.rhtml" mv:preview="showOne">
|
139
|
+
<div class="<%= singular_name %>_destroy sidebar">
|
140
|
+
<h1>Tasks:</h1>
|
141
|
+
<ul>
|
142
|
+
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
143
|
+
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_show');" mv:link_to=":action => 'show<%= suffix %>', :id => @<%= singular_name %>.id">Show this <%= singular_name %></a></li>
|
144
|
+
</ul>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<div class="<%= singular_name %>_destroy content">
|
148
|
+
<h1><%= plural_name.capitalize %></h1>
|
149
|
+
|
150
|
+
<div class="error_messages" mv:replace="error_messages_for :<%= singular_name %>">
|
151
|
+
error messages
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<div class="messages">Are you sure you want to delete this item?</div>
|
155
|
+
<br/>
|
156
|
+
<form mv:form=":action => 'destroy', :id => @<%= singular_name %>.id">
|
157
|
+
<div mv:replace="render :partial => 'show'" mv:preview="copyOf:<%= singular_name %>_show_partial">
|
158
|
+
copyOf:<%= singular_name %>_show_partial
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<br/>
|
162
|
+
<div class="<%= singular_name %>_edit operations">
|
163
|
+
<input type="submit" value="Delete" mv:submit="" onclick="javascript:mvpreview.showOneSection('<%= singular_name %>_list');return false;"/>
|
164
|
+
<input type="button" value="Cancel" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" />
|
165
|
+
</div>
|
166
|
+
</form>
|
167
|
+
</div>
|
168
|
+
</div>
|
169
|
+
</div>
|
170
|
+
|
171
|
+
<script type="text/javascript" mv:replace="" src="../../../public/javascripts/mvpreview.js"></script>
|
172
|
+
<script type="text/javascript" mv:replace="">
|
173
|
+
mvpreview.copySections();
|
174
|
+
mvpreview.showOneSection('<%= singular_name %>_list');
|
175
|
+
</script>
|
176
|
+
|
177
|
+
</body>
|
178
|
+
</html>
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
var mvpreview = new Object();
|
2
|
+
|
3
|
+
mvpreview.preview_divs = $A( document.getElementsByTagName('div') ).findAll( function(elem){ return (elem.getAttribute('mv:preview') != null); });
|
4
|
+
|
5
|
+
mvpreview.copySections = function(){
|
6
|
+
var mv_sections_needing_copy = this.preview_divs.findAll( function(elem){
|
7
|
+
var prevAttr = elem.getAttribute('mv:preview');
|
8
|
+
return (prevAttr.substring(0,7) == 'copyOf:');
|
9
|
+
});
|
10
|
+
|
11
|
+
//copy sections
|
12
|
+
mv_sections_needing_copy.each( function(e){
|
13
|
+
var id = e.getAttribute('mv:preview').split(':')[1];
|
14
|
+
e.innerHTML = $(id).innerHTML;
|
15
|
+
} );
|
16
|
+
};
|
17
|
+
|
18
|
+
mvpreview.sections = mvpreview.preview_divs.findAll( function(elem){ return (elem.getAttribute('mv:preview') == 'showOne'); });
|
19
|
+
|
20
|
+
mvpreview.hideSections = function(){
|
21
|
+
this.sections.each( function(elem){ window.Element.hide(elem); } );
|
22
|
+
}
|
23
|
+
|
24
|
+
mvpreview.findSectionToShow = function(id){
|
25
|
+
return this.sections.find( function(e){ return (e.id == id); } );
|
26
|
+
}
|
27
|
+
|
28
|
+
mvpreview.showOneSection = function(id){
|
29
|
+
this.hideSections();
|
30
|
+
window.Element.show( this.findSectionToShow(id) );
|
31
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
;; Object templates/
|
2
|
+
;; SEMANTICDB Tags save file
|
3
|
+
(semanticdb-project-database-file "templates/"
|
4
|
+
:tables (list
|
5
|
+
(semanticdb-table "masterview.rhtml"
|
6
|
+
:major-mode 'html-mode
|
7
|
+
:tags '((": {{{= controller.action_name }}}" section nil nil [74 282]) ("messages" section nil nil [282 411]) ("messages" section nil nil [411 540]) ("messages" section nil nil [540 667]) ("messages" section nil nil [667 808]) ("messages" section (:members (("Tasks:" section (:members (("Back to overview" section nil nil [1175 1403]))) nil [1143 1403]) ("Creating <%= singular_name %>" section (:members (("Creating <%= singular_name %>" section nil nil [1511 2406]))) nil [1403 2406]) ("Tasks:" section (:members (("Back to overview" section nil nil [2438 2667]))) nil [2406 2667]) ("Editing <%= singular_name %>" section (:members (("Editing <%= singular_name %>" section nil nil [2807 3579]))) nil [2667 3579]) ("Tasks:" section (:members (("Create new <%= singular_name %>" section nil nil [3611 3853]))) nil [3579 3853]) ("Previous page" section nil nil [3853 4650]) ("Tasks:" section (:members (("Back to overview" section nil nil [4682 4833]) ("Edit this <%= singular_name %>" section nil nil [4833 5108]))) nil [4650 5108]) ("Tasks:" section nil nil [5108 5495]) ("Tasks:" section (:members (("Back to overview" section nil nil [5530 5686]) ("Show this <%= singular_name %>" section nil nil [5686 5957]))) nil [5495 5957]) ("error messages" section nil nil [5957 6847]))) nil [808 6847]) ("mvpreview.copySections();
|
8
|
+
mvpreview.showOneSection('product_list');" section nil nil [6847 6953]) ("mvpreview.copySections();
|
9
|
+
mvpreview.showOneSection('product_list');" section nil nil [6953 6961]))
|
10
|
+
:file "masterview.rhtml"
|
11
|
+
:pointmax 7120
|
12
|
+
:unmatched-syntax 'nil
|
13
|
+
)
|
14
|
+
(semanticdb-table "fields_scaffold.rhtml"
|
15
|
+
:major-mode 'html-mode
|
16
|
+
:tags 'nil
|
17
|
+
:file "fields_scaffold.rhtml"
|
18
|
+
:pointmax 60
|
19
|
+
)
|
20
|
+
(semanticdb-table "form.rhtml"
|
21
|
+
:major-mode 'html-mode
|
22
|
+
:tags 'nil
|
23
|
+
:file "form.rhtml"
|
24
|
+
:pointmax 81
|
25
|
+
)
|
26
|
+
(semanticdb-table "show_line_scaffolding.rhtml"
|
27
|
+
:major-mode 'html-mode
|
28
|
+
:tags 'nil
|
29
|
+
:file "show_line_scaffolding.rhtml"
|
30
|
+
:pointmax 284
|
31
|
+
)
|
32
|
+
(semanticdb-table "show_scaffold.rhtml"
|
33
|
+
:major-mode 'html-mode
|
34
|
+
:tags 'nil
|
35
|
+
:file "show_scaffold.rhtml"
|
36
|
+
:pointmax 132
|
37
|
+
)
|
38
|
+
(semanticdb-table "list_line_scaffold.rhtml"
|
39
|
+
:major-mode 'html-mode
|
40
|
+
:tags '(("Show" section nil nil [87 274]) ("Edit" section nil nil [274 461]) ("Destroy" section nil nil [461 464]))
|
41
|
+
:file "list_line_scaffold.rhtml"
|
42
|
+
:pointmax 621
|
43
|
+
)
|
44
|
+
(semanticdb-table "form_scaffold.rhtml"
|
45
|
+
:major-mode 'html-mode
|
46
|
+
:tags 'nil
|
47
|
+
:file "form_scaffold.rhtml"
|
48
|
+
:pointmax 132
|
49
|
+
)
|
50
|
+
(semanticdb-table "layout.rhtml"
|
51
|
+
:major-mode 'html-mode
|
52
|
+
:tags '((": <%%= controller.action_name %>" section nil nil [17 142]) ("" section nil nil [142 147]))
|
53
|
+
:file "layout.rhtml"
|
54
|
+
:pointmax 195
|
55
|
+
)
|
56
|
+
(semanticdb-table "view_destroy.rhtml"
|
57
|
+
:major-mode 'html-mode
|
58
|
+
:tags '(("Tasks:" section nil nil [22 290]) ("Are you sure you want to delete this item?" section nil nil [290 293]))
|
59
|
+
:file "view_destroy.rhtml"
|
60
|
+
:pointmax 516
|
61
|
+
)
|
62
|
+
(semanticdb-table "view_edit.rhtml"
|
63
|
+
:major-mode 'html-mode
|
64
|
+
:tags '(("Tasks:" section nil nil [22 163]) ("\"edit\", :id => @<%=singular_name%>.id %>
|
65
|
+
|
66
|
+
<div class=\"form\">
|
67
|
+
<h2>Editing <%= singular_name %>" section (:members (("Editing <%= singular_name %>" section nil nil [302 305]))) nil [163 166]))
|
68
|
+
:file "view_edit.rhtml"
|
69
|
+
:pointmax 482
|
70
|
+
)
|
71
|
+
(semanticdb-table "view_new.rhtml"
|
72
|
+
:major-mode 'html-mode
|
73
|
+
:tags '(("Tasks:" section nil nil [22 163]) ("\"new\" %>
|
74
|
+
|
75
|
+
<div class=\"form\">
|
76
|
+
<h2>Creating <%= singular_name %>" section (:members (("Creating <%= singular_name %>" section nil nil [270 273]))) nil [163 166]))
|
77
|
+
:file "view_new.rhtml"
|
78
|
+
:pointmax 451
|
79
|
+
)
|
80
|
+
)
|
81
|
+
:file "semantic.cache"
|
82
|
+
:semantic-tag-version "2.0pre3"
|
83
|
+
:semanticdb-version "2.0pre3"
|
84
|
+
)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
.fieldWithErrors {
|
20
|
+
padding: 2px;
|
21
|
+
background-color: red;
|
22
|
+
display: table;
|
23
|
+
}
|
24
|
+
|
25
|
+
.messages {
|
26
|
+
color: green;
|
27
|
+
}
|
28
|
+
|
29
|
+
.label {
|
30
|
+
text-align: right;
|
31
|
+
}
|
32
|
+
|
33
|
+
#ErrorExplanation {
|
34
|
+
width: 400px;
|
35
|
+
border: 2px solid #red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 12px;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#ErrorExplanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
background-color: #c00;
|
49
|
+
color: #fff;
|
50
|
+
}
|
51
|
+
|
52
|
+
#ErrorExplanation p {
|
53
|
+
color: #333;
|
54
|
+
margin-bottom: 0;
|
55
|
+
padding: 5px;
|
56
|
+
}
|
57
|
+
|
58
|
+
#ErrorExplanation ul li {
|
59
|
+
font-size: 12px;
|
60
|
+
list-style: square;
|
61
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generator to generate small init.rb plugin which is used in
|
2
|
+
# conjunction with the masterview gem
|
3
|
+
class MasterviewGemPluginGenerator < Rails::Generator::Base
|
4
|
+
def initialize(runtime_args, runtime_options = {})
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def manifest
|
9
|
+
record do |m|
|
10
|
+
m.directory 'vendor/plugins/masterview'
|
11
|
+
m.directory 'vendor/plugins/masterview/directives'
|
12
|
+
m.template 'init.rb', 'vendor/plugins/masterview/init.rb'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
def banner
|
18
|
+
"Usage: #{$0} masterview_gem_plugin"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright (c) 2006 Jeff Barczewski
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
# a copy of this software and associated documentation files (the
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
# the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be
|
15
|
+
# included in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#++
|
25
|
+
#
|
26
|
+
# = MasterView - Rails-optimized (x)html friendly template engine
|
27
|
+
#
|
28
|
+
# MasterView is a ruby/rails optimized HTML/XHTML friendly template engine.
|
29
|
+
# It is designed to use the full power and productivity of rails including
|
30
|
+
# layouts, partials, and rails html helpers while still being editable/styleable
|
31
|
+
# in a WYSIWYG HTML editor.
|
32
|
+
|
33
|
+
require 'masterview'
|
34
|
+
|
35
|
+
module ::MasterView
|
36
|
+
#override any constants here, see masterview.rb for more
|
37
|
+
#DefaultDirectiveLoadPaths.push File.join( File.dirname(__FILE__), 'directives') #uncomment if you want to add a local directives dir
|
38
|
+
#DefaultParserOptions = { :tidy => false, :escape_erb => true }
|
39
|
+
#TidyPath = '/usr/lib/libtidy.so'
|
40
|
+
end
|
41
|
+
|
42
|
+
require 'masterview/extras/rails_init.rb'
|
43
|
+
|
data/init.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright (c) 2006 Jeff Barczewski
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
# a copy of this software and associated documentation files (the
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
# the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be
|
15
|
+
# included in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#++
|
25
|
+
#
|
26
|
+
# = MasterView - Rails-optimized (x)html friendly template engine
|
27
|
+
#
|
28
|
+
# MasterView is a ruby/rails optimized HTML/XHTML friendly template engine.
|
29
|
+
# It is designed to use the full power and productivity of rails including
|
30
|
+
# layouts, partials, and rails html helpers while still being editable/styleable
|
31
|
+
# in a WYSIWYG HTML editor.
|
32
|
+
|
33
|
+
require 'masterview'
|
34
|
+
|
35
|
+
module ::MasterView
|
36
|
+
#override any constants here, see masterview.rb for more
|
37
|
+
#DefaultDirectiveLoadPaths.push File.join( File.dirname(__FILE__), 'directives') #uncomment if you want to add a local directives dir
|
38
|
+
#DefaultParserOptions = { :tidy => false, :escape_erb => true }
|
39
|
+
#TidyPath = '/usr/lib/libtidy.so'
|
40
|
+
end
|
41
|
+
|
42
|
+
require 'masterview/extras/rails_init.rb'
|
43
|
+
|
@@ -0,0 +1,163 @@
|
|
1
|
+
module MasterView
|
2
|
+
|
3
|
+
class DirectiveBase
|
4
|
+
include PluginLoadTracking
|
5
|
+
include DirectiveHelpers
|
6
|
+
|
7
|
+
# Register a class manually without regard to whether it inherits from DirectiveBase.
|
8
|
+
# Classes which derive from DirectiveBase will automatically be registered as they are
|
9
|
+
# loaded.
|
10
|
+
def self.register_directive(directive_class)
|
11
|
+
self.register_class(directive_class)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(attribute_value)
|
15
|
+
@attribute_value = attribute_value
|
16
|
+
end
|
17
|
+
|
18
|
+
#if this method exists, it will be called by renderer to save directive_call_stack before each method call
|
19
|
+
def save_directive_call_stack(directive_call_stack)
|
20
|
+
@directive_call_stack = directive_call_stack
|
21
|
+
end
|
22
|
+
|
23
|
+
# returns the full attribute name which is the mv_ns prefix + attr_name if that method has been provided, otherwise
|
24
|
+
# it default to the class name (without any module prefix) and it downcases the first letter
|
25
|
+
def self.full_attr_name(namespace_prefix)
|
26
|
+
namespace_prefix + (self.respond_to?(:attr_name) ? self.attr_name : self.name.split(':').last.downcase_first_letter)
|
27
|
+
end
|
28
|
+
|
29
|
+
#get the directives attribute value string
|
30
|
+
def attr_value
|
31
|
+
@attribute_value
|
32
|
+
end
|
33
|
+
|
34
|
+
#set the directives attribute value string
|
35
|
+
def attr_value=(attribute_value)
|
36
|
+
@attribute_value = attribute_value
|
37
|
+
end
|
38
|
+
|
39
|
+
#get attribute hash from tag
|
40
|
+
def attrs
|
41
|
+
@directive_call_stack.context[:tag].attributes
|
42
|
+
end
|
43
|
+
|
44
|
+
#set attribute hash for tag
|
45
|
+
def attrs=(attributes)
|
46
|
+
@directive_call_stack.context[:tag].attributes = attributes
|
47
|
+
end
|
48
|
+
|
49
|
+
#get attribute hash with lowercased keys and values, and cache it
|
50
|
+
def attrs_lckv
|
51
|
+
@attrs_lckv ||= lowercase_attribute_keys_and_values(attrs)
|
52
|
+
end
|
53
|
+
|
54
|
+
#get attribute hash with lowercased keys (and original values) and cache it
|
55
|
+
def attrs_lck
|
56
|
+
@attrs_lck ||= lowercase_attribute_keys(attrs)
|
57
|
+
end
|
58
|
+
|
59
|
+
#returns true if the value for lckey of the attribute hash with lowercased keys and values
|
60
|
+
#matches (lowercase) lcmatch string
|
61
|
+
def attr_lckv_matches(lckey, lcmatch)
|
62
|
+
(attrs_lckv[lckey] && attrs_lckv[lckey] == lcmatch.downcase) ? true : false
|
63
|
+
end
|
64
|
+
|
65
|
+
#output '<% '+str+' %>'
|
66
|
+
def erb(str)
|
67
|
+
ERB_START + str + ERB_END
|
68
|
+
end
|
69
|
+
|
70
|
+
#output '<%= '+str+' %>
|
71
|
+
def erb_content(str)
|
72
|
+
ERB_EVAL + str + ERB_END
|
73
|
+
end
|
74
|
+
|
75
|
+
#get tag_name
|
76
|
+
def tag_name
|
77
|
+
@directive_call_stack.context[:tag].tag_name
|
78
|
+
end
|
79
|
+
|
80
|
+
#set tag_name
|
81
|
+
def tag_name=(tag_name)
|
82
|
+
@directive_call_stack.context[:tag].tag_name = tag_name
|
83
|
+
end
|
84
|
+
|
85
|
+
#inside characters, cdata, or comment you can call this to get the characters passed
|
86
|
+
def data
|
87
|
+
@directive_call_stack.context[:content_part]
|
88
|
+
end
|
89
|
+
|
90
|
+
#set the data that will be passed to characters, cdata, or comment directives
|
91
|
+
def data=(data)
|
92
|
+
@directive_call_stack.context[:content_part]=data
|
93
|
+
end
|
94
|
+
|
95
|
+
# rolled up content from all children of the tag, note this will not be complete until hitting the end tag method :etag
|
96
|
+
def content
|
97
|
+
@directive_call_stack.context[:tag].content
|
98
|
+
end
|
99
|
+
|
100
|
+
#return rolled up content from all children as string, note this will not be complete until hitting the end tag method :etag
|
101
|
+
def content_str
|
102
|
+
content = @directive_call_stack.context[:tag].content
|
103
|
+
content = content.join if content.respond_to? :join
|
104
|
+
content
|
105
|
+
end
|
106
|
+
|
107
|
+
# replace the content from all children with a new value
|
108
|
+
def content=(content)
|
109
|
+
@directive_call_stack.context[:tag].content = content
|
110
|
+
end
|
111
|
+
|
112
|
+
#add single quotes around string
|
113
|
+
def quote(str)
|
114
|
+
'\''+str+'\''
|
115
|
+
end
|
116
|
+
|
117
|
+
def remove_strings_from_attr_value!
|
118
|
+
self.attr_value = remove_prepended_strings(attr_value)
|
119
|
+
end
|
120
|
+
|
121
|
+
#prepend string to attribute value adding a comma if attribute value was not empty
|
122
|
+
def prepend_to_attr_value!(str)
|
123
|
+
return attr_value if str.nil? || str.strip.empty?
|
124
|
+
av = str
|
125
|
+
av << ', ' << attr_value unless attr_value.strip.empty?
|
126
|
+
self.attr_value = av
|
127
|
+
end
|
128
|
+
|
129
|
+
#append string to attribute value adding a comma if attribute value was not empty
|
130
|
+
def append_to_attr_value!(str)
|
131
|
+
return attr_value if str.nil? || str.strip.empty?
|
132
|
+
av = attr_value
|
133
|
+
av << ', ' unless av.strip.empty?
|
134
|
+
av << str
|
135
|
+
self.attr_value = av
|
136
|
+
end
|
137
|
+
|
138
|
+
#merge merge_hash into hashes stored in attribute_value string
|
139
|
+
#hash_index is the zero based index of the hash you want to add to
|
140
|
+
def merge_hash_attr_value!(hash_index, merge_hash)
|
141
|
+
self.attr_value = merge_into_embedded_hash(attr_value, hash_index, merge_hash)
|
142
|
+
end
|
143
|
+
|
144
|
+
#calls non-evaling parse to split into string arguments
|
145
|
+
def parse_attr_value
|
146
|
+
parse(attr_value)
|
147
|
+
end
|
148
|
+
|
149
|
+
# check for common html options and return the hash
|
150
|
+
def common_html_options(attrs_lck)
|
151
|
+
options = {}
|
152
|
+
options[:class] = attrs_lck['class'] if attrs_lck['class']
|
153
|
+
options[:style] = attrs_lck['style'] if attrs_lck['style']
|
154
|
+
options[:tabindex] = attrs_lck['tabindex'] if attrs_lck['tabindex']
|
155
|
+
options[:accesskey] = attrs_lck['accesskey'] if attrs_lck['accesskey']
|
156
|
+
options[:disabled] = true if attrs_lck['disabled']
|
157
|
+
options[:readonly] = true if attrs_lck['readonly']
|
158
|
+
options
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|