masterview 0.2.5 → 0.3.0
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 +31 -1
- data/README +70 -69
- data/RELEASE_NOTES +70 -64
- data/Rakefile +26 -27
- data/TODO +13 -29
- data/doc/about.html +246 -0
- data/doc/configuration.html +49 -36
- data/doc/developer.html +423 -41
- data/doc/directives.html +139 -51
- data/doc/guide.html +19 -9
- data/doc/index.html +90 -224
- data/doc/installation.html +36 -28
- data/doc/media_list.html +30 -20
- data/doc/simple_diagram.html +3 -5
- data/doc/stylesheets/masterview.css +16 -1
- data/examples/rails_app_config/masterview/settings.rb +2 -1
- data/init.rb +1 -1
- data/lib/#ChangeLog# +6 -0
- data/lib/masterview/analyzer.rb +48 -34
- data/lib/masterview/attr_string_parser.rb +5 -1
- data/lib/masterview/case_insensitive_hash.rb +69 -0
- data/lib/masterview/{pathname_extensions.rb → core_ext/pathname.rb} +0 -0
- data/lib/masterview/{string_extensions.rb → core_ext/string.rb} +0 -0
- data/lib/masterview/deprecated/directive_base.rb +362 -0
- data/lib/masterview/directive_base.rb +201 -179
- data/lib/masterview/directive_dsl.rb +457 -0
- data/lib/masterview/directive_helpers.rb +28 -141
- data/lib/masterview/directive_load_path.rb +388 -0
- data/lib/masterview/directive_metadata.rb +377 -0
- data/lib/masterview/directive_registry.rb +259 -69
- data/lib/masterview/directives/.metadata +16 -0
- data/lib/masterview/directives/attr.rb +9 -8
- data/lib/masterview/directives/block.rb +11 -14
- data/lib/masterview/directives/check_box.rb +13 -18
- data/lib/masterview/directives/collection_select.rb +15 -29
- data/lib/masterview/directives/content.rb +9 -3
- data/lib/masterview/directives/else.rb +15 -13
- data/lib/masterview/directives/elsif.rb +14 -13
- data/lib/masterview/directives/eval.rb +20 -0
- data/lib/masterview/directives/form.rb +56 -9
- data/lib/masterview/directives/form_remote.rb +26 -0
- data/lib/masterview/directives/global_inline_erb.rb +10 -14
- data/lib/masterview/directives/hidden_field.rb +11 -20
- data/lib/masterview/directives/if.rb +13 -12
- data/lib/masterview/directives/image_tag.rb +20 -28
- data/lib/masterview/directives/import.rb +5 -12
- data/lib/masterview/directives/import_render.rb +7 -19
- data/lib/masterview/directives/insert_generated_comment.rb +8 -11
- data/lib/masterview/directives/javascript_include.rb +21 -12
- data/lib/masterview/directives/link_to.rb +14 -8
- data/lib/masterview/directives/link_to_function.rb +22 -0
- data/lib/masterview/directives/link_to_if.rb +15 -13
- data/lib/masterview/directives/link_to_remote.rb +13 -8
- data/lib/masterview/directives/omit_tag.rb +32 -16
- data/lib/masterview/directives/password_field.rb +10 -22
- data/lib/masterview/directives/radio_button.rb +11 -22
- data/lib/masterview/directives/replace.rb +7 -8
- data/lib/masterview/directives/select.rb +11 -24
- data/lib/masterview/directives/stylesheet_link.rb +20 -12
- data/lib/masterview/directives/submit.rb +11 -5
- data/lib/masterview/directives/text_area.rb +10 -23
- data/lib/masterview/directives/text_field.rb +10 -22
- data/lib/masterview/exceptions.rb +21 -0
- data/lib/masterview/extras/app/controllers/masterview_controller.rb +102 -75
- data/lib/masterview/extras/app/views/layouts/masterview_admin.rhtml +24 -23
- data/lib/masterview/extras/app/views/layouts/masterview_admin_config.rhtml +81 -0
- data/lib/masterview/extras/app/views/masterview/admin/configuration.rhtml +5 -1
- data/lib/masterview/extras/app/views/masterview/admin/create.rhtml +2 -2
- data/lib/masterview/extras/app/views/masterview/admin/directives.rhtml +5 -0
- data/lib/masterview/extras/app/views/masterview/admin/features.rhtml +5 -79
- data/lib/masterview/extras/app/views/masterview/admin/interact.rhtml +5 -0
- data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +3 -71
- data/lib/masterview/extras/init_mv_admin_pages.rb +42 -23
- data/lib/masterview/filter_helpers.rb +26 -0
- data/lib/masterview/initializer.rb +99 -53
- data/lib/masterview/io.rb +19 -15
- data/lib/masterview/keyword_expander.rb +7 -2
- data/lib/masterview/masterview_info.rb +229 -23
- data/lib/masterview/masterview_version.rb +2 -2
- data/lib/masterview/parser.rb +275 -105
- data/lib/masterview/parser_helpers.rb +54 -0
- data/lib/masterview/rails_ext/action_controller_erb_direct.rb +29 -0
- data/lib/masterview/rails_ext/action_controller_reparse_checking.rb +27 -0
- data/lib/masterview/{extras/init_rails_erb_mv_direct.rb → rails_ext/action_view_erb_direct.rb} +12 -59
- data/lib/masterview/template_spec.rb +3 -2
- data/lib/masterview.rb +21 -12
- data/lib/rexml/parsers/baseparser_with_doctype_fix.rb +473 -0
- data/lib/rexml/parsers/sax2parser_with_doctype_fix.rb +243 -0
- data/test/directive_test_helper.rb +135 -0
- data/test/fixtures/directives/id_check.rb +18 -0
- data/test/fixtures/directives/test_directive_events.rb +70 -0
- data/test/test_helper.rb +18 -5
- data/test/tmp/views/layouts/product.rhtml +10 -10
- data/test/tmp/views/product/_form.rhtml +4 -4
- data/test/tmp/views/product/_product.rhtml +3 -3
- data/test/tmp/views/product/destroy.rhtml +5 -5
- data/test/tmp/views/product/edit.rhtml +4 -4
- data/test/tmp/views/product/list.rhtml +3 -3
- data/test/tmp/views/product/new.rhtml +4 -4
- data/test/tmp/views/product/show.rhtml +2 -2
- data/test/unit/attr_string_parser_test.rb +105 -0
- data/test/unit/case_insensitive_hash_mod_test.rb +104 -0
- data/test/unit/config_settings_test.rb +13 -1
- data/test/unit/default_generate_mio_filter_test.rb +3 -3
- data/test/unit/deprecated_directive_base_test.rb +30 -0
- data/test/unit/directive_attr_test.rb +111 -35
- data/test/unit/directive_base_test.rb +520 -1
- data/test/unit/directive_block_test.rb +30 -22
- data/test/unit/directive_content_test.rb +24 -11
- data/test/unit/directive_else_test.rb +18 -15
- data/test/unit/directive_elsif_test.rb +17 -15
- data/test/unit/directive_form_remote_test.rb +59 -0
- data/test/unit/directive_form_test.rb +31 -39
- data/test/unit/directive_global_inline_erb_test.rb +28 -17
- data/test/unit/directive_grid_test_notready.rb +38 -0
- data/test/unit/directive_helpers_test.rb +39 -0
- data/test/unit/directive_hidden_field_test.rb +44 -29
- data/test/unit/directive_if_test.rb +10 -7
- data/test/unit/directive_image_tag_test.rb +69 -61
- data/test/unit/directive_import_render_test.rb +28 -38
- data/test/unit/directive_import_test.rb +16 -14
- data/test/unit/directive_insert_generated_comment_test.rb +32 -0
- data/test/unit/directive_javascript_include_test.rb +40 -43
- data/test/unit/directive_link_to_function_test.rb +40 -0
- data/test/unit/directive_link_to_if_test.rb +52 -12
- data/test/unit/directive_link_to_remote_test.rb +58 -0
- data/test/unit/directive_link_to_test.rb +46 -31
- data/test/unit/directive_load_path_test.rb +257 -0
- data/test/unit/directive_metadata_test.rb +313 -0
- data/test/unit/directive_omit_tag_test.rb +73 -21
- data/test/unit/directive_password_field_test.rb +44 -38
- data/test/unit/directive_registry_test.rb +44 -0
- data/test/unit/directive_replace_test.rb +28 -12
- data/test/unit/directive_stylesheet_link_test.rb +43 -36
- data/test/unit/directive_submit_test.rb +29 -30
- data/test/unit/directive_text_area_test.rb +40 -36
- data/test/unit/directive_text_field_test.rb +44 -38
- data/test/unit/example_directive_child_events_test.rb +41 -0
- data/test/unit/example_test.rb +31 -4
- data/test/unit/file_mio_test.rb +18 -13
- data/test/unit/filter_helpers_test.rb +10 -8
- data/test/unit/find_directive_parent_test.rb +174 -0
- data/test/unit/keyword_expander_test.rb +4 -2
- data/test/unit/mio_test.rb +18 -11
- data/test/unit/mtime_string_hash_mio_tree_test.rb +5 -1
- data/test/unit/parser_test.rb +41 -29
- data/test/unit/pathname_extensions_test.rb +1 -1
- data/test/unit/run_parser_test.rb +2 -2
- data/test/unit/simplified_directive_base_test.rb +256 -0
- data/test/unit/string_hash_mio_test.rb +5 -1
- data/test/unit/template_file_watcher_test.rb +2 -2
- data/test/unit/template_test.rb +221 -46
- metadata +86 -45
- data/lib/masterview/directives/testfilter.rb +0 -55
- data/lib/masterview/extras/init_rails_reparse_checking.rb +0 -62
data/doc/media_list.html
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
<body>
|
17
17
|
|
18
18
|
<div id="pageHeader">
|
19
|
-
<a href="index.html"><img id="logo" src="images/masterview_logo.png" alt="MasterView Rails-optimized (x)html friendly template engine"/></a>
|
19
|
+
<a href="index.html"><img id="logo" src="images/masterview_logo.png" alt="MasterView Rails-optimized (x)html friendly template engine" /></a>
|
20
20
|
</div>
|
21
21
|
|
22
22
|
<div id="headerNav">
|
@@ -24,6 +24,8 @@
|
|
24
24
|
·
|
25
25
|
<a href="./index.html">Doc Home</a>
|
26
26
|
|
|
27
|
+
<a href="./about.html">About</a>
|
28
|
+
|
|
27
29
|
<a href="./installation.html">Installation</a>
|
28
30
|
|
|
29
31
|
<a href="./configuration.html">Configuration</a>
|
@@ -31,8 +33,10 @@
|
|
31
33
|
<a href="./guide.html">Usage</a>
|
32
34
|
|
|
33
35
|
<a href="./directives.html">Directives</a>
|
34
|
-
 
