[NBP web-reskin] [SCM] UNNAMED PROJECT branch, master,
updated. 5f2b8805417bba5f42f12eaac6587b161413f257
ethan at nbp.org
ethan at nbp.org
Mon Aug 10 12:33:59 EDT 2009
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "UNNAMED PROJECT".
The branch, master has been updated
via 5f2b8805417bba5f42f12eaac6587b161413f257 (commit)
via 5426096b8731b7c6f4fa0e05dfd3303014cfdc8a (commit)
via 6ab54fccaf3377f461808f154cd6dcb91c7e00c0 (commit)
from e8cf27ae7abd07a84d2d2a1f0ac5e639e0718996 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5f2b8805417bba5f42f12eaac6587b161413f257
Author: Ethan Rowe <ethan at endpoint.com>
Date: Mon Aug 10 12:32:33 2009 -0400
Clean up voices-of-our-readers to use the new [template] tag.
Note that the header/footer stuff is all stripped from these, and
instead they simply use [template header] and [template footer].
Along the way I cleaned up some quotation marks that probably came
from Windows-1252 or Latin-1, but don't play nice with the ASCII
encoding of this site.
commit 5426096b8731b7c6f4fa0e05dfd3303014cfdc8a
Author: Ethan Rowe <ethan at endpoint.com>
Date: Mon Aug 10 12:28:22 2009 -0400
Introduce new template usertag for easier template management.
The use of this tag is pretty simple: at the top of your page,
you do:
[template header]
And then at the bottom of your page:
[template footer]
This wraps around calls to NBP::Template which figures out what
template variables to include.
If you need to specify a different template prefix than what would
ordinarily be used by your current position in the system (based on the
path of the page relative to the catalog's pages/ directory), then you
can do so prior to invoking this tag:
[tmp template_prefix]SPECIAL_PREFIX[/tmp]
[template header]
...
[template footer]
(The above would include SPECIAL_PREFIX_TEMPLATE_TOP and
SPECIAL_PREFIX_TEMPLATE_BOTTOM, based on the value provided
to "template_prefix").
You can override the top and bottom template defaults, respectively,
via:
[tmp template_header]MY_HEADER_VARIABLE_NAME_HERE[/tmp]
[tmp template_footer]MY_FOOTER_VARIABLE_NAME_HERE[/tmp]
commit 6ab54fccaf3377f461808f154cd6dcb91c7e00c0
Author: Ethan Rowe <ethan at endpoint.com>
Date: Mon Aug 10 11:45:51 2009 -0400
Introduce NBP::Template for smarter template management.
Given the standard $::CGI and $::Scratch areas as "input", this
module provides logic to:
* programmatically determine "where" in the application the request
is (based on the page being processed) and determine what head/foot
templates to used based on that location.
* give $::Scratch variable "interface" for overriding the default
template determination, so any given page can specify alternate
templates as needed.
This has a unit test. Fancy that.
-----------------------------------------------------------------------
Summary of changes:
commit 5f2b8805417bba5f42f12eaac6587b161413f257
Author: Ethan Rowe <ethan at endpoint.com>
Date: Mon Aug 10 12:32:33 2009 -0400
Clean up voices-of-our-readers to use the new [template] tag.
Note that the header/footer stuff is all stripped from these, and
instead they simply use [template header] and [template footer].
Along the way I cleaned up some quotation marks that probably came
from Windows-1252 or Latin-1, but don't play nice with the ASCII
encoding of this site.
---
catalogs/nbp/pages/support/voices.html | 24 +-------------------
catalogs/nbp/pages/support/voices1.html | 36 ++++++-------------------------
catalogs/nbp/pages/support/voices2.html | 23 +------------------
catalogs/nbp/pages/support/voices3.html | 23 +------------------
catalogs/nbp/pages/support/voices4.html | 25 ++-------------------
catalogs/nbp/pages/support/voices5.html | 25 ++-------------------
catalogs/nbp/pages/support/voices6.html | 25 ++-------------------
catalogs/nbp/pages/support/voices7.html | 25 ++-------------------
catalogs/nbp/pages/support/voices8.html | 23 +------------------
9 files changed, 27 insertions(+), 202 deletions(-)
diff --git a/catalogs/nbp/pages/support/voices.html b/catalogs/nbp/pages/support/voices.html
index f27e721..ecb5f46 100644
--- a/catalogs/nbp/pages/support/voices.html
+++ b/catalogs/nbp/pages/support/voices.html
@@ -1,25 +1,5 @@
-[comment]
-ui_page: support/voices.html
-ui_type: page
-ui_name: support/voices.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Voices of Our Readers[/seti]
-
-[calc interpolate=0]
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-[/calc]
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
@@ -61,4 +41,4 @@ ui_page_version: 4.9.7
</div>
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
diff --git a/catalogs/nbp/pages/support/voices1.html b/catalogs/nbp/pages/support/voices1.html
index 6ec9bca..c0cdbc2 100644
--- a/catalogs/nbp/pages/support/voices1.html
+++ b/catalogs/nbp/pages/support/voices1.html
@@ -1,27 +1,5 @@
-[comment]
-ui_page: voices1.html
-ui_type: page
-ui_name: voices1.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Erik Weihenmayer[/seti]
-
-[calc interpolate=0]
-
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-
-[/calc]
-
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
<h1 class="contentheader">Erik Weihenmayer</h1>
@@ -32,22 +10,22 @@ ui_page_version: 4.9.7
<img src="/nbp/images/voices/weihenmeyer.jpg" width="260" style="float: right; clear: right; margin: 0px 0px 5px 5px;">
<p class="content">When I finally lost my sight after many years of gradual decline, I knew nothing about blindness. I had no action plan. I had
-not a clue how I would survive as a blind person. I couldnt accept myself as being blind. My life seemed to be going in
+not a clue how I would survive as a blind person. I couldn't accept myself as being blind. My life seemed to be going in
reverse. I was learning to read, to carry my own tray, to move around the hallway, all over again. My teenage mind cried out
-for freedom. Independence didnt come in leaping strides but in tiny successes, almost imperceptible. Although small, they
+for freedom. Independence didn't come in leaping strides but in tiny successes, almost imperceptible. Although small, they
gave me the courage to dream a little bigger.</p>
<p class="content">Learning braille was one of those successes. My braille teacher informed me that I would need to learn braille to keep up
with my classes. I wanted no part of this; I had already learned to read in first grade and now I would need to learn it
-again and this time with tiny splatters of dots and with stumbling fingers that couldnt decipher one word from another.
+again and this time with tiny splatters of dots and with stumbling fingers that couldn't decipher one word from another.
The idea seemed ludicrous. Usually my frustration was directed toward my braille teacher for forcing me to waste my time
deciphering complicated patterns of dots. But my teacher outsmarted me with an article about minor-league baseball players
struggling to make it into the big leagues. I realized that there was more to braille than just raised dots; there were
stories about people dreaming, and those stories made the gigantic leap from my stumbling fingertips all the way to my
brain.</p>
-<p class="floating_quote" style="margin:0px 8px 8px 0px;">I realized that there was more to braille
-than just raised dots; there were stories about people dreaming...</p>
+<p class="floating_quote" style="margin:0px 8px 8px 0px;">"I realized that there was more to braille
+than just raised dots; there were stories about people dreaming..."</p>
<P>Recently, Erik has taken on his most ambitious mountain yet: training blind teenagers to do what he does. Learn more about this project, in which Erik and his Everest teammates will climb a Himalayan peak with six blind Tibetan teens. Go to <a href="http://www.climbingblind.org">climbingblind.org</a> to interact with the expedition team, find exciting activities about braille, and more. (National Braille Press is proud to have donated braille books for this adventure.)</P>
@@ -75,4 +53,4 @@ than just raised dots; there were stories about people dreaming...
</div>
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
diff --git a/catalogs/nbp/pages/support/voices2.html b/catalogs/nbp/pages/support/voices2.html
index e611291..ca07793 100644
--- a/catalogs/nbp/pages/support/voices2.html
+++ b/catalogs/nbp/pages/support/voices2.html
@@ -1,24 +1,5 @@
-[comment]
-ui_page: voices2.html
-ui_type: page
-ui_name: voices2.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Rachael McCauley[/seti]
-[calc interpolate=0]
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-[/calc]
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
<h1 class="contentheader">Rachael McCauley</h1>
@@ -81,4 +62,4 @@ My favorite braille books:
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
diff --git a/catalogs/nbp/pages/support/voices3.html b/catalogs/nbp/pages/support/voices3.html
index c0b2382..01c361f 100644
--- a/catalogs/nbp/pages/support/voices3.html
+++ b/catalogs/nbp/pages/support/voices3.html
@@ -1,24 +1,5 @@
-[comment]
-ui_page: voices1.html
-ui_type: page
-ui_name: voices1.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Deborah Kendrick[/seti]
-[calc interpolate=0]
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-[/calc]
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
<h1 class="contentheader">Deborah Kendrick</h1>
@@ -103,4 +84,4 @@ Dictionary.com
</div>
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
diff --git a/catalogs/nbp/pages/support/voices4.html b/catalogs/nbp/pages/support/voices4.html
index 1026b19..c035565 100644
--- a/catalogs/nbp/pages/support/voices4.html
+++ b/catalogs/nbp/pages/support/voices4.html
@@ -1,24 +1,5 @@
-[comment]
-ui_page: voices4.html
-ui_type: page
-ui_name: voices4.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Christine Faltz[/seti]
-[calc interpolate=0]
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-[/calc]
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
<h1 class="contentheader">Christine Faltz</h1>
@@ -38,7 +19,7 @@ I love braille and cannot possibly express how much I prefer braille as the medi
</p>
<p class="floating_quote" style="margin:8px 0px 8px 0px;">
-Law School, without a doubt, would have been absolutely brutal without knowing how to read...
+"Law School, without a doubt, would have been absolutely brutal without knowing how to read..."
</p>
</td>
@@ -89,4 +70,4 @@ you probably won't be tempted to go to law school
</div>
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
diff --git a/catalogs/nbp/pages/support/voices5.html b/catalogs/nbp/pages/support/voices5.html
index 5b39631..47db0bd 100644
--- a/catalogs/nbp/pages/support/voices5.html
+++ b/catalogs/nbp/pages/support/voices5.html
@@ -1,24 +1,5 @@
-[comment]
-ui_page: voices1.html
-ui_type: page
-ui_name: voices1.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Kent Cullers[/seti]
-[calc interpolate=0]
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-[/calc]
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
<h1 class="contentheader">Kent Cullers</h1>
@@ -34,7 +15,7 @@ When I received my Ph.D. from Berkeley in 1980, I was the world's first totally
</p>
<p class="floating_quote" style="float: left; width:180px; margin: 0px 8px 8px 0px;">
-Because braille can now represent mathematics and diagrams, not only the world but also the universe is open to blind people.
+"Because braille can now represent mathematics and diagrams, not only the world but also the universe is open to blind people."
</p>
<p class="content">
@@ -48,4 +29,4 @@ The written word is the foremost tool for clear thinking and communication. Usin
</div>
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
diff --git a/catalogs/nbp/pages/support/voices6.html b/catalogs/nbp/pages/support/voices6.html
index 1b671f7..0258502 100644
--- a/catalogs/nbp/pages/support/voices6.html
+++ b/catalogs/nbp/pages/support/voices6.html
@@ -1,24 +1,5 @@
-[comment]
-ui_page: voices1.html
-ui_type: page
-ui_name: voices1.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Deborah Kent Stein[/seti]
-[calc interpolate=0]
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-[/calc]
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
<h1 class="contentheader">Deborah Kent Stein</h1>
@@ -30,7 +11,7 @@ ui_page_version: 4.9.7
<img src="/nbp/images/voices/stein.jpg" width="203" style="float: right; clear: right;">
<p class="floating_quote" style="width:265px; margin:0px 8px 8px 0px;">
-As I learned each new word in braille, the doors to reading opened before me.
+"As I learned each new word in braille, the doors to reading opened before me."
</p>
<p class="content">
@@ -64,4 +45,4 @@ More than thirty years after my mother showed me a sample of braille for the fir
</div>
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
diff --git a/catalogs/nbp/pages/support/voices7.html b/catalogs/nbp/pages/support/voices7.html
index aa65c09..d90db9a 100644
--- a/catalogs/nbp/pages/support/voices7.html
+++ b/catalogs/nbp/pages/support/voices7.html
@@ -1,24 +1,5 @@
-[comment]
-ui_page: voices1.html
-ui_type: page
-ui_name: voices1.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Timothy Vernon[/seti]
-[calc interpolate=0]
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-[/calc]
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
<h1 class="contentheader">Timothy Vernon</h1>
@@ -38,7 +19,7 @@ This club was my first experience in reading books and helped to "open my eyes"
</p>
<p class="floating_quote" style="float: left; width:180px; margin:0px 8px 8px 0px;">
-In my opinion, the usefulness of braille will never become obsolete, just as print will always be useful.
+"In my opinion, the usefulness of braille will never become obsolete, just as print will always be useful."
</p>
<p class="content">
@@ -60,4 +41,4 @@ In my opinion, the usefulness of braille will never become obsolete, just as pri
</div>
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
diff --git a/catalogs/nbp/pages/support/voices8.html b/catalogs/nbp/pages/support/voices8.html
index 6c4a31f..b4784fa 100644
--- a/catalogs/nbp/pages/support/voices8.html
+++ b/catalogs/nbp/pages/support/voices8.html
@@ -1,24 +1,5 @@
-[comment]
-ui_page: voices8.html
-ui_type: page
-ui_name: voices8.html
-ui_page_template: Ethan_test_fundraising
-ui_version: 4.9.7
-ui_page_version: 4.9.7
-[/comment]
-
-
-
-[control reset=1]
-[control reset=1]
-
[seti xtitle]NBP - Ways to Give - Lidia, Guy, and Madeleine Bradley[/seti]
-[calc interpolate=0]
- my $area = uc($Scratch->{nbp_area});
- $area = 'SUPPORT' unless exists $Variable->{$area . '_TEMPLATE_TOP'};
- $Tag->tmp('template_bottom', $area . '_TEMPLATE_BOTTOM' );
- return $Variable->{ $area . '_TEMPLATE_TOP' };
-[/calc]
+[template header]
<!-- BEGIN CONTENT -->
<div class="box_m5px">
<h1 class="contentheader">Lidia, Guy, and Madeleine Bradley</h1>
@@ -53,4 +34,4 @@ The Bradleys have supported the literacy work of National Braille Press for a nu
</div>
</div>
<!-- END CONTENT -->
-[var name=|[scratch template_bottom]|]
+[template footer]
commit 5426096b8731b7c6f4fa0e05dfd3303014cfdc8a
Author: Ethan Rowe <ethan at endpoint.com>
Date: Mon Aug 10 12:28:22 2009 -0400
Introduce new template usertag for easier template management.
The use of this tag is pretty simple: at the top of your page,
you do:
[template header]
And then at the bottom of your page:
[template footer]
This wraps around calls to NBP::Template which figures out what
template variables to include.
If you need to specify a different template prefix than what would
ordinarily be used by your current position in the system (based on the
path of the page relative to the catalog's pages/ directory), then you
can do so prior to invoking this tag:
[tmp template_prefix]SPECIAL_PREFIX[/tmp]
[template header]
...
[template footer]
(The above would include SPECIAL_PREFIX_TEMPLATE_TOP and
SPECIAL_PREFIX_TEMPLATE_BOTTOM, based on the value provided
to "template_prefix").
You can override the top and bottom template defaults, respectively,
via:
[tmp template_header]MY_HEADER_VARIABLE_NAME_HERE[/tmp]
[tmp template_footer]MY_FOOTER_VARIABLE_NAME_HERE[/tmp]
---
interchange/custom/UserTag/templating.tag | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
create mode 100644 interchange/custom/UserTag/templating.tag
diff --git a/interchange/custom/UserTag/templating.tag b/interchange/custom/UserTag/templating.tag
new file mode 100644
index 0000000..8704320
--- /dev/null
+++ b/interchange/custom/UserTag/templating.tag
@@ -0,0 +1,22 @@
+Require module NBP::Template
+
+UserTag template Order type
+UserTag template Interpolate 1
+UserTag template Routine <<EOF
+sub {
+ my $type = shift;
+
+ die "Invalid template type '$type'" unless $type =~ /^(?:head|foot)er$/;
+ my $method = NBP::Template->can("${type}_template");
+ return unless $method;
+
+ my $template = NBP::Template->$method;
+ return unless $template;
+
+ my $tag = Vend::Tags->new;
+ return $tag->var(
+ $template
+ );
+}
+EOF
+
commit 6ab54fccaf3377f461808f154cd6dcb91c7e00c0
Author: Ethan Rowe <ethan at endpoint.com>
Date: Mon Aug 10 11:45:51 2009 -0400
Introduce NBP::Template for smarter template management.
Given the standard $::CGI and $::Scratch areas as "input", this
module provides logic to:
* programmatically determine "where" in the application the request
is (based on the page being processed) and determine what head/foot
templates to used based on that location.
* give $::Scratch variable "interface" for overriding the default
template determination, so any given page can specify alternate
templates as needed.
This has a unit test. Fancy that.
---
interchange/custom/lib/NBP/Template.pm | 33 ++++++++
interchange/custom/lib/t/0000-Template.t | 118 ++++++++++++++++++++++++++++++
2 files changed, 151 insertions(+), 0 deletions(-)
create mode 100644 interchange/custom/lib/NBP/Template.pm
create mode 100755 interchange/custom/lib/t/0000-Template.t
diff --git a/interchange/custom/lib/NBP/Template.pm b/interchange/custom/lib/NBP/Template.pm
new file mode 100644
index 0000000..c227350
--- /dev/null
+++ b/interchange/custom/lib/NBP/Template.pm
@@ -0,0 +1,33 @@
+package NBP::Template;
+
+sub template_prefix_for {
+ my ($class, $path) = @_;
+ return unless my ($namespace) = ($path =~ m!([^/]+)/!);
+ return uc $namespace;
+}
+
+sub page {
+ return $::CGI->{mv_nextpage};
+}
+
+sub template_prefix {
+ my $class = shift;
+ return $::Scratch->{template_prefix}
+ if defined $::Scratch->{template_prefix};
+
+ return $class->template_prefix_for( $class->page );
+}
+
+sub header_template {
+ return $::Scratch->{template_header}
+ if defined $::Scratch->{template_header};
+ return sprintf('%s_TEMPLATE_TOP', shift->template_prefix);
+}
+
+sub footer_template {
+ return $::Scratch->{template_footer}
+ if defined $::Scratch->{template_footer};
+ return sprintf('%s_TEMPLATE_BOTTOM', shift->template_prefix);
+}
+
+1;
diff --git a/interchange/custom/lib/t/0000-Template.t b/interchange/custom/lib/t/0000-Template.t
new file mode 100755
index 0000000..1ad4fa7
--- /dev/null
+++ b/interchange/custom/lib/t/0000-Template.t
@@ -0,0 +1,118 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use NBP::Config;
+
+use Test::More tests => 21;
+my $class;
+
+BEGIN {
+ $class = 'NBP::Template';
+ use_ok $class;
+}
+
+verify_path_variable('braille/index', 'BRAILLE');
+verify_path_variable('cbbc/index', 'CBBC');
+verify_path_variable('company/index', 'COMPANY');
+verify_path_variable('education/index', 'EDUCATION');
+verify_path_variable('production/index', 'PRODUCTION');
+verify_path_variable('publications/index', 'PUBLICATIONS');
+verify_path_variable('readbooks/index', 'READBOOKS');
+verify_path_variable('support/index', 'SUPPORT');
+verify_path_variable('support/foo/foo', 'SUPPORT');
+
+stub_globals();
+$::CGI->{mv_nextpage} = 'foo';
+is(
+ $class->page,
+ 'foo',
+ 'page() driven from CGI mv_nextpage',
+);
+
+stub_globals();
+$::CGI->{mv_nextpage} = 'braille/foo';
+is(
+ $class->template_prefix,
+ 'BRAILLE',
+ 'template_prefix determines prefix from page',
+);
+
+stub_globals();
+$::CGI->{mv_nextpage} = 'braille/foo';
+$::Scratch->{template_prefix} = 'ALTERNATE';
+is(
+ $class->template_prefix,
+ 'ALTERNATE',
+ 'template_prefix uses Scratch value if defined',
+);
+
+stub_globals();
+$::CGI->{mv_nextpage} = 'braille/bloo';
+is(
+ $class->header_template,
+ 'BRAILLE_TEMPLATE_TOP',
+ 'header_template bases top template on page default prefix',
+);
+
+is(
+ $class->footer_template,
+ 'BRAILLE_TEMPLATE_BOTTOM',
+ 'footer_template bases bottom template on default page prefix',
+);
+
+$::Scratch->{template_prefix} = 'FLIMFLAM';
+is(
+ $class->header_template,
+ 'FLIMFLAM_TEMPLATE_TOP',
+ 'header_template bases top template on scratch prefix if present',
+);
+
+is(
+ $class->footer_template,
+ 'FLIMFLAM_TEMPLATE_BOTTOM',
+ 'footer_template bases bottom tempalte on scratch prefix if present',
+);
+
+$::Scratch->{template_header} = 'SPECIFIC_HEADER';
+is(
+ $class->header_template,
+ 'SPECIFIC_HEADER',
+ 'header_template uses Scratch template_header when present',
+);
+
+is(
+ $class->footer_template,
+ 'FLIMFLAM_TEMPLATE_BOTTOM',
+ 'footer_template ignores Scratch template_header',
+);
+
+delete $::Scratch->{template_header};
+$::Scratch->{template_footer} = 'SPECIFIC_FOOTER';
+is(
+ $class->footer_template,
+ 'SPECIFIC_FOOTER',
+ 'footer_template uses Scratch template_footer when present',
+);
+
+is(
+ $class->header_template,
+ 'FLIMFLAM_TEMPLATE_TOP',
+ 'header_template ignores Scratch template_footer',
+);
+
+sub verify_path_variable {
+ my ($path, $expected_variable) = @_;
+ return is(
+ $class->template_prefix_for($path),
+ $expected_variable,
+ "template_from_path gives $expected_variable for $path",
+ );
+}
+
+# stub out standard IC globals
+sub stub_globals {
+ $::Scratch = {};
+ $::CGI = {};
+ return;
+}
hooks/post-receive
--
UNNAMED PROJECT
More information about the Web-reskin
mailing list