PageTemplate 2.1.5 → 2.1.6
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/Changes +6 -3
- data/Rakefile +1 -1
- data/lib/PageTemplate/parser.rb +9 -2
- data/test.rb +11 -0
- metadata +1 -28
- data/site/Makefile +0 -15
- data/site/MySubpageRenderer.rb +0 -43
- data/site/PageNavRenderer.rb +0 -37
- data/site/RedClothRenderer.rb +0 -20
- data/site/Site.rb +0 -11
- data/site/SiteNewsRenderer.rb +0 -23
- data/site/XhtmlTemplateRenderer.rb +0 -141
- data/site/base.css +0 -4
- data/site/footer.txt +0 -2
- data/site/header.txt +0 -2
- data/site/html/SiteMap.html +0 -43
- data/site/html/base.css +0 -4
- data/site/html/designer.html +0 -524
- data/site/html/index.html +0 -267
- data/site/html/install.html +0 -125
- data/site/html/programmer.html +0 -289
- data/site/html/version2.html +0 -103
- data/site/src/SiteMap +0 -8
- data/site/src/designer +0 -410
- data/site/src/index +0 -165
- data/site/src/install +0 -80
- data/site/src/metadata.txt +0 -4
- data/site/src/programmer +0 -235
- data/site/src/version2 +0 -59
data/Changes
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
|
1
|
+
2.1.3:
|
2
2
|
Bugfixes:
|
3
3
|
HTGlossary didn't survive the change from 2.0 to 2.1. I've
|
4
4
|
added unit tests and fixed the HTGlossary bugs. Whoops.
|
5
5
|
setup.rb attempted to chmod every directory in its path on install.
|
6
6
|
Report and fix by: Lars Olsson
|
7
7
|
Changes:
|
8
|
+
__INDEX__ added to LoopCommand objects. It's 0-based, but if a
|
9
|
+
designer wants 1-based, then can do:
|
10
|
+
[% var __INDEX__.succ %]
|
8
11
|
If a glossary directive has multiple captures, PT will use
|
9
12
|
the first non-nil one.
|
10
|
-
Namespaces now use parser.
|
11
|
-
by PageTemplate.new('
|
13
|
+
Namespaces now use parser.method_separators. Defined on creation
|
14
|
+
by PageTemplate.new('method_separators' => './').
|
12
15
|
Inspired by Jeremy Apthorp and YAML paths.
|
13
16
|
|
14
17
|
2.1.2:
|
data/Rakefile
CHANGED
data/lib/PageTemplate/parser.rb
CHANGED
@@ -69,11 +69,18 @@ class PageTemplate
|
|
69
69
|
return @parent.get(val) if @parent
|
70
70
|
return nil
|
71
71
|
when @object.respond_to?(:has_key?)
|
72
|
-
|
72
|
+
if @object.has_key?(key)
|
73
|
+
@values[key] = @object[key]
|
74
|
+
else
|
75
|
+
return @parent.get(val) if @parent
|
76
|
+
nil
|
77
|
+
end
|
73
78
|
when @object.respond_to?(sym = key.to_sym)
|
74
79
|
@values[key] = @object.send(sym)
|
75
80
|
when key == '__ITEM__'
|
76
81
|
@object
|
82
|
+
when @parent
|
83
|
+
return @parent.get(val)
|
77
84
|
else
|
78
85
|
nil
|
79
86
|
end
|
@@ -348,7 +355,7 @@ class PageTemplate
|
|
348
355
|
when /^(?:elsif|elseif|else if) (.+)$/i
|
349
356
|
cmd.elsif($1)
|
350
357
|
true
|
351
|
-
when /^else|no|empty$/i
|
358
|
+
when /^(else|no|empty)$/i
|
352
359
|
cmd.else
|
353
360
|
true
|
354
361
|
else
|
data/test.rb
CHANGED
@@ -409,6 +409,17 @@ module TestPageTemplate
|
|
409
409
|
@@ns = PageTemplate::Namespace.new
|
410
410
|
end
|
411
411
|
|
412
|
+
def test_nested_namespaces
|
413
|
+
@@ns.object = {'meat'=>'Caribou Eyes'}
|
414
|
+
p = PageTemplate::Namespace.new
|
415
|
+
@@ns.parent = p
|
416
|
+
p['soda'] = 'Ebola Cola' # Transmetropolitan! Read it!
|
417
|
+
assert_equal(@@ns.get('meat'),'Caribou Eyes',
|
418
|
+
'Namespace#get(meat) did not return correct value!')
|
419
|
+
assert_equal(@@ns.get('soda'),'Ebola Cola',
|
420
|
+
'Namespace#get(meat) did not return parent\'s correct value!')
|
421
|
+
end
|
422
|
+
|
412
423
|
def test_clear_cache
|
413
424
|
assert(@@ns.clear_cache,
|
414
425
|
"Use Namespace#clear_cache to reset a Namespace's values.")
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: PageTemplate
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 2.1.
|
6
|
+
version: 2.1.6
|
7
7
|
date: 2006-01-04 00:00:00 -08:00
|
8
8
|
summary: A simple templating system for Web sites.
|
9
9
|
require_paths:
|
@@ -36,7 +36,6 @@ files:
|
|
36
36
|
- README.txt
|
37
37
|
- setup-usage.txt
|
38
38
|
- setup.rb
|
39
|
-
- site
|
40
39
|
- tdata
|
41
40
|
- test-install.rb
|
42
41
|
- test.rb
|
@@ -46,32 +45,6 @@ files:
|
|
46
45
|
- lib/PageTemplate/commands.rb
|
47
46
|
- lib/PageTemplate/htglossary.rb
|
48
47
|
- lib/PageTemplate/parser.rb
|
49
|
-
- site/base.css
|
50
|
-
- site/footer.txt
|
51
|
-
- site/header.txt
|
52
|
-
- site/html
|
53
|
-
- site/Makefile
|
54
|
-
- site/MySubpageRenderer.rb
|
55
|
-
- site/PageNavRenderer.rb
|
56
|
-
- site/RedClothRenderer.rb
|
57
|
-
- site/Site.rb
|
58
|
-
- site/SiteNewsRenderer.rb
|
59
|
-
- site/src
|
60
|
-
- site/XhtmlTemplateRenderer.rb
|
61
|
-
- site/html/base.css
|
62
|
-
- site/html/designer.html
|
63
|
-
- site/html/index.html
|
64
|
-
- site/html/install.html
|
65
|
-
- site/html/programmer.html
|
66
|
-
- site/html/SiteMap.html
|
67
|
-
- site/html/version2.html
|
68
|
-
- site/src/designer
|
69
|
-
- site/src/index
|
70
|
-
- site/src/install
|
71
|
-
- site/src/metadata.txt
|
72
|
-
- site/src/programmer
|
73
|
-
- site/src/SiteMap
|
74
|
-
- site/src/version2
|
75
48
|
- tdata/dummy.txt
|
76
49
|
test_files:
|
77
50
|
- test.rb
|
data/site/Makefile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
all: site css
|
2
|
-
css:
|
3
|
-
cp base.css html/
|
4
|
-
site:
|
5
|
-
ruby Site.rb
|
6
|
-
images: site
|
7
|
-
mkdir html/images
|
8
|
-
cp extras/images/* html/images/
|
9
|
-
doc:
|
10
|
-
cp -R extras/doc/PageTemplate html/doc
|
11
|
-
clean:
|
12
|
-
rm -rf html
|
13
|
-
|
14
|
-
test-install:
|
15
|
-
sudo cp -Rf html/* /var/www/html
|
data/site/MySubpageRenderer.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'ZenWeb/GenericRenderer'
|
2
|
-
|
3
|
-
=begin
|
4
|
-
|
5
|
-
= Class SubpageRenderer
|
6
|
-
|
7
|
-
Generates a list of known subpages in a format compatible with
|
8
|
-
TextToHtmlRenderer.
|
9
|
-
|
10
|
-
=== Methods
|
11
|
-
|
12
|
-
=end
|
13
|
-
|
14
|
-
class MySubpageRenderer < GenericRenderer
|
15
|
-
|
16
|
-
=begin
|
17
|
-
|
18
|
-
--- SubpageRenderer#render(content)
|
19
|
-
|
20
|
-
Renders a list of known subpages in a format compatible with
|
21
|
-
TextToHtmlRenderer. Adds the list to the end of the content.
|
22
|
-
|
23
|
-
=end
|
24
|
-
|
25
|
-
def render(content)
|
26
|
-
subpages = @document.subpages.clone
|
27
|
-
if (subpages.length > 0) then
|
28
|
-
push("\n\n")
|
29
|
-
push("<h2>Subpages:</h2>\n\n")
|
30
|
-
subpages.each_index { | index |
|
31
|
-
url = subpages[index]
|
32
|
-
doc = @website[url]
|
33
|
-
title = doc.fulltitle
|
34
|
-
|
35
|
-
push("* <A HREF=\"#{url}\">#{title}</A>\n")
|
36
|
-
}
|
37
|
-
push("\n")
|
38
|
-
end
|
39
|
-
|
40
|
-
return content + self.result
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
data/site/PageNavRenderer.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'ZenWeb/GenericRenderer'
|
2
|
-
|
3
|
-
class PageNavRenderer < GenericRenderer
|
4
|
-
def render(content)
|
5
|
-
# I know there's a quicker way to do this, but I'm in a hurry.
|
6
|
-
this_url = @document.url
|
7
|
-
doc_order = @sitemap.doc_order
|
8
|
-
this_index = doc_order.index(this_url)
|
9
|
-
forward = backward = " "
|
10
|
-
|
11
|
-
last_url = doc_order[this_index - 1]
|
12
|
-
last_page = @sitemap.documents[last_url]
|
13
|
-
if last_page and File.dirname(last_url) == File.dirname(this_url)
|
14
|
-
title = last_page.title
|
15
|
-
url = File.basename(last_url)
|
16
|
-
backward = "<p><- <a href='#{url}'>#{title}</a></p>\n"
|
17
|
-
end
|
18
|
-
|
19
|
-
next_url = doc_order[this_index + 1]
|
20
|
-
next_page = @sitemap.documents[next_url]
|
21
|
-
if next_page and File.dirname(next_url) == File.dirname(this_url)
|
22
|
-
title = next_page.title
|
23
|
-
url = File.basename(next_url)
|
24
|
-
forward = "<p><a href='#{url}'>#{title}</a>- ></p>\n"
|
25
|
-
end
|
26
|
-
|
27
|
-
push("<table width='100%' border='0'><tr>\n")
|
28
|
-
push("<td>#{backward}</td>\n")
|
29
|
-
push("<td align='right'>#{forward}</td>\n")
|
30
|
-
push("</tr></table>\n")
|
31
|
-
|
32
|
-
push(content)
|
33
|
-
|
34
|
-
return self.result
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
data/site/RedClothRenderer.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'ZenWeb/GenericRenderer'
|
2
|
-
|
3
|
-
# Hands content off to the RedCloth text formatter for rendering.
|
4
|
-
#
|
5
|
-
# + Set Attributes in the 'RedClothAttributes' metadata.
|
6
|
-
# + filter_html -- HTML not created by RedCloth is escaped
|
7
|
-
# + filter_styles -- style markup specifier is disabled
|
8
|
-
# + See http://www.whytheluckystiff.net/ruby/redcloth/
|
9
|
-
class RedClothRenderer < GenericRenderer
|
10
|
-
require 'redcloth'
|
11
|
-
|
12
|
-
def render(content)
|
13
|
-
attributes = []
|
14
|
-
if @document.metadata.has_key?('RedClothAttributes')
|
15
|
-
attributes = @document['RedClothAttributes']
|
16
|
-
end
|
17
|
-
rc = RedCloth::new(content, attributes)
|
18
|
-
return rc.to_html(:textile)
|
19
|
-
end
|
20
|
-
end
|
data/site/Site.rb
DELETED
data/site/SiteNewsRenderer.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'ZenWeb/GenericRenderer'
|
2
|
-
|
3
|
-
class SiteNewsRenderer < GenericRenderer
|
4
|
-
require 'yaml'
|
5
|
-
|
6
|
-
def render(content)
|
7
|
-
newsfile = 'news.yml'
|
8
|
-
newsitems = YAML.load(File.open(newsfile).read())
|
9
|
-
limit = @document['NewsLimit']
|
10
|
-
|
11
|
-
if newsitems
|
12
|
-
newsitems.each do |item|
|
13
|
-
push("\n<div class='newsitem'>\n\nh3. #{item['title']}\n\np(date). #{item['date']}\n\n#{item['content']}\n</div>\n")
|
14
|
-
if limit
|
15
|
-
limit -= 1
|
16
|
-
break if limit == 0
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
return self.result
|
22
|
-
end
|
23
|
-
end
|
@@ -1,141 +0,0 @@
|
|
1
|
-
require 'ZenWeb/HtmlRenderer'
|
2
|
-
|
3
|
-
=begin
|
4
|
-
|
5
|
-
= Class HtmlTemplateRenderer
|
6
|
-
|
7
|
-
Generates a consistant HTML page header and footer, including a
|
8
|
-
navigation bar, title, subtitle, and appropriate META tags.
|
9
|
-
|
10
|
-
=== Methods
|
11
|
-
|
12
|
-
=end
|
13
|
-
|
14
|
-
class XhtmlTemplateRenderer < HtmlRenderer
|
15
|
-
|
16
|
-
=begin
|
17
|
-
|
18
|
-
--- HtmlTemplateRenderer#render(content)
|
19
|
-
|
20
|
-
Renders a standardized HTML header and footer. This currently also
|
21
|
-
includes a navigation bar and a list of subpages, which will
|
22
|
-
probably be broken out to their own renderers soon.
|
23
|
-
|
24
|
-
Metadata variables used:
|
25
|
-
|
26
|
-
+ author
|
27
|
-
+ banner - graphic at the top of the page, usually a logo
|
28
|
-
+ bgcolor - defaults to not being defined
|
29
|
-
+ copyright
|
30
|
-
+ description
|
31
|
-
+ dtd (default: 'DTD HTML 4.0 Transitional')
|
32
|
-
+ email - used in a mailto in metadata
|
33
|
-
+ keywords
|
34
|
-
+ rating (default: 'general')
|
35
|
-
+ stylesheet - reference to a CSS file
|
36
|
-
+ style - CSS code directly (for smaller snippets)
|
37
|
-
+ subtitle
|
38
|
-
+ title (default: 'Unknown Title')
|
39
|
-
+ icbm - longitude and latitude for geourl.org
|
40
|
-
+ icbm_title - defaults to the page title
|
41
|
-
|
42
|
-
=end
|
43
|
-
|
44
|
-
def render(content)
|
45
|
-
author = @document['author']
|
46
|
-
banner = @document['banner']
|
47
|
-
bgcolor = @document['bgcolor']
|
48
|
-
dtd = @document['dtd'] || 'DTD HTML 4.0 Transitional'
|
49
|
-
copyright = @document['copyright']
|
50
|
-
description = @document['description']
|
51
|
-
email = @document['email']
|
52
|
-
keywords = @document['keywords']
|
53
|
-
rating = @document['rating'] || 'general'
|
54
|
-
stylesheet = @document['stylesheet']
|
55
|
-
subtitle = @document['subtitle']
|
56
|
-
title = @document['title'] || 'Unknown Title'
|
57
|
-
icbm = @document['icbm']
|
58
|
-
icbm_title = @document['icbm_title'] || @document['title']
|
59
|
-
charset = @document['charset']
|
60
|
-
style = @document['style']
|
61
|
-
|
62
|
-
titletext = @document.fulltitle
|
63
|
-
|
64
|
-
# TODO: iterate over a list of metas and add them in one nicely organized block
|
65
|
-
|
66
|
-
# header
|
67
|
-
push([
|
68
|
-
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">',
|
69
|
-
"<head>\n",
|
70
|
-
"<title>#{titletext}</title>\n",
|
71
|
-
stylesheet ? "<link rel=\"STYLESHEET\" href=\"#{stylesheet}\" type=\"text/css\" title=\"#{stylesheet}\">\n" : [],
|
72
|
-
style ? "<style>\n#{style}\n</style>" : [],
|
73
|
-
"</head>\n",
|
74
|
-
"<body>\n"
|
75
|
-
])
|
76
|
-
|
77
|
-
self.navbar
|
78
|
-
|
79
|
-
if banner then
|
80
|
-
push("<img src=\"#{banner}\" /><br />\n")
|
81
|
-
unless (subtitle) then
|
82
|
-
push("<h3>#{title}</h3>\n")
|
83
|
-
end
|
84
|
-
else
|
85
|
-
push("<h1>#{title}</h1>\n")
|
86
|
-
end
|
87
|
-
|
88
|
-
push([
|
89
|
-
subtitle ? "<h2>#{subtitle}</h2>\n" : [],
|
90
|
-
"<hr />\n\n",
|
91
|
-
content,
|
92
|
-
"<hr />\n\n",
|
93
|
-
])
|
94
|
-
|
95
|
-
self.navbar
|
96
|
-
|
97
|
-
push("\n</body>\n</html>\n")
|
98
|
-
|
99
|
-
return self.result
|
100
|
-
end
|
101
|
-
|
102
|
-
=begin
|
103
|
-
|
104
|
-
--- HtmlTemplateRenderer#navbar
|
105
|
-
|
106
|
-
Generates a navbar that contains a link to the sitemap, search
|
107
|
-
page (if any), and a fake "breadcrumbs" trail which is really just
|
108
|
-
a list of all of the parent titles up the chain to the top.
|
109
|
-
|
110
|
-
=end
|
111
|
-
|
112
|
-
def navbar
|
113
|
-
|
114
|
-
sep = " / "
|
115
|
-
search = @website["/Search.html"]
|
116
|
-
|
117
|
-
push([
|
118
|
-
"<p class=\"navbar\">\n",
|
119
|
-
"<a href=\"#{@sitemap.url}\">Sitemap</a>",
|
120
|
-
search ? " | <a href=\"#{search.url}\"><em>Search</em></a>" : [],
|
121
|
-
" || ",
|
122
|
-
])
|
123
|
-
|
124
|
-
path = []
|
125
|
-
current = @document
|
126
|
-
while current and current != current.parent do
|
127
|
-
current = current.parent
|
128
|
-
path.unshift(current) if current
|
129
|
-
end
|
130
|
-
|
131
|
-
push([
|
132
|
-
path.map{|doc| ["<a href=\"#{doc.url}\">#{doc['title']}</a>\n", sep]},
|
133
|
-
@document['title'],
|
134
|
-
"</p>\n",
|
135
|
-
])
|
136
|
-
|
137
|
-
return []
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
data/site/base.css
DELETED
data/site/footer.txt
DELETED
data/site/header.txt
DELETED
data/site/html/SiteMap.html
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
2
|
-
<HTML>
|
3
|
-
<HEAD>
|
4
|
-
<TITLE>SiteMap: There are 6 pages in this website.</TITLE>
|
5
|
-
<LINK REL="STYLESHEET" HREF="base.css" type="text/css" title="base.css">
|
6
|
-
<META NAME="rating" CONTENT="general">
|
7
|
-
<META NAME="GENERATOR" CONTENT="ZenWeb v. 2.17.0 http://www.zenspider.com/ZSS/Products/ZenWeb/">
|
8
|
-
<META NAME="keywords" CONTENT="sitemap, website">
|
9
|
-
<META NAME="description" CONTENT="This page links to every page in the website.">
|
10
|
-
<link rel="up" href="index.html" title="PageTemplate">
|
11
|
-
<link rel="contents" href="" title="SiteMap">
|
12
|
-
<link rel="top" href="index.html" title="PageTemplate">
|
13
|
-
</HEAD>
|
14
|
-
<BODY>
|
15
|
-
<h1>Yo!</h1>
|
16
|
-
<hr />
|
17
|
-
<P class="navbar">
|
18
|
-
<A HREF="">Sitemap</A> || <A HREF="index.html">PageTemplate</A>
|
19
|
-
/ SiteMap</P>
|
20
|
-
<H1>SiteMap</H1>
|
21
|
-
<H2>There are 6 pages in this website.</H2>
|
22
|
-
<HR SIZE="3" NOSHADE>
|
23
|
-
|
24
|
-
<UL>
|
25
|
-
<LI><A HREF="index.html">PageTemplate</A></LI>
|
26
|
-
<LI><A HREF="install.html">Getting It</A></LI>
|
27
|
-
<LI><A HREF="designer.html">The Designer's Perspective</A></LI>
|
28
|
-
<LI><A HREF="programmer.html">The Programmer's Perspective</A></LI>
|
29
|
-
<LI><A HREF="version2.html">PageTemplate Version 2: What's New?</A></LI>
|
30
|
-
<LI><A HREF="">SiteMap: There are 6 pages in this website.</A></LI>
|
31
|
-
</UL>
|
32
|
-
<HR SIZE="3" NOSHADE>
|
33
|
-
|
34
|
-
<P class="navbar">
|
35
|
-
<A HREF="">Sitemap</A> || <A HREF="index.html">PageTemplate</A>
|
36
|
-
/ SiteMap</P>
|
37
|
-
|
38
|
-
<h1>Yo!</h1>
|
39
|
-
<hr />
|
40
|
-
<h1>Yo!</h1>
|
41
|
-
<hr />
|
42
|
-
</BODY>
|
43
|
-
</HTML>
|