|
35
|
-
<a href="./
|
36
|
+
|
|
37
|
+
<a href="./developer.html">Developers</a>
|
38
|
+
|
|
39
|
+
<a href="./media_list.html">Screencasts</a>
|
36
40
|
·
|
37
41
|
</div>
|
38
42
|
</div>
|
@@ -40,43 +44,43 @@
|
|
40
44
|
<div id="pageBody">
|
41
45
|
<div id="bodyContent">
|
42
46
|
|
43
|
-
<h1>MasterView
|
47
|
+
<h1>MasterView Screencasts, Diagrams, and Screenshots</h1>
|
44
48
|
|
45
49
|
<h2>Illustrations/Diagrams</h2>
|
46
50
|
<ul>
|
47
|
-
<li><a href="simple_diagram.html"
|
48
|
-
<a href="simple_diagram.html"
|
51
|
+
<li><a href="simple_diagram.html">MasterView rendering illustration</a> - showing how MasterView renders rhtml internally<br /><br />
|
52
|
+
<a href="simple_diagram.html"><img src="images/masterview_rhtml_rendering_thumbnail.png" title="MasterView rhtml Rendering Illustration" alt="MasterView rhtml Rendering Illustration" /><br />
|
49
53
|
Click for larger view</a>
|
50
54
|
</li>
|
51
55
|
</ul>
|
52
56
|
|
53
57
|
<h2>Videos</h2>
|
54
58
|
<ul>
|
55
|
-
<li><a href="http://masterview.org/videos/demo_short.html">MasterView Short Video</a> - demonstrating basic usage of MasterView (no audio, ~5 minutes, uses flash)<br/><br/>
|
56
|
-
<a href="http://masterview.org/videos/demo_short.html"><img src="screenshots/generated_list_thumbnail.png"/></a><br/><br/>
|
59
|
+
<li><a href="http://masterview.org/videos/demo_short.html">MasterView Short Video</a> - demonstrating basic usage of MasterView (no audio, ~5 minutes, uses flash)<br /><br />
|
60
|
+
<a href="http://masterview.org/videos/demo_short.html"><img src="screenshots/generated_list_thumbnail.png" title="MasterView short video" alt="MasterView short video" /></a><br /><br />
|
57
61
|
|
58
62
|
</li>
|
59
|
-
<li><a href="http://masterview.org/videos/masterview_quick_start.html">MasterView Quick Start Video</a> - longer video detailing basic configuration and operation of MasterView (no audio, ~25 minutes, uses flash)<br/><br/>
|
60
|
-
<a href="http://masterview.org/videos/masterview_quick_start.html"><img src="screenshots/masterview_admin_thumbnail.png"/></a><br/><br/>
|
63
|
+
<li><a href="http://masterview.org/videos/masterview_quick_start.html">MasterView Quick Start Video</a> - longer video detailing basic configuration and operation of MasterView (no audio, ~25 minutes, uses flash)<br /><br />
|
64
|
+
<a href="http://masterview.org/videos/masterview_quick_start.html"><img src="screenshots/masterview_admin_thumbnail.png" title="MasterView quick-start video" alt="MasterView quick-start video" /></a><br /><br />
|
61
65
|
</li>
|
62
66
|
</ul>
|
63
67
|
|
64
68
|
<h2>Screenshots</h2>
|
65
|
-
<p>Here are some screenshots for some masterview generated views. <br/><br/>
|
69
|
+
<p>Here are some screenshots for some masterview generated views. <br /><br />
|
66
70
|
|
67
71
|
<b>** Click on the image for fullsize view **</b>
|
68
72
|
</p>
|
69
73
|
|
70
74
|
<p>
|
71
75
|
|
72
|
-
<b>Generated list view</b><br/>
|
73
|
-
<a href="screenshots/generated_list.png"
|
76
|
+
<b>Generated list view</b><br />
|
77
|
+
<a href="screenshots/generated_list.png"><img src="screenshots/generated_list_medium.png" title="Click for fullsize image of generated list view" alt="Click for fullsize image of generated list view" /></a><br /><br />
|
74
78
|
|
75
|
-
<b>Generated New view</b><br/>
|
76
|
-
<a href="screenshots/generated_new.png"
|
79
|
+
<b>Generated New view</b><br />
|
80
|
+
<a href="screenshots/generated_new.png"><img src="screenshots/generated_new_medium.png" title="Click for fullsize image of generated new view" alt="Click for fullsize image of generated new view" /></a><br /><br />
|
77
81
|
|
78
|
-
<b>MasterView Admin Page</b><br/>
|
79
|
-
<a href="screenshots/masterview_admin.png"
|
82
|
+
<b>MasterView Admin Page</b><br />
|
83
|
+
<a href="screenshots/masterview_admin.png"><img src="screenshots/masterview_admin_medium.png" title="Click for fullsize image of MasterView Admin Page" alt="Click for fullsize image of MasterView Admin Page" /></a><br /><br />
|
80
84
|
|
81
85
|
</p>
|
82
86
|
|
@@ -88,6 +92,8 @@ Click for larger view</a>
|
|
88
92
|
·
|
89
93
|
<a href="./index.html">Doc Home</a>
|
90
94
|
|
|
95
|
+
<a href="./about.html">About</a>
|
96
|
+
|
|
91
97
|
<a href="./installation.html">Installation</a>
|
92
98
|
|
|
93
99
|
<a href="./configuration.html">Configuration</a>
|
@@ -95,8 +101,10 @@ Click for larger view</a>
|
|
95
101
|
<a href="./guide.html">Usage</a>
|
96
102
|
|
|
97
103
|
<a href="./directives.html">Directives</a>
|
98
|
-
 
