masterview 0.0.2 → 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.
Files changed (76) hide show
  1. data/CHANGELOG +3 -1
  2. data/Rakefile +201 -37
  3. metadata +23 -85
  4. data/generators/masterview/USAGE +0 -32
  5. data/generators/masterview/masterview_generator.rb +0 -277
  6. data/generators/masterview/templates/controller.rb +0 -50
  7. data/generators/masterview/templates/fields_scaffold.rhtml +0 -1
  8. data/generators/masterview/templates/form_scaffold.rhtml +0 -3
  9. data/generators/masterview/templates/functional_test.rb +0 -83
  10. data/generators/masterview/templates/helper.rb +0 -2
  11. data/generators/masterview/templates/layout.rhtml +0 -11
  12. data/generators/masterview/templates/list_head_scaffold.rhtml +0 -4
  13. data/generators/masterview/templates/list_line_scaffold.rhtml +0 -6
  14. data/generators/masterview/templates/masterview.rhtml +0 -182
  15. data/generators/masterview/templates/mvpreview.js +0 -31
  16. data/generators/masterview/templates/semantic.cache +0 -84
  17. data/generators/masterview/templates/show_scaffold.rhtml +0 -3
  18. data/generators/masterview/templates/style.css +0 -61
  19. data/generators/masterview_gem_plugin/masterview_gem_plugin_generator.rb +0 -21
  20. data/generators/masterview_gem_plugin/templates/init.rb +0 -43
  21. data/init.rb +0 -43
  22. data/lib/masterview/directive_base.rb +0 -163
  23. data/lib/masterview/directive_helpers.rb +0 -176
  24. data/lib/masterview/directives/block.rb +0 -30
  25. data/lib/masterview/directives/content.rb +0 -10
  26. data/lib/masterview/directives/else.rb +0 -25
  27. data/lib/masterview/directives/elsif.rb +0 -26
  28. data/lib/masterview/directives/form.rb +0 -19
  29. data/lib/masterview/directives/global_inline_erb.rb +0 -39
  30. data/lib/masterview/directives/hidden_field.rb +0 -31
  31. data/lib/masterview/directives/if.rb +0 -24
  32. data/lib/masterview/directives/insert_generated_comment.rb +0 -30
  33. data/lib/masterview/directives/javascript_include.rb +0 -15
  34. data/lib/masterview/directives/link_to.rb +0 -17
  35. data/lib/masterview/directives/link_to_if.rb +0 -21
  36. data/lib/masterview/directives/link_to_remote.rb +0 -17
  37. data/lib/masterview/directives/password_field.rb +0 -33
  38. data/lib/masterview/directives/preview.rb +0 -10
  39. data/lib/masterview/directives/replace.rb +0 -18
  40. data/lib/masterview/directives/stylesheet_link.rb +0 -14
  41. data/lib/masterview/directives/submit.rb +0 -14
  42. data/lib/masterview/directives/testfilter.rb +0 -55
  43. data/lib/masterview/directives/text_area.rb +0 -34
  44. data/lib/masterview/directives/text_field.rb +0 -33
  45. data/lib/masterview/extras/rails_init.rb +0 -67
  46. data/lib/masterview/extras/watcher.rb +0 -30
  47. data/lib/masterview/masterview_version.rb +0 -9
  48. data/lib/masterview/parser.rb +0 -585
  49. data/lib/masterview/plugin_load_tracking.rb +0 -41
  50. data/lib/masterview/runtime_helpers.rb +0 -9
  51. data/lib/masterview/string_extensions.rb +0 -15
  52. data/lib/masterview.rb +0 -130
  53. data/test/block_test.rb +0 -47
  54. data/test/content_test.rb +0 -26
  55. data/test/else_test.rb +0 -31
  56. data/test/elsif_test.rb +0 -31
  57. data/test/example_test.rb +0 -11
  58. data/test/filter_helpers_test.rb +0 -142
  59. data/test/form_test.rb +0 -66
  60. data/test/global_inline_erb_test.rb +0 -30
  61. data/test/hidden_field_test.rb +0 -62
  62. data/test/if_test.rb +0 -23
  63. data/test/javascript_include_test.rb +0 -26
  64. data/test/link_to_if_test.rb +0 -27
  65. data/test/link_to_test.rb +0 -52
  66. data/test/parser_test.rb +0 -166
  67. data/test/password_field_test.rb +0 -89
  68. data/test/replace_test.rb +0 -27
  69. data/test/run_parser_test.rb +0 -27
  70. data/test/stylesheet_link_test.rb +0 -26
  71. data/test/submit_test.rb +0 -54
  72. data/test/template_file_watcher_test.rb +0 -50
  73. data/test/template_test.rb +0 -181
  74. data/test/test_helper.rb +0 -24
  75. data/test/text_area_test.rb +0 -81
  76. data/test/text_field_test.rb +0 -89
