masterview 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. data/CHANGELOG +31 -1
  2. data/README +70 -69
  3. data/RELEASE_NOTES +70 -64
  4. data/Rakefile +26 -27
  5. data/TODO +13 -29
  6. data/doc/about.html +246 -0
  7. data/doc/configuration.html +49 -36
  8. data/doc/developer.html +423 -41
  9. data/doc/directives.html +139 -51
  10. data/doc/guide.html +19 -9
  11. data/doc/index.html +90 -224
  12. data/doc/installation.html +36 -28
  13. data/doc/media_list.html +30 -20
  14. data/doc/simple_diagram.html +3 -5
  15. data/doc/stylesheets/masterview.css +16 -1
  16. data/examples/rails_app_config/masterview/settings.rb +2 -1
  17. data/init.rb +1 -1
  18. data/lib/#ChangeLog# +6 -0
  19. data/lib/masterview/analyzer.rb +48 -34
  20. data/lib/masterview/attr_string_parser.rb +5 -1
  21. data/lib/masterview/case_insensitive_hash.rb +69 -0
  22. data/lib/masterview/{pathname_extensions.rb → core_ext/pathname.rb} +0 -0
  23. data/lib/masterview/{string_extensions.rb → core_ext/string.rb} +0 -0
  24. data/lib/masterview/deprecated/directive_base.rb +362 -0
  25. data/lib/masterview/directive_base.rb +201 -179
  26. data/lib/masterview/directive_dsl.rb +457 -0
  27. data/lib/masterview/directive_helpers.rb +28 -141
  28. data/lib/masterview/directive_load_path.rb +388 -0
  29. data/lib/masterview/directive_metadata.rb +377 -0
  30. data/lib/masterview/directive_registry.rb +259 -69
  31. data/lib/masterview/directives/.metadata +16 -0
  32. data/lib/masterview/directives/attr.rb +9 -8
  33. data/lib/masterview/directives/block.rb +11 -14
  34. data/lib/masterview/directives/check_box.rb +13 -18
  35. data/lib/masterview/directives/collection_select.rb +15 -29
  36. data/lib/masterview/directives/content.rb +9 -3
  37. data/lib/masterview/directives/else.rb +15 -13
  38. data/lib/masterview/directives/elsif.rb +14 -13
  39. data/lib/masterview/directives/eval.rb +20 -0
  40. data/lib/masterview/directives/form.rb +56 -9
  41. data/lib/masterview/directives/form_remote.rb +26 -0
  42. data/lib/masterview/directives/global_inline_erb.rb +10 -14
  43. data/lib/masterview/directives/hidden_field.rb +11 -20
  44. data/lib/masterview/directives/if.rb +13 -12
  45. data/lib/masterview/directives/image_tag.rb +20 -28
  46. data/lib/masterview/directives/import.rb +5 -12
  47. data/lib/masterview/directives/import_render.rb +7 -19
  48. data/lib/masterview/directives/insert_generated_comment.rb +8 -11
  49. data/lib/masterview/directives/javascript_include.rb +21 -12
  50. data/lib/masterview/directives/link_to.rb +14 -8
  51. data/lib/masterview/directives/link_to_function.rb +22 -0
  52. data/lib/masterview/directives/link_to_if.rb +15 -13
  53. data/lib/masterview/directives/link_to_remote.rb +13 -8
  54. data/lib/masterview/directives/omit_tag.rb +32 -16
  55. data/lib/masterview/directives/password_field.rb +10 -22
  56. data/lib/masterview/directives/radio_button.rb +11 -22
  57. data/lib/masterview/directives/replace.rb +7 -8
  58. data/lib/masterview/directives/select.rb +11 -24
  59. data/lib/masterview/directives/stylesheet_link.rb +20 -12
  60. data/lib/masterview/directives/submit.rb +11 -5
  61. data/lib/masterview/directives/text_area.rb +10 -23
  62. data/lib/masterview/directives/text_field.rb +10 -22
  63. data/lib/masterview/exceptions.rb +21 -0
  64. data/lib/masterview/extras/app/controllers/masterview_controller.rb +102 -75
  65. data/lib/masterview/extras/app/views/layouts/masterview_admin.rhtml +24 -23
  66. data/lib/masterview/extras/app/views/layouts/masterview_admin_config.rhtml +81 -0
  67. data/lib/masterview/extras/app/views/masterview/admin/configuration.rhtml +5 -1
  68. data/lib/masterview/extras/app/views/masterview/admin/create.rhtml +2 -2
  69. data/lib/masterview/extras/app/views/masterview/admin/directives.rhtml +5 -0
  70. data/lib/masterview/extras/app/views/masterview/admin/features.rhtml +5 -79
  71. data/lib/masterview/extras/app/views/masterview/admin/interact.rhtml +5 -0
  72. data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +3 -71
  73. data/lib/masterview/extras/init_mv_admin_pages.rb +42 -23
  74. data/lib/masterview/filter_helpers.rb +26 -0
  75. data/lib/masterview/initializer.rb +99 -53
  76. data/lib/masterview/io.rb +19 -15
  77. data/lib/masterview/keyword_expander.rb +7 -2
  78. data/lib/masterview/masterview_info.rb +229 -23
  79. data/lib/masterview/masterview_version.rb +2 -2
  80. data/lib/masterview/parser.rb +275 -105
  81. data/lib/masterview/parser_helpers.rb +54 -0
  82. data/lib/masterview/rails_ext/action_controller_erb_direct.rb +29 -0
  83. data/lib/masterview/rails_ext/action_controller_reparse_checking.rb +27 -0
  84. data/lib/masterview/{extras/init_rails_erb_mv_direct.rb → rails_ext/action_view_erb_direct.rb} +12 -59
  85. data/lib/masterview/template_spec.rb +3 -2
  86. data/lib/masterview.rb +21 -12
  87. data/lib/rexml/parsers/baseparser_with_doctype_fix.rb +473 -0
  88. data/lib/rexml/parsers/sax2parser_with_doctype_fix.rb +243 -0
  89. data/test/directive_test_helper.rb +135 -0
  90. data/test/fixtures/directives/id_check.rb +18 -0
  91. data/test/fixtures/directives/test_directive_events.rb +70 -0
  92. data/test/test_helper.rb +18 -5
  93. data/test/tmp/views/layouts/product.rhtml +10 -10
  94. data/test/tmp/views/product/_form.rhtml +4 -4
  95. data/test/tmp/views/product/_product.rhtml +3 -3
  96. data/test/tmp/views/product/destroy.rhtml +5 -5
  97. data/test/tmp/views/product/edit.rhtml +4 -4
  98. data/test/tmp/views/product/list.rhtml +3 -3
  99. data/test/tmp/views/product/new.rhtml +4 -4
  100. data/test/tmp/views/product/show.rhtml +2 -2
  101. data/test/unit/attr_string_parser_test.rb +105 -0
  102. data/test/unit/case_insensitive_hash_mod_test.rb +104 -0
  103. data/test/unit/config_settings_test.rb +13 -1
  104. data/test/unit/default_generate_mio_filter_test.rb +3 -3
  105. data/test/unit/deprecated_directive_base_test.rb +30 -0
  106. data/test/unit/directive_attr_test.rb +111 -35
  107. data/test/unit/directive_base_test.rb +520 -1
  108. data/test/unit/directive_block_test.rb +30 -22
  109. data/test/unit/directive_content_test.rb +24 -11
  110. data/test/unit/directive_else_test.rb +18 -15
  111. data/test/unit/directive_elsif_test.rb +17 -15
  112. data/test/unit/directive_form_remote_test.rb +59 -0
  113. data/test/unit/directive_form_test.rb +31 -39
  114. data/test/unit/directive_global_inline_erb_test.rb +28 -17
  115. data/test/unit/directive_grid_test_notready.rb +38 -0
  116. data/test/unit/directive_helpers_test.rb +39 -0
  117. data/test/unit/directive_hidden_field_test.rb +44 -29
  118. data/test/unit/directive_if_test.rb +10 -7
  119. data/test/unit/directive_image_tag_test.rb +69 -61
  120. data/test/unit/directive_import_render_test.rb +28 -38
  121. data/test/unit/directive_import_test.rb +16 -14
  122. data/test/unit/directive_insert_generated_comment_test.rb +32 -0
  123. data/test/unit/directive_javascript_include_test.rb +40 -43
  124. data/test/unit/directive_link_to_function_test.rb +40 -0
  125. data/test/unit/directive_link_to_if_test.rb +52 -12
  126. data/test/unit/directive_link_to_remote_test.rb +58 -0
  127. data/test/unit/directive_link_to_test.rb +46 -31
  128. data/test/unit/directive_load_path_test.rb +257 -0
  129. data/test/unit/directive_metadata_test.rb +313 -0
  130. data/test/unit/directive_omit_tag_test.rb +73 -21
  131. data/test/unit/directive_password_field_test.rb +44 -38
  132. data/test/unit/directive_registry_test.rb +44 -0
  133. data/test/unit/directive_replace_test.rb +28 -12
  134. data/test/unit/directive_stylesheet_link_test.rb +43 -36
  135. data/test/unit/directive_submit_test.rb +29 -30
  136. data/test/unit/directive_text_area_test.rb +40 -36
  137. data/test/unit/directive_text_field_test.rb +44 -38
  138. data/test/unit/example_directive_child_events_test.rb +41 -0
  139. data/test/unit/example_test.rb +31 -4
  140. data/test/unit/file_mio_test.rb +18 -13
  141. data/test/unit/filter_helpers_test.rb +10 -8
  142. data/test/unit/find_directive_parent_test.rb +174 -0
  143. data/test/unit/keyword_expander_test.rb +4 -2
  144. data/test/unit/mio_test.rb +18 -11
  145. data/test/unit/mtime_string_hash_mio_tree_test.rb +5 -1
  146. data/test/unit/parser_test.rb +41 -29
  147. data/test/unit/pathname_extensions_test.rb +1 -1
  148. data/test/unit/run_parser_test.rb +2 -2
  149. data/test/unit/simplified_directive_base_test.rb +256 -0
  150. data/test/unit/string_hash_mio_test.rb +5 -1
  151. data/test/unit/template_file_watcher_test.rb +2 -2
  152. data/test/unit/template_test.rb +221 -46
  153. metadata +86 -45
  154. data/lib/masterview/directives/testfilter.rb +0 -55
  155. data/lib/masterview/extras/init_rails_reparse_checking.rb +0 -62
