masterview_plugin_generator 0.1.5 → 0.2.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/masterview_plugin_generator.rb +6 -0
- data/templates/development.rb +22 -0
- data/templates/empty.rhtml +1 -1
- data/templates/init.rb +26 -12
- data/templates/masterview.rake +42 -23
- data/templates/production.rb +9 -0
- data/templates/settings.rb +59 -0
- metadata +6 -3
@@ -17,9 +17,15 @@ class MasterviewPluginGenerator < Rails::Generator::Base
|
|
17
17
|
m.directory 'vendor/plugins/masterview/lib/masterview/extras/app/views/masterview'
|
18
18
|
m.directory 'vendor/plugins/masterview/lib/masterview/extras/app/views/masterview/admin'
|
19
19
|
m.directory 'vendor/plugins/masterview/tasks'
|
20
|
+
m.directory 'config'
|
21
|
+
m.directory 'config/masterview'
|
22
|
+
m.directory 'config/masterview/environments'
|
20
23
|
m.file 'empty.rhtml', 'vendor/plugins/masterview/lib/masterview/extras/app/views/masterview/admin/empty.rhtml'
|
21
24
|
m.file 'init.rb', 'vendor/plugins/masterview/init.rb'
|
22
25
|
m.file 'masterview.rake', 'vendor/plugins/masterview/tasks/masterview.rake'
|
26
|
+
m.file 'settings.rb', 'config/masterview/settings.rb'
|
27
|
+
m.file 'development.rb', 'config/masterview/environments/development.rb'
|
28
|
+
m.file 'production.rb', 'config/masterview/environments/production.rb'
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Development environment config settings for the MasterView template engine.
|
2
|
+
#
|
3
|
+
# The MasterView configuration specification is referenced through +config+.
|
4
|
+
#
|
5
|
+
# Settings specified here will take precedence over those specified in the
|
6
|
+
# general MasterView config in +config/masterview/settings.rb+.
|
7
|
+
#
|
8
|
+
# Set development-mode config settings here
|
9
|
+
|
10
|
+
# General options
|
11
|
+
#config.log_level = 'DEBUG'
|
12
|
+
|
13
|
+
# Rails application options
|
14
|
+
#config.reparse_changed_masterview_templates = true # enable in development env
|
15
|
+
|
16
|
+
#config.log_level = 'WARN'
|
17
|
+
#config.after_initialize {
|
18
|
+
# MasterView.log_level = 'DEBUG'
|
19
|
+
#}
|
20
|
+
|
21
|
+
# Only use the MasterView admin pages for development
|
22
|
+
# config.enable_admin_pages = true
|
data/templates/empty.rhtml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class="<%= @controller_file_name %>_<%= @action_name %> sidebar LHS">
|
3
3
|
<h2>Tasks:</h2>
|
4
4
|
<ul>
|
5
|
-
<li><a class="list_link" href="
|
5
|
+
<li><a class="list_link" href="list.html" mv:link_to=":action => 'list'">Back to overview</a></li>
|
6
6
|
</ul>
|
7
7
|
</div>
|
8
8
|
|
data/templates/init.rb
CHANGED
@@ -29,17 +29,31 @@
|
|
29
29
|
# It is designed to use the full power and productivity of rails including
|
30
30
|
# layouts, partials, and rails html helpers while still being editable/styleable
|
31
31
|
# in a WYSIWYG HTML editor.
|
32
|
+
#
|
33
|
+
# To activate MasterView in your rails application, simply install
|
34
|
+
# the masterview plugin, either as a complete install in your
|
35
|
+
# rails +vendor/plugin+ or by installing the +masterview+ gem and
|
36
|
+
# running the +masterview_plugin+ generator to configure a plugin stub.
|
37
|
+
#
|
38
|
+
# To customize the MasterView configuration, create a +masterview+ directory
|
39
|
+
# in your rails application's +config+ directory. To set MasterView
|
40
|
+
# configuration settings options for your application, provide a
|
41
|
+
# +config/masterview/settings.rb+ file which installs your custom settings
|
42
|
+
# in the +config+.
|
43
|
+
#
|
44
|
+
# # set MasterView configuration options
|
45
|
+
# config.enable_admin_pages = false
|
46
|
+
# config.default_parser_options[:tidy] = true
|
47
|
+
# config.tidy_path = '/usr/lib/libtidy.so'
|
48
|
+
# config.directive_paths << File.join( RAILS_ROOT, 'masterview-ext', 'directives' )
|
49
|
+
#
|
50
|
+
# To customize the configuration for the current Rails environment,
|
51
|
+
# provide a +config/masterview/environments/#{environment}.rb+ file
|
52
|
+
# which sets config values for that environment using the +config+ variable.
|
53
|
+
# Environment-specific values override general application settings
|
54
|
+
# installed in the main +config/masterview/settings.rb+.
|
55
|
+
#
|
56
|
+
# See MasterView::Configuration for descriptions of the customizable options.
|
57
|
+
#
|
32
58
|
|
33
59
|
require 'masterview'
|
34
|
-
|
35
|
-
module ::MasterView
|
36
|
-
#override any constants here, see masterview.rb for more
|
37
|
-
#Note that you may also put your override configuration in vendor/plugins/masterview/user.rb and user_development.rb, user_test.rb, ...
|
38
|
-
#DefaultDirectiveLoadPaths.push File.join( File.dirname(__FILE__), 'directives') #uncomment if you want to add a local directives dir
|
39
|
-
#DefaultParserOptions = { :tidy => false, :escape_erb => true }
|
40
|
-
#TidyPath = '/usr/lib/libtidy.so'
|
41
|
-
#EnableMasterViewAdminPages = true
|
42
|
-
end
|
43
|
-
|
44
|
-
require 'masterview/extras/rails_init.rb'
|
45
|
-
|
data/templates/masterview.rake
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
|
1
|
+
# MasterView template engine rake tasks
|
2
2
|
|
3
|
-
MasterView
|
3
|
+
# load MasterView engine with the std config (uses app config settings when in rails app)
|
4
|
+
mv_lib_dir_path = File.join( File.dirname(__FILE__), '../lib' )
|
5
|
+
mv_admin_controller_install_dir_path = File.join( mv_lib_dir_path, 'masterview/extras' ) # ./app/views/masterview
|
6
|
+
|
7
|
+
# doing load and require this way so that it works from both gems and plugin install
|
8
|
+
$LOAD_PATH.push( mv_lib_dir_path )
|
9
|
+
require "masterview"
|
10
|
+
|
11
|
+
MasterView.set_log_level('ERROR')
|
4
12
|
|
5
13
|
namespace :mv do
|
6
14
|
|
@@ -22,20 +30,18 @@ namespace :mv do
|
|
22
30
|
puts "\tgenerates: #{ts.gen_parts.join(', ')}\n\n"
|
23
31
|
end
|
24
32
|
end
|
25
|
-
|
26
|
-
desc 'Rebuild/update template imports, specify TEMPLATE=foo.html'
|
33
|
+
|
34
|
+
desc 'Rebuild/update template imports, specify TEMPLATE=foo/bar.html'
|
27
35
|
task :rebuild do
|
28
|
-
raise "Usage: rake mv:rebuild TEMPLATE=foo.html" unless ENV['TEMPLATE']
|
36
|
+
raise "Usage: rake mv:rebuild TEMPLATE=foo/bar.html" unless ENV['TEMPLATE']
|
29
37
|
path = ENV['TEMPLATE']
|
30
|
-
|
31
|
-
short_name = short_name+'.html' unless short_name.index('.')
|
32
|
-
path = File.join('app/views', MasterView::TemplateSrcRelativePath, short_name)
|
38
|
+
path = MasterView::IOMgr.template.cleanup_path_get_relative_pathname(path).to_s
|
33
39
|
template_specs, content_hash = MasterView::TemplateSpec.scan
|
34
40
|
template_spec = template_specs[path]
|
35
41
|
raise 'Template '+path+' not found' unless template_spec
|
36
42
|
if template_spec.rebuild_template(content_hash, :write_to_file => true)
|
37
43
|
puts 'File '+path+' updated'
|
38
|
-
puts 'Note: Backup was created in '
|
44
|
+
puts 'Note: Backup was created in MasterView::IOMgr.backup location' if MasterView::IOMgr.backup
|
39
45
|
else
|
40
46
|
puts 'Identical content - no update needed for '+path
|
41
47
|
end
|
@@ -53,41 +59,54 @@ namespace :mv do
|
|
53
59
|
files_rebuilt.each do |f|
|
54
60
|
puts f+' updated'
|
55
61
|
end
|
56
|
-
unless files_rebuilt.empty? || MasterView::
|
57
|
-
puts 'Note: Backups were created in '
|
62
|
+
unless files_rebuilt.empty? || MasterView::IOMgr.backup.nil?
|
63
|
+
puts 'Note: Backups were created in MasterView::IOMgr.backup location' if MasterView::IOMgr.backup
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
61
|
-
# checks app path first for views and files, then falls back to files in MV
|
67
|
+
# checks app path first for views and files, then falls back to files in MV installation dir
|
62
68
|
def find_path(path)
|
63
|
-
mv_path = File.join(
|
69
|
+
mv_path = File.join( mv_admin_controller_install_dir_path, path )
|
64
70
|
working_path = (File.exist?(path)) ? path : mv_path
|
65
71
|
end
|
66
72
|
|
67
|
-
desc 'Create shell template using layout of existing masterview template, requires TEMPLATE=foo.html ACTION=list'
|
73
|
+
desc 'Create shell template using layout of existing masterview template, requires TEMPLATE=foo/bar.html ACTION=list'
|
68
74
|
task :copy_layout do
|
69
|
-
raise "Usage: rake mv:copy_layout TEMPLATE=foo.html ACTION=list" unless ENV['TEMPLATE'] && ENV['ACTION']
|
75
|
+
raise "Usage: rake mv:copy_layout TEMPLATE=foo/bar.html ACTION=list" unless ENV['TEMPLATE'] && ENV['ACTION']
|
70
76
|
action_to_create = ENV['ACTION']
|
71
|
-
|
72
|
-
|
77
|
+
path = ENV['TEMPLATE']
|
78
|
+
path = MasterView::IOMgr.template.cleanup_path_get_relative_pathname(path).to_s
|
73
79
|
empty_file_path = find_path('app/views/masterview/admin/empty.rhtml')
|
74
80
|
empty_insert_erb = File.readlines(empty_file_path).join
|
75
81
|
|
76
|
-
src_file =
|
82
|
+
src_file = path
|
77
83
|
dst_file = MasterView::TemplateSpec.create_empty_shell_for_action(src_file, action_to_create, empty_insert_erb, :write_to_file => true)
|
78
84
|
puts dst_file+' created'
|
79
85
|
end
|
80
86
|
|
81
87
|
desc "Run parser manually on masterview html files to generate the erb/rhtml files"
|
82
88
|
task :parse do
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
MasterView::Parser.parse_file( file, OutputDir)
|
87
|
-
puts 'Generated erb/rhtml files from '+file
|
89
|
+
MasterView::IOMgr.template.find(:pattern => MasterView::TemplateFilenamePattern ) do |mio|
|
90
|
+
puts 'Generated erb/rhtml files from '+mio.pathname.to_s
|
91
|
+
MasterView::Parser.parse_mio(mio, MasterView::IOMgr.erb)
|
88
92
|
end
|
89
93
|
puts 'Generated erb/rhtml output was created in app/views/** tree'
|
90
94
|
end
|
91
95
|
|
96
|
+
desc "View erb/rhtml that masterview generated - specify rhtml name like RHTML=product/_form.rhtml or RHTML=layouts/product.rhtml"
|
97
|
+
task :view_rhtml do
|
98
|
+
raise "Usage: rake mv:view_rhtml RHTML=product/_form.rhtml" unless ENV['RHTML']
|
99
|
+
rhtml_file = ENV['RHTML']
|
100
|
+
|
101
|
+
# make sure they are parsed
|
102
|
+
string_hash_mio_tree = MasterView::StringHashMIOTree.new
|
103
|
+
MasterView::IOMgr.template.find(:pattern => MasterView::TemplateFilenamePattern ) do |mio|
|
104
|
+
MasterView::Parser.parse_mio(mio, string_hash_mio_tree)
|
105
|
+
end
|
106
|
+
|
107
|
+
f = string_hash_mio_tree.path(rhtml_file)
|
108
|
+
raise "RHTML ("+rhtml_file+") does not exist. Use rake mv:list_all to find correct rhtml file to view" unless f.exist?
|
109
|
+
puts f.read
|
110
|
+
end
|
92
111
|
|
93
112
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# Development environment config settings for the MasterView template engine.
|
2
|
+
#
|
3
|
+
# The MasterView configuration specification is referenced through +config+.
|
4
|
+
#
|
5
|
+
# Settings specified here will take precedence over those specified in the
|
6
|
+
# general MasterView config in +config/masterview/settings.rb+.
|
7
|
+
#
|
8
|
+
# Set production-mode config settings here
|
9
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Application configuration settings for the MasterView template engine.
|
2
|
+
#
|
3
|
+
# This code is run at plugin load time, after the base rails framework
|
4
|
+
# has been loaded and configured, but before any application-specific config
|
5
|
+
# in +environment.rb+ is run.
|
6
|
+
#
|
7
|
+
# The MasterView configuration specification is referenced through +config+.
|
8
|
+
#
|
9
|
+
# Set standard application configuration options here.
|
10
|
+
# General settings can be overridden for specific environments by providing
|
11
|
+
# additional settings values in +config/masterview/environments/#{environment}.rb+.
|
12
|
+
#
|
13
|
+
# See Rails::Configuration for details on the available configuration settings.
|
14
|
+
#
|
15
|
+
|
16
|
+
# General options - root paths for config settings, directives, templates
|
17
|
+
#config.root_path = RAILS_ROOT
|
18
|
+
#config.config_dir_path = 'config/masterview' # relative path from config.root_path
|
19
|
+
#config.environment = RAILS_ENV
|
20
|
+
#config.directive_paths << '/path/to/custom/directives'
|
21
|
+
#config.logger = 'log4r'
|
22
|
+
#config.log_level = 'WARN'
|
23
|
+
#config.after_initialize { MasterView::Log.level = DEBUG }
|
24
|
+
|
25
|
+
# Template Source Options
|
26
|
+
#config.template_src_dir_path = 'app/views' # relative path from config.root_path
|
27
|
+
#config.template_src_dir_abs_path( '/path/to/masterview/templates' )
|
28
|
+
#config.template_filename_pattern = '*.html'
|
29
|
+
|
30
|
+
# Template Generation Options
|
31
|
+
#config.template_dst_dir_path = 'app/views' # relative path from config.root_path
|
32
|
+
#config.template_dst_dir_abs_path( '/path/to/masterview/output' )
|
33
|
+
#config.output_filename_extension = '.rhtml'
|
34
|
+
#config.generated_file_default_extension = '.rhtml'
|
35
|
+
#config.include_generated_file_comment = true
|
36
|
+
|
37
|
+
# generate a more concise generated-file warning comment that the standard MV comment
|
38
|
+
#config.generated_file_comment = "# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
|
39
|
+
#config.generated_file_comment << "\n# DO NOT EDIT - generated by MasterView from template file:\n"
|
40
|
+
#config.generated_file_comment << '# #{template_path}' # carefully avoid premature substitution eval
|
41
|
+
#config.generated_file_comment << "\n# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
|
42
|
+
|
43
|
+
# Template Parsing Options
|
44
|
+
#config.handle_parse_exceptions = true
|
45
|
+
#config.default_parser_options = { :tidy => false, :escape_erb => true }
|
46
|
+
#config.tidy_path = '/usr/lib/libtidy.so' # *nix
|
47
|
+
#config.tidy_path = 'tidy.exe' # Win32 (assumes on system PATH)
|
48
|
+
#config.namespace_prefix = 'mv:'
|
49
|
+
#config.inline_erb_start = '{{{'
|
50
|
+
#config.inline_erb_end = '}}}'
|
51
|
+
#config.inline_erb_substitution_regex = /\{\{\{(([^}]|\}[^}]|\}\}[^}])*)\}\}\}/
|
52
|
+
|
53
|
+
# Rails application options
|
54
|
+
#config.parse_masterview_templates_at_startup = true
|
55
|
+
#config.reparse_changed_masterview_templates = false # enable in development env
|
56
|
+
#config.enable_admin_pages = false
|
57
|
+
#config.enable_view_rhtml = false
|
58
|
+
#config.generate_rhtml_files = false
|
59
|
+
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: masterview_plugin_generator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2006-06-21 00:00:00 -05:00
|
8
8
|
summary: A (x)html friendly template engine for rails with the power of layouts, and partials. MasterView Plugin Generator for GEM
|
9
9
|
require_paths:
|
10
10
|
- .
|
@@ -29,9 +29,12 @@ authors:
|
|
29
29
|
- Jeff Barczewski
|
30
30
|
files:
|
31
31
|
- masterview_plugin_generator.rb
|
32
|
-
- templates/
|
32
|
+
- templates/development.rb
|
33
|
+
- templates/settings.rb
|
33
34
|
- templates/empty.rhtml
|
34
35
|
- templates/init.rb
|
36
|
+
- templates/masterview.rake
|
37
|
+
- templates/production.rb
|
35
38
|
- Rakefile
|
36
39
|
test_files: []
|
37
40
|
|