|
99
|
-
<a href="./
|
104
|
+
|
|
105
|
+
<a href="./developer.html">Developers</a>
|
106
|
+
|
|
107
|
+
<a href="./media_list.html">Screencasts</a>
|
100
108
|
·
|
101
109
|
</div>
|
102
110
|
<table summary="layout area">
|
@@ -104,7 +112,9 @@ Click for larger view</a>
|
|
104
112
|
<tr>
|
105
113
|
<td class="copyright">© Copyright MasterView 2006</td>
|
106
114
|
<td class="validators">
|
107
|
-
<a href="http://validator.w3.org/check/referer"
|
115
|
+
<a href="http://validator.w3.org/check/referer"><img
|
116
|
+
src="http://www.w3.org/Icons/valid-xhtml10" class="w3c_validator"
|
117
|
+
title="Valid XHTML 1.0!" alt="Valid XHTML 1.0!" /></a>
|
108
118
|
</td>
|
109
119
|
</tr>
|
110
120
|
</tbody>
|
data/doc/simple_diagram.html
CHANGED
@@ -106,15 +106,13 @@ Store</h1></span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(
|
|
106
106
|
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><span style="color: rgb(0, 0, 153);"></body></span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);"></html></span>
|
107
107
|
</div> <div id="new"><span style="font-weight: bold;">store/new.rhtml</span><br><span style="color: rgb(0, 153, 0);"><div></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);">
|
108
108
|
<h2>New</h2></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);">
|
109
|
-
<%= form_tag
|
110
|
-
'new'</span> %></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);"> <%=
|
109
|
+
<%= form_tag(<span style="color: rgb(204, 153, 51);">:action =>
|
110
|
+
'new'</span>) %></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);"> <%=
|
111
111
|
render <span style="color: rgb(204, 153, 51);">:partial
|
112
112
|
=> 'store/form'</span> %></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);">
|
113
113
|
</span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);"><%=
|
114
114
|
submit_tag
|
115
|
-
'<span style="color: rgb(204, 153, 51);">save</span>' %></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);"> <
|
116
|
-
end_form_tag
|
117
|
-
%> </span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);"></div></span>
|
115
|
+
'<span style="color: rgb(204, 153, 51);">save</span>' %></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);"> </form> </span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);"></div></span>
|
118
116
|
</div> <div id="form"><span style="font-weight: bold;">store/_form.rhtml</span><br><span style="color: rgb(102, 0, 204);"><div></span><br style="color: rgb(102, 0, 204);"><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
119
117
|
Name: </span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);"> <%=
|
120
118
|
text_field '<span style="color: rgb(204, 153, 51);">product</span>',
|
@@ -26,6 +26,7 @@ th, td {
|
|
26
26
|
/* --- general text styles ----------------------------- */
|
27
27
|
|
28
28
|
h1,h2,h3,h4,h5,h6 {
|
29
|
+
color: #00008b; /* darkblue */
|
29
30
|
font-family: Verdana,Arial,Helvetica,sans-serif;
|
30
31
|
margin: 0;
|
31
32
|
/*background: transparent; */
|
@@ -50,6 +51,10 @@ td > a {
|
|
50
51
|
text-decoration: none;
|
51
52
|
}
|
52
53
|
|
54
|
+
dt {
|
55
|
+
font-weight: bold;
|
56
|
+
}
|
57
|
+
|
53
58
|
/* === Page layout structure elements ===================================== */
|
54
59
|
|
55
60
|
/* ???? from rdoc.....
|
@@ -130,7 +135,7 @@ div#pageHeader a { background: transparent; text-decoration: none; }
|
|
130
135
|
|
131
136
|
/* --- page body styles -------------------------------- */
|
132
137
|
|
133
|
-
|
138
|
+
/* Following came in from the rdoc stylesheet - does not appear to be used:
|
134
139
|
div#description {
|
135
140
|
padding: 0.5em 1.5em;
|
136
141
|
background-color: #efefef;
|
@@ -140,6 +145,7 @@ div#description h1,h2,h3,h4,h5,h6 {
|
|
140
145
|
color: #125;
|
141
146
|
background: transparent;
|
142
147
|
}
|
148
|
+
*/
|
143
149
|
|
144
150
|
/* --- page footer styles ------------------------------ */
|
145
151
|
|
@@ -172,6 +178,8 @@ img.w3c_validator {
|
|
172
178
|
height: 31px;
|
173
179
|
}
|
174
180
|
|
181
|
+
/*###TODO: alt colophon_ images from plone for more compact link###*/
|
182
|
+
|
175
183
|
/* === Page content style elements ======================================== */
|
176
184
|
|
177
185
|
.productName {
|
@@ -206,7 +214,14 @@ pre.code { /* from http://facets.rubyforge.org/wiki/wiki.css */
|
|
206
214
|
white-space: pre;
|
207
215
|
color: black;
|
208
216
|
background-color: #e6e6e6;
|
217
|
+
}
|
209
218
|
|
219
|
+
div.todo {
|
220
|
+
margin: 6px 20px;
|
221
|
+
border: thin dotted black;
|
222
|
+
padding: 4px;
|
223
|
+
font-style: italic;
|
224
|
+
font-size: smaller;
|
210
225
|
}
|
211
226
|
|
212
227
|
/* --- Ruby keyword styles --------------------- */
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#config.root_path = RAILS_ROOT
|
18
18
|
#config.config_dir_path = 'config/masterview' # relative path from config.root_path
|
19
19
|
#config.environment = RAILS_ENV
|
20
|
-
#config.
|
20
|
+
#config.add_directive_path '/path/to/custom/directives'
|
21
21
|
#config.logger = 'log4r'
|
22
22
|
#config.log_level = 'WARN'
|
23
23
|
#config.after_initialize { MasterView::Log.level = 'DEBUG' }
|
@@ -46,6 +46,7 @@
|
|
46
46
|
#config.tidy_path = '/usr/lib/libtidy.so' # *nix
|
47
47
|
#config.tidy_path = 'c:/tidy/lib/tidy.dll' # Win32
|
48
48
|
#config.namespace_prefix = 'mv:'
|
49
|
+
#config.namespace_prefix_extensions = 'mvx:'
|
49
50
|
#config.inline_erb_start = '{{{'
|
50
51
|
#config.inline_erb_end = '}}}'
|
51
52
|
#config.inline_erb_substitution_regex = /\{\{\{(([^}]|\}[^}]|\}\}[^}])*)\}\}\}/
|
data/init.rb
CHANGED
@@ -45,7 +45,7 @@
|
|
45
45
|
# config.enable_admin_pages = false
|
46
46
|
# config.default_parser_options[:tidy] = true
|
47
47
|
# config.tidy_path = '/usr/lib/libtidy.so'
|
48
|
-
# config.
|
48
|
+
# config.add_directive_path File.join( RAILS_ROOT, 'masterview-ext', 'directives' )
|
49
49
|
#
|
50
50
|
# To customize the configuration for the current Rails environment,
|
51
51
|
# provide a +config/masterview/environments/#{environment}.rb+ file
|
data/lib/#ChangeLog#
ADDED
data/lib/masterview/analyzer.rb
CHANGED
@@ -1,17 +1,24 @@
|
|
1
1
|
module MasterView
|
2
|
+
|
3
|
+
# The Analyzer module provides parsing and analysis services for the
|
4
|
+
# TemplateSpec class to determine the parts of a template document
|
5
|
+
# and their up-to-date status
|
6
|
+
#
|
2
7
|
module Analyzer
|
3
8
|
|
4
9
|
ExpandAlwaysElements = %w{ script textarea }
|
5
10
|
|
6
11
|
module Common
|
12
|
+
|
7
13
|
def calc_hash(data)
|
8
14
|
#MasterView::Log.warn { 'hash= '+data.hash.to_s+' data='+data }
|
9
15
|
data.gsub( /\s+/, ' ' ).hash #collapse whitespace
|
10
16
|
end
|
11
17
|
|
12
18
|
def src_hash(data_orig)
|
13
|
-
|
14
|
-
data =
|
19
|
+
mv_ns = DirectiveRegistry.current.mv_namespace_prefix
|
20
|
+
data = data_orig.gsub mv_ns+'import_render', mv_ns+'gen_partial'
|
21
|
+
data = data.gsub mv_ns+'import', mv_ns+'generate'
|
15
22
|
calc_hash(data)
|
16
23
|
end
|
17
24
|
|
@@ -20,14 +27,14 @@ module MasterView
|
|
20
27
|
class ContentEntry
|
21
28
|
include Common
|
22
29
|
attr_accessor :hash, :data
|
23
|
-
|
30
|
+
|
24
31
|
def initialize(data)
|
25
32
|
@data = data
|
26
33
|
@hash = src_hash(data)
|
27
34
|
end
|
28
35
|
|
29
36
|
end
|
30
|
-
|
37
|
+
|
31
38
|
class StackEntry
|
32
39
|
attr_accessor :name, :buffer, :depth, :import, :parts
|
33
40
|
|
@@ -60,7 +67,7 @@ module MasterView
|
|
60
67
|
|
61
68
|
# builder class facilitates the hash_check and building process by monitoring if all parts of a
|
62
69
|
# file have been requested, if not when a higher index part is requested all the other previous
|
63
|
-
# parts will be sent along as well, this is necessary for cases where a file doesn't have as many
|
70
|
+
# parts will be sent along as well, this is necessary for cases where a file doesn't have as many
|
64
71
|
# internal parts or none at all. This way the hash and all the parts of the file will still be there
|
65
72
|
# if layout has two parts and only last part -1 is requested, this builder will give back part 0 and part 1
|
66
73
|
# if layout would have had three parts then it would have given back all three.
|
@@ -85,7 +92,7 @@ module MasterView
|
|
85
92
|
return '' if content_parts.nil? || (next_index_to_use+1 > content_parts_length)
|
86
93
|
highest_index = content_parts.length - 1
|
87
94
|
requested_index = (index == -1) ? highest_index : index
|
88
|
-
content = content_parts[next_index_to_use..requested_index].collect do |ce|
|
95
|
+
content = content_parts[next_index_to_use..requested_index].collect do |ce|
|
89
96
|
(ce.data.gsub( /\s/, '' ).empty?) ? '' : ce.data # if only white space then get rid of it
|
90
97
|
end.join
|
91
98
|
@builder_hash[name] = requested_index + 1 # store next index to use
|
@@ -110,6 +117,19 @@ module MasterView
|
|
110
117
|
@default_extname = options[:default_extname] || ::MasterView::IOMgr.erb.default_extension
|
111
118
|
@keyword_expander = KeywordExpander.new
|
112
119
|
@keyword_expander.set_template_pathname( options[:template_pathname], @default_extname ) if options[:template_pathname]
|
120
|
+
mv_ns = DirectiveRegistry.current.mv_namespace_prefix
|
121
|
+
@mv_processing_directives = {
|
122
|
+
# attribute_qname => directive_type_flags
|
123
|
+
mv_ns+'generate' => { :partial => false, :import => false },
|
124
|
+
mv_ns+'gen_partial' => { :partial => true, :import => false },
|
125
|
+
mv_ns+'import' => { :partial => false, :import => true },
|
126
|
+
mv_ns+'import_render' => { :partial => true, :import => true },
|
127
|
+
}
|
128
|
+
@mv_import_directive_mappings = {
|
129
|
+
# mv:import and mv:import_render get mapped to generate directives during analysis
|
130
|
+
mv_ns+'import_render' => mv_ns+'gen_partial',
|
131
|
+
mv_ns+'import' => mv_ns+'generate',
|
132
|
+
}
|
113
133
|
Log.debug { "only_check_hash => true" } if @only_check_hash
|
114
134
|
end
|
115
135
|
|
@@ -125,7 +145,7 @@ module MasterView
|
|
125
145
|
#todo
|
126
146
|
end
|
127
147
|
|
128
|
-
def doctype(name,
|
148
|
+
def doctype(name, pub_sys, long_name, uri)
|
129
149
|
#todo
|
130
150
|
end
|
131
151
|
|
@@ -133,26 +153,23 @@ module MasterView
|
|
133
153
|
unescape_attributes!(attributes)
|
134
154
|
@depth += 1
|
135
155
|
|
156
|
+
# expand the target specification to the actual path for import/generate directives in case of rebuilding
|
157
|
+
path = nil
|
136
158
|
import = false
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
attributes[::MasterView::NamespacePrefix+'import_render'] = expanded_partial_attr # put back expanded version in case of rebuilding
|
152
|
-
partial = find_string_val_in_string_hash( expanded_partial_attr, :partial)
|
153
|
-
path = render_partial_name_to_file_name(partial, @default_extname)
|
154
|
-
import = true
|
155
|
-
end
|
159
|
+
@mv_processing_directives.each_pair { | mv_attr_name, directive_type_flags |
|
160
|
+
if attributes.has_key?( mv_attr_name )
|
161
|
+
expanded_attr_value = @keyword_expander.expand_keywords(attributes[mv_attr_name])
|
162
|
+
attributes[mv_attr_name] = expanded_attr_value
|
163
|
+
if directive_type_flags[:partial]
|
164
|
+
partial = find_string_val_in_string_hash( expanded_attr_value, :partial )
|
165
|
+
path = render_partial_name_to_file_name(partial, @default_extname)
|
166
|
+
else
|
167
|
+
path = expanded_attr_value
|
168
|
+
end
|
169
|
+
import = directive_type_flags[:import]
|
170
|
+
break
|
171
|
+
end
|
172
|
+
}
|
156
173
|
|
157
174
|
if path
|
158
175
|
store_last_buffer false
|
@@ -160,21 +177,18 @@ module MasterView
|
|
160
177
|
end
|
161
178
|
|
162
179
|
unless @stack.empty?
|
163
|
-
@stack.last.buffer << "<#{qname}"
|
180
|
+
@stack.last.buffer << "<#{qname}"
|
164
181
|
sorted_attributes = attributes.sort do |a,b| # sort import and import_render like generate and gen_partial so hashs work
|
165
182
|
a_working = a[0]
|
166
183
|
b_working = b[0]
|
167
184
|
working_cmp = [a_working, b_working].collect do |working|
|
168
|
-
|
169
|
-
|
170
|
-
elsif working == ::MasterView::NamespacePrefix+'import'
|
171
|
-
working = ::MasterView::NamespacePrefix+'generate'
|
172
|
-
end
|
185
|
+
# mv:import and mv:import_render to generate directives
|
186
|
+
working = @mv_import_directive_mappings.fetch(working, working)
|
173
187
|
working
|
174
188
|
end
|
175
189
|
working_cmp[0] <=> working_cmp[1]
|
176
190
|
end
|
177
|
-
sorted_attributes.each do |name, value|
|
191
|
+
sorted_attributes.each do |name, value|
|
178
192
|
@stack.last.buffer << " #{name}=\"#{value}\""
|
179
193
|
end
|
180
194
|
@stack.last.buffer << '>' #must output as separate string so simplify_empty_elements can find it
|
@@ -202,7 +216,7 @@ module MasterView
|
|
202
216
|
@stack.last.buffer << '</' << "#{qname}>" #must output </ as separate string so simplify_empty_elements can find it
|
203
217
|
end
|
204
218
|
end
|
205
|
-
|
219
|
+
|
206
220
|
if @stack.last && @depth == @stack.last.depth
|
207
221
|
store_last_buffer true
|
208
222
|
@stack.pop
|
@@ -8,7 +8,11 @@ module MasterView
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
11
|
+
# Directive attribute value string parser.
|
12
|
+
#
|
13
|
+
# Used for parsing the attr_value string of a directive attribute
|
14
|
+
# into arguments for consumation by directives.
|
15
|
+
#
|
12
16
|
class AttrStringParser
|
13
17
|
# returns array of string arguments which are trimmed(stripped) representing the arguments
|
14
18
|
# declared in the attr_value string
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module MasterView
|
2
|
+
# Extends Hash to allow case insensitive access to data using any case string or symbol,
|
3
|
+
# however it retains the original case when iterated on. When updating a value it first checks
|
4
|
+
# for the existence of a case indendependent key and if found uses that for storage key,
|
5
|
+
# thus the first form to store determines the case.
|
6
|
+
class CaseInsensitiveHash < Hash
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
init_lcks_map
|
10
|
+
end
|
11
|
+
|
12
|
+
# uses a lowercased symbol to find original key which is then used to find value
|
13
|
+
def [](key)
|
14
|
+
original_key = @lcks_to_original_key[convert_to_lcs(key)]
|
15
|
+
(original_key.nil?) ? nil : super(original_key)
|
16
|
+
end
|
17
|
+
|
18
|
+
# put value into map first checking if there is already an entry using lowercased
|
19
|
+
# symbol, if so use it (it determines key case), otherwise add new entry
|
20
|
+
def []=(key, value)
|
21
|
+
lcks = convert_to_lcs(key)
|
22
|
+
original_key = @lcks_to_original_key[lcks]
|
23
|
+
if original_key.nil? # not found so create new original key in map
|
24
|
+
@lcks_to_original_key[lcks] = key
|
25
|
+
original_key = key
|
26
|
+
end
|
27
|
+
super(original_key, value)
|
28
|
+
end
|
29
|
+
|
30
|
+
alias :store :[]=
|
31
|
+
|
32
|
+
# build hash from another hash
|
33
|
+
def replace(hash)
|
34
|
+
super(hash)
|
35
|
+
init_lcks_map
|
36
|
+
hash.each do |k,v|
|
37
|
+
@lcks_to_original_key[convert_to_lcs(k)] = k
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# retrieves the lowercased string value for the key
|
42
|
+
def get_lowercase_str_value(key)
|
43
|
+
value = self[key]
|
44
|
+
unless value.nil?
|
45
|
+
if value.is_a? String
|
46
|
+
value.downcase!
|
47
|
+
elsif value.is_a? Symbol
|
48
|
+
value = value.to_s.downcase
|
49
|
+
else
|
50
|
+
value = value.inspect.downcase
|
51
|
+
end
|
52
|
+
end
|
53
|
+
value
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
# reset lowercased symbol map
|
59
|
+
def init_lcks_map
|
60
|
+
@lcks_to_original_key = {} # lower case key symbol to original key map
|
61
|
+
end
|
62
|
+
|
63
|
+
# convert to lowercased symbol
|
64
|
+
def convert_to_lcs(key)
|
65
|
+
key.to_s.downcase.to_sym
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
File without changes
|
File without changes
|