@@ -29,6 +29,55 @@
29
29
  #++
30
30
 
31
31
  module MasterView
32
+
33
+ module ConfigInfoHelpers #:nodoc:
34
+
35
+ # HTML fragment templates; optionally include class/style attributes to control rendering
36
+ DEFAULT_RENDERING_OPTIONS = {
37
+ :title => '<h1>%s</h1>', #parms: config settings title
38
+ :preamble => '<p><b>MasterView Version:</b> %s</p>', #parms: MasterView version
39
+ :container => "<table%s>\n<tbody>%s</tbody>\n</table>", #parms: :container_attrs, section/property entries
40
+ :container_attrs => '',
41
+ :section_entry => '<tr%s><td colspan="2">%s</td></tr>', #parms: :section_attrs, section_name
42
+ :section_attrs => 'style="background-color: #dcdcdc; font-weight: bold; margin-top: 6px;"',
43
+ :option_entry => '<tr><td%s>%s</td><td%s>%s</td></tr>', #parms: :option_name_attrs, option_name, :option_value_attrs, option_value
44
+ :option_name_attrs => 'style="padding-left: 6px; padding-right: 6px; font-weight: bold;"',
45
+ :option_value_attrs => '',
46
+ :postscript => '',
47
+ }
48
+
49
+ ELEMENTS_WITH_ATTRS = [ :container, :section_entry ]
50
+
51
+ # get the option parameter value; provide default in not specified in client params.
52
+ def self.getOption(option_name, params, defaults=DEFAULT_RENDERING_OPTIONS)
53
+ params.fetch( option_name, defaults[option_name] )
54
+ end
55
+
56
+ # Get the option parameter value for an html element; provide default in not specified in client params.
57
+ # Resolve any element attributes so rendering can focus on filling in content entries
58
+ def self.getHtmlTemplate(element_option_name, params, defaults=DEFAULT_RENDERING_OPTIONS)
59
+ element_template = getOption( element_option_name, params, defaults )
60
+ return element_template if element_template == :none
61
+ if ELEMENTS_WITH_ATTRS.include? element_option_name
62
+ attrs_option_name = "#{element_option_name.to_s.split('_')[0]}_attrs".to_sym # :foo_attrs
63
+ element_attrs = getOption( attrs_option_name, params, defaults )
64
+ # ensure separator space for ' style="xxx"' on the section entry style/class attr(s)
65
+ element_attrs.insert(0, ' ') if (element_attrs && element_attrs != '' && element_attrs[0...1] != ' ')
66
+ element_template = element_template.sub( '%s', element_attrs ) # resolve the first parm slot in the template to the attrs
67
+ elsif element_option_name == :option_entry
68
+ # double-up: attrs/value template parm pair for both option_name and option_value
69
+ option_entry_name_attrs = getOption( :option_name_attrs, params, defaults )
70
+ option_entry_value_attrs = getOption( :option_value_attrs, params, defaults )
71
+ # ensure separator space for ' style="xxx"' on the option name/value style/class attr(s)
72
+ option_entry_name_attrs.insert(0, ' ') if (option_entry_name_attrs && option_entry_name_attrs != '' && option_entry_name_attrs[0...1] != ' ')
73
+ option_entry_value_attrs.insert(0, ' ') if (option_entry_value_attrs && option_entry_value_attrs != '' && option_entry_value_attrs[0...1] != ' ')
74
+ element_template = element_template % [ option_entry_name_attrs, '%s', option_entry_value_attrs, '%s' ] # install the optional style settings once, just plug in option name/value hereafter
75
+ end
76
+ element_template
77
+ end
78
+
79
+ end
80
+
32
81
  module Info #:nodoc:
