masterview 0.0.6 → 0.0.7

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 (66) hide show
  1. data/Rakefile +8 -5
  2. data/init.rb +43 -0
  3. data/lib/facets/AUTHORS +36 -0
  4. data/lib/facets/CHANGELOG +266 -0
  5. data/lib/facets/COPYING +403 -0
  6. data/lib/facets/ProjectInfo +74 -0
  7. data/lib/facets/README +252 -0
  8. data/lib/facets/core/string/blank.rb +36 -0
  9. data/lib/facets/core/string/indent.rb +68 -0
  10. data/lib/facets/core/string/starts_with.rb +24 -0
  11. data/lib/masterview/directive_base.rb +163 -0
  12. data/lib/masterview/directive_helpers.rb +176 -0
  13. data/lib/masterview/directives/block.rb +30 -0
  14. data/lib/masterview/directives/content.rb +10 -0
  15. data/lib/masterview/directives/else.rb +25 -0
  16. data/lib/masterview/directives/elsif.rb +26 -0
  17. data/lib/masterview/directives/form.rb +19 -0
  18. data/lib/masterview/directives/global_inline_erb.rb +39 -0
  19. data/lib/masterview/directives/hidden_field.rb +31 -0
  20. data/lib/masterview/directives/if.rb +24 -0
  21. data/lib/masterview/directives/insert_generated_comment.rb +30 -0
  22. data/lib/masterview/directives/javascript_include.rb +15 -0
  23. data/lib/masterview/directives/link_to.rb +17 -0
  24. data/lib/masterview/directives/link_to_if.rb +21 -0
  25. data/lib/masterview/directives/link_to_remote.rb +17 -0
  26. data/lib/masterview/directives/password_field.rb +33 -0
  27. data/lib/masterview/directives/preview.rb +10 -0
  28. data/lib/masterview/directives/replace.rb +18 -0
  29. data/lib/masterview/directives/stylesheet_link.rb +14 -0
  30. data/lib/masterview/directives/submit.rb +14 -0
  31. data/lib/masterview/directives/testfilter.rb +55 -0
  32. data/lib/masterview/directives/text_area.rb +34 -0
  33. data/lib/masterview/directives/text_field.rb +33 -0
  34. data/lib/masterview/extras/rails_init.rb +67 -0
  35. data/lib/masterview/extras/watcher.rb +30 -0
  36. data/lib/masterview/masterview_version.rb +9 -0
  37. data/lib/masterview/parser.rb +585 -0
  38. data/lib/masterview/plugin_load_tracking.rb +41 -0
  39. data/lib/masterview/runtime_helpers.rb +9 -0
  40. data/lib/masterview/string_extensions.rb +15 -0
  41. data/lib/masterview.rb +129 -0
  42. data/test/block_test.rb +47 -0
  43. data/test/content_test.rb +26 -0
  44. data/test/else_test.rb +31 -0
  45. data/test/elsif_test.rb +31 -0
  46. data/test/example_test.rb +11 -0
  47. data/test/filter_helpers_test.rb +142 -0
  48. data/test/form_test.rb +66 -0
  49. data/test/global_inline_erb_test.rb +30 -0
  50. data/test/hidden_field_test.rb +62 -0
  51. data/test/if_test.rb +23 -0
  52. data/test/javascript_include_test.rb +26 -0
  53. data/test/link_to_if_test.rb +27 -0
  54. data/test/link_to_test.rb +52 -0
  55. data/test/parser_test.rb +166 -0
  56. data/test/password_field_test.rb +89 -0
  57. data/test/replace_test.rb +27 -0
  58. data/test/run_parser_test.rb +27 -0
  59. data/test/stylesheet_link_test.rb +26 -0
  60. data/test/submit_test.rb +54 -0
  61. data/test/template_file_watcher_test.rb +50 -0
  62. data/test/template_test.rb +181 -0
  63. data/test/test_helper.rb +24 -0
  64. data/test/text_area_test.rb +81 -0
  65. data/test/text_field_test.rb +89 -0
  66. metadata +71 -11
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,67 @@
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
+
@@ -0,0 +1,30 @@
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
+
@@ -0,0 +1,9 @@
1
+ module MasterView
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 7
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end