@@ -1,26 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- #outputs an elsif/end block around the text tags and remove previous end (from if)
5
- class Elsif < MasterView::DirectiveBase
6
- def priority
7
- DirectivePriorities::High
8
- end
9
-
10
- def stag(directive_call_stack)
11
- tag = @directive_call_stack.context[:tag]
12
- delete_last_in_parent(tag, erb('end') )
13
- ret = []
14
- ret << erb('elsif '+attr_value)
15
- ret << directive_call_stack.render
16
- end
17
-
18
- def etag(directive_call_stack)
19
- ret = []
20
- ret << directive_call_stack.render
21
- ret << erb('end')
22
- end
23
-
24
- end
25
- end
26
- end
@@ -1,19 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- # creates start_form_tag and end_form_tag from values in form
5
- class Form < MasterView::DirectiveBase
6
- def stag(directive_call_stack)
7
- options = {}
8
- options[:multipart] = true if attr_lckv_matches('enctype', 'multipart/form-data')
9
- options[:method] = 'get' if attr_lckv_matches('method', 'get')
10
- merge_hash_attr_value!(1, options)
11
- erb_content('form_tag ' + attr_value)
12
- end
13
-
14
- def etag(directive_call_stack)
15
- erb_content('end_form_tag')
16
- end
17
- end
18
- end
19
- end
@@ -1,39 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- #outputs a block around the text tags, if left bracket count is higher than right
5
- #assume that the end is a right bracket otherwise use end
6
- class Global_inline_erb < MasterView::DirectiveBase
7
- def initialize(attribute_value = nil)
8
- super(attribute_value)
9
- end
10
-
11
- def priority
12
- DirectivePriorities::Low
13
- end
14
-
15
- def global_directive?
16
- true
17
- end
18
-
19
- def stag(dcs)
20
- attrs.each do |key, value|
21
- replace_with_erb!( value )
22
- end
23
- dcs.render
24
- end
25
-
26
- def characters(dcs)
27
- replace_with_erb!( data )
28
- dcs.render
29
- end
30
-
31
- private
32
-
33
- def replace_with_erb!(value)
34
- subs = value.gsub!( MasterView::InlineErbSubstitutionRegex, '<%\1%>' )
35
- end
36
-
37
- end
38
- end
39
- end
@@ -1,31 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class Hidden_field < MasterView::DirectiveBase
5
- def stag(dcs)
6
- #eat
7
- end
8
-
9
- def etag(dcs)
10
- args = parse_attr_value
11
- obj = args[0]
12
- method = args[1]
13
-
14
- obj = quote(obj) unless obj =~ /^:|'|"/
15
- method = quote(method) unless method =~ /^:|'|"/
16
-
17
- options = {}
18
- options.merge! common_html_options(attrs_lck)
19
- remove_strings_from_attr_value!
20
- merge_hash_attr_value!(0, options)
21
-
22
- a = []
23
- a << 'hidden_field '+ obj
24
- a << method
25
- a << attr_value unless attr_value.strip.empty?
26
- erb_content(a.join(', '))
27
- end
28
-
29
- end
30
- end
31
- end
@@ -1,24 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- #outputs an if/end block around the text tags
5
- class If < MasterView::DirectiveBase
6
- def priority
7
- DirectivePriorities::High
8
- end
9
-
10
- def stag(directive_call_stack)
11
- ret = []
12
- ret << erb('if '+attr_value)
13
- ret << directive_call_stack.render
14
- end
15
-
16
- def etag(directive_call_stack)
17
- ret = []
18
- ret << directive_call_stack.render
19
- ret << erb('end')
20
- end
21
-
22
- end
23
- end
24
- end
@@ -1,30 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- # Inserts a comment into the file that indicates that this file was generated
5
- # and should not be edited, else changes could be lost. It includes the path to
6
- # the original file that should be edited instead
7
- class Insert_generated_comment < MasterView::DirectiveBase
8
- Generated_comment_text = <<-END
9
- # WARNING - This file was generated by MasterView plugin.
10
- # Do not edit this file otherwise you may lose your changes
11
- # when this file is re-generated.
12
- #
13
- # To make changes edit the MasterView file which is located at:
14
- END
15
-
16
- def priority
17
- DirectivePriorities::Lowest
18
- end
19
-
20
- def stag(directive_call_stack)
21
- comment = "\n<% \n" + Generated_comment_text + "# "+ attr_value + "\n%>"
22
-
23
- ret = []
24
- ret << directive_call_stack.render
25
- ret << comment
26
- end
27
-
28
- end
29
- end
30
- end
@@ -1,15 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- #creates a link_to
5
- class Javascript_include < MasterView::DirectiveBase
6
- def stag(dcs)
7
- end
8
-
9
- def etag(dcs)
10
- val = attr_value.starts_with?(':') ? attr_value : quote(attr_value)
11
- erb_content('javascript_include_tag ' + val)
12
- end
13
- end
14
- end
15
- end
@@ -1,17 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- #creates a link_to
5
- class Link_to < MasterView::DirectiveBase
6
- def stag(dcs)
7
- end
8
-
9
- def etag(dcs)
10
- remove_strings_from_attr_value!
11
- prepend_to_attr_value! quote( content_str ) #prepend quoted link name
12
- self.content=''
13
- erb_content('link_to ' + attr_value)
14
- end
15
- end
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class Link_to_if < MasterView::DirectiveBase
5
- def stag(dcs)
6
- end
7
-
8
- def etag(dcs)
9
- args = parse_attr_value
10
- condition = args[0]
11
- remove_strings_from_attr_value!
12
- a = []
13
- a << 'link_to_if '+condition
14
- a << quote(content_str)
15
- a << attr_value unless attr_value.strip.empty?
16
- self.content=''
17
- erb_content(a.join(', '))
18
- end
19
- end
20
- end
21
- end
@@ -1,17 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- #creates a link_to_remote
5
- class Link_to_remote < MasterView::DirectiveBase
6
- def stag(dcs)
7
- end
8
-
9
- def etag(dcs)
10
- remove_strings_from_attr_value!
11
- prepend_to_attr_value! quote( content_str ) #prepend quoted link name
12
- self.content=''
13
- erb_content('link_to_remote ' + attr_value)
14
- end
15
- end
16
- end
17
- end
@@ -1,33 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class Password_field < MasterView::DirectiveBase
5
- def stag(dcs)
6
- #eat
7
- end
8
-
9
- def etag(dcs)
10
- args = parse_attr_value
11
- obj = args[0]
12
- method = args[1]
13
-
14
- obj = quote(obj) unless obj =~ /^:|'|"/
15
- method = quote(method) unless method =~ /^:|'|"/
16
-
17
- options = {}
18
- options[:size] = attrs_lck['size'].to_i if attrs_lck['size']
19
- options[:maxlength] = attrs_lck['maxlength'].to_i if attrs_lck['maxlength']
20
- options.merge! common_html_options(attrs_lck)
21
- remove_strings_from_attr_value!
22
- merge_hash_attr_value!(0, options)
23
-
24
- a = []
25
- a << 'password_field '+ obj
26
- a << method
27
- a << attr_value unless attr_value.strip.empty?
28
- erb_content(a.join(', '))
29
- end
30
-
31
- end
32
- end
33
- end
@@ -1,10 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class Preview
5
- def initialize(attribute_value)
6
- @attribute_value = attribute_value
7
- end
8
- end
9
- end
10
- end
@@ -1,18 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class Replace < MasterView::DirectiveBase
5
- def priority
6
- DirectivePriorities::MediumLow
7
- end
8
-
9
- def stag(directive_call_stack)
10
- end
11
-
12
- def etag(directive_call_stack)
13
- self.content=''
14
- erb_content(attr_value) unless attr_value.blank?
15
- end
16
- end
17
- end
18
- end
@@ -1,14 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- #creates a link_to
5
- class Stylesheet_link < MasterView::DirectiveBase
6
- def stag(dcs)
7
- end
8
-
9
- def etag(dcs)
10
- erb_content('stylesheet_link_tag ' + quote(attr_value))
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class Submit < MasterView::DirectiveBase
5
- def stag(directive_call_stack); end
6
-
7
- def etag(directive_call_stack)
8
- remove_strings_from_attr_value!
9
- prepend_to_attr_value! quote( attrs_lck['value'] ) #prepend quoted submit button name
10
- erb_content('submit_tag ' + attr_value)
11
- end
12
- end
13
- end
14
- end
@@ -1,55 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class TestDirective < MasterView::DirectiveBase
5
- def priority
6
- DirectivePriorities::Low
7
- end
8
-
9
- def stag(dcs)
10
- ret = []
11
- ret << 'stag'
12
- ret << dcs.render
13
- ret << 'stagend'
14
- end
15
-
16
- def characters(dcs)
17
- ret = []
18
- ret << 'char'
19
- ret << dcs.render
20
- end
21
-
22
- def comment(dcs)
23
- ret = []
24
- ret << 'com'
25
- ret << dcs.render
26
- end
27
-
28
- def cdata(dcs)
29
- ret = []
30
- ret << 'cdata'
31
- ret << dcs.render
32
- end
33
-
34
- def etag(dcs)
35
- ret = []
36
- ret << 'etag'
37
- ret << dcs.render
38
- ret << 'etagend'
39
- end
40
-
41
- def child_title_stag(dcs)
42
- ret = []
43
- ret << 'desctitle'
44
- ret << dcs.render
45
- end
46
-
47
- def child_title_etag(dcs)
48
- dcs.context[:tag].content = @attribute_value
49
- ret = []
50
- ret << dcs.render
51
- end
52
-
53
- end
54
- end
55
- end
@@ -1,34 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class Text_area < MasterView::DirectiveBase
5
- def stag(dcs)
6
- #eat
7
- end
8
-
9
- def etag(dcs)
10
- args = parse_attr_value
11
- obj = args[0]
12
- method = args[1]
13
-
14
- obj = quote(obj) unless obj =~ /^:|'|"/
15
- method = quote(method) unless method =~ /^:|'|"/
16
-
17
- options = {}
18
- options[:rows] = attrs_lck['rows'].to_i if attrs_lck['rows']
19
- options[:cols] = attrs_lck['cols'].to_i if attrs_lck['cols']
20
- options.merge! common_html_options(attrs_lck)
21
- remove_strings_from_attr_value!
22
- merge_hash_attr_value!(0, options)
23
-
24
- a = []
25
- a << 'text_area '+ obj
26
- a << method
27
- a << attr_value unless attr_value.strip.empty?
28
- self.content=''
29
- erb_content(a.join(', '))
30
- end
31
-
32
- end
33
- end
34
- end
@@ -1,33 +0,0 @@
1
- module MasterView
2
- module Directives
3
-
4
- class Text_field < MasterView::DirectiveBase
5
- def stag(dcs)
6
- #eat
7
- end
8
-
9
- def etag(dcs)
10
- args = parse_attr_value
11
- obj = args[0]
12
- method = args[1]
13
-
14
- obj = quote(obj) unless obj =~ /^:|'|"/
15
- method = quote(method) unless method =~ /^:|'|"/
16
-
17
- options = {}
18
- options[:size] = attrs_lck['size'].to_i if attrs_lck['size']
19
- options[:maxlength] = attrs_lck['maxlength'].to_i if attrs_lck['maxlength']
20
- options.merge! common_html_options(attrs_lck)
21
- remove_strings_from_attr_value!
22
- merge_hash_attr_value!(0, options)
23
-
24
- a = []
25
- a << 'text_field '+ obj
26
- a << method
27
- a << attr_value unless attr_value.strip.empty?
28
- erb_content(a.join(', '))
29
- end
30
-
31
- end
32
- end
33
- end
@@ -1,67 +0,0 @@
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
- # setup hook so that masterview output files are always current
34
- # always checks mtimes before each call when perform_caching is off (development)
35
- # otherwise only checks the first time system is hit
36
- require 'masterview'
37
- require 'masterview/extras/watcher'
38
-
39
- # only run if auto parsing and when launching server, check if need to update mv files
40
- if MasterView::AutoParseMasterViewFiles && $PROGRAM_NAME =~ /server|dispatch/
41
- mvtemplate_src_root = File.join( ActionController::Base.template_root, MasterView::TemplateSrcRelativePath)
42
- mvtemplate_dst_root = File.join( ActionController::Base.template_root, MasterView::TemplateDestRelativePath)
43
- MasterView::TemplateFileWatcher.check(mvtemplate_src_root, MasterView::TemplateFilenamePattern, true) do |f|
44
- MasterView::Parser.parse_file( f, mvtemplate_dst_root)
45
- end
46
- end
47
-
48
-
49
- if MasterView::AutoParseMasterViewFiles
50
- # if not caching then check for masterview updates on every request
51
- unless ActionController::Base.perform_caching
52
- module ::ActionController
53
- class Base
54
- alias :process_orig :process
55
- def process(request, response, method = :perform_action, *arguments)
56
- mvtemplate_src_root = File.join(self.class.view_root, MasterView::TemplateSrcRelativePath)
57
- mvtemplate_dst_root = File.join(self.class.view_root, MasterView::TemplateDestRelativePath)
58
- MasterView::TemplateFileWatcher.check(mvtemplate_src_root, MasterView::TemplateFilenamePattern, true) do |f|
59
- MasterView::Parser.parse_file( f, mvtemplate_dst_root )
60
- end
61
- process_orig(request, response, method, *arguments)
62
- end
63
- end
64
- end
65
- end
66
- end
67
-
@@ -1,30 +0,0 @@
1
- module MasterView
2
- class TemplateFileWatcher
3
- # Check path for filenames matching filename_pattern and if found
4
- # exec block passing in the full path name.
5
- # filename_pattern is a wildcard pattern similar to those used in shells
6
- # If check_subdirectories is true then the system will recurse into
7
- # subdirectories looking for filename matches as well.
8
- # returns an array of files that were modified and the block was run for
9
- def self.check(path, filename_pattern, check_subdirectories, &block)
10
- files_run = []
11
- return unless File.exist?(path)
12
- Dir.new(path).each do |f|
13
- full_name = File.join(path, f)
14
- if File.directory? full_name
15
- self.check(full_name, filename_pattern, check_subdirectories, &block) if check_subdirectories && !f.starts_with?('.')
16
- elsif File.fnmatch?(filename_pattern, f)
17
- mtime = File.mtime(full_name)
18
- @@file_mtimes ||= {}
19
- unless @@file_mtimes[full_name] == mtime
20
- yield full_name
21
- @@file_mtimes[full_name] = File.mtime(full_name)
22
- files_run << full_name
23
- end
24
- end
25
- end
26
- files_run
27
- end
28
- end
29
- end
30
-
@@ -1,9 +0,0 @@
1
- module MasterView
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 0
5
- TINY = 2
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end