masterview 0.2.0 → 0.2.1
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 +7 -0
- data/TODO +17 -1
- data/doc/configuration.html +2 -0
- data/doc/directives.html +71 -0
- data/doc/guide.html +2 -0
- data/doc/index.html +20 -2
- data/doc/installation.html +2 -0
- data/doc/media_list.html +71 -0
- data/doc/simple_diagram.html +138 -0
- data/examples/rails_app_config/masterview/environment/development.rb +8 -6
- data/examples/rails_app_config/masterview/environment/production.rb +2 -1
- data/examples/rails_app_config/masterview/settings.rb +3 -3
- data/lib/masterview/directive_helpers.rb +10 -0
- data/lib/masterview/directives/image_tag.rb +43 -0
- data/lib/masterview/directives/javascript_include.rb +10 -2
- data/lib/masterview/directives/stylesheet_link.rb +10 -1
- data/lib/masterview/extras/app/controllers/masterview_controller.rb +4 -0
- data/lib/masterview/extras/app/views/masterview/admin/features.rhtml +79 -0
- data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +1 -0
- data/lib/masterview/extras/init_rails_erb_mv_direct.rb +1 -0
- data/lib/masterview/extras/init_rails_reparse_checking.rb +3 -0
- data/lib/masterview/initializer.rb +8 -1
- data/lib/masterview/masterview_version.rb +1 -1
- data/test/unit/directive_image_tag_test.rb +89 -0
- data/test/unit/directive_javascript_include_test.rb +47 -0
- data/test/unit/directive_stylesheet_link_test.rb +37 -0
- data/test/unit/template_test.rb +154 -0
- metadata +7 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
0.2.1 - June 28th, 2006
|
2
|
+
Added Mongrel support
|
3
|
+
Added image_tag directive
|
4
|
+
Update javascript_include directive to infer path from src if attr_value is empty
|
5
|
+
Update stylesheet_link directive to infer path from src if attr_value is empty
|
6
|
+
New illustration
|
7
|
+
|
1
8
|
0.2.0 - June 20th, 2006 - Big release. Added capability for eliminating rhtml generation, extends rails so that rhtml can be pulled directly from MasterView.
|
2
9
|
Support template compilation directly into Rails view cache for templates in app/views (rhtml generation now optional)
|
3
10
|
New mechanism for configuring MasterView from settings files; internal initialization rework. Configuration can now be driven by editing config/masterview/settings.rb and/or config/masterview/environments/*.rb.
|
data/TODO
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
- put image, stylesheets, javascript relative path regex in initializer
|
1
2
|
- create install.rb for rails 1.1 plugin installs, it will create config/masterview and some sample configs
|
2
3
|
- create namespace for mv and publish, update generated files
|
3
4
|
- more videos
|
4
|
-
- image_tag (improve support for referencing image assets in MasterView directives markup)
|
5
5
|
- allow multiple namespace prefixes for directives (allow custom directives to declare their own namespace)
|
6
6
|
- wiki for site
|
7
7
|
- render from db
|
@@ -9,10 +9,26 @@
|
|
9
9
|
- include additional stylesheets
|
10
10
|
- ajax examples
|
11
11
|
- ajax table component
|
12
|
+
- fix admin controller config page so it fits into admin layout
|
12
13
|
- documentation
|
14
|
+
- update the plugin generator descr in installation.html: also installs config file templates in config
|
15
|
+
- add tips in installation.doc about running gems rdoc server to view installed gems' rdoc
|
16
|
+
- update admin controller description to point out that it installs public/stylesheets/masterview
|
17
|
+
- run spelling checker on our html and release docs; retrofit to rdoc comments
|
13
18
|
- directive developer documentation and examples
|
14
19
|
- more tests
|
20
|
+
- build improvements
|
21
|
+
- add release tasks to automate archiving trunk to tags/masterview-N.N.N, resetting tags/masterview
|
22
|
+
- investigate mirror sites for obtaining gems (supplement primary rubyforge host)
|
23
|
+
- improve RubyForge project site: include online docs; post release msgs in news
|
15
24
|
- internal code cleanup
|
16
25
|
- DirectiveHelpers ERB_xx constants to differentiate ' %>' and ' -%>'
|
17
26
|
- replace MasterView::NamespacePrefix+'<gen/import directivename>' concats in parser/analyzer with directive attr name constants
|
18
27
|
- run spell checker on doc/*.html, ripple typo fixes back in rdoc comment
|
28
|
+
- reverse engineer legacy rhtml into masterview templates
|
29
|
+
|
30
|
+
--####################
|
31
|
+
??? can we tweak the admin controller for gem plugin so it puts its empty.rhtml in, say, config/masterview/admin??
|
32
|
+
=> better loc than vendor/plugins/masterview/........ if users are going to customize that guy
|
33
|
+
|
34
|
+
--####################
|
data/doc/configuration.html
CHANGED
@@ -467,6 +467,8 @@ with the pathname of the source template file.
|
|
467
467
|
<a href="./guide.html">Usage</a>
|
468
468
|
|
|
469
469
|
<a href="./directives.html">Directives</a>
|
470
|
+
|
471
|
+
<a href="./media_list.html">Media (Videos/Illustrations)</a>
|
470
472
|
·
|
471
473
|
</div>
|
472
474
|
<table summary="layout area">
|
data/doc/directives.html
CHANGED
@@ -145,6 +145,14 @@ directive markup in the template.
|
|
145
145
|
<td colspan="2"><a href="#asset_link_directives">Rails Asset and Link Helper Directives</a></td>
|
146
146
|
</tr>
|
147
147
|
<tr>
|
148
|
+
<td class="directive"><a href="#mv_image_tag">mv:image_tag</a></td>
|
149
|
+
<td>Replaces this element using the Rails <code>image_tag</code> helper.
|
150
|
+
<span class="explanation">(
|
151
|
+
Used on <code><img></code> elements
|
152
|
+
)</span>
|
153
|
+
</td>
|
154
|
+
</tr>
|
155
|
+
<tr>
|
148
156
|
<td class="directive"><a href="#mv_javascript_include">mv:javascript_include</a></td>
|
149
157
|
<td>Replaces this element using the Rails <code>javascript_include_tag</code> helper.
|
150
158
|
<span class="explanation">(
|
@@ -639,6 +647,41 @@ Inline substitutions
|
|
639
647
|
<a name="asset_link_directives"></a>
|
640
648
|
<h3>Rails Asset and Link Helper Directives</h3>
|
641
649
|
|
650
|
+
<a name="mv_image_tag"></a>
|
651
|
+
<h4>mv:image_tag</h4>
|
652
|
+
<p>
|
653
|
+
mv:image_tag="cat.jpg"
|
654
|
+
</p>
|
655
|
+
<pre>
|
656
|
+
Replaces the tag with a image_tag helper, size is determined by width and height, other html attributes
|
657
|
+
are passed through. for example...
|
658
|
+
|
659
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag="cat.jpg"/>
|
660
|
+
|
661
|
+
becomes
|
662
|
+
|
663
|
+
<%= image_tag 'cat.jpg' %>
|
664
|
+
|
665
|
+
|
666
|
+
<img src="../../../public/images/cat.jpg" alt="my cat" width="20" height="10" mv:image_tag="cat.jpg"/>
|
667
|
+
|
668
|
+
becomes
|
669
|
+
|
670
|
+
<%= image_tag 'cat.jpg', :alt => 'my cat', :size => '20x10' %>
|
671
|
+
|
672
|
+
Also if path isn't specified in the mv:image_tag attribute value then it will infer the path looking
|
673
|
+
for what follows the public/images/ in the src atttribute, like so
|
674
|
+
|
675
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag=""/>
|
676
|
+
|
677
|
+
becomes
|
678
|
+
|
679
|
+
<%= image_tag 'cat.jpg' %>
|
680
|
+
|
681
|
+
This is useful to allow images to be used for demos/prototypes and then at runtime
|
682
|
+
use the appropriate asset using the rails helper.
|
683
|
+
</pre>
|
684
|
+
|
642
685
|
<a name="mv_javascript_include"></a>
|
643
686
|
<h4>mv:javascript_include</h4>
|
644
687
|
<p>
|
@@ -654,6 +697,24 @@ mv:javascript_include="prototype.js"
|
|
654
697
|
|
655
698
|
<%= javascript_include_tag 'prototype.js' %>
|
656
699
|
|
700
|
+
You can also use a symbol
|
701
|
+
|
702
|
+
<script type="text/javascript" src="../../../public/javascripts/prototype.js"
|
703
|
+
mv:javascript_include=":defaults"></script>
|
704
|
+
|
705
|
+
becomes
|
706
|
+
|
707
|
+
<%= javascript_include_tag :defaults %>
|
708
|
+
|
709
|
+
And you can have the path inferred from the src path (uses the relative path to public/javascripts)
|
710
|
+
|
711
|
+
<script type="text/javascript" src="../../../public/javascripts/prototype.js"
|
712
|
+
mv:javascript_include=""></script>
|
713
|
+
|
714
|
+
becomes
|
715
|
+
|
716
|
+
<%= javascript_include_tag 'prototype.js' %>
|
717
|
+
|
657
718
|
This is useful to allow scripts to be used for demos/prototypes and then at runtime
|
658
719
|
use the appropriate asset using the rails helper.
|
659
720
|
</pre>
|
@@ -723,6 +784,14 @@ mv:stylesheet_link="style"
|
|
723
784
|
|
724
785
|
<%= stylesheet_link_tag "scaffold" %>
|
725
786
|
|
787
|
+
You may also leave attribute empty and it will infer the path from src (uses relative path from public/stylesheets)
|
788
|
+
|
789
|
+
<link rel="stylesheet" type="text/css" href="../../../public/stylesheets/scaffold.css" mv:stylesheet_link=""/>
|
790
|
+
|
791
|
+
becomes
|
792
|
+
|
793
|
+
<%= stylesheet_link_tag "scaffold.css" %>
|
794
|
+
|
726
795
|
This is useful to allow style to be used for demos/prototypes and then at runtime
|
727
796
|
use the appropriate asset using the rails helper.
|
728
797
|
</pre>
|
@@ -1068,6 +1137,8 @@ Used on <code><input></code> form elements
|
|
1068
1137
|
<a href="./guide.html">Usage</a>
|
1069
1138
|
|
|
1070
1139
|
<a href="./directives.html">Directives</a>
|
1140
|
+
|
1141
|
+
<a href="./media_list.html">Media (Videos/Illustrations)</a>
|
1071
1142
|
·
|
1072
1143
|
</div>
|
1073
1144
|
<table summary="layout area">
|
data/doc/guide.html
CHANGED
@@ -225,6 +225,8 @@ rake -T
|
|
225
225
|
<a href="./guide.html">Usage</a>
|
226
226
|
|
|
227
227
|
<a href="./directives.html">Directives</a>
|
228
|
+
|
229
|
+
<a href="./media_list.html">Media (Videos/Illustrations)</a>
|
228
230
|
·
|
229
231
|
</div>
|
230
232
|
<table summary="layout area">
|
data/doc/index.html
CHANGED
@@ -45,6 +45,7 @@ If you are interested in the background story behind all this, it is at the
|
|
45
45
|
end of this page.
|
46
46
|
</p>
|
47
47
|
|
48
|
+
<p>
|
48
49
|
<table summary="project location and author information">
|
49
50
|
<tr>
|
50
51
|
<td>Author:</td>
|
@@ -77,8 +78,21 @@ end of this page.
|
|
77
78
|
<td> </td>
|
78
79
|
<td>masterview-devel - MasterView project developer list</td>
|
79
80
|
</tr>
|
80
|
-
<tr><td>Videos:</td><td><a href="http://masterview.org/videos/masterview_quick_start.html">MasterView Quick Start Video</a> - demonstrating basic usage of MasterView (no audio)</td></tr>
|
81
81
|
</table>
|
82
|
+
</p>
|
83
|
+
|
84
|
+
<h2>Illustrations/Diagrams</h2>
|
85
|
+
<ul>
|
86
|
+
<li><a href="simple_diagram.html" alt="MasterView rhtml Rendering Illustration">MasterView rendering illustration</a> - showing how MasterView renders rhtml internally</li>
|
87
|
+
</ul>
|
88
|
+
|
89
|
+
<h2>Videos</h2>
|
90
|
+
<ul>
|
91
|
+
<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)</li>
|
92
|
+
<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)</li>
|
93
|
+
</ul>
|
94
|
+
|
95
|
+
|
82
96
|
|
83
97
|
<h2>Goals</h2>
|
84
98
|
<ul>
|
@@ -136,7 +150,9 @@ application.
|
|
136
150
|
|
137
151
|
<h2>Usage</h2>
|
138
152
|
|
139
|
-
<p>See the <a href="guide.html">MasterView User's Guide</a> for information on using MasterView templates and supporting services
|
153
|
+
<p>See the <a href="guide.html">MasterView User's Guide</a> for information on using MasterView templates and supporting services.
|
154
|
+
View the <a href="simple_diagram.html" alt="MasterView rhtml rendering illustration">MasterView rendering illustration</a> to understand how a MasterView template renders rhtml
|
155
|
+
</p>
|
140
156
|
|
141
157
|
|
142
158
|
<h2>MasterView attribute directive syntax</h2>
|
@@ -269,6 +285,8 @@ gmail.com)
|
|
269
285
|
<a href="./guide.html">Usage</a>
|
270
286
|
|
|
271
287
|
<a href="./directives.html">Directives</a>
|
288
|
+
|
289
|
+
<a href="./media_list.html">Media (Videos/Illustrations)</a>
|
272
290
|
·
|
273
291
|
</div>
|
274
292
|
<table summary="layout area">
|
data/doc/installation.html
CHANGED
@@ -358,6 +358,8 @@ releases. They are obsolete and should be ignored.
|
|
358
358
|
<a href="./guide.html">Usage</a>
|
359
359
|
|
|
360
360
|
<a href="./directives.html">Directives</a>
|
361
|
+
|
362
|
+
<a href="./media_list.html">Media (Videos/Illustrations)</a>
|
361
363
|
·
|
362
364
|
</div>
|
363
365
|
<table summary="layout area">
|
data/doc/media_list.html
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
|
9
|
+
<title>MasterView - Media list</title>
|
10
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
11
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
12
|
+
|
13
|
+
<link href="./stylesheets/masterview.css" rel="stylesheet" type="text/css" />
|
14
|
+
</head>
|
15
|
+
|
16
|
+
<body>
|
17
|
+
|
18
|
+
<div id="pageHeader">
|
19
|
+
<div>MasterView Template Engine</div>
|
20
|
+
<div class="description">Rails-optimized (x)html friendly template engine</div>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div id="pageBody">
|
24
|
+
<div id="bodyContent" mv:generate="{template_path}" mv:omit_tag="">
|
25
|
+
|
26
|
+
<h1>MasterView - Media list</h1>
|
27
|
+
|
28
|
+
<h2>Illustrations/Diagrams</h2>
|
29
|
+
<ul>
|
30
|
+
<li><a href="simple_diagram.html" alt="MasterView rhtml Rendering Illustration">MasterView rendering illustration</a> - showing how MasterView renders rhtml internally</li>
|
31
|
+
</ul>
|
32
|
+
|
33
|
+
<h2>Videos</h2>
|
34
|
+
<ul>
|
35
|
+
<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)</li>
|
36
|
+
<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)</li>
|
37
|
+
</ul>
|
38
|
+
|
39
|
+
</div> <!-- bodyContent -->
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<div id="pageFooter">
|
43
|
+
<div>
|
44
|
+
·
|
45
|
+
<a href="./index.html">Doc Home</a>
|
46
|
+
|
|
47
|
+
<a href="./installation.html">Installation</a>
|
48
|
+
|
|
49
|
+
<a href="./configuration.html">Configuration</a>
|
50
|
+
|
|
51
|
+
<a href="./guide.html">Usage</a>
|
52
|
+
|
|
53
|
+
<a href="./directives.html">Directives</a>
|
54
|
+
|
55
|
+
<a href="./media_list.html">Media (Videos/Illustrations)</a>
|
56
|
+
·
|
57
|
+
</div>
|
58
|
+
<table summary="layout area">
|
59
|
+
<tbody>
|
60
|
+
<tr>
|
61
|
+
<td class="copyright">© Copyright MasterView 2006</td>
|
62
|
+
<td class="validators">
|
63
|
+
<a href="http://validator.w3.org/check/referer">[Valid XHTML]</a>
|
64
|
+
</td>
|
65
|
+
</tr>
|
66
|
+
</tbody>
|
67
|
+
</table>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
</body>
|
71
|
+
</html>
|
@@ -0,0 +1,138 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
+
<html><head>
|
3
|
+
<style type="text/css">
|
4
|
+
body { font-size: small;
|
5
|
+
}
|
6
|
+
|
7
|
+
div#template { border-style: solid;
|
8
|
+
border-width: 1px;
|
9
|
+
padding: 10px;
|
10
|
+
position: absolute;
|
11
|
+
left: 30px;
|
12
|
+
top: 105px;
|
13
|
+
}
|
14
|
+
|
15
|
+
div#new { padding: 10px;
|
16
|
+
position: absolute;
|
17
|
+
background-color: rgb(188, 255, 153);
|
18
|
+
left: 530px;
|
19
|
+
top: 270px;
|
20
|
+
}
|
21
|
+
|
22
|
+
div#form { padding: 10px;
|
23
|
+
position: absolute;
|
24
|
+
background-color: rgb(204, 204, 255);
|
25
|
+
left: 600px;
|
26
|
+
top: 440px;
|
27
|
+
}
|
28
|
+
|
29
|
+
div#layout { padding: 10px;
|
30
|
+
position: absolute;
|
31
|
+
left: 460px;
|
32
|
+
background-color: rgb(204, 255, 255);
|
33
|
+
top: 103px;
|
34
|
+
}
|
35
|
+
|
36
|
+
div#arrows { position: absolute;
|
37
|
+
color: rgb(153, 0, 0);
|
38
|
+
font-size: x-large;
|
39
|
+
left: 420px;
|
40
|
+
top: 180px;
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
</style></head>
|
45
|
+
<body> <h1>MasterView Rendering</h1>
|
46
|
+
<p>A diagram representing how MasterView transforms a template into the equivalent rhtml
|
47
|
+
</p><div id="template"><span style="font-weight: bold;">MasterView template -
|
48
|
+
store/new.html</span><br><div style="text-align: left;"><span style="color: rgb(0, 0, 153);"><html
|
49
|
+
<span style="color: rgb(204, 0, 0);">mv:generate</span>="<span style="color: rgb(204, 153, 51);">layouts/store.rhtml</span>"></span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">
|
50
|
+
<body></span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">
|
51
|
+
<h1>My
|
52
|
+
Store</h1></span><br><br>
|
53
|
+
<span style="color: rgb(0, 153, 0);"><div</span>
|
54
|
+
<span style="color: rgb(204, 0, 0);">mv:generate</span>="<span style="color: rgb(204, 153, 51);">store/new.rhtml</span>"
|
55
|
+
<br>
|
56
|
+
|
57
|
+
<span style="color: rgb(204, 0, 0);">mv:gen_replace</span>="<span style="color: rgb(204, 153, 51);">@content_for_layout</span>"><br><br><br>
|
58
|
+
|
59
|
+
<span style="color: rgb(0, 153, 0);"><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);">
|
60
|
+
|
61
|
+
<form <span style="color: rgb(204, 0, 0);">mv:form</span>="<span style="color: rgb(204, 153, 51);">:action => 'new'</span>"></span><br><br>
|
62
|
+
|
63
|
+
<span style="color: rgb(102, 0, 204);"><div</span> <span style="color: rgb(204, 0, 0);">mv:gen_partial</span>="<span style="color: rgb(204, 153, 51);">:partial
|
64
|
+
=> 'store/form'</span>"><br><br><br><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
65
|
+
|
66
|
+
Name:
|
67
|
+
</span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
68
|
+
|
69
|
+
<input type="text"
|
70
|
+
size="<span style="color: rgb(204, 153, 51);">20</span>"
|
71
|
+
</span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
72
|
+
|
73
|
+
|
74
|
+
<span style="color: rgb(204, 0, 0);">mv:text_field</span>="<span style="color: rgb(204, 153, 51);">product,
|
75
|
+
name</span>"/></span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
76
|
+
|
77
|
+
</span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
78
|
+
|
79
|
+
Description: </span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
80
|
+
|
81
|
+
<text_area rows="<span style="color: rgb(204, 153, 51);">5</span>" cols="<span style="color: rgb(204, 153, 51);">40</span>"
|
82
|
+
</span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
83
|
+
|
84
|
+
|
85
|
+
<span style="color: rgb(204, 0, 0);">mv:text_area</span>="<span style="color: rgb(204, 153, 51);">product, desc</span>"/></span><br style="color: rgb(102, 0, 204);"><br style="color: rgb(102, 0, 204);"><br style="color: rgb(102, 0, 204);"><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
86
|
+
|
87
|
+
</div></span><br><br>
|
88
|
+
|
89
|
+
<span style="color: rgb(0, 153, 0);"><input
|
90
|
+
type="submit"
|
91
|
+
value="<span style="color: rgb(204, 153, 51);">save</span>" </span><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);">
|
92
|
+
|
93
|
+
|
94
|
+
<span style="color: rgb(204, 0, 0);">mv:submit</span>=""/></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);">
|
95
|
+
|
96
|
+
</form></span><br style="color: rgb(0, 153, 0);"><br style="color: rgb(0, 153, 0);"><span style="color: rgb(0, 153, 0);">
|
97
|
+
</div></span><br><br><br>
|
98
|
+
<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><br></div>
|
99
|
+
|
100
|
+
</div> <div id="layout"><span style="font-weight: bold;">layouts/store.rhtml</span><br><span style="color: rgb(0, 0, 153);"><html></span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">
|
101
|
+
<body></span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">
|
102
|
+
<h1>My
|
103
|
+
Store</h1></span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">
|
104
|
+
<%= <span style="color: rgb(204, 153, 51);">@content_for_layout</span>
|
105
|
+
%></span><br><br>
|
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
|
+
</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
|
+
<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 <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
|
+
render <span style="color: rgb(204, 153, 51);">:partial
|
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
|
+
</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
|
+
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>
|
118
|
+
</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
|
+
Name: </span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);"> <%=
|
120
|
+
text_field '<span style="color: rgb(204, 153, 51);">product</span>',
|
121
|
+
'<span style="color: rgb(204, 153, 51);">name</span>',
|
122
|
+
:size => <span style="color: rgb(204, 153, 51);">20</span>
|
123
|
+
%></span><br style="color: rgb(102, 0, 204);"><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
124
|
+
Description: </span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);"> <%=
|
125
|
+
text_area
|
126
|
+
'<span style="color: rgb(204, 153, 51);">product</span>',
|
127
|
+
'<span style="color: rgb(204, 153, 51);">desc</span>',
|
128
|
+
</span><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);">
|
129
|
+
|
130
|
+
|
131
|
+
:cols
|
132
|
+
=> <span style="color: rgb(204, 153, 51);">20</span>,
|
133
|
+
:rows => <span style="color: rgb(204, 153, 51);">5</span>
|
134
|
+
%></span><br style="color: rgb(102, 0, 204);"><br style="color: rgb(102, 0, 204);"><span style="color: rgb(102, 0, 204);"></div></span>
|
135
|
+
</div> <div id="arrows">=><br><br><br><br><br>=><br><br><br><br><br><br>=><br><br><br><br><br><br>=><br><br><br><br>=></div>
|
136
|
+
|
137
|
+
|
138
|
+
</body></html>
|
@@ -8,15 +8,17 @@
|
|
8
8
|
# Set development-mode config settings here
|
9
9
|
|
10
10
|
# General options
|
11
|
-
#config.log_level = '
|
11
|
+
#config.log_level = 'INFO'
|
12
12
|
|
13
|
-
# Rails application options
|
14
|
-
#config.reparse_changed_masterview_templates = true
|
13
|
+
# Rails application options - normally enabled (only) in development env
|
14
|
+
#config.reparse_changed_masterview_templates = true
|
15
15
|
|
16
|
+
# Rails application options that you might want to enable for development
|
17
|
+
#config.enable_admin_pages = false
|
18
|
+
#config.enable_view_rhtml = false
|
19
|
+
|
20
|
+
# Sample of how you might want to modify logging config for development
|
16
21
|
#config.log_level = 'WARN'
|
17
22
|
#config.after_initialize {
|
18
23
|
# MasterView.log_level = 'DEBUG'
|
19
24
|
#}
|
20
|
-
|
21
|
-
# Only use the MasterView admin pages for development
|
22
|
-
# config.enable_admin_pages = true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Production environment config settings for the MasterView template engine.
|
2
2
|
#
|
3
3
|
# The MasterView configuration specification is referenced through +config+.
|
4
4
|
#
|
@@ -6,4 +6,5 @@
|
|
6
6
|
# general MasterView config in +config/masterview/settings.rb+.
|
7
7
|
#
|
8
8
|
# Set production-mode config settings here
|
9
|
+
#
|
9
10
|
|
@@ -20,7 +20,7 @@
|
|
20
20
|
#config.directive_paths << '/path/to/custom/directives'
|
21
21
|
#config.logger = 'log4r'
|
22
22
|
#config.log_level = 'WARN'
|
23
|
-
#config.after_initialize { MasterView::Log.level = DEBUG }
|
23
|
+
#config.after_initialize { MasterView::Log.level = 'DEBUG' }
|
24
24
|
|
25
25
|
# Template Source Options
|
26
26
|
#config.template_src_dir_path = 'app/views' # relative path from config.root_path
|
@@ -52,8 +52,8 @@
|
|
52
52
|
|
53
53
|
# Rails application options
|
54
54
|
#config.parse_masterview_templates_at_startup = true
|
55
|
-
#config.reparse_changed_masterview_templates = false #
|
55
|
+
#config.reparse_changed_masterview_templates = false # enabled in development env
|
56
56
|
#config.enable_admin_pages = false
|
57
57
|
#config.enable_view_rhtml = false
|
58
|
-
#config.generate_rhtml_files = false
|
58
|
+
#config.generate_rhtml_files = false # compile directly to Rails view cache
|
59
59
|
|
@@ -185,6 +185,16 @@ module MasterView
|
|
185
185
|
attributes.each { |k,v| lcattrs[k.downcase] = v.downcase }
|
186
186
|
lcattrs
|
187
187
|
end
|
188
|
+
|
189
|
+
# using hash, symbolize keys, sort keys, serialize to string
|
190
|
+
def symbolize_sort_and_serialize_hash_to_str(hash)
|
191
|
+
symbolized = {}
|
192
|
+
hash.each{ |k,v| symbolized[k.to_sym] = v } #symbolize
|
193
|
+
sorted = symbolized.sort{ |a,b| a[0].to_s <=> b[0].to_s } # sort the keys
|
194
|
+
sorted_strings = sorted.collect{ |k,v| "#{k.inspect} => '#{v}'"} # create strings
|
195
|
+
sorted_strings.join(', ') # finally combine them
|
196
|
+
end
|
197
|
+
|
188
198
|
end
|
189
199
|
|
190
200
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
# creates a image_tag.
|
5
|
+
# if path is specified in attr_value then it will be used exactly as listed, otherwise if attr_value is empty
|
6
|
+
# then masterview will attempt to find the public/images in the string and infer the path from what follows.
|
7
|
+
# otherwise it will simply use the src path.
|
8
|
+
# If both width and height attr values are specified then it will build the :size option from them.
|
9
|
+
# Other html attributes will be passed into image_tag options.
|
10
|
+
class Image_tag < MasterView::DirectiveBase
|
11
|
+
IMAGE_SRC_EXTRACT_REGEX = /public\/images\/(.*)/
|
12
|
+
|
13
|
+
def stag(dcs)
|
14
|
+
end
|
15
|
+
|
16
|
+
def etag(dcs)
|
17
|
+
src = attrs_lck['src']
|
18
|
+
if attr_value.empty? && src
|
19
|
+
match = IMAGE_SRC_EXTRACT_REGEX.match(src)
|
20
|
+
image_loc = (match) ? match[1] : src
|
21
|
+
else
|
22
|
+
image_loc = attr_value
|
23
|
+
end
|
24
|
+
|
25
|
+
image_tag_params = quote(image_loc)
|
26
|
+
attrs.delete('src') # delete this if exists, path has already been specified
|
27
|
+
|
28
|
+
width = attrs_lck['width']
|
29
|
+
height = attrs_lck['height']
|
30
|
+
if width && height
|
31
|
+
attrs.delete('width') #delete these since being used in size
|
32
|
+
attrs.delete('height')
|
33
|
+
attrs[:size] = "#{width}x#{height}"
|
34
|
+
end
|
35
|
+
|
36
|
+
options = symbolize_sort_and_serialize_hash_to_str(attrs)
|
37
|
+
image_tag_params += (', '+options) unless options.empty?
|
38
|
+
|
39
|
+
erb_content('image_tag ' + image_tag_params)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -3,12 +3,20 @@ module MasterView
|
|
3
3
|
|
4
4
|
#creates a link_to
|
5
5
|
class Javascript_include < MasterView::DirectiveBase
|
6
|
+
JAVASCRIPT_SRC_EXTRACT_REGEX = /public\/javascripts\/(.*)/
|
7
|
+
|
6
8
|
def stag(dcs)
|
7
9
|
end
|
8
10
|
|
9
11
|
def etag(dcs)
|
10
|
-
|
11
|
-
|
12
|
+
src = attrs_lck['src']
|
13
|
+
if attr_value.empty? && src
|
14
|
+
match = JAVASCRIPT_SRC_EXTRACT_REGEX.match(src)
|
15
|
+
js_loc = quote( (match) ? match[1] : src )
|
16
|
+
else
|
17
|
+
js_loc = attr_value.starts_with?(':') ? attr_value : quote(attr_value)
|
18
|
+
end
|
19
|
+
erb_content('javascript_include_tag ' + js_loc)
|
12
20
|
end
|
13
21
|
end
|
14
22
|
end
|
@@ -3,11 +3,20 @@ module MasterView
|
|
3
3
|
|
4
4
|
#creates a link_to
|
5
5
|
class Stylesheet_link < MasterView::DirectiveBase
|
6
|
+
STYLESHEET_SRC_EXTRACT_REGEX = /public\/stylesheets\/(.*)/
|
7
|
+
|
6
8
|
def stag(dcs)
|
7
9
|
end
|
8
10
|
|
9
11
|
def etag(dcs)
|
10
|
-
|
12
|
+
src = attrs_lck['src']
|
13
|
+
if attr_value.empty? && src
|
14
|
+
match = STYLESHEET_SRC_EXTRACT_REGEX.match(src)
|
15
|
+
ss_loc = (match) ? match[1] : src
|
16
|
+
else
|
17
|
+
ss_loc = attr_value
|
18
|
+
end
|
19
|
+
erb_content('stylesheet_link_tag ' + quote(ss_loc))
|
11
20
|
end
|
12
21
|
end
|
13
22
|
end
|
@@ -68,6 +68,10 @@ class MasterviewController < ApplicationController
|
|
68
68
|
smart_render 'masterview/admin/list'
|
69
69
|
end
|
70
70
|
|
71
|
+
def features
|
72
|
+
smart_render 'masterview/admin/features'
|
73
|
+
end
|
74
|
+
|
71
75
|
# Rebuild all templates in the application.
|
72
76
|
# Invoked from the main masterview admin page.
|
73
77
|
def rebuild_all
|
@@ -0,0 +1,79 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Masterview Admin</title>
|
4
|
+
|
5
|
+
<%= stylesheet_link_tag 'masterview/style' %>
|
6
|
+
<%= stylesheet_link_tag 'masterview/sidebox' %>
|
7
|
+
<%= stylesheet_link_tag 'masterview/color-scheme' %>
|
8
|
+
<%= javascript_include_tag :defaults %>
|
9
|
+
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<!-- ###### Header ###### -->
|
14
|
+
|
15
|
+
<div id="header">
|
16
|
+
<span class="headerTitle">Admin</span>
|
17
|
+
<div class="menuBar">
|
18
|
+
<%= link_to 'Home', :action => :index %>
|
19
|
+
<!-- | <a href="">Another link</a> -->
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
|
24
|
+
<div class="main">
|
25
|
+
|
26
|
+
<div class="create_div" id="mv_admin_features"><!-- ###### features ###### -->
|
27
|
+
<div class="mv_admin_features sidebar LHS">
|
28
|
+
<h2>Tasks:</h2>
|
29
|
+
<ul>
|
30
|
+
<li><%= link_to 'Back to overview', :action => 'list' %></li>
|
31
|
+
</ul>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="mv_admin_features content">
|
35
|
+
<h1>Loaded Features</h1>
|
36
|
+
<b>MasterView Version:</b> <%= MasterView::VERSION::STRING %><br/><br/>
|
37
|
+
|
38
|
+
<% if @flash[:notice] %>
|
39
|
+
<div class="messages" id="admin_messages">
|
40
|
+
<%= h @flash[:notice] %>
|
41
|
+
</div>
|
42
|
+
<% end %>
|
43
|
+
|
44
|
+
<table>
|
45
|
+
<thead>
|
46
|
+
<tr><th>Feature</th><th>Loaded</th></tr>
|
47
|
+
</thead>
|
48
|
+
<tbody>
|
49
|
+
<tr><td>Filter templates through tidy on read</td><td><%= (MasterView::LoadedFeatures[:tidy_template_read]) ? 'true' : 'false' %></td></tr>
|
50
|
+
<tr><td>Parse templates at startup</td><td><%= (MasterView::LoadedFeatures[:rails_parse_at_startup]) ? 'true' : 'false' %></td></tr>
|
51
|
+
<tr><td>Reparse modified templates</td><td><%= (MasterView::LoadedFeatures[:rails_reparse_checking]) ? 'true' : 'false' %></td></tr>
|
52
|
+
<tr><td>Read ERB directly from MasterView</td><td><%= (MasterView::LoadedFeatures[:rails_erb_mv_direct]) ? 'true' : 'false' %></td></tr>
|
53
|
+
</tbody>
|
54
|
+
</table>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
</div>
|
60
|
+
|
61
|
+
<!-- ###### Footer ###### -->
|
62
|
+
|
63
|
+
<div id="footer">
|
64
|
+
<div class="footerLHS">
|
65
|
+
<a href="http://validator.w3.org/check/referer">Valid XHTML 1.0 Strict</a>
|
66
|
+
</div>
|
67
|
+
|
68
|
+
<div class="footerLHS">
|
69
|
+
<a href="http://jigsaw.w3.org/css-validator/check/referer">Valid CSS 2</a>
|
70
|
+
</div>
|
71
|
+
|
72
|
+
<div>
|
73
|
+
Powered by MasterView
|
74
|
+
</div>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
|
78
|
+
</body>
|
79
|
+
</html>
|
@@ -27,6 +27,7 @@
|
|
27
27
|
<h2>Tasks:</h2>
|
28
28
|
<ul>
|
29
29
|
<li><%= link_to 'View Configuration', :action => 'configuration' %></li>
|
30
|
+
<li><%= link_to 'View Loaded Features', :action => 'features' %></li>
|
30
31
|
<li><%= link_to 'Rebuild all outdated templates', :action => 'rebuild_all' %></li>
|
31
32
|
</ul>
|
32
33
|
</div>
|
@@ -42,6 +42,7 @@
|
|
42
42
|
#++
|
43
43
|
#
|
44
44
|
|
45
|
+
|
45
46
|
MasterView::Log.info { 'Adding hook to allow MasterView to check for templates that have changed when processing a request' }
|
46
47
|
|
47
48
|
module ActionController #:nodoc:
|
@@ -57,3 +58,5 @@ module ActionController #:nodoc:
|
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
61
|
+
|
62
|
+
MasterView::LoadedFeatures[:rails_reparse_checking] = true
|
@@ -425,7 +425,7 @@ module MasterView
|
|
425
425
|
@mv_installation_dir = File.expand_path( "#{File.dirname(__FILE__)}/../.." )
|
426
426
|
|
427
427
|
#ISSUE: should probably also detect std console or breakpointer launch scripts [DJL 10-Jun-2006]
|
428
|
-
@rails_runner_scripts_pattern = /server|dispatch/
|
428
|
+
@rails_runner_scripts_pattern = /server|dispatch|mongrel_rails/
|
429
429
|
|
430
430
|
@has_rails_context = (defined?(::RAILS_ROOT) != nil)
|
431
431
|
decide_if_running_rails
|
@@ -751,6 +751,10 @@ module MasterView
|
|
751
751
|
|
752
752
|
config = configuration
|
753
753
|
|
754
|
+
# create loaded feature map - this map will track exactly what was loaded taking into account failures, so it can differ
|
755
|
+
# from what is configured. key = feature symbol, value = true if enabled and loaded
|
756
|
+
MasterView.const_set('LoadedFeatures', {} )
|
757
|
+
|
754
758
|
# we don't record root_path or config_dir_path - their purpose is satisfied
|
755
759
|
# by the time we're done processing this installation configuration
|
756
760
|
|
@@ -823,6 +827,7 @@ module MasterView
|
|
823
827
|
end
|
824
828
|
io_mgr.backup = FileMIOTree.new( config.rebuild_backups_tmp_dir_path ) if config.rebuild_backups_tmp_dir_path
|
825
829
|
MasterView.const_set('IOMgr', io_mgr)
|
830
|
+
MasterView::LoadedFeatures[:tidy_template_read] = config.default_parser_options[:tidy]
|
826
831
|
end
|
827
832
|
|
828
833
|
# Initialize MasterView::Log with a logger which emits to std output, default DEBUG level
|
@@ -837,6 +842,7 @@ module MasterView
|
|
837
842
|
parse_templates_at_startup
|
838
843
|
enable_reparse_changed_templates
|
839
844
|
enable_rails_erb_direct
|
845
|
+
MasterView::Log.info{ 'MasterView plugin initialized - Version '+MasterView::VERSION::STRING }
|
840
846
|
end
|
841
847
|
|
842
848
|
# install the MasterviewController to support masterview admin pages in the site
|
@@ -883,6 +889,7 @@ module MasterView
|
|
883
889
|
MasterView::IOMgr.template.find(:pattern => MasterView::TemplateFilenamePattern) do |mio|
|
884
890
|
MasterView::Parser.parse_mio(mio, MasterView::IOMgr.erb)
|
885
891
|
end
|
892
|
+
MasterView::LoadedFeatures[:rails_parse_at_startup] = true
|
886
893
|
end
|
887
894
|
end
|
888
895
|
|
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
currentPath = File.dirname(__FILE__)
|
5
|
+
require File.join( currentPath, '../../lib/masterview' )
|
6
|
+
require File.join( currentPath, '../../lib/masterview/directives/image_tag' )
|
7
|
+
|
8
|
+
class ImageTagTest < Test::Unit::TestCase
|
9
|
+
include MasterView::Directives
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@directives = MasterView::DirectiveSet.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_default
|
16
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
17
|
+
@directives.directives = []
|
18
|
+
attr_value = "hello world"
|
19
|
+
@directives << Image_tag.new(attr_value)
|
20
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
21
|
+
dcs = @directives.determine_dcs(:etag)
|
22
|
+
dcs.context = tag.create_context
|
23
|
+
assert_equal "<%= image_tag 'hello world' %>", dcs.render
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_default_size
|
27
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
28
|
+
@directives.directives = []
|
29
|
+
attr_value = "hello world"
|
30
|
+
@directives << Image_tag.new(attr_value)
|
31
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
32
|
+
dcs = @directives.determine_dcs(:etag)
|
33
|
+
dcs.context = tag.create_context
|
34
|
+
dcs.context[:tag].attributes['width'] = '20'
|
35
|
+
dcs.context[:tag].attributes['height'] = '10'
|
36
|
+
assert_equal "<%= image_tag 'hello world', :size => '20x10' %>", dcs.render
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_default_size_alt
|
40
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
41
|
+
@directives.directives = []
|
42
|
+
attr_value = "hello world"
|
43
|
+
@directives << Image_tag.new(attr_value)
|
44
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
45
|
+
dcs = @directives.determine_dcs(:etag)
|
46
|
+
dcs.context = tag.create_context
|
47
|
+
dcs.context[:tag].attributes['width'] = '20'
|
48
|
+
dcs.context[:tag].attributes['height'] = '10'
|
49
|
+
dcs.context[:tag].attributes['alt'] = 'foo'
|
50
|
+
assert_equal "<%= image_tag 'hello world', :alt => 'foo', :size => '20x10' %>", dcs.render
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_empty_infer_path
|
54
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
55
|
+
@directives.directives = []
|
56
|
+
attr_value = ""
|
57
|
+
@directives << Image_tag.new(attr_value)
|
58
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
59
|
+
dcs = @directives.determine_dcs(:etag)
|
60
|
+
dcs.context = tag.create_context
|
61
|
+
dcs.context[:tag].attributes['src'] = '../../public/images/foo.js'
|
62
|
+
assert_equal "<%= image_tag 'foo.js' %>", dcs.render
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_empty_infer_path_sub
|
66
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
67
|
+
@directives.directives = []
|
68
|
+
attr_value = ""
|
69
|
+
@directives << Image_tag.new(attr_value)
|
70
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
71
|
+
dcs = @directives.determine_dcs(:etag)
|
72
|
+
dcs.context = tag.create_context
|
73
|
+
dcs.context[:tag].attributes['src'] = '../../public/images/bar/foo.js'
|
74
|
+
assert_equal "<%= image_tag 'bar/foo.js' %>", dcs.render
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_empty_use_src
|
78
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
79
|
+
@directives.directives = []
|
80
|
+
attr_value = ""
|
81
|
+
@directives << Image_tag.new(attr_value)
|
82
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
83
|
+
dcs = @directives.determine_dcs(:etag)
|
84
|
+
dcs.context = tag.create_context
|
85
|
+
dcs.context[:tag].attributes['src'] = '/myimages/foo.js'
|
86
|
+
assert_equal "<%= image_tag '/myimages/foo.js' %>", dcs.render
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -23,4 +23,51 @@ class JavascriptIncludeTest < Test::Unit::TestCase
|
|
23
23
|
assert_equal "<%= javascript_include_tag 'hello world' %>", dcs.render
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_symbol
|
27
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
28
|
+
@directives.directives = []
|
29
|
+
attr_value = ":defaults"
|
30
|
+
@directives << Javascript_include.new(attr_value)
|
31
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
32
|
+
dcs = @directives.determine_dcs(:etag)
|
33
|
+
dcs.context = tag.create_context
|
34
|
+
assert_equal "<%= javascript_include_tag :defaults %>", dcs.render
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_empty_infer_path
|
38
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
39
|
+
@directives.directives = []
|
40
|
+
attr_value = ""
|
41
|
+
@directives << Javascript_include.new(attr_value)
|
42
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
43
|
+
dcs = @directives.determine_dcs(:etag)
|
44
|
+
dcs.context = tag.create_context
|
45
|
+
dcs.context[:tag].attributes['src'] = '../../public/javascripts/foo.js'
|
46
|
+
assert_equal "<%= javascript_include_tag 'foo.js' %>", dcs.render
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_empty_infer_path_sub
|
50
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
51
|
+
@directives.directives = []
|
52
|
+
attr_value = ""
|
53
|
+
@directives << Javascript_include.new(attr_value)
|
54
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
55
|
+
dcs = @directives.determine_dcs(:etag)
|
56
|
+
dcs.context = tag.create_context
|
57
|
+
dcs.context[:tag].attributes['src'] = '../../public/javascripts/bar/foo.js'
|
58
|
+
assert_equal "<%= javascript_include_tag 'bar/foo.js' %>", dcs.render
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_empty_use_src
|
62
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
63
|
+
@directives.directives = []
|
64
|
+
attr_value = ""
|
65
|
+
@directives << Javascript_include.new(attr_value)
|
66
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
67
|
+
dcs = @directives.determine_dcs(:etag)
|
68
|
+
dcs.context = tag.create_context
|
69
|
+
dcs.context[:tag].attributes['src'] = '/myjavascripts/foo.js'
|
70
|
+
assert_equal "<%= javascript_include_tag '/myjavascripts/foo.js' %>", dcs.render
|
71
|
+
end
|
72
|
+
|
26
73
|
end
|
@@ -23,4 +23,41 @@ class StylesheetLinkTest < Test::Unit::TestCase
|
|
23
23
|
assert_equal "<%= stylesheet_link_tag 'hello world' %>", dcs.render
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_empty_infer_path
|
27
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
28
|
+
@directives.directives = []
|
29
|
+
attr_value = ""
|
30
|
+
@directives << Stylesheet_link.new(attr_value)
|
31
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
32
|
+
dcs = @directives.determine_dcs(:etag)
|
33
|
+
dcs.context = tag.create_context
|
34
|
+
dcs.context[:tag].attributes['src'] = '../../public/stylesheets/foo.css'
|
35
|
+
assert_equal "<%= stylesheet_link_tag 'foo.css' %>", dcs.render
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_empty_infer_path_sub
|
39
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
40
|
+
@directives.directives = []
|
41
|
+
attr_value = ""
|
42
|
+
@directives << Stylesheet_link.new(attr_value)
|
43
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
44
|
+
dcs = @directives.determine_dcs(:etag)
|
45
|
+
dcs.context = tag.create_context
|
46
|
+
dcs.context[:tag].attributes['src'] = '../../public/stylesheets/bar/foo.css'
|
47
|
+
assert_equal "<%= stylesheet_link_tag 'bar/foo.css' %>", dcs.render
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_empty_use_src
|
51
|
+
tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil)
|
52
|
+
@directives.directives = []
|
53
|
+
attr_value = ""
|
54
|
+
@directives << Stylesheet_link.new(attr_value)
|
55
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
56
|
+
dcs = @directives.determine_dcs(:etag)
|
57
|
+
dcs.context = tag.create_context
|
58
|
+
dcs.context[:tag].attributes['src'] = '/mystylesheets/foo.css'
|
59
|
+
assert_equal "<%= stylesheet_link_tag '/mystylesheets/foo.css' %>", dcs.render
|
60
|
+
end
|
61
|
+
|
62
|
+
|
26
63
|
end
|
data/test/unit/template_test.rb
CHANGED
@@ -468,7 +468,161 @@ class TestTemplate < Test::Unit::TestCase
|
|
468
468
|
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
469
469
|
end
|
470
470
|
|
471
|
+
def test_image_tag
|
472
|
+
template = <<-END
|
473
|
+
<div mv:generate='foo/bar'>
|
474
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag="cat.jpg"/>
|
475
|
+
</div>
|
476
|
+
END
|
477
|
+
expected = {
|
478
|
+
'foo/bar' => "<div><%= image_tag 'cat.jpg' %></div>"
|
479
|
+
}
|
480
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
481
|
+
end
|
482
|
+
|
483
|
+
def test_image_tag_infer_path
|
484
|
+
template = <<-END
|
485
|
+
<div mv:generate='foo/bar'>
|
486
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag=""/>
|
487
|
+
</div>
|
488
|
+
END
|
489
|
+
expected = {
|
490
|
+
'foo/bar' => "<div><%= image_tag 'cat.jpg' %></div>"
|
491
|
+
}
|
492
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
493
|
+
end
|
494
|
+
|
495
|
+
def test_image_tag_infer_path_use_src
|
496
|
+
template = <<-END
|
497
|
+
<div mv:generate='foo/bar'>
|
498
|
+
<img src="/myimages/cat.jpg" mv:image_tag=""/>
|
499
|
+
</div>
|
500
|
+
END
|
501
|
+
expected = {
|
502
|
+
'foo/bar' => "<div><%= image_tag '/myimages/cat.jpg' %></div>"
|
503
|
+
}
|
504
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
505
|
+
end
|
506
|
+
|
507
|
+
def test_image_tag_infer_path_size
|
508
|
+
template = <<-END
|
509
|
+
<div mv:generate='foo/bar'>
|
510
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag="" width="20" height="10"/>
|
511
|
+
</div>
|
512
|
+
END
|
513
|
+
expected = {
|
514
|
+
'foo/bar' => "<div><%= image_tag 'cat.jpg', :size => '20x10' %></div>"
|
515
|
+
}
|
516
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
517
|
+
end
|
518
|
+
|
519
|
+
def test_image_tag_infer_missing_width
|
520
|
+
template = <<-END
|
521
|
+
<div mv:generate='foo/bar'>
|
522
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag="" height="10"/>
|
523
|
+
</div>
|
524
|
+
END
|
525
|
+
expected = {
|
526
|
+
'foo/bar' => "<div><%= image_tag 'cat.jpg', :height => '10' %></div>"
|
527
|
+
}
|
528
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
529
|
+
end
|
471
530
|
|
531
|
+
def test_image_tag_infer_missing_height
|
532
|
+
template = <<-END
|
533
|
+
<div mv:generate='foo/bar'>
|
534
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag="" width="20"/>
|
535
|
+
</div>
|
536
|
+
END
|
537
|
+
expected = {
|
538
|
+
'foo/bar' => "<div><%= image_tag 'cat.jpg', :width => '20' %></div>"
|
539
|
+
}
|
540
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
541
|
+
end
|
542
|
+
|
543
|
+
def test_image_tag_infer_path_size_alt
|
544
|
+
template = <<-END
|
545
|
+
<div mv:generate='foo/bar'>
|
546
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag="" width="20" height="10" alt="my cat"/>
|
547
|
+
</div>
|
548
|
+
END
|
549
|
+
expected = {
|
550
|
+
'foo/bar' => "<div><%= image_tag 'cat.jpg', :alt => 'my cat', :size => '20x10' %></div>"
|
551
|
+
}
|
552
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
553
|
+
end
|
554
|
+
|
555
|
+
def test_image_tag_infer_path_alt
|
556
|
+
template = <<-END
|
557
|
+
<div mv:generate='foo/bar'>
|
558
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag="" alt="my cat"/>
|
559
|
+
</div>
|
560
|
+
END
|
561
|
+
expected = {
|
562
|
+
'foo/bar' => "<div><%= image_tag 'cat.jpg', :alt => 'my cat' %></div>"
|
563
|
+
}
|
564
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
565
|
+
end
|
566
|
+
|
567
|
+
def test_image_tag_infer_path_class
|
568
|
+
template = <<-END
|
569
|
+
<div mv:generate='foo/bar'>
|
570
|
+
<img src="../../../public/images/cat.jpg" mv:image_tag="" alt="my cat" class="blue"/>
|
571
|
+
</div>
|
572
|
+
END
|
573
|
+
expected = {
|
574
|
+
'foo/bar' => "<div><%= image_tag 'cat.jpg', :alt => 'my cat', :class => 'blue' %></div>"
|
575
|
+
}
|
576
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
577
|
+
end
|
578
|
+
|
579
|
+
def test_javascript_include
|
580
|
+
template = <<-END
|
581
|
+
<div mv:generate='foo/bar'>
|
582
|
+
<img src="../../../public/javascripts/cat.js" mv:javascript_include="cat.js"/>
|
583
|
+
</div>
|
584
|
+
END
|
585
|
+
expected = {
|
586
|
+
'foo/bar' => "<div><%= javascript_include_tag 'cat.js' %></div>"
|
587
|
+
}
|
588
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
589
|
+
end
|
590
|
+
|
591
|
+
def test_javascript_include_symbols
|
592
|
+
template = <<-END
|
593
|
+
<div mv:generate='foo/bar'>
|
594
|
+
<img src="../../../public/javascripts/cat.js" mv:javascript_include=":defaults"/>
|
595
|
+
</div>
|
596
|
+
END
|
597
|
+
expected = {
|
598
|
+
'foo/bar' => "<div><%= javascript_include_tag :defaults %></div>"
|
599
|
+
}
|
600
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
601
|
+
end
|
602
|
+
|
603
|
+
def test_javascript_include_infer_path
|
604
|
+
template = <<-END
|
605
|
+
<div mv:generate='foo/bar'>
|
606
|
+
<img src="../../../public/javascripts/cat.js" mv:javascript_include=""/>
|
607
|
+
</div>
|
608
|
+
END
|
609
|
+
expected = {
|
610
|
+
'foo/bar' => "<div><%= javascript_include_tag 'cat.js' %></div>"
|
611
|
+
}
|
612
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
613
|
+
end
|
614
|
+
|
615
|
+
def test_javascript_include_infer_path_use_src
|
616
|
+
template = <<-END
|
617
|
+
<div mv:generate='foo/bar'>
|
618
|
+
<img src="/myjavascripts/cat.js" mv:javascript_include=""/>
|
619
|
+
</div>
|
620
|
+
END
|
621
|
+
expected = {
|
622
|
+
'foo/bar' => "<div><%= javascript_include_tag '/myjavascripts/cat.js' %></div>"
|
623
|
+
}
|
624
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
625
|
+
end
|
472
626
|
|
473
627
|
|
474
628
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: masterview
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2006-06-
|
6
|
+
version: 0.2.1
|
7
|
+
date: 2006-06-28 00:00:00 -05:00
|
8
8
|
summary: A (x)html friendly template engine for rails with the power of layouts, and partials.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/masterview/directives/import.rb
|
83
83
|
- lib/masterview/directives/content.rb
|
84
84
|
- lib/masterview/directives/text_area.rb
|
85
|
+
- lib/masterview/directives/image_tag.rb
|
85
86
|
- lib/masterview/extras/app
|
86
87
|
- lib/masterview/extras/init_logger.rb
|
87
88
|
- lib/masterview/extras/watcher.rb
|
@@ -96,6 +97,7 @@ files:
|
|
96
97
|
- lib/masterview/extras/app/views/masterview/admin/list.rhtml
|
97
98
|
- lib/masterview/extras/app/views/masterview/admin/empty.rhtml
|
98
99
|
- lib/masterview/extras/app/views/masterview/admin/create.rhtml
|
100
|
+
- lib/masterview/extras/app/views/masterview/admin/features.rhtml
|
99
101
|
- Rakefile
|
100
102
|
- init.rb
|
101
103
|
- doc/stylesheets
|
@@ -106,6 +108,8 @@ files:
|
|
106
108
|
- doc/configuration.html
|
107
109
|
- doc/index.html
|
108
110
|
- doc/troubleshooting.html
|
111
|
+
- doc/media_list.html
|
112
|
+
- doc/simple_diagram.html
|
109
113
|
- doc/stylesheets/mv-directives.css
|
110
114
|
- doc/stylesheets/mv-installation.css
|
111
115
|
- doc/stylesheets/mv-config.css
|
@@ -160,6 +164,7 @@ files:
|
|
160
164
|
- test/unit/directive_text_area_test.rb
|
161
165
|
- test/unit/pathname_extensions_test.rb
|
162
166
|
- test/unit/string_hash_mio_test.rb
|
167
|
+
- test/unit/directive_image_tag_test.rb
|
163
168
|
- test/xtras/config_initialize_standalone.rb
|
164
169
|
- test/xtras/config-mv-logger_config.rb
|
165
170
|
- test/fixtures/configs
|