33
82
 
34
83
  PROP_CATEGORY_ROOTS = 'MasterView Roots'
@@ -43,50 +92,48 @@ module MasterView
43
92
  [ PROP_CATEGORY_ROOTS,
44
93
  [ :mv_installation_dir, :rails_app?, :on_rails? ] ],
45
94
  [ PROP_CATEGORY_GENERAL_OPTIONS,
46
- [ :root_path, :config_dir_path, :environment ] ], #:directive_paths
95
+ [ :root_path, :config_dir_path, :environment ] ], #:directive_load_path
47
96
  [ PROP_CATEGORY_TEMPLATE_SRC_OPTIONS,
48
97
  [ :template_src_dir_path, :template_filename_pattern ] ],
49
98
  [ PROP_CATEGORY_TEMPLATE_GEN_OPTIONS,
50
99
  [ :template_dst_dir_path, :output_filename_extension, :generated_file_default_extension, :include_generated_file_comment ] ],
51
100
  [ PROP_CATEGORY_TEMPLATE_PARSE_OPTIONS,
52
- [ :default_parser_options, :namespace_prefix ] ],
101
+ [ :default_parser_options, :namespace_prefix, :namespace_prefix_extensions ] ],
53
102
  [ PROP_CATEGORY_RAILS_APP_OPTIONS,
54
103
  [ :parse_masterview_templates_at_startup, :reparse_changed_masterview_templates, :generate_rhtml_files ] ]
