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.
- data/CHANGELOG +31 -1
- data/README +70 -69
- data/RELEASE_NOTES +70 -64
- data/Rakefile +26 -27
- data/TODO +13 -29
- data/doc/about.html +246 -0
- data/doc/configuration.html +49 -36
- data/doc/developer.html +423 -41
- data/doc/directives.html +139 -51
- data/doc/guide.html +19 -9
- data/doc/index.html +90 -224
- data/doc/installation.html +36 -28
- data/doc/media_list.html +30 -20
- data/doc/simple_diagram.html +3 -5
- data/doc/stylesheets/masterview.css +16 -1
- data/examples/rails_app_config/masterview/settings.rb +2 -1
- data/init.rb +1 -1
- data/lib/#ChangeLog# +6 -0
- data/lib/masterview/analyzer.rb +48 -34
- data/lib/masterview/attr_string_parser.rb +5 -1
- data/lib/masterview/case_insensitive_hash.rb +69 -0
- data/lib/masterview/{pathname_extensions.rb → core_ext/pathname.rb} +0 -0
- data/lib/masterview/{string_extensions.rb → core_ext/string.rb} +0 -0
- data/lib/masterview/deprecated/directive_base.rb +362 -0
- data/lib/masterview/directive_base.rb +201 -179
- data/lib/masterview/directive_dsl.rb +457 -0
- data/lib/masterview/directive_helpers.rb +28 -141
- data/lib/masterview/directive_load_path.rb +388 -0
- data/lib/masterview/directive_metadata.rb +377 -0
- data/lib/masterview/directive_registry.rb +259 -69
- data/lib/masterview/directives/.metadata +16 -0
- data/lib/masterview/directives/attr.rb +9 -8
- data/lib/masterview/directives/block.rb +11 -14
- data/lib/masterview/directives/check_box.rb +13 -18
- data/lib/masterview/directives/collection_select.rb +15 -29
- data/lib/masterview/directives/content.rb +9 -3
- data/lib/masterview/directives/else.rb +15 -13
- data/lib/masterview/directives/elsif.rb +14 -13
- data/lib/masterview/directives/eval.rb +20 -0
- data/lib/masterview/directives/form.rb +56 -9
- data/lib/masterview/directives/form_remote.rb +26 -0
- data/lib/masterview/directives/global_inline_erb.rb +10 -14
- data/lib/masterview/directives/hidden_field.rb +11 -20
- data/lib/masterview/directives/if.rb +13 -12
- data/lib/masterview/directives/image_tag.rb +20 -28
- data/lib/masterview/directives/import.rb +5 -12
- data/lib/masterview/directives/import_render.rb +7 -19
- data/lib/masterview/directives/insert_generated_comment.rb +8 -11
- data/lib/masterview/directives/javascript_include.rb +21 -12
- data/lib/masterview/directives/link_to.rb +14 -8
- data/lib/masterview/directives/link_to_function.rb +22 -0
- data/lib/masterview/directives/link_to_if.rb +15 -13
- data/lib/masterview/directives/link_to_remote.rb +13 -8
- data/lib/masterview/directives/omit_tag.rb +32 -16
- data/lib/masterview/directives/password_field.rb +10 -22
- data/lib/masterview/directives/radio_button.rb +11 -22
- data/lib/masterview/directives/replace.rb +7 -8
- data/lib/masterview/directives/select.rb +11 -24
- data/lib/masterview/directives/stylesheet_link.rb +20 -12
- data/lib/masterview/directives/submit.rb +11 -5
- data/lib/masterview/directives/text_area.rb +10 -23
- data/lib/masterview/directives/text_field.rb +10 -22
- data/lib/masterview/exceptions.rb +21 -0
- data/lib/masterview/extras/app/controllers/masterview_controller.rb +102 -75
- data/lib/masterview/extras/app/views/layouts/masterview_admin.rhtml +24 -23
- data/lib/masterview/extras/app/views/layouts/masterview_admin_config.rhtml +81 -0
- data/lib/masterview/extras/app/views/masterview/admin/configuration.rhtml +5 -1
- data/lib/masterview/extras/app/views/masterview/admin/create.rhtml +2 -2
- data/lib/masterview/extras/app/views/masterview/admin/directives.rhtml +5 -0
- data/lib/masterview/extras/app/views/masterview/admin/features.rhtml +5 -79
- data/lib/masterview/extras/app/views/masterview/admin/interact.rhtml +5 -0
- data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +3 -71
- data/lib/masterview/extras/init_mv_admin_pages.rb +42 -23
- data/lib/masterview/filter_helpers.rb +26 -0
- data/lib/masterview/initializer.rb +99 -53
- data/lib/masterview/io.rb +19 -15
- data/lib/masterview/keyword_expander.rb +7 -2
- data/lib/masterview/masterview_info.rb +229 -23
- data/lib/masterview/masterview_version.rb +2 -2
- data/lib/masterview/parser.rb +275 -105
- data/lib/masterview/parser_helpers.rb +54 -0
- data/lib/masterview/rails_ext/action_controller_erb_direct.rb +29 -0
- data/lib/masterview/rails_ext/action_controller_reparse_checking.rb +27 -0
- data/lib/masterview/{extras/init_rails_erb_mv_direct.rb → rails_ext/action_view_erb_direct.rb} +12 -59
- data/lib/masterview/template_spec.rb +3 -2
- data/lib/masterview.rb +21 -12
- data/lib/rexml/parsers/baseparser_with_doctype_fix.rb +473 -0
- data/lib/rexml/parsers/sax2parser_with_doctype_fix.rb +243 -0
- data/test/directive_test_helper.rb +135 -0
- data/test/fixtures/directives/id_check.rb +18 -0
- data/test/fixtures/directives/test_directive_events.rb +70 -0
- data/test/test_helper.rb +18 -5
- data/test/tmp/views/layouts/product.rhtml +10 -10
- data/test/tmp/views/product/_form.rhtml +4 -4
- data/test/tmp/views/product/_product.rhtml +3 -3
- data/test/tmp/views/product/destroy.rhtml +5 -5
- data/test/tmp/views/product/edit.rhtml +4 -4
- data/test/tmp/views/product/list.rhtml +3 -3
- data/test/tmp/views/product/new.rhtml +4 -4
- data/test/tmp/views/product/show.rhtml +2 -2
- data/test/unit/attr_string_parser_test.rb +105 -0
- data/test/unit/case_insensitive_hash_mod_test.rb +104 -0
- data/test/unit/config_settings_test.rb +13 -1
- data/test/unit/default_generate_mio_filter_test.rb +3 -3
- data/test/unit/deprecated_directive_base_test.rb +30 -0
- data/test/unit/directive_attr_test.rb +111 -35
- data/test/unit/directive_base_test.rb +520 -1
- data/test/unit/directive_block_test.rb +30 -22
- data/test/unit/directive_content_test.rb +24 -11
- data/test/unit/directive_else_test.rb +18 -15
- data/test/unit/directive_elsif_test.rb +17 -15
- data/test/unit/directive_form_remote_test.rb +59 -0
- data/test/unit/directive_form_test.rb +31 -39
- data/test/unit/directive_global_inline_erb_test.rb +28 -17
- data/test/unit/directive_grid_test_notready.rb +38 -0
- data/test/unit/directive_helpers_test.rb +39 -0
- data/test/unit/directive_hidden_field_test.rb +44 -29
- data/test/unit/directive_if_test.rb +10 -7
- data/test/unit/directive_image_tag_test.rb +69 -61
- data/test/unit/directive_import_render_test.rb +28 -38
- data/test/unit/directive_import_test.rb +16 -14
- data/test/unit/directive_insert_generated_comment_test.rb +32 -0
- data/test/unit/directive_javascript_include_test.rb +40 -43
- data/test/unit/directive_link_to_function_test.rb +40 -0
- data/test/unit/directive_link_to_if_test.rb +52 -12
- data/test/unit/directive_link_to_remote_test.rb +58 -0
- data/test/unit/directive_link_to_test.rb +46 -31
- data/test/unit/directive_load_path_test.rb +257 -0
- data/test/unit/directive_metadata_test.rb +313 -0
- data/test/unit/directive_omit_tag_test.rb +73 -21
- data/test/unit/directive_password_field_test.rb +44 -38
- data/test/unit/directive_registry_test.rb +44 -0
- data/test/unit/directive_replace_test.rb +28 -12
- data/test/unit/directive_stylesheet_link_test.rb +43 -36
- data/test/unit/directive_submit_test.rb +29 -30
- data/test/unit/directive_text_area_test.rb +40 -36
- data/test/unit/directive_text_field_test.rb +44 -38
- data/test/unit/example_directive_child_events_test.rb +41 -0
- data/test/unit/example_test.rb +31 -4
- data/test/unit/file_mio_test.rb +18 -13
- data/test/unit/filter_helpers_test.rb +10 -8
- data/test/unit/find_directive_parent_test.rb +174 -0
- data/test/unit/keyword_expander_test.rb +4 -2
- data/test/unit/mio_test.rb +18 -11
- data/test/unit/mtime_string_hash_mio_tree_test.rb +5 -1
- data/test/unit/parser_test.rb +41 -29
- data/test/unit/pathname_extensions_test.rb +1 -1
- data/test/unit/run_parser_test.rb +2 -2
- data/test/unit/simplified_directive_base_test.rb +256 -0
- data/test/unit/string_hash_mio_test.rb +5 -1
- data/test/unit/template_file_watcher_test.rb +2 -2
- data/test/unit/template_test.rb +221 -46
- metadata +86 -45
- data/lib/masterview/directives/testfilter.rb +0 -55
- 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 ] ], #:
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
-
|
89
|
-
|
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 = ' ' #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
|