arrow 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1590 -0
- data/LICENSE +28 -0
- data/README +75 -0
- data/Rakefile +366 -0
- data/Rakefile.local +63 -0
- data/data/arrow/applets/TEMPLATE.rb.tpl +53 -0
- data/data/arrow/applets/args.rb +50 -0
- data/data/arrow/applets/config.rb +55 -0
- data/data/arrow/applets/error.rb +63 -0
- data/data/arrow/applets/files.rb +46 -0
- data/data/arrow/applets/inspect.rb +46 -0
- data/data/arrow/applets/nosuchapplet.rb +31 -0
- data/data/arrow/applets/status.rb +92 -0
- data/data/arrow/applets/test.rb +133 -0
- data/data/arrow/applets/tutorial/counter.rb +96 -0
- data/data/arrow/applets/tutorial/dingus.rb +67 -0
- data/data/arrow/applets/tutorial/hello.rb +34 -0
- data/data/arrow/applets/tutorial/hello2.rb +73 -0
- data/data/arrow/applets/tutorial/imgtext.rb +90 -0
- data/data/arrow/applets/tutorial/imgtext2.rb +286 -0
- data/data/arrow/applets/tutorial/index.rb +36 -0
- data/data/arrow/applets/tutorial/logo.rb +98 -0
- data/data/arrow/applets/tutorial/memcache.rb +61 -0
- data/data/arrow/applets/tutorial/missing.rb +37 -0
- data/data/arrow/applets/tutorial/protected.rb +100 -0
- data/data/arrow/applets/tutorial/redirector.rb +52 -0
- data/data/arrow/applets/tutorial/rndimages.rb +159 -0
- data/data/arrow/applets/tutorial/sharenotes.rb +83 -0
- data/data/arrow/applets/tutorial/subclassed-hello.rb +32 -0
- data/data/arrow/applets/tutorial/superhello.rb +72 -0
- data/data/arrow/applets/tutorial/timeclock.rb +78 -0
- data/data/arrow/applets/view-applet.rb +123 -0
- data/data/arrow/applets/view-template.rb +85 -0
- data/data/arrow/applets/wiki.rb +274 -0
- data/data/arrow/templates/TEMPLATE.tmpl.tpl +36 -0
- data/data/arrow/templates/applet-status.tmpl +153 -0
- data/data/arrow/templates/args-display.tmpl +120 -0
- data/data/arrow/templates/config/display-table.tmpl +36 -0
- data/data/arrow/templates/config/display.tmpl +36 -0
- data/data/arrow/templates/counter-deleted.tmpl +33 -0
- data/data/arrow/templates/counter.tmpl +59 -0
- data/data/arrow/templates/dingus.tmpl +55 -0
- data/data/arrow/templates/enumtable.tmpl +8 -0
- data/data/arrow/templates/error-display.tmpl +92 -0
- data/data/arrow/templates/filemap.tmpl +89 -0
- data/data/arrow/templates/hello-world-src.tmpl +34 -0
- data/data/arrow/templates/hello-world.tmpl +60 -0
- data/data/arrow/templates/imgtext/fontlist.tmpl +46 -0
- data/data/arrow/templates/imgtext/form.tmpl +70 -0
- data/data/arrow/templates/imgtext/reload-error.tmpl +40 -0
- data/data/arrow/templates/imgtext/reload.tmpl +55 -0
- data/data/arrow/templates/inspect/display.tmpl +80 -0
- data/data/arrow/templates/loginform.tmpl +64 -0
- data/data/arrow/templates/logout.tmpl +32 -0
- data/data/arrow/templates/memcache/display.tmpl +41 -0
- data/data/arrow/templates/navbar.incl +27 -0
- data/data/arrow/templates/nosuchapplet.tmpl +32 -0
- data/data/arrow/templates/printsource.tmpl +35 -0
- data/data/arrow/templates/protected.tmpl +36 -0
- data/data/arrow/templates/rndimages.tmpl +38 -0
- data/data/arrow/templates/service-response.tmpl +13 -0
- data/data/arrow/templates/sharenotes/display.tmpl +38 -0
- data/data/arrow/templates/status.tmpl +120 -0
- data/data/arrow/templates/templateviewer.tmpl +43 -0
- data/data/arrow/templates/test/harness.tmpl +57 -0
- data/data/arrow/templates/test/list.tmpl +48 -0
- data/data/arrow/templates/test/problem.tmpl +42 -0
- data/data/arrow/templates/tutorial/index.tmpl +37 -0
- data/data/arrow/templates/tutorial/missingapplet.tmpl +29 -0
- data/data/arrow/templates/view-applet-nosuch.tmpl +32 -0
- data/data/arrow/templates/view-applet.tmpl +40 -0
- data/data/arrow/templates/view-template.tmpl +83 -0
- data/data/arrow/templates/wiki/formerror.tmpl +47 -0
- data/data/arrow/templates/wiki/markup_help.incl +6 -0
- data/data/arrow/templates/wiki/new.tmpl +56 -0
- data/data/arrow/templates/wiki/new_system.tmpl +122 -0
- data/data/arrow/templates/wiki/sectionlist.tmpl +43 -0
- data/data/arrow/templates/wiki/show.tmpl +34 -0
- data/docs/manual/layouts/default.page +43 -0
- data/docs/manual/lib/api-filter.rb +81 -0
- data/docs/manual/lib/editorial-filter.rb +64 -0
- data/docs/manual/lib/examples-filter.rb +244 -0
- data/docs/manual/lib/links-filter.rb +117 -0
- data/lib/apache/fakerequest.rb +448 -0
- data/lib/apache/logger.rb +33 -0
- data/lib/arrow.rb +51 -0
- data/lib/arrow/acceptparam.rb +207 -0
- data/lib/arrow/applet.rb +725 -0
- data/lib/arrow/appletmixins.rb +218 -0
- data/lib/arrow/appletregistry.rb +590 -0
- data/lib/arrow/applettestcase.rb +503 -0
- data/lib/arrow/broker.rb +255 -0
- data/lib/arrow/cache.rb +176 -0
- data/lib/arrow/config-loaders/yaml.rb +75 -0
- data/lib/arrow/config.rb +615 -0
- data/lib/arrow/constants.rb +24 -0
- data/lib/arrow/cookie.rb +359 -0
- data/lib/arrow/cookieset.rb +108 -0
- data/lib/arrow/dispatcher.rb +368 -0
- data/lib/arrow/dispatcherloader.rb +50 -0
- data/lib/arrow/exceptions.rb +61 -0
- data/lib/arrow/fallbackhandler.rb +48 -0
- data/lib/arrow/formvalidator.rb +631 -0
- data/lib/arrow/htmltokenizer.rb +343 -0
- data/lib/arrow/logger.rb +488 -0
- data/lib/arrow/logger/apacheoutputter.rb +69 -0
- data/lib/arrow/logger/arrayoutputter.rb +63 -0
- data/lib/arrow/logger/coloroutputter.rb +111 -0
- data/lib/arrow/logger/fileoutputter.rb +96 -0
- data/lib/arrow/logger/htmloutputter.rb +54 -0
- data/lib/arrow/logger/outputter.rb +123 -0
- data/lib/arrow/mixins.rb +425 -0
- data/lib/arrow/monkeypatches.rb +94 -0
- data/lib/arrow/object.rb +117 -0
- data/lib/arrow/path.rb +196 -0
- data/lib/arrow/service.rb +447 -0
- data/lib/arrow/session.rb +289 -0
- data/lib/arrow/session/dbstore.rb +100 -0
- data/lib/arrow/session/filelock.rb +160 -0
- data/lib/arrow/session/filestore.rb +132 -0
- data/lib/arrow/session/id.rb +98 -0
- data/lib/arrow/session/lock.rb +253 -0
- data/lib/arrow/session/md5id.rb +42 -0
- data/lib/arrow/session/nulllock.rb +42 -0
- data/lib/arrow/session/posixlock.rb +166 -0
- data/lib/arrow/session/sha1id.rb +54 -0
- data/lib/arrow/session/store.rb +366 -0
- data/lib/arrow/session/usertrackid.rb +52 -0
- data/lib/arrow/spechelpers.rb +73 -0
- data/lib/arrow/template.rb +713 -0
- data/lib/arrow/template/attr.rb +31 -0
- data/lib/arrow/template/call.rb +31 -0
- data/lib/arrow/template/comment.rb +33 -0
- data/lib/arrow/template/container.rb +118 -0
- data/lib/arrow/template/else.rb +41 -0
- data/lib/arrow/template/elsif.rb +44 -0
- data/lib/arrow/template/escape.rb +53 -0
- data/lib/arrow/template/export.rb +87 -0
- data/lib/arrow/template/for.rb +145 -0
- data/lib/arrow/template/if.rb +78 -0
- data/lib/arrow/template/import.rb +119 -0
- data/lib/arrow/template/include.rb +206 -0
- data/lib/arrow/template/iterator.rb +208 -0
- data/lib/arrow/template/nodes.rb +734 -0
- data/lib/arrow/template/parser.rb +571 -0
- data/lib/arrow/template/prettyprint.rb +53 -0
- data/lib/arrow/template/render.rb +191 -0
- data/lib/arrow/template/selectlist.rb +94 -0
- data/lib/arrow/template/set.rb +87 -0
- data/lib/arrow/template/timedelta.rb +81 -0
- data/lib/arrow/template/unless.rb +78 -0
- data/lib/arrow/template/urlencode.rb +51 -0
- data/lib/arrow/template/yield.rb +139 -0
- data/lib/arrow/templatefactory.rb +125 -0
- data/lib/arrow/testcase.rb +567 -0
- data/lib/arrow/transaction.rb +608 -0
- data/rake/191_compat.rb +26 -0
- data/rake/dependencies.rb +76 -0
- data/rake/documentation.rb +114 -0
- data/rake/helpers.rb +502 -0
- data/rake/hg.rb +282 -0
- data/rake/manual.rb +787 -0
- data/rake/packaging.rb +129 -0
- data/rake/publishing.rb +278 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +668 -0
- data/rake/testing.rb +187 -0
- data/rake/verifytask.rb +64 -0
- data/spec/arrow/acceptparam_spec.rb +157 -0
- data/spec/arrow/applet_spec.rb +575 -0
- data/spec/arrow/appletmixins_spec.rb +409 -0
- data/spec/arrow/appletregistry_spec.rb +294 -0
- data/spec/arrow/broker_spec.rb +153 -0
- data/spec/arrow/config_spec.rb +224 -0
- data/spec/arrow/cookieset_spec.rb +164 -0
- data/spec/arrow/dispatcher_spec.rb +137 -0
- data/spec/arrow/dispatcherloader_spec.rb +65 -0
- data/spec/arrow/formvalidator_spec.rb +781 -0
- data/spec/arrow/logger_spec.rb +346 -0
- data/spec/arrow/mixins_spec.rb +120 -0
- data/spec/arrow/service_spec.rb +645 -0
- data/spec/arrow/session_spec.rb +121 -0
- data/spec/arrow/template/iterator_spec.rb +222 -0
- data/spec/arrow/templatefactory_spec.rb +185 -0
- data/spec/arrow/transaction_spec.rb +319 -0
- data/spec/arrow_spec.rb +37 -0
- data/spec/lib/appletmatchers.rb +281 -0
- data/spec/lib/constants.rb +77 -0
- data/spec/lib/helpers.rb +41 -0
- data/spec/lib/matchers.rb +44 -0
- data/tests/cookie.tests.rb +310 -0
- data/tests/path.tests.rb +157 -0
- data/tests/session.tests.rb +111 -0
- data/tests/session_id.tests.rb +82 -0
- data/tests/session_lock.tests.rb +191 -0
- data/tests/session_store.tests.rb +53 -0
- data/tests/template.tests.rb +1360 -0
- metadata +339 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'arrow/exceptions'
|
4
|
+
require 'arrow/path'
|
5
|
+
require 'arrow/template/nodes'
|
6
|
+
|
7
|
+
# The Arrow::Arrow::Template::AttrDirective class, a derivative of Arrow::Directive.
|
8
|
+
# This is the class which defines the behaviour of the 'attr' template directive.
|
9
|
+
#
|
10
|
+
# == Syntax
|
11
|
+
#
|
12
|
+
# <?attr foo ?>
|
13
|
+
# <?attr "%0.2f" % foo ?>
|
14
|
+
#
|
15
|
+
# == Authors
|
16
|
+
#
|
17
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
18
|
+
#
|
19
|
+
# Please see the file LICENSE in the top-level directory for licensing details.
|
20
|
+
#
|
21
|
+
class Arrow::Template::AttrDirective < Arrow::Template::AttributeDirective # :nodoc:
|
22
|
+
|
23
|
+
# SVN Revision
|
24
|
+
SVNRev = %q$Rev$
|
25
|
+
|
26
|
+
# SVN Id
|
27
|
+
SVNId = %q$Id$
|
28
|
+
|
29
|
+
|
30
|
+
end # class Arrow::Template::AttrDirective
|
31
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'arrow/exceptions'
|
4
|
+
require 'arrow/path'
|
5
|
+
require 'arrow/template/nodes'
|
6
|
+
|
7
|
+
# The Arrow::Template::CallDirective class, a derivative of
|
8
|
+
# Arrow::Template::AttributeDirective. This is the class which defines the
|
9
|
+
# behaviour of the 'call' template directive.
|
10
|
+
#
|
11
|
+
# == Syntax
|
12
|
+
#
|
13
|
+
# <?call foo.to_html ?>
|
14
|
+
# <?call var.any(other_var.method).chain ?>
|
15
|
+
# <?call "$%0.2f" % var.any(other_var.method).chain ?>
|
16
|
+
#
|
17
|
+
# == Authors
|
18
|
+
#
|
19
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
20
|
+
#
|
21
|
+
# Please see the file LICENSE in the top-level directory for licensing details.
|
22
|
+
#
|
23
|
+
class Arrow::Template::CallDirective < Arrow::Template::AttributeDirective # :nodoc:
|
24
|
+
|
25
|
+
# SVN Revision
|
26
|
+
SVNRev = %q$Rev$
|
27
|
+
|
28
|
+
# SVN Id
|
29
|
+
SVNId = %q$Id$
|
30
|
+
|
31
|
+
end # class Arrow::Template::CallDirective
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'arrow/exceptions'
|
4
|
+
require 'arrow/path'
|
5
|
+
require 'arrow/template/nodes'
|
6
|
+
|
7
|
+
# The Arrow::Template::Comment class, a derivative of
|
8
|
+
# Arrow::Template::AttributeDirective. This is the class which defines
|
9
|
+
# the behaviour of the 'comment' template directive.
|
10
|
+
#
|
11
|
+
# == VCS Id
|
12
|
+
#
|
13
|
+
# $Id$
|
14
|
+
#
|
15
|
+
# == Authors
|
16
|
+
#
|
17
|
+
# * Mahlon E. Smith <mahlon@martini.nu>
|
18
|
+
#
|
19
|
+
# Please see the file LICENSE in the top-level directory for licensing details.
|
20
|
+
#
|
21
|
+
class Arrow::Template::CommentDirective < Arrow::Template::AttributeDirective # :nodoc:
|
22
|
+
|
23
|
+
######
|
24
|
+
public
|
25
|
+
######
|
26
|
+
|
27
|
+
### Return an empty string instead of rendering anything within
|
28
|
+
### a comment directive.
|
29
|
+
def render( template, scope )
|
30
|
+
return ''
|
31
|
+
end
|
32
|
+
|
33
|
+
end # class Arrow::Template::CommentDirective
|
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
require 'arrow/exceptions'
|
6
|
+
require 'arrow/path'
|
7
|
+
|
8
|
+
# The Arrow::Template::Container class, a derivative of
|
9
|
+
# Arrow::Object. Instances of this class are stateful containers for
|
10
|
+
# ContainerDirective nodes .
|
11
|
+
#
|
12
|
+
# == Authors
|
13
|
+
#
|
14
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
15
|
+
#
|
16
|
+
# Please see the file LICENSE in the top-level directory for licensing details.
|
17
|
+
#
|
18
|
+
class Arrow::Template::Container < Arrow::Object
|
19
|
+
extend Forwardable
|
20
|
+
include Enumerable
|
21
|
+
|
22
|
+
# SVN Revision
|
23
|
+
SVNRev = %q$Rev$
|
24
|
+
|
25
|
+
# SVN Id
|
26
|
+
SVNId = %q$Id$
|
27
|
+
|
28
|
+
# The methods of collections which are delegated to their contents Array
|
29
|
+
DelegatedMethods =
|
30
|
+
( (Array.instance_methods(false) | Enumerable.instance_methods(false)) -
|
31
|
+
%w{<<} )
|
32
|
+
|
33
|
+
#############################################################
|
34
|
+
### I N S T A N C E M E T H O D S
|
35
|
+
#############################################################
|
36
|
+
|
37
|
+
### Create a new Arrow::Template::Container object with the given +name+
|
38
|
+
### and +contents+.
|
39
|
+
def initialize( name, *contents )
|
40
|
+
@name = name
|
41
|
+
@contents = contents
|
42
|
+
|
43
|
+
@sortblock = nil
|
44
|
+
@filters = []
|
45
|
+
|
46
|
+
super()
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
######
|
52
|
+
public
|
53
|
+
######
|
54
|
+
|
55
|
+
# Delegate index methods to contents
|
56
|
+
def_delegators :@contents, *DelegatedMethods
|
57
|
+
|
58
|
+
# The contents of the container
|
59
|
+
attr_accessor :contents
|
60
|
+
|
61
|
+
# The name of the container
|
62
|
+
attr_reader :name
|
63
|
+
|
64
|
+
# The Array of transform functions applied to this container at render
|
65
|
+
# time, in the order in which they will be applied.
|
66
|
+
attr_reader :filters
|
67
|
+
|
68
|
+
# The sort block associated with the container.
|
69
|
+
attr_reader :sortblock
|
70
|
+
|
71
|
+
|
72
|
+
### Add the given object/s to this container.
|
73
|
+
def <<( object )
|
74
|
+
@contents << object
|
75
|
+
return self
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
### Add the specified filter +block+ to the container. When the
|
80
|
+
### container is used in a render, the filter block will be called once
|
81
|
+
### for each contained object and whatever it returns will be used
|
82
|
+
### instead of the original.
|
83
|
+
def addFilter( &block )
|
84
|
+
@filters << block
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
### Add the specified sort +block+ to the container. When the container
|
89
|
+
### is used in a render, its contents will be used in the order returned
|
90
|
+
### from the sort block.
|
91
|
+
def setSort( &block )
|
92
|
+
@sortblock = block
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
### Iterate over the contents of this container after applying filters,
|
97
|
+
### sort blocks, etc. to them.
|
98
|
+
def each( &block )
|
99
|
+
raise LocalJumpError, "no block given" unless block_given?
|
100
|
+
|
101
|
+
contents = @contents.dup
|
102
|
+
contents.sort!( &@sortblock ) if @sortblock
|
103
|
+
@filters.each {|filter|
|
104
|
+
contents = contents.collect( &filter )
|
105
|
+
}
|
106
|
+
|
107
|
+
Arrow::Template::Iterator.new( *contents ).each( &block )
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
### Return the last value to be set in this container
|
112
|
+
def last
|
113
|
+
@contents.last
|
114
|
+
end
|
115
|
+
|
116
|
+
end # class Arrow::Template::Container
|
117
|
+
|
118
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'arrow/exceptions'
|
4
|
+
require 'arrow/path'
|
5
|
+
require 'arrow/template/nodes'
|
6
|
+
|
7
|
+
# The Arrow::Template::ElseDirective class, a derivative of
|
8
|
+
# Arrow::Template::Directive. This is the class which defines the behaviour of
|
9
|
+
# the 'else' template directive.
|
10
|
+
#
|
11
|
+
# == Authors
|
12
|
+
#
|
13
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
14
|
+
#
|
15
|
+
# Please see the file LICENSE in the top-level directory for licensing details.
|
16
|
+
#
|
17
|
+
class Arrow::Template::ElseDirective < Arrow::Template::Directive # :nodoc:
|
18
|
+
|
19
|
+
# SVN Revision
|
20
|
+
SVNRev = %q$Rev$
|
21
|
+
|
22
|
+
# SVN Id
|
23
|
+
SVNId = %q$Id$
|
24
|
+
|
25
|
+
|
26
|
+
#############################################################
|
27
|
+
### I N S T A N C E M E T H O D S
|
28
|
+
#############################################################
|
29
|
+
|
30
|
+
### Create a new Arrow::Template::ElsifDirective object.
|
31
|
+
def initialize( body, parser, state )
|
32
|
+
unless state.current_branch_node.is_a?( Arrow::Template::ConditionalDirective )
|
33
|
+
raise Arrow::TemplateError,
|
34
|
+
"else outside of conditional directive (%p)" %
|
35
|
+
state.current_branch_node
|
36
|
+
end
|
37
|
+
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
end # class Arrow::Template::ElseDirective
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'arrow/exceptions'
|
4
|
+
require 'arrow/path'
|
5
|
+
require 'arrow/template/nodes'
|
6
|
+
|
7
|
+
# The Arrow::Template::ElsifDirective class, a derivative of
|
8
|
+
# Arrow::Template::Directive. This is the class which defines the behaviour of
|
9
|
+
# the 'elsif' template directive.
|
10
|
+
#
|
11
|
+
# == Authors
|
12
|
+
#
|
13
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
14
|
+
#
|
15
|
+
# Please see the file LICENSE in the top-level directory for licensing details.
|
16
|
+
#
|
17
|
+
class Arrow::Template::ElsifDirective < Arrow::Template::AttributeDirective # :nodoc:
|
18
|
+
include Arrow::Template::ConditionalDirective
|
19
|
+
|
20
|
+
# SVN Revision
|
21
|
+
SVNRev = %q$Rev$
|
22
|
+
|
23
|
+
# SVN Id
|
24
|
+
SVNId = %q$Id$
|
25
|
+
|
26
|
+
|
27
|
+
#############################################################
|
28
|
+
### I N S T A N C E M E T H O D S
|
29
|
+
#############################################################
|
30
|
+
|
31
|
+
### Create a new Arrow::Template::ElsifDirective object.
|
32
|
+
def initialize( body, parser, state )
|
33
|
+
unless state.current_branch_node.is_a?( Arrow::Template::ConditionalDirective )
|
34
|
+
raise Arrow::TemplateError,
|
35
|
+
"elsif outside of conditional directive (%p)" %
|
36
|
+
state.current_branch_node
|
37
|
+
end
|
38
|
+
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end # class Arrow::Template::Elsif
|
44
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'arrow/exceptions'
|
4
|
+
require 'arrow/path'
|
5
|
+
require 'arrow/template/call'
|
6
|
+
|
7
|
+
# The Arrow::Template::EscapeDirective class, a derivative of
|
8
|
+
# Arrow::Template::CallDirective. This is the class which defines the behaviour
|
9
|
+
# of the 'escape' template directive., which HTML escapes the stringified
|
10
|
+
# version of its associated attribute/s.
|
11
|
+
#
|
12
|
+
# == Syntax
|
13
|
+
#
|
14
|
+
# <pre><?escape data.to_yaml?></pre>
|
15
|
+
# <?escape some_string_with_htmlish_bits?>
|
16
|
+
#
|
17
|
+
# == Authors
|
18
|
+
#
|
19
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
20
|
+
#
|
21
|
+
# Please see the file LICENSE in the top-level directory for licensing details.
|
22
|
+
#
|
23
|
+
class Arrow::Template::EscapeDirective < Arrow::Template::CallDirective # :nodoc:
|
24
|
+
|
25
|
+
# SVN Revision
|
26
|
+
SVNRev = %q$Rev$
|
27
|
+
|
28
|
+
# SVN Id
|
29
|
+
SVNId = %q$Id$
|
30
|
+
|
31
|
+
|
32
|
+
### Render the content and return it as HTML-escaped text.
|
33
|
+
def render( template, scope )
|
34
|
+
rawary = super
|
35
|
+
rary = []
|
36
|
+
|
37
|
+
# Try our best to skip debugging comments
|
38
|
+
if template._config[:debuggingComments]
|
39
|
+
rary.push( rawary.shift ) if /^<!--.*-->$/ =~ rawary.first
|
40
|
+
end
|
41
|
+
|
42
|
+
rawary.each do |line|
|
43
|
+
rary << line.to_s.
|
44
|
+
gsub( /&/, '&' ).
|
45
|
+
gsub( /</, '<' ).
|
46
|
+
gsub( />/, '>' ).
|
47
|
+
gsub( /"/, '"' )
|
48
|
+
end
|
49
|
+
|
50
|
+
return rary
|
51
|
+
end
|
52
|
+
|
53
|
+
end # class Arrow::Template::Escape
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'arrow/exceptions'
|
4
|
+
require 'arrow/path'
|
5
|
+
require 'arrow/template/nodes'
|
6
|
+
|
7
|
+
#
|
8
|
+
# The Arrow::Template::ExportDirective class, a derivative of
|
9
|
+
# Arrow::Template::BracketingDirective. This is the class which defines the
|
10
|
+
# behaviour of the 'export' template directive.
|
11
|
+
#
|
12
|
+
# == Syntax
|
13
|
+
#
|
14
|
+
# <?export foo ?>
|
15
|
+
# <!-- Some content for 'foo' attributes of enclosing templates. -->
|
16
|
+
# <?end?>
|
17
|
+
#
|
18
|
+
# == VCS Id
|
19
|
+
#
|
20
|
+
# $Id$
|
21
|
+
#
|
22
|
+
# == Authors
|
23
|
+
#
|
24
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
25
|
+
#
|
26
|
+
# Please see the file LICENSE in the top-level directory for licensing details.
|
27
|
+
#
|
28
|
+
class Arrow::Template::ExportDirective < Arrow::Template::BracketingDirective # :nodoc:
|
29
|
+
include Arrow::Template::Parser::Patterns
|
30
|
+
|
31
|
+
# SVN Revision
|
32
|
+
SVNRev = %q$Rev$
|
33
|
+
|
34
|
+
# SVN Id
|
35
|
+
SVNId = %q$Id$
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
#############################################################
|
40
|
+
### C L A S S M E T H O D S
|
41
|
+
#############################################################
|
42
|
+
|
43
|
+
### Disallow formats and methodchains
|
44
|
+
def self::allows_format?; false; end
|
45
|
+
def self::allows_method_chains?; false; end
|
46
|
+
|
47
|
+
|
48
|
+
#############################################################
|
49
|
+
### I N S T A N C E M E T H O D S
|
50
|
+
#############################################################
|
51
|
+
|
52
|
+
### Add the imported attributes when this node is rendered.
|
53
|
+
def before_rendering( template )
|
54
|
+
st = template
|
55
|
+
|
56
|
+
while st = st._enclosing_template
|
57
|
+
surrogate = template.class.new( self.subnodes )
|
58
|
+
|
59
|
+
# :TODO: Does appending to the attribute make more sense?
|
60
|
+
st._attributes[ self.name ] = surrogate
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
### Add attributes contained by subnodes, but not the attribute
|
66
|
+
### for this node itself, which will be looked for in the
|
67
|
+
### enclosing template.
|
68
|
+
def add_to_template( template ) # :nodoc:
|
69
|
+
self.subnodes.each do |node|
|
70
|
+
template.install_node( node )
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
#########
|
76
|
+
protected
|
77
|
+
#########
|
78
|
+
|
79
|
+
### Override the default behavior, which is to render subnodes. Since the
|
80
|
+
### whole point of this directive is to give content to a containing
|
81
|
+
### template, this becomes a no-op.
|
82
|
+
def render_contents( template, scope )
|
83
|
+
return []
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
end # class Arrow::Template::ExportDirective
|