55
104
  ]
56
105
 
57
106
  PROPERTY_CATEGORIES = CATEGORIZED_PROPERTY_SPECS.collect { | catEntry | catEntry[0] }
58
107
 
108
+ def self.getHtmlTemplate(element_option_name, params)
109
+ ConfigInfoHelpers.getHtmlTemplate( element_option_name, params )#, defaults=ConfigInfoHelpers.::DEFAULT_RENDERING_OPTIONS
110
+ end
59
111
 
60
- # Answer an html rendering
112
+ # Answer an html rendering of the Configuration
113
+ # Optionally provide HTML fragment templates and class/style attributes to customize rendering
61
114
  def self.to_html( params={} )
62
115
 
116
+ config = MasterView::ConfigSettings
117
+
63
118
  # unpack the supported keyword args
64
- # Provide HTML fragment templates; optionally include class/style attributes to control rendering
65
- title_html_template = params.fetch( :title, '<h1>%s</h1>' ) #parms: MV Config title
66
- preamble_html_template = params.fetch( :preamble, '<p><b>MasterView Version:</b> %s</p>' ) #parms: MasterView version
67
- config_settings_html_template = params.fetch( :table, "<table>\n<tbody>%s</tbody>\n</table>" % ['%s'] ) #parms: section/property table rows
68
- section_entry_attrs = params.fetch( :section_attrs, 'style="background-color: #dcdcdc; font-weight: bold; margin-top: 6px;"' )
69
- section_entry_html_template = params.fetch( :section_entry, '<tr%s><td colspan="2">%s</td></tr>' ) #parms: :section_attrs, section_name
70
- option_entry_name_attrs = params.fetch( :option_name_attrs, 'style="padding-left: 6px; padding-right: 6px; font-weight: bold;"' )
71
- option_entry_value_attrs = params.fetch( :option_value_attrs, '' )
72
- option_entry_html_template = params.fetch( :option_entry, '<tr><td%s>%s</td><td%s>%s</td></tr>' ) #parms: :option_name_attrs, option_name, :option_value_attrs, option_value
73
- postscript_html = params.fetch( :postscript, '' ) #'<div style="padding-top: 6px;">(back to <a href=".">Admin home</a>)</div>'
119
+ title_html_template = getHtmlTemplate( :title, params ) #parms: config settings title
120
+ preamble_html_template = getHtmlTemplate( :preamble, params ) #parms: MasterView version
121
+ config_settings_html_template = getHtmlTemplate( :container, params ) #parms: section/option entries
122
+ section_entry_html_template = getHtmlTemplate( :section_entry, params ) #parms: :section_attrs, section_name
123
+ option_entry_html_template = getHtmlTemplate( :option_entry, params ) #parms: :option_name_attrs, option_name, :option_value_attrs, option_value
124
+ postscript_html = getHtmlTemplate( :postscript, params )
74
125
 
