masterview_gem_plugin_generator 0.0.3

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 ADDED
@@ -0,0 +1,3 @@
1
+ 0.0.3 - April 18, 2006 - Repackaging
2
+
3
+ 0.0.2 - April 16, 2006 - First public release
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006 Jeff Barczewski
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,574 @@
1
+ = MasterView - Rails-optimized (x)html friendly template engine
2
+
3
+ MasterView is a ruby/rails optimized HTML/XHTML friendly template engine.
4
+ It is designed to use the full power and productivity of rails including
5
+ layouts, partials, and rails html helpers while still being editable/styleable
6
+ in a WYSIWYG HTML editor.
7
+
8
+ MasterView is distributed as a gem or a plugin. You may install it as a gem and then generate a lightweight plugin which mainly refers to the gem *or* you can simply install as a plugin which is self contained. I personally prefer installing as a gem for ease of management, however if you are running at a shared hosting environment you might not have authority to install this gem so you may install as a self contained plugin.
9
+
10
+ If you are interested in the background story behind all this, it is at the end of this page.
11
+
12
+ Author:: Jeff Barczewski
13
+ Email:: jeff.barczewski @ gmail.com
14
+ Rubyforge project:: masterview
15
+ Website:: http://masterview.org
16
+ License:: MIT open source license like Rails
17
+
18
+ == Goals
19
+
20
+ - Create/extend a template engine for rails that would be XHTML friendly and thus could be edited/styled with a WYSIWYG HTML editor even late in development without breaking template.
21
+ - Keep it simple. DRY. No extra config files, simple syntax with ruby flavor.
22
+ - Design it specifically for ruby and rails. Use the full power and not be limited in its capabilities over what can be done with ERb
23
+ - Work nicely with layouts, partials, and rails html helpers.
24
+ - Reduce complexity, work with existing rails code, no extra view logic or hashes than what is used by ERb. Scaffold generate initial templates or work from existing html prototype.
25
+ - Use one master file to drive all related sections, simplifying editing.
26
+ - Preview in browser without running an app. Allow for dummy data in the template so that the page can be viewed and styled independently of the application.
27
+ - Performance equal to ERb
28
+
29
+ == Prerequisites
30
+
31
+ Requires::
32
+ facets (gem)
33
+
34
+ Optional::
35
+ tidy (gem) and tidy library - if these are installed you can use tidy to cleanup html into valid xhtml for use by MasterView
36
+ log4r (gem) - if this gem is installed then MasterView will use it for logging otherwise it defaults to using built in Logger.
37
+
38
+ == Installation
39
+
40
+ Install in one of the two following ways depending on whether you can use gems or not.
41
+
42
+ === Installation using gems (if you are able to use gems)
43
+
44
+ If you can use gems you may simply do the following
45
+
46
+ gem install masterview
47
+
48
+ Now your gem is installed and you can skip that step in the future. After creating your rails directory, change directory to it and run the following to create a very lightweight plugin instance for this application mainly consisting of an init.rb file which will get loaded at runtime. This init.rb refers to the gem for everything but allows you to override any constants or setup that has been provided. See MasterView module masterview.rb for a list of the available constants.
49
+
50
+ script/generate masterview_gem_plugin
51
+
52
+ After this MasterView is ready for use. Skip down to the Usage section for more details.
53
+
54
+ === Installation without using gems, install as plugin
55
+
56
+ script/plugin install masterview
57
+
58
+ This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants.
59
+
60
+ == Usage
61
+
62
+ You may add MasterView attributes to existing (x)html or you may use the masterview generator to create a complete working application. The generator can create controllers, models, and the MasterView template file similar to how the built-in generator works. Simply change directory to your rails application and run the following
63
+
64
+ script/generate masterview YourModelName
65
+
66
+ Once it is done generating, the generated MasterView template file will be created in app/views/masterview/YourModelName.html. This file is html and can be edited with any standard html editor. The rails specific logic is contained in simple attributes which are ignored by html editors. The syntax for these attributes is heavily derived from the rails helper tags themselves so it should feel natural to the rails developer.
67
+
68
+ Another interesting thing to know is that while all of the pages for this Model have been bundled up into one html file for ease of editing, at runtime this template gets rendered into the exact same layouts and partials that you would use if you were building from scratch. Its jsut that now you can see what your pages will render like in your wysiwyg html editor and change and layout accordingly. Additionally MasterView supplies some javascript to show only one action view at time (list, new, show, edit, delete) so you can view in your browser without running in Rails. Dummy html can be included to improve the accuracy of the page which can be easily removed at runtime.
69
+
70
+ MasterView is designed to be easy for a developer and designer to work together. By keeping the template in an html friendly format, designers can apply style, layout changes, wording changes, without causing havoc on the rails view code. The designer can be involved at anytime during the development cycle including being able to change style and layout after the system is built. This is great for allowing design or wording changes without reinvolving the developers. One can even start from a designer created prototype and add MasterView tags to make it become real. Whichever way you prefer to work, MasterView accomodates you.
71
+
72
+ == MasterView attribute directive syntax
73
+
74
+ These attribute directives are provided by MasterView and you can create your own custom attributes for even more power.
75
+
76
+ mv:generate="layouts/product.rhtml"
77
+ When the generate directive is encountered it creates a new output rhtml file where this element and its
78
+ children will be rendered. It also will suspend outputting to any previous output file until it is done with this
79
+ one (nested). MasterView will not output any rhtml files unless it encouters one of these or mv:gen_render directive
80
+ below. Typically you will have one of these in the very top html element to generate the layout, and you will have
81
+ additional directives further inside to output different view partials and forms. MasterView takes this one html
82
+ file and generates all the other layout, forms, and partials that you would do manually. for example...
83
+
84
+ <html mv:generate="layouts/product.rhtml">
85
+ <title>Hello</title>
86
+ <body>
87
+ <div mv:replace="@content_for_layout">
88
+ <div mv:generate="product/new.rhtml">
89
+ <form></form>
90
+ </div>
91
+ </div>
92
+ </body>
93
+ </html>
94
+
95
+ outputs to two files
96
+
97
+ app/views/layouts/product.rhtml
98
+ <html>
99
+ <title>Hello</title>
100
+ <body>
101
+ <%= @content_for_layout %>
102
+ </body>
103
+ </html>
104
+
105
+ app/views/product/new.rhtml
106
+ <div>
107
+ <form></form>
108
+ </div>
109
+
110
+
111
+ mv:gen_render=":partial => 'product/form'"
112
+ This directive does two things it creates a partial and it outputs the appropriate code to render this
113
+ partial in the parent output file before beginning output of the partial. It calculates the file name from the
114
+ :partial value and appends .rhtml for example...
115
+
116
+
117
+ <html mv:generate="layouts/product.rhtml">
118
+ <body>
119
+ <div mv:gen_render=":partial => 'product/show'">
120
+ Name: <span class="static" mv:content="h @product.send(:name)">product Name dummy text</span>
121
+ Description: <span class="static" mv:content="h @product.send(:description)">product description dummy text</span>
122
+ </div>
123
+ </body>
124
+ </html>
125
+
126
+ outputs two files
127
+
128
+ app/views/layouts/product.rhtml
129
+ <html>
130
+ <body>
131
+ <%= render :partial => 'product/show' %>
132
+ </body>
133
+ </html>
134
+
135
+ app/views/product/_show.rhtml
136
+ <div>
137
+ Name: <span class="static"><%= h @product.send(:name) %></span>
138
+ Description: <span class="static"><%= h @product.send(:description) %></span>
139
+ </div>
140
+
141
+ You can also use collections with your partials like
142
+
143
+ <div mv:gen_render=":partial => 'shared/product', :collection => @products">
144
+
145
+ which will create the partial shared/_product.rhtml and will render this partial over a collection
146
+
147
+ mv:gen_replace="whatToLeave"
148
+ When used in conjunction with mv:generate directive it causes the value of the attribute to be erb
149
+ executed output in the parent file before transferring to the child (nested) output file. for example...
150
+
151
+ <html mv:generate="layouts/product.rhtml">
152
+ <title>Hello</title>
153
+ <body>
154
+ <div mv:generate="product/new.rhtml" mv:gen_replace="@content_for_layout>
155
+ <form></form>
156
+ </div>
157
+ </body>
158
+ </html>
159
+
160
+ outputs two files
161
+
162
+ app/views/layouts/product.rhtml
163
+ <html>
164
+ <title>Hello</title>
165
+ <body>
166
+ <%= @content_for_layout %>
167
+ </body>
168
+ </html>
169
+
170
+ app/views/product/new.rhtml
171
+ <div>
172
+ <form></form>
173
+ </div>
174
+
175
+ mv:block="rubyBlockCodeHere"
176
+ At runtime this expands to the equivalent rhtml (erb) block code around this element, for example...
177
+
178
+ <div mv:block="products.each do |product|">foobar</div>
179
+
180
+ becomes
181
+
182
+ <% products.each do |product| %>
183
+ <div>foobar</div>
184
+ <% end %>
185
+
186
+ Note how MasterView automatically put in the 'end' after the closing tag.
187
+ Another example using the brace form of a block
188
+
189
+ <div mv:block="products.each { |product|">foobar</div>
190
+
191
+ becomes
192
+
193
+ <% products.each { |product| %>
194
+ <div>foobar</div>
195
+ <% } %>
196
+
197
+ Its all based on the ruby and rails syntax while keeping things xhtml and designer friendly.
198
+
199
+ mv:content="foo"
200
+ Replaces the content of the tag with the erb output of foo, for example...
201
+
202
+ <div mv:content="foo">some dummy html here</div>
203
+
204
+ becomes
205
+
206
+ <div><%= foo %></div>
207
+
208
+ mv:form=":action => 'new'"
209
+ Replaces this tag and closing tag with the form_tag and end_form_tag helpers. It also pulls the
210
+ method and multipart attributes from the element and merges that into the form_tag options, for example...
211
+
212
+ <form mv:form=":action => 'new'">foobar</form>
213
+
214
+ becomes
215
+
216
+ <% form_tag :action => 'new' %>
217
+ foobar
218
+ <% end_form_tag %>
219
+
220
+ <form method="GET" mv:form=":action => 'new'">foobar</form>
221
+
222
+ becomes
223
+
224
+ <% form_tag { :action => 'new' }, :method => 'GET' %>
225
+ foobar
226
+ <% end_form_tag %>
227
+
228
+ mv:hidden_field="object, method"
229
+ Replaces this tag with an hidden input tag using the rails hidden_tag helper, for example...
230
+
231
+ <input mv:hidden_field="product, desc" type="hidden" value="dummy text"/>
232
+
233
+ becomes
234
+
235
+ <%= hidden_field product, desc %>
236
+
237
+ mv:if="yourIfConditionHere"
238
+ Wraps the tag with an if block using the attribute contents for the condition, for example...
239
+
240
+ <div mv:if="@flash[:notice]">foo</div>
241
+
242
+ becomes
243
+
244
+ <% if @flash[:notice] %>
245
+ <div>foo</div>
246
+ <% end %>
247
+
248
+ And combining if and content directives we can do the following
249
+
250
+ <div mv:if="@flash[:notice]" mv:content="@flash[:notice]" class="messages">
251
+ dummy notice message here
252
+ </div>
253
+
254
+ becomes
255
+
256
+ <% if @flash[:notice] %>
257
+ <div>
258
+ <%= @flash[:notice] %>
259
+ </div>
260
+ <% end %>
261
+
262
+ mv:elsif="yourElseConditionHere"
263
+ Used in conjunction with an if directive allows you to create if, elsif blocks, for example...
264
+
265
+ <div mv:if="foo()">
266
+ hello
267
+ </div>
268
+ <div mv:elsif="bar()">
269
+ world
270
+ </div>
271
+
272
+ becomes
273
+
274
+ <% if foo() %>
275
+ <div>
276
+ hello
277
+ </div>
278
+ <% elsif bar() %>
279
+ <div>
280
+ world
281
+ </div>
282
+ <% end %>
283
+
284
+ Note that the elsif directive element needs to follow the if element's closing tag
285
+
286
+ mv:else=""
287
+ Used in conjunction with if and elsif, allows you to create if, elseif, else blocks, for example...
288
+
289
+ <div mv:if="@foo">
290
+ hello
291
+ </div>
292
+ <div mv:else="">
293
+ world
294
+ </div>
295
+
296
+ becomes
297
+
298
+ <% if @foo %>
299
+ <div>
300
+ hello
301
+ </div>
302
+ <% else %>
303
+ <div>
304
+ world
305
+ </div>
306
+ <% end %>
307
+
308
+ mv:javascript_include="prototype.js"
309
+ Replaces the tag with a javascript_include_tag helper, for example...
310
+
311
+ <script type="text/javascript" src="../../../public/javascripts/prototype.js"
312
+ mv:javascript_include="prototype.js"></script>
313
+
314
+ becomes
315
+
316
+ <%= javascript_include_tag 'prototype.js' %>
317
+
318
+ This is useful to allow scripts to be used for demos/prototypes and then at runtime
319
+ use the appropriate asset using the rails helper.
320
+
321
+ mv:link_to="linkToOptions"
322
+ Replaces the tag with a link_to helper, it uses the contents of the tag for the name of the link,
323
+ so the name of the link can be changed by the html designer and it gets used in the appropriate place
324
+ in the helper, for example...
325
+
326
+ <a mv:link_to=":action => 'new'">New product</a>
327
+
328
+ becomes
329
+
330
+ <%= link_to 'New product', :action => 'new' %>
331
+
332
+ mv:link_to_if="linkToIfConditionAndOption"
333
+ Replaces the tag with a link_to_if helper, uses the contents of the tag for the name of the
334
+ link so the name of the link can be changed by the html designer and it gets used in the appropriate
335
+ place in the helper, for example...
336
+
337
+ <a mv:link_to_if="@product_pages.current.previous, { :page => @product_pages.current.previous }"Previous page"</a>
338
+
339
+ becomes
340
+
341
+ <%= link_to_if @product_pages.current.previous, 'Previous page', {:page => @product_pages.current.previous } %>
342
+
343
+ mv:link_to_remote="linkToRemoteOptions"
344
+ Replaces the tag with a link_to_remote helper, uses the contents of the tag for the name of the
345
+ link so the name of the link can be changed by the html designer and it gets used in the appropriate
346
+ place in the helper, for example...
347
+
348
+ <a mv:link_to_remote=":action => 'new'">New product</a>
349
+
350
+ becomes
351
+
352
+ <%= link_to_remote 'New product', :action => 'new' %>
353
+
354
+ mv:password_field="user, password"
355
+ Replaces the tag with a password_field helper using the attribute as well as merging any html
356
+ attributes that have been set by the designer, for example...
357
+
358
+ <input type="password" mv:password_field="user, password"/>
359
+
360
+ becomes
361
+
362
+ <%= password_field user, password %>
363
+
364
+ and similarly
365
+
366
+ <input type="password" mv:password_field="user, password" size="10" maxlength="15" class="pwdStyle"/>
367
+
368
+ becomes
369
+
370
+ <%= password_field, user, password, :class => 'pwdStyle', :maxlength = 15, :size => 10 %>
371
+
372
+ mv:replace="foo bar"
373
+ Replaces the tag and contents with the erb executed output of the attribute. If the attribute
374
+ value is an empty string then the tag is simply removed and nothing is output, for example...
375
+
376
+ <span mv:replace="h product.name">dummy product name</span>
377
+
378
+ becomes
379
+
380
+ <%= h product.name %>
381
+
382
+ and similarly, you can use this to remove dummy html which was there for prototyping/demoing
383
+
384
+ <table>
385
+ other rows here
386
+ <tr mv:replace="">
387
+ <td>foo</td>
388
+ <td>bar</td>
389
+ </tr>
390
+ </table>
391
+
392
+ becomes
393
+
394
+ <table>
395
+ other rows here
396
+ </table>
397
+
398
+ Passing in an empty attribute simply eliminated the tag, children, and contents
399
+
400
+ mv:stylesheet_link="style"
401
+ Replaces the tag with a stylesheet_link_tag helper, for example...
402
+
403
+ <link rel="stylesheet" type="text/css" href="../../../public/stylesheets/scaffold.css" mv:stylesheet_link="scaffold"/>
404
+
405
+ becomes
406
+
407
+ <%= stylesheet_link_tag "scaffold" %>
408
+
409
+ This is useful to allow style to be used for demos/prototypes and then at runtime
410
+ use the appropriate asset using the rails helper.
411
+
412
+ mv:submit="submitOptions"
413
+ Replaces the tag with a submit_tag helper, it uses the html value attribute to set the text
414
+ in the helper, and appends any options after, for example...
415
+
416
+ <input type="submit" mv:submit="" value="Save product"/>
417
+
418
+ becomes
419
+
420
+ <%= submit_tag 'Save product' %>
421
+
422
+ and
423
+
424
+ <input type="submit" mv:submit=":foo => 'bar'" value="Save product"/>
425
+
426
+ becomes
427
+
428
+ <%= submit_tag 'Save product', :foo => 'bar' %>
429
+
430
+
431
+ mv:text_area="object, method"
432
+ Replaces the tag with a text_area helper, it uses the html attributes like rows, cols, disabled,
433
+ readonly, class, style, tabindex, accesskey and merges them with the object and method specified
434
+ in the attribute value, for example...
435
+
436
+ <textarea mv:text_areas="product, desc">dummy text</textarea>
437
+
438
+ becomes
439
+
440
+ <%= text_area prouct, desc %>
441
+
442
+ or a more complex example
443
+
444
+ <textarea mv:text_area="product, desc" rows="4" cols="60", class="mystyle">dummy text</textarea>
445
+
446
+ becomes
447
+
448
+ <%= textarea product, desc, :class => 'mystyle', :cols => '60', :rows => 4 %>
449
+
450
+ mv:text_field="object, method"
451
+ Replaces the tag with a text_field helper, it uses the html attributes like size, maxlength,
452
+ disabled, readonly, class, style, tabindex, accesskey and merges them with the object and
453
+ method specified in the attribute value, for example...
454
+
455
+ <input type="text" mv:text_field="product, name" value="dummy text"/>
456
+
457
+ becomes
458
+
459
+ <%= text_field product, name %>
460
+
461
+ and
462
+
463
+ <input type="text" mv:text_field="product, name" value="dummy text" class="mystyle" size="15" maxlength="20"/>
464
+
465
+ becomes
466
+
467
+ <%= text_field product, name, :class => 'mystyle', :maxlength => 20, :size => 15 %>
468
+
469
+
470
+
471
+ Inline substitutions
472
+ Since <%= foobar %> and <% foo %> are invalid xhtml values, MasterView has an inline substitution to
473
+ replace these for the cases when you simply want to inject something. {{{ gets replaced with <%
474
+ and {{{= gets replaced with <%= also }}} gets replaced with %> If you instead want to use the
475
+ old <% syntax instead, MasterView by default is setup to perform a substitution on those values before
476
+ parsing. However to be safe you should use the xhtml safe syntax otherwise html editors might end
477
+ up changing things on you.
478
+
479
+ {{{= foobar }}}
480
+
481
+ becomes
482
+
483
+ <%= foobar %>
484
+
485
+
486
+ and
487
+
488
+ {{{ foo }}}
489
+
490
+ becomes
491
+
492
+ <% foo %>
493
+
494
+
495
+ == Background story
496
+
497
+ I came from a Java Struts environment when I was introduced to Ruby. I
498
+ was just in the process of evaluating Tapestry and JSF when I learned about Rails.
499
+ Ruby and Rails changed my world forever. I had to however drop many of my bad
500
+ habits aquired from years of Java and C++ work. I had to embrace the new ideas
501
+ and approach things now with a different mindset. (If you ever have a chance to
502
+ hear Dave Thomas speak, you will know what I mean. He has a wonderfully entertaining
503
+ yet enlightening way of illustrating this.)
504
+
505
+ After learning the Ruby and Rails way, (Thank you Matz and DHH for such wonderful
506
+ gifts to the world) I was amazed at how productive this environment is. Programming was
507
+ fun once again, and everything you do in Ruby or Rails is easier than any other
508
+ language or framework I have ever seen. Even taking into account having to learn
509
+ something new, I was still far more productive than ever before. The only thing
510
+ that I felt that could be done better, was to have a nice html friendly templating
511
+ engine so that designers and developers could work collaboratively together on a project.
512
+ The designers could style and layout the pages with their WYSIWYG HTML editors and
513
+ developers would have the full power of Ruby and Rails without having to jump
514
+ through extra hoops to use them. I looked at the available html template engines
515
+ to see if anything fit with my style. I was disappointed with each of them, mainly because
516
+ they all made it harder than straigt ERb (rhtml) and were not able to use layouts
517
+ and partials easily.
518
+
519
+ After all the hard work so many people have put into Ruby and Rails, I wanted to see
520
+ if there was anyway I could contribute as well, maybe extending one of the existing
521
+ template projects to have the ideal functionality I was striving for. I wanted
522
+ something to make my own web development even more productive. However after
523
+ reviewing each of them and even getting into the source code, the closest ones seemed
524
+ to be Amrita2, Liquid, and Kwartz. Unfortunately it was not going to be easy to add
525
+ the functionality and usability I desired.
526
+
527
+ During my research I learned that many of the rails gurus were putting down html
528
+ template engines because they felt that they handicapped the developer severely,
529
+ namely by not taking advantage of rails layouts, partials, and html helpers.
530
+ After doing some projects with ERb (rhtml) I realized that they were right. I too
531
+ did not want to give up any of that power either. I also didn't want to create a
532
+ bunch of extra code or config to use the templates (extra view code, or data
533
+ structures to pass to the templates) as so many of the other engines relied on.
534
+
535
+ I expanded my search outside of Ruby for the best html template technology I could find.
536
+ After reviewing all the front runners I still didn't find anything that quite met with my
537
+ goals for developing with ruby and rails. I also didn't find any technology that was
538
+ close enough that I could adapt it. However I did come across features in a variety of
539
+ systems that inspired me, and helped me shape the ideas that are presented here.
540
+
541
+ After putting much thought into all the possible options I could not see extending
542
+ an existing template engine to meet my needs. And since I wanted this engine to have
543
+ all the power of ruby and rails, it seemed that I would be best served by developing
544
+ a html template syntax that was a thin layer above ERb. That way it would be intuitive
545
+ to use (not having to learn yet another syntax) yet very powerful. Once I was able to
546
+ come up with the desired syntax and approach it became apparent that this would also
547
+ be fairly straightforward to build.
548
+
549
+ I ran the concept by the guys at the St. Louis Ruby Group http://stlruby.org and
550
+ they were excited about the project. With their help I was able to simply some of
551
+ the confusing or complicated areas before beginning development. They also sparked
552
+ some ideas about how to make this infinitely extensible such that developers could
553
+ easily add their own attribute directives. This would give them the power to create
554
+ custom extensions that would encapsulate some of their development work. This would
555
+ serve a couple needs, it would not only make this engine extensible, it would also
556
+ allow this engine to grow easily being composed of small pluggable attribute directives.
557
+ Many thanks to the members of this group, I continue to enjoy discussing the power of
558
+ Ruby and learning from each of them on a monthly basis.
559
+
560
+ While I am on the subject of thanks, I would like to thank my wife and daughter for
561
+ their support as I took time away from them to work on this project and I want to
562
+ thank God for bringing the right people into my life just when I needed them and for
563
+ bringing me on this wonderful journey, I am so very blessed. May I be able to give
564
+ back some of what has been given to me.
565
+
566
+ So that's the story, I hope that many of you will find MasterView to be a useful
567
+ tool for your development. I am continuing to refine MasterView by using it daily for
568
+ Genesis Ministry sites and all my web projects. I know that there is much more work needed
569
+ in documentation, examples, test cases, additional directives, etc., so I would
570
+ appreciate any feedback and ideas that you have. Thanks for taking the time to
571
+ review MasterView!
572
+
573
+ Jeff Barczewski (jeff.barczewski @ gmail.com)
574
+
data/Rakefile ADDED
@@ -0,0 +1,313 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/contrib/rubyforgepublisher'
8
+
9
+ $LOAD_PATH.unshift( File.join( File.dirname(__FILE__), 'lib') )
10
+ require 'masterview'
11
+
12
+ RUBY_FORGE_PROJECT = "masterview"
13
+ RUBY_FORGE_USER = "jeffbski"
14
+ RUBY_FORGE_GROUPID = "1290"
15
+ RUBY_FORGE_PACKAGEID = "1581" #verify this from http://rubyforge.org/frs/admin/?group_id=1290
16
+
17
+ desc "Default Task"
18
+ task :default => [ :test ]
19
+
20
+ desc "Delete tar.gz / zip / rdoc"
21
+ task :cleanup => [ :rm_packages, :clobber_rdoc ]
22
+
23
+ # Run the unit tests
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << "lib"
26
+ t.libs << "test"
27
+ t.pattern = 'test/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+ # Run parser on masterview html files
32
+ desc "Run parser on masterview html files"
33
+ task :mvparse do
34
+ TmpOutputDir = 'tmp/views'
35
+ filelist = Dir.glob('examples/**/*.html')
36
+ filelist.each do |file|
37
+ MasterView::Parser.parse_file( file, TmpOutputDir, :tidy => true )
38
+ end
39
+ end
40
+
41
+
42
+ task :install => [:package] do
43
+ `gem install pkg/#{PKG_FILE_NAME}.gem`
44
+ end
45
+
46
+ task :syntax do
47
+ filelist = Dir.glob('**/*.rb')
48
+ filelist.each do |file|
49
+ output = `ruby -c #{file}`
50
+ unless output =~ /Syntax OK/
51
+ puts "#{file}:"
52
+ puts " #{output}"
53
+ return
54
+ end
55
+ end
56
+ puts 'Syntax OK'
57
+ end
58
+
59
+ # Genereate the RDoc documentation
60
+ Rake::RDocTask.new { |rdoc|
61
+ rdoc.rdoc_dir = 'doc'
62
+ rdoc.title = "MasterView Template Engine"
63
+ rdoc.options << '--line-numbers' << '--inline-source'
64
+ rdoc.rdoc_files.include('README')
65
+ rdoc.rdoc_files.include('lib/**/*.rb')
66
+ }
67
+
68
+ task :lines do
69
+ lines = 0
70
+ codelines = 0
71
+ Dir.foreach("lib") { |file_name|
72
+ next unless file_name =~ /.*rb/
73
+
74
+ f = File.open("lib/" + file_name)
75
+
76
+ while line = f.gets
77
+ lines += 1
78
+ next if line =~ /^\s*$/
79
+ next if line =~ /^\s*#/
80
+ codelines += 1
81
+ end
82
+ }
83
+ puts "Lines #{lines}, LOC #{codelines}"
84
+ end
85
+
86
+
87
+ # Publish beta gem
88
+ #desc "Publish the gem"
89
+ #task :publish => [:rdoc, :package] do
90
+ # Rake::SshFilePublisher.new("foobar.com", "dist/pkg", "pkg", "#{PKG_FILE_NAME}.zip").upload
91
+ # Rake::SshFilePublisher.new("foobar.com", "dist/pkg", "pkg", "#{PKG_FILE_NAME}.tgz").upload
92
+ # Rake::SshFilePublisher.new("foobar.com", "dist/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
93
+ #
94
+ # Rake::SshDirPublisher.new("foobar.com", "dist/api/#{PKG_NAME}", "doc").upload
95
+ #end
96
+
97
+ desc 'Build all packages'
98
+ task :package_all => ['masterview_complete:package',
99
+ 'masterview:package',
100
+ 'masterview_parser:package',
101
+ 'masterview_generator:package',
102
+ 'masterview_gem_plugin_generator:package']
103
+
104
+ desc 'Re-build all packages'
105
+ task :repackage_all => ['masterview_complete:repackage',
106
+ 'masterview:repackage',
107
+ 'masterview_parser:repackage',
108
+ 'masterview_generator:repackage',
109
+ 'masterview_gem_plugin_generator:repackage']
110
+
111
+ namespace 'masterview_complete' do
112
+ module MasterViewComplete
113
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
114
+ PKG_NAME = 'masterview_complete'
115
+ PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD
116
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
117
+ PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
118
+ RELEASE_NAME = "REL #{PKG_VERSION}"
119
+ PKG_FILES = FileList[
120
+ "lib/**/*",
121
+ "generators/**/*",
122
+ "directives/**/*",
123
+ "test/**/*",
124
+ "example/**/*",
125
+ "[A-Z]*",
126
+ "Rakefile",
127
+ "init.rb"
128
+ ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
129
+
130
+ spec = Gem::Specification.new do |s|
131
+ s.name = PKG_NAME
132
+ s.version = PKG_VERSION
133
+ s.summary = "A (x)html friendly template engine for rails with the power of layouts, and partials. This is the plugin version which contains everything."
134
+ s.has_rdoc = true
135
+ s.files = PKG_FILES
136
+ s.require_path = 'lib'
137
+ s.autorequire = 'masterview'
138
+ s.author = "Jeff Barczewski"
139
+ s.email = "jeff.barczewski@gmail.com"
140
+ s.homepage = "http://masterview.org/"
141
+ end
142
+
143
+ # Create Rubygem package
144
+ Rake::GemPackageTask.new(spec) do |p|
145
+ p.gem_spec = spec
146
+ p.need_tar = true
147
+ p.need_zip = true
148
+ end
149
+ end
150
+ end
151
+
152
+ namespace 'masterview' do
153
+ module MasterViewGem
154
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
155
+ PKG_NAME = 'masterview'
156
+ PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD
157
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
158
+ PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
159
+ RELEASE_NAME = "REL #{PKG_VERSION}"
160
+ PKG_FILES = FileList[
161
+ "[A-Z]*",
162
+ ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
163
+
164
+ spec = Gem::Specification.new do |s|
165
+ s.name = PKG_NAME
166
+ s.version = PKG_VERSION
167
+ s.summary = "A (x)html friendly template engine for rails with the power of layouts, and partials. Main gem which requires all others"
168
+ s.has_rdoc = true
169
+ s.files = PKG_FILES
170
+ s.require_path = 'lib'
171
+ #s.autorequire = 'masterview'
172
+ s.add_dependency 'masterview_parser'
173
+ s.add_dependency 'masterview_generator'
174
+ s.add_dependency 'masterview_gem_plugin_generator'
175
+ s.author = "Jeff Barczewski"
176
+ s.email = "jeff.barczewski@gmail.com"
177
+ s.homepage = "http://masterview.org/"
178
+ end
179
+
180
+ # Create Rubygem package
181
+ Rake::GemPackageTask.new(spec) do |p|
182
+ p.gem_spec = spec
183
+ p.need_tar = false
184
+ p.need_zip = false
185
+ end
186
+ end
187
+ end
188
+
189
+ namespace 'masterview_parser' do
190
+ module MasterViewParser
191
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
192
+ PKG_NAME = 'masterview_parser'
193
+ PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD
194
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
195
+ PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
196
+ RELEASE_NAME = "REL #{PKG_VERSION}"
197
+ PKG_FILES = FileList[
198
+ "lib/**/*",
199
+ "directives/**/*",
200
+ "test/**/*",
201
+ "example/**/*",
202
+ "[A-Z]*",
203
+ "Rakefile",
204
+ "init.rb"
205
+ ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
206
+
207
+ spec = Gem::Specification.new do |s|
208
+ s.name = PKG_NAME
209
+ s.version = PKG_VERSION
210
+ s.summary = "A (x)html friendly template engine for rails with the power of layouts, and partials. Parser gem"
211
+ s.has_rdoc = true
212
+ s.files = PKG_FILES
213
+ s.require_path = 'lib'
214
+ s.autorequire = 'masterview'
215
+ s.author = "Jeff Barczewski"
216
+ s.email = "jeff.barczewski@gmail.com"
217
+ s.homepage = "http://masterview.org/"
218
+ end
219
+
220
+ # Create Rubygem package
221
+ Rake::GemPackageTask.new(spec) do |p|
222
+ p.gem_spec = spec
223
+ p.need_tar = false
224
+ p.need_zip = false
225
+ end
226
+ end
227
+ end
228
+
229
+ namespace 'masterview_generator' do
230
+ module MasterViewGenerator
231
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
232
+ PKG_NAME = 'masterview_generator'
233
+ PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD
234
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
235
+ PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
236
+ RELEASE_NAME = "REL #{PKG_VERSION}"
237
+ PKG_FILES = FileList[
238
+ "generators/masterview/**/*",
239
+ "[A-Z]*"
240
+ ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
241
+
242
+ spec = Gem::Specification.new do |s|
243
+ s.name = PKG_NAME
244
+ s.version = PKG_VERSION
245
+ s.summary = "A (x)html friendly template engine for rails with the power of layouts, and partials. MasterView Generator for GEM"
246
+ s.has_rdoc = true
247
+ s.files = PKG_FILES
248
+ s.require_path = 'generators/masterview'
249
+ #s.autorequire = 'masterview_generator'
250
+ s.add_dependency 'masterview_parser'
251
+ s.author = "Jeff Barczewski"
252
+ s.email = "jeff.barczewski@gmail.com"
253
+ s.homepage = "http://masterview.org/"
254
+ end
255
+
256
+ # Create Rubygem package
257
+ Rake::GemPackageTask.new(spec) do |p|
258
+ p.gem_spec = spec
259
+ p.need_tar = false
260
+ p.need_zip = false
261
+ end
262
+ end
263
+ end
264
+
265
+
266
+ namespace 'masterview_gem_plugin_generator' do
267
+ module MasterViewGemPluginGenerator
268
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
269
+ PKG_NAME = 'masterview_gem_plugin_generator'
270
+ PKG_VERSION = MasterView::VERSION::STRING + PKG_BUILD
271
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
272
+ PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
273
+ RELEASE_NAME = "REL #{PKG_VERSION}"
274
+ PKG_FILES = FileList[
275
+ "generators/masterview_gem_plugin/**/*",
276
+ "[A-Z]*"
277
+ ].exclude(/\bCVS\b|~$|\.svn|semantic.cache/)
278
+
279
+ spec = Gem::Specification.new do |s|
280
+ s.name = PKG_NAME
281
+ s.version = PKG_VERSION
282
+ s.summary = "A (x)html friendly template engine for rails with the power of layouts, and partials. MasterView Plugin Generator for GEM"
283
+ s.has_rdoc = true
284
+ s.files = PKG_FILES
285
+ s.require_path = 'generators/masterview_gem_plugin'
286
+ #s.autorequire = 'masterview_gem_plugin_generator'
287
+ s.add_dependency 'masterview_parser'
288
+ s.author = "Jeff Barczewski"
289
+ s.email = "jeff.barczewski@gmail.com"
290
+ s.homepage = "http://masterview.org/"
291
+ end
292
+
293
+ # Create Rubygem package
294
+ Rake::GemPackageTask.new(spec) do |p|
295
+ p.gem_spec = spec
296
+ p.need_tar = false
297
+ p.need_zip = false
298
+ end
299
+ end
300
+ end
301
+
302
+
303
+ # --- Ruby forge release manager by florian gross -------------------------------------------------
304
+ desc "Publish the release files to RubyForge."
305
+ task :release => [:gem, :package] do
306
+ files = ["zip", "tgz"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
307
+
308
+ system("rubyforge login --username #{RUBY_FORGE_USER}")
309
+
310
+ files.each do |file|
311
+ system("rubyforge add_release #{RUBY_FORGE_GROUPID} #{RUBY_FORGE_PACKAGEID} \"#{RELEASE_NAME}\" #{file}")
312
+ end
313
+ end
@@ -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
+
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: masterview_gem_plugin_generator
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.3
7
+ date: 2006-04-18 00:00:00 -05:00
8
+ summary: A (x)html friendly template engine for rails with the power of layouts, and partials. MasterView Plugin Generator for GEM
9
+ require_paths:
10
+ - generators/masterview_gem_plugin
11
+ email: jeff.barczewski@gmail.com
12
+ homepage: http://masterview.org/
13
+ rubyforge_project:
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Jeff Barczewski
30
+ files:
31
+ - generators/masterview_gem_plugin/templates
32
+ - generators/masterview_gem_plugin/masterview_gem_plugin_generator.rb
33
+ - generators/masterview_gem_plugin/templates/init.rb
34
+ - CHANGELOG
35
+ - MIT-LICENSE
36
+ - Rakefile
37
+ - README
38
+ test_files: []
39
+
40
+ rdoc_options: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ requirements: []
49
+
50
+ dependencies:
51
+ - !ruby/object:Gem::Dependency
52
+ name: masterview_parser
53
+ version_requirement:
54
+ version_requirements: !ruby/object:Gem::Version::Requirement
55
+ requirements:
56
+ - - ">"
57
+ - !ruby/object:Gem::Version
58
+ version: 0.0.0
59
+ version: