masterview 0.3.0 → 0.3.1

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 CHANGED
@@ -1,3 +1,10 @@
1
+ 0.3.1 - November 20, 2006
2
+ Fixed problem with deprecated/directive_base was missing registry include
3
+ Update image_tag docs, indicating that it now simply passes through width and height rather than setting size
4
+ Fixed problem with Ruby 1.8.5 Pathname.dirname now calls self.class.new and was getting wrong number of arguments 1 for 2 (in FileMIO)
5
+ Accomodate change with Rails 1.2 which changed number of arguments for force_file_collision, use custom method
6
+
7
+
1
8
  0.3.0 - November 8, 2006
2
9
  Fixed compatibility of AdminPages with edge rails using dependency mechanism
3
10
  Refactored directive api using DSL to simplify and solidify creation of directives
@@ -1,9 +1,30 @@
1
1
  = MasterView - Rails-optimized (x)html friendly template engine
2
2
 
3
- == Recent changes (Release 0.3.0 - Major update - refactoring of directive API (for developing directives)
4
- The directive API for creating directives has been refactored and simplified. This will enable directives to be developed more easily by both core developers and MasterView users. The end goal is to make it extremely simple for anyone to create their own custom directives and to share those with the community, and thus the project can live and grow into many specialty areas. The directive API refactoring is one more step towards those goals.
3
+ == Recent changes (Release 0.3.1 - Maintenance release
4
+ This release addresses an issue with ruby 1.8.5, fixes a problem with the
5
+ deprecated/directive_base used for custom directives, updates a few out of
6
+ date docs, and accomodates a change to the API of the Rails 1.2 generator
7
+
5
8
 
6
- The old directive_base.rb which provided the API for directives has been deprecated and moved to deprecated/directive_base.rb, MasterViewdevelopers which have developed custom directives should upgrade those directives to the new API as soon as possible. During the transition period one can use the original API by requiring the deprecated/directive_base.rb file and changing their directive to inherit from DirectiveBaseOld rather than DirectiveBase.
9
+ == Recent changes (Release 0.3.0 - Major update - refactoring of directive API (for developing directives)
10
+ The directive API for creating directives has been refactored and simplified
11
+ and improvements have been made to better support directive extensions through
12
+ directive load path configuration and enabling multiple namespaces in directive markup.
13
+ This will enable directives to be developed more easily by both core developers
14
+ and MasterView users. The end goal is to make it extremely simple for anyone to
15
+ create their own custom directives and to share those with the community, and
16
+ thus the project can live and grow into many specialty areas. The directive API
17
+ refactoring is one more step towards those goals.
18
+
19
+ The old directive_base.rb which provided the API and implementation framework
20
+ for directives has been deprecated and moved to deprecated/directive_base.rb.
21
+ MasterView developers who have developed custom directives are strongly
22
+ encouraged to upgrade those directives to the new API as soon as possible.
23
+
24
+ To provide backwards compatibility during a transition period, you can continue to
25
+ use the original directive implementation framework by requiring the
26
+ masterview/deprecated/directive_base.rb file in your directive implementation and
27
+ changing the directive class to inherit from DirectiveBaseOld rather than DirectiveBase.
7
28
 
8
29
 
9
30
  == Recent changes (Release 0.2.5)
data/TODO CHANGED
@@ -46,3 +46,7 @@ TODO LIST
46
46
  - liquid directives or other non-evaling safe mode which allows user created templates or parts
47
47
 
48
48
  - handle all xml syntax including processing_instruction, attlistdecl, elementdecl, entitydecl, notationdecl
49
+
50
+ - more docs and examples about directive API and helpers
51
+
52
+ - sitemesh style directives
@@ -765,7 +765,7 @@ mv:image_tag="cat.jpg"
765
765
 
766
766
  becomes
767
767
 
768
- <%= image_tag 'cat.jpg', :alt => 'my cat', :size => '20x10' %>
768
+ <%= image_tag 'cat.jpg', :alt => 'my cat', :height => 10, :width => 20 %>
769
769
 
770
770
  Also if path isn't specified in the mv:image_tag attribute value then it will infer the path looking
771
771
  for what follows the public/images/ in the src atttribute, like so
@@ -79,7 +79,7 @@ for additional information and links to the <code>RubyGems</code> documentation.
79
79
  <h2>Supported Platforms</h2>
80
80
 
81
81
  <p><span class="productName">MasterView</span> has been tested
82
- on Ruby 1.8.4 and Rails 1.1.2 on *nix and Windows.
82
+ on Ruby 1.8.5r3 and Rails 1.1.6 on *nix and Windows.
83
83
  </p>
84
84
 
85
85
 
@@ -1,11 +1,5 @@
1
1
  module MasterView
2
2
 
3
- # Namespace module for built-in directive implementations
4
- # that are standard with the MasterView template engine.
5
- #
6
- module Directives
7
- end
8
-
9
3
  # THIS CLASS IS DEPRECATED!!! UPGRADE DIRECTIVES TO USE NEW DirectiveBase
10
4
  #
11
5
  # Base class for directive implementations.
@@ -81,6 +75,7 @@ module MasterView
81
75
  #
82
76
  class DirectiveBaseOld
83
77
  include PluginLoadTracking
78
+ include DirectiveMetadata
84
79
  include DirectiveHelpers
85
80
 
86
81
  # Register a class manually without regard to whether it inherits from DirectiveBase.
@@ -93,6 +88,8 @@ module MasterView
93
88
  MasterView.register_directive(directive_class)
94
89
  end
95
90
 
91
+ #DEPRECATED- superseded by DirectiveMetadata attribute_qname
92
+ #
96
93
  # Returns the fully qualified attribute name of the directive,
97
94
  # consisting of the directive namespace and the directive attribute name.
98
95
  #
@@ -111,6 +108,8 @@ module MasterView
111
108
  namespace_prefix + self.attr_name
112
109
  end
113
110
 
111
+ #DEPRECATED- superseded by DirectiveMetadata attribute_name
112
+ #
114
113
  # Returns the attribute name of the directive.
115
114
  #
116
115
  # Use full_attr_name to obtain the fully-qualified name
@@ -124,6 +123,7 @@ module MasterView
124
123
  self.default_attr_name()
125
124
  end
126
125
 
126
+ #DEPRECATED- superseded by DirectiveMetadata default_directive_name
127
127
  def self.default_attr_name() #:nodoc:
128
128
  self.name.split(':').last.downcase_first_letter
129
129
  end
@@ -273,6 +273,7 @@ module MasterView
273
273
 
274
274
  # check for common html options and return the hash
275
275
  def common_html_options(attrs_lck)
276
+ ####CHANGED: new DirectiveBase provides more extensive list
276
277
  options = {}
277
278
  options[:id] = attrs_lck['id'] if attrs_lck['id']
278
279
  options[:class] = attrs_lck['class'] if attrs_lck['class']
@@ -12,7 +12,7 @@ module MasterView
12
12
 
13
13
  DEBUG_TRACE_LOADING = false #:nodoc: ##DEBUG##
14
14
  TRACE_MD_HARDENING_SUBJECT = nil #'MasterView::DirectiveTests::TestEventsDirective'
15
- DEBUG_BUILTIN_DIRECTIVE_REGISTRATION = true #:nodoc:
15
+ DEBUG_BUILTIN_DIRECTIVE_REGISTRATION = false #:nodoc:
16
16
  DEBUG_CURRENT = false #:nodoc:
17
17
 
18
18
  # The DirectiveRegistry for managing the loaded directives available
@@ -5,7 +5,8 @@ module MasterView
5
5
  # if path is specified in attr_value then it will be used exactly as listed, otherwise if attr_value is empty
6
6
  # then masterview will attempt to find the public/images in the string and infer the path from what follows.
7
7
  # otherwise it will simply use the src path.
8
- # If both width and height attr values are specified then it will build the :size option from them.
8
+ # If width and/or height attr values are specified in the html then they will be appended to the output of the
9
+ # image tag helper. These are used instead of the size attribute because they are more flexible and a direct mapping.
9
10
  # Other html attributes will be passed into image_tag options.
10
11
  class ImageTag < MasterView::DirectiveBase
11
12
 
@@ -9,7 +9,7 @@ require File.join( File.dirname(__FILE__), 'filter_helpers' )
9
9
 
10
10
  module MasterView
11
11
 
12
- # An InvalidPathError that is raised when an invalid template path is given,
12
+ # An InvalidPathError that is raised when an invalid template path is given,
13
13
  # or if the path is outside of the root_path of the template
14
14
  # processing operating context.
15
15
  #
@@ -19,7 +19,7 @@ module MasterView
19
19
  # The MIO module contains facilities for template processing I/O.
20
20
  module MIO
21
21
  # IOManager which retrieves the proper MasterViewIOTree object for the type of object being requested
22
- # set and access MasterViewIOTree by using accessors
22
+ # set and access MasterViewIOTree by using accessors
23
23
  # IOMgr.template = FileMIOTree()
24
24
  # ftree = IOMgr.template
25
25
  # IOMgr.erb = FileMIOTree()
@@ -41,9 +41,9 @@ module MIO
41
41
  # exist?(path)
42
42
  # identical?(content)
43
43
  # mtime()
44
-
45
44
 
46
- # mixin which encapsulates the apply filter to new MIO objects and
45
+
46
+ # mixin which encapsulates the apply filter to new MIO objects and
47
47
  # the default filter block
48
48
  module MasterViewIOTreeMixin
49
49
  DefaultExtensionInstances = {}
@@ -53,7 +53,7 @@ module MIO
53
53
  # options[:escape_erb] = true enables erb escaping
54
54
  # options[:tidy] = true enables tidy processing to cleanup bad xhtml
55
55
  # options[:caching] = true enables caching so that reads are cached
56
- # options[:logging] = true enables logging of reads and writes
56
+ # options[:logging] = true enables logging of reads and writes
57
57
  # options[:default_generate] = true enables creation of default generate directive if none found
58
58
  def apply_filters(mio, options, block)
59
59
  if block
@@ -152,7 +152,7 @@ module MIO
152
152
  end
153
153
 
154
154
  def find(options = {})
155
- path = options[:path] || ''
155
+ path = options[:path] || ''
156
156
  path = '' if path == '.'
157
157
  found = []
158
158
  @string_hash.each { |p,v| found << p if p.starts_with?(path) }
@@ -170,7 +170,7 @@ module MIO
170
170
  def initialize
171
171
  self.default_extension = default_extension
172
172
  end
173
-
173
+
174
174
  def path(path)
175
175
  end
176
176
 
@@ -229,7 +229,8 @@ module MIO
229
229
  include MasterViewIOIdenticalMixin
230
230
  attr_reader :pathname
231
231
 
232
- def initialize(path, full_path)
232
+ def initialize(path, full_path=nil)
233
+ full_path = path if full_path.nil? # ruby 1.8.5 Pathname.dirname calls self.class.new so we need to allow for single argument
233
234
  super(full_path)
234
235
  @pathname = Pathname.for_path(path)
235
236
  end
@@ -318,7 +319,7 @@ module MIO
318
319
 
319
320
 
320
321
  module CachingMIOFilter #todo
321
- def read(options={})
322
+ def read(options={})
322
323
  if options[:disable_cache]
323
324
  super
324
325
  else #caching on
@@ -342,10 +343,10 @@ module MIO
342
343
  end
343
344
 
344
345
  # checks to see that mv:generate or mv:gen_partial has been used somewhere in file
345
- # and if not then it puts in a default mv:generate directive based on the following
346
+ # and if not then it puts in a default mv:generate directive based on the following
346
347
  # logic. If a body tag exists then add the mv:generate directive to the body tag
347
348
  # and also add a mv:omit_tag="" directive. This is based on the assumption that we are
348
- # body will be defined in a layout somewhere so we are only interested in the
349
+ # body will be defined in a layout somewhere so we are only interested in the
349
350
  # internal content of it (excluding the body tag itself).
350
351
  # If a body tag does not exist, then simply add the mv:generate tag to the root element.
351
352
  #
@@ -353,7 +354,7 @@ module MIO
353
354
  # <html><body>Hello world</body></html>
354
355
  # becomes
355
356
  # <html><body mv:generate="{template_path}" mv:omit_tag="">Hello world</body></html>
356
- #
357
+ #
357
358
  # <div>Hello</div>
358
359
  # becomes
359
360
  # <div mv:generate="{template_path}">Hello</div>
@@ -2,7 +2,7 @@ module MasterView
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ currentPath = File.dirname(__FILE__)
5
+ testDirPath = File.join( currentPath, '..' )
6
+ require File.join( currentPath, '../../lib/masterview' )
7
+ require File.join( currentPath, '../../lib/masterview/deprecated/directive_base' )
8
+ require File.join( testDirPath, 'test_helper' )
9
+ require File.join( testDirPath, 'directive_test_helper' )
10
+
11
+ class TestDirectiveOld < MasterView::DirectiveBaseOld
12
+ def stag(dcs)
13
+ 'Hello '+attr_value
14
+ end
15
+
16
+ def etag(dcs)
17
+ end
18
+
19
+ end
20
+
21
+ class TestTestDirectiveOld < Test::Unit::TestCase
22
+ include DirectiveTestHelpers
23
+
24
+ def setup
25
+ MasterView::IOMgr.erb = MasterView::MIO::StringHashMIOTree.new({}, '.rhtml', :logging => true)
26
+ end
27
+
28
+ def test_directive_name
29
+ # old formula for auto-generating directive name wasn't smart enough about camel-casing
30
+ assert_equal 'testDirectiveOld', TestDirectiveOld.attr_name
31
+ # new DirectiveMetadata follows rails-ish conventions
32
+ assert_equal 'test_directive_old', TestDirectiveOld.attribute_name
33
+ end
34
+
35
+ def test_directive_namespace
36
+ assert_equal MasterView::DirectiveRegistry.current.mv_extensions_namespace_prefix, TestDirectiveOld.namespace_prefix
37
+ end
38
+
39
+ def test_test_directive
40
+ template = <<-END
41
+ <div mv:generate='foo/bar'>
42
+ <head mvx:test_directive_old="woo">
43
+ </head>
44
+ </div>
45
+ END
46
+ #Note: why the trailing space from the old guy? whatever [DJL 12-Nov-2006]
47
+ expected = {
48
+ 'foo/bar' => "<div>Hello woo </div>"
49
+ }
50
+ assert_template_result expected, template
51
+ end
52
+
53
+ end
@@ -7,7 +7,7 @@ require File.join( currentPath, '../../lib/masterview/deprecated/directive_base'
7
7
 
8
8
  class TestDirectiveBase < Test::Unit::TestCase
9
9
  def setup
10
- @base = MasterView::DirectiveBase.new('')
10
+ @base = MasterView::DirectiveBaseOld.new('')
11
11
  end
12
12
 
13
13
  def test_quote
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ currentPath = File.dirname(__FILE__)
5
+ testDirPath = File.join( currentPath, '..' )
6
+ require File.join( currentPath, '../../lib/masterview' )
7
+ require File.join( currentPath, '../../lib/masterview/deprecated/directive_base' )
8
+ require File.join( testDirPath, 'test_helper' )
9
+ require File.join( testDirPath, 'directive_test_helper' )
10
+
11
+ class TestDirectiveOld < MasterView::DirectiveBaseOld
12
+ def stag(dcs)
13
+ 'Hello '+attr_value
14
+ end
15
+
16
+ def etag(dcs)
17
+ end
18
+
19
+ end
20
+
21
+ class TestTestDirectiveOld < Test::Unit::TestCase
22
+ include DirectiveTestHelpers
23
+
24
+ def setup
25
+ MasterView::IOMgr.erb = MasterView::MIO::StringHashMIOTree.new({}, '.rhtml', :logging => true)
26
+ end
27
+
28
+ def test_test_directive
29
+ template = <<-END
30
+ <div mv:generate='foo/bar'>
31
+ <head mvx:test_directive_old="woo">
32
+ </head>
33
+ </div>
34
+ END
35
+ expected = {
36
+ 'foo/bar' => "<div>Hello woo </div>"
37
+ }
38
+ assert_template_result expected, template
39
+ end
40
+
41
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: masterview
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.0
7
- date: 2006-11-08 00:00:00 -06:00
6
+ version: 0.3.1
7
+ date: 2006-11-20 00:00:00 -06:00
8
8
  summary: A (x)html friendly template engine for rails with the power of layouts, and partials.
9
9
  require_paths:
10
10
  - lib
@@ -137,6 +137,7 @@ files:
137
137
  - doc/stylesheets
138
138
  - doc/directives.html
139
139
  - doc/guide.html
140
+ - doc/api
140
141
  - doc/screenshots
141
142
  - doc/installation.html
142
143
  - doc/configuration.html
@@ -234,6 +235,8 @@ files:
234
235
  - test/unit/directive_global_inline_erb_test.rb
235
236
  - test/unit/directive_load_path_test.rb
236
237
  - test/unit/deprecated_directive_base_test.rb
238
+ - test/unit/example_directive_base_old_test.rb
239
+ - test/unit/deprecated_directive_base_example_test.rb
237
240
  - test/xtras/config_initialize_standalone.rb
238
241
  - test/xtras/config-mv-logger_config.rb
239
242
  - test/fixtures/configs