75
126
  # prepare our templates for convenient use during the generation loop below
76
127
  config_settings_html_start, config_settings_html_end = config_settings_html_template.split('%s')
77
- # ensure separator space for ' style="xxx"' on the section entry style/class attr(s)
78
- section_entry_attrs.insert(0, ' ') if (section_entry_attrs && section_entry_attrs != '' && section_entry_attrs[0...1] != ' ')
79
- section_entry_html_template = section_entry_html_template % [ section_entry_attrs, '%s' ] # install the optional style setting once, just plug in section_name hereafter
80
- # ensure separator space for ' style="xxx"' on the option name/value style/class attr(s)
81
- option_entry_name_attrs.insert(0, ' ') if (option_entry_name_attrs && option_entry_name_attrs != '' && option_entry_name_attrs[0...1] != ' ')
82
- option_entry_value_attrs.insert(0, ' ') if (option_entry_value_attrs && option_entry_value_attrs != '' && option_entry_value_attrs[0...1] != ' ')
83
- option_entry_html_template = option_entry_html_template % [ option_entry_name_attrs, '%s', option_entry_value_attrs, '%s' ] # install the optional style settings once, just plug in option name/value hereafter
84
128
 
85
129
  # and off we go at last
86
- config = MasterView::ConfigSettings
87
130
  html = []
88
- html << title_html_template % [ 'MasterView Configuration' ] if title_html_template # allow client to suppress
89
- html << preamble_html_template % [ MasterView::VERSION::STRING ] if preamble_html_template
131
+ unless title_html_template == :none # allow client to suppress
132
+ html << title_html_template % [ 'MasterView Configuration' ]
133
+ end
134
+ unless preamble_html_template == :none # allow client to suppress
135
+ html << preamble_html_template % [ MasterView::VERSION::STRING ]
136
+ end
90
137
  html << config_settings_html_start
91
138
  CATEGORIZED_PROPERTY_SPECS.each { | section_name, options |
92
139
  html << section_entry_html_template % section_name
@@ -114,4 +161,163 @@ module MasterView
114
161
  end
115
162
 
116
163
  end
164
+
165
+ module DirectivesInfo #:nodoc:
166
+
167
+ DEFAULT_RENDERING_OPTIONS = ConfigInfoHelpers::DEFAULT_RENDERING_OPTIONS.clone
168
+ #config_notes template parms: default directive priority level name
169
+ DEFAULT_RENDERING_OPTIONS[:config_notes] = '<div style="font-style: italic;"><b>Note:</b> default directive priority level is <b>%s</b>.</div>'
170
+ # priority label 'default (Med)' gets wrapped regardless of width, so give up
171
+ #DEFAULT_RENDERING_OPTIONS[:option_value_attrs] = 'style="width: 140px;"'
172
+ DEFAULT_RENDERING_OPTIONS[:option_subentry_entry] = '<tr><td colspan="2" style="font-style: italic; padding-left: 20px;">%s</td></tr>'
173
+
174
+ def self.getHtmlTemplate(element_option_name, params)
175
+ ConfigInfoHelpers.getHtmlTemplate( element_option_name, params, DEFAULT_RENDERING_OPTIONS )
176
+ end
177
+
178
+ # Answer an html rendering of the Configuration
179
+ # Optionally provide HTML fragment templates and class/style attributes to customize rendering
180
+ def self.to_html( params={} )
181
+
182
+ default_priority = MasterView::DirectiveMetadata::DirectivePriorities::Default
183
+ default_priority = MasterView::DirectiveMetadata.get_priority_name(default_priority)
184
+
185
+ # organize the directives info we want to present
186
+ directive_load_path = MasterView::DirectiveLoadPath.current
187
+ directive_registry = MasterView::DirectiveRegistry.current
188
+ namespaces = directive_registry.loaded_namespaces.sort
189
+ directives = {}
190
+ namespaces.each { | ns_name | directives[ns_name] = {} }
191
+ directive_registry.loaded_classes.each { | directive_class |
192
+ ns_name = directive_class.namespace_name
193
+ attr_name = directive_class.attribute_name
194
+ directives[ns_name][attr_name] = directive_class
195
+ }
196
+
197
+ # unpack the supported keyword args
198
+ title_html_template = getHtmlTemplate( :title, params ) #parms: config settings title
199
+ preamble_html_template = getHtmlTemplate( :preamble, params ) #parms: MasterView version
200
+ config_notes_html_template = getHtmlTemplate( :config_notes, params ) #parms: default priority level
201
+ config_settings_html_template = getHtmlTemplate( :container, params ) #parms: section/option entries
202
+ section_entry_html_template = getHtmlTemplate( :section_entry, params ) #parms: :section_attrs, section_name
203
+ option_entry_html_template = getHtmlTemplate( :option_entry, params ) #parms: :option_name_attrs, option_name, :option_value_attrs, option_value
204
+ option_subentry_entry_html_template = getHtmlTemplate( :option_subentry_entry, params ) #parms: value
205
+ postscript_html = getHtmlTemplate( :postscript, params )
206
+
207
+ # prepare our templates for convenient use during the generation loop below
208
+ config_settings_html_start, config_settings_html_end = config_settings_html_template.split('%s')
209
+
210
+ # and off we go at last
211
+ config = MasterView::ConfigSettings
212
+ html = []
213
+ unless title_html_template == :none # allow client to suppress
214
+ html << title_html_template % [ 'MasterView Configuration' ]
215
+ end
216
+ unless preamble_html_template == :none # allow client to suppress
217
+ html << preamble_html_template % [ MasterView::VERSION::STRING ]
218
+ end
219
+ unless config_notes_html_template == :none # allow client to suppress
220
+ html << config_notes_html_template % [ default_priority ]
221
+ end
222
+ html << config_settings_html_start
223
+ # Loaded directives
224
+ namespaces.each { | ns_name |
225
+ html << section_entry_html_template % "#{ns_name}: Namespace Directives"
226
+ directives_map = directives[ns_name] ###[attr_name] = directive_class
227
+ directives_map.keys.sort.each { | attr_name |
228
+ directive_class = directives_map[attr_name]
229
+ attr_qname = directive_class.attribute_qname
230
+ priority = MasterView::DirectiveMetadata.get_priority_label(directive_class.priority)
231
+ description = priority #too verbose: "priority #{priority}"
232
+ html << option_entry_html_template % [ attr_qname, description ]
233
+ description = directive_class.metadata_values[:description]
234
+ if description
235
+ html << option_subentry_entry_html_template % description
236
+ end
237
+ }
238
+ }
239
+ # load path
240
+ html << section_entry_html_template % 'Directives Load Path'
241
+ directive_load_path.each { | dpe |
242
+ option_name = dpe.dir_path
243
+ option_value = '&nbsp;' #TODO: dpe.options.inspect
244
+ html << option_entry_html_template % [ option_name, option_value ]
245
+ }
246
+ html << config_settings_html_end
247
+ unless postscript_html == :none # allow client to suppress
248
+ html << postscript_html
249
+ end
250
+ html.join("\n")
251
+
252
+ end
253
+
254
+ end
255
+
256
+ module FeaturesInfo #:nodoc:
257
+
258
+ # Jeff's original rendering
259
+ CONTAINER_HTML = "<table%s>\n<thead>\n <tr><th>Feature</th><th>Loaded</th></tr>\n</thead>\n<tbody>\n%s\n</tbody>\n</table>"
260
+
261
+ DEFAULT_RENDERING_OPTIONS = ConfigInfoHelpers::DEFAULT_RENDERING_OPTIONS.clone
262
+ #DEFAULT_RENDERING_OPTIONS[:container] = CONTAINER_HTML
263
+ DEFAULT_RENDERING_OPTIONS[:section_entry] = '<tr%s><td>%s</td><td>%s</td></tr>' #parms: :section_attrs, section_name
264
+ DEFAULT_RENDERING_OPTIONS[:section_attrs] = 'style="background-color: #dcdcdc; font-weight: bold; margin-top: 6px;"'
265
+ DEFAULT_RENDERING_OPTIONS[:option_name_attrs] = ''
266
+ #already is: DEFAULT_RENDERING_OPTIONS[:option_value_attrs] = ''
267
+
268
+ def self.getHtmlTemplate(element_option_name, params)
269
+ ConfigInfoHelpers.getHtmlTemplate( element_option_name, params, DEFAULT_RENDERING_OPTIONS )
270
+ end
271
+
272
+ FEATURE_SPECS = [
273
+ # [ <option_name>, <label>, <type> ]
274
+ [ :tidy_template_read, 'Filter templates through tidy on read', 'boolean' ],
275
+ [ :rails_parse_at_startup, 'Parse templates at startup', 'boolean' ],
276
+ [ :rails_reparse_checking, 'Reparse modified templates', 'boolean' ],
277
+ [ :rails_erb_mv_direct, 'Read ERB directly from MasterView', 'boolean' ],
278
+ ]
279
+
280
+ # Answer an html rendering of the Loaded Features
281
+ # Optionally provide HTML fragment templates and class/style attributes to customize rendering
282
+ def self.to_html( params={} )
283
+
284
+ features = MasterView::LoadedFeatures
285
+
286
+ # unpack the supported keyword args
287
+ title_html_template = getHtmlTemplate( :title, params ) #parms: config settings title
288
+ preamble_html_template = getHtmlTemplate( :preamble, params ) #parms: MasterView version
289
+ config_settings_html_template = getHtmlTemplate( :container, params ) #parms: section/option entries
290
+ section_entry_html_template = getHtmlTemplate( :section_entry, params ) #parms: :section_attrs, section_name
291
+ option_entry_html_template = getHtmlTemplate( :option_entry, params ) #parms: :option_name_attrs, option_name, :option_value_attrs, option_value
292
+ option_subentry_entry_html_template = params.fetch( :option_subentry_entry, '<tr><td colspan="2" style="font-style: italic; padding-left: 20px;">%s</td></tr>' )
293
+ postscript_html = ConfigInfoHelpers.getHtmlTemplate( :postscript, params )
294
+
295
+ # prepare our templates for convenient use during the generation loop below
296
+ config_settings_html_start, config_settings_html_end = config_settings_html_template.split('%s')
297
+
298
+ # and off we go at last
299
+ config = MasterView::ConfigSettings
300
+ html = []
301
+ unless title_html_template == :none # allow client to suppress
302
+ html << title_html_template % [ 'MasterView Configuration' ]
303
+ end
304
+ unless preamble_html_template == :none # allow client to suppress
305
+ html << preamble_html_template % [ MasterView::VERSION::STRING ]
306
+ end
307
+ html << config_settings_html_start
308
+ # Loaded features
309
+ html << section_entry_html_template % [ 'Feature', 'Loaded' ]
310
+ FEATURE_SPECS.each {| option_name, label, value_type |
311
+ option_value = features[option_name]
312
+ option_value = option_value ? 'true' : 'false' if value_type == 'boolean'
313
+ html << option_entry_html_template % [ label, option_value ]
314
+ }
315
+ html << config_settings_html_end
316
+ html << postscript_html if postscript_html
317
+ html.join("\n")
318
+
319
+ end
320
+
321
+ end
322
+
117
323
  end
@@ -1,8 +1,8 @@
1
1
  module MasterView
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 2
5
- TINY = 5
4
+ MINOR = 3
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end