Skip to content

Commit

Permalink
pull content from the wiki instead of hard-coding it
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Closs committed Feb 10, 2009
1 parent b6dc393 commit 8673b1d
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 94 deletions.
6 changes: 6 additions & 0 deletions bin/render-site
Expand Up @@ -4,10 +4,16 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use VanBio;
use Socialtext::Resting::Getopt qw/get_rester/;

my $rester = get_rester(
'rester-config' => "$FindBin::Bin/../.biodiesel-rester.conf",
);

VanBio->new(
template_dir => "$FindBin::Bin/../template",
output_dir => "$FindBin::Bin/../web",
static_dir => "$FindBin::Bin/../static",
rester => $rester,
)->render;

42 changes: 37 additions & 5 deletions lib/VanBio.pm
Expand Up @@ -5,15 +5,18 @@ use Template;
use File::Path qw/rmtree mkpath/;
use Fatal qw/rmtree mkpath/;
use Carp qw/croak/;
use Socialtext::WikiObject;

sub new {
my $class = shift;
my $self = { @_ };

for (qw/output_dir static_dir template_dir/) {
for (qw/output_dir static_dir template_dir rester/) {
croak "$_ is required!" unless $self->{$_};
}
bless $self, $class;

$self->{rester}->accept('text/html');
return $self;
}

Expand Down Expand Up @@ -45,17 +48,23 @@ sub copy_static {

sub render_homepage {
my $self = shift;
$self->_render_page( 'index' );

my $content = $self->_get_page_html('home page');
$self->_render_page( 'index', { content => $content } );
}

sub render_news {
my $self = shift;
$self->_render_page( 'news' );

my $content = $self->_get_page_html('news page');
$self->_render_page( 'news', { content => $content } );
}

sub render_join {
my $self = shift;
$self->_render_page( 'join' );

my $content = $self->_get_page_html('join page');
$self->_render_page( 'join', { content => $content } );
}

sub render_photos {
Expand All @@ -70,7 +79,24 @@ sub render_press {

sub render_links {
my $self = shift;
$self->_render_page( 'links' );

$self->{rester}->accept('text/x.socialtext-wiki');
my $page = Socialtext::WikiObject->new(
rester => $self->{rester},
page => 'links page',
);
my $links = [];
my $link_table = $page->{links}{table};
shift @$link_table; # pop off the header row
for my $row (@$link_table) {
push @$links, {
href => $row->[0],
name => $row->[1],
desc => $row->[2],
};
}

$self->_render_page( 'links', { links => $links } );
}

sub _render_page {
Expand All @@ -87,4 +113,10 @@ sub _render_page {
|| die $template->error();
}

sub _get_page_html {
my $self = shift;
my $page = shift;
$self->{rester}->accept('text/html');
return $self->{rester}->get_page($page);
}
1;
33 changes: 1 addition & 32 deletions template/index.html.tt2
@@ -1,34 +1,3 @@
[% WRAPPER "two-column.html.tt2" %]
<p class="style11" align="left">The Little Pump that Could</p>
<p align="left">The
Vancouver Biodiesel Co-op is proud to announce the opening of Recycling
Alternative’s new 4220 Litre pump with an automatic cardlock system.
For the first time, members will be able to purchase fuel at any time,
and in any amount using the keypad. For members currently signed on, we
are awaiting the member cards.<br>
<br>
<br>
<span class="style6">THE PUMP IS LOCATED AT :</span><br>
<strong>RECYCLING ALTERNATIVE</strong><br>
360 INDUSTRIAL AVE, VANCOUVER.<br>
<span class="style8">(near Terminal and Main in Vancouver.)</span><br>
<br>
Please see <a href="http://www.recyclingalternative.com/" target="_blank">Recycling Alternative’s website</a> for the most up-to-date pricing.<br>
<br>
Simply come down to Recycling Alternative at 360 Industrial Avenue in
Vancouver and sign up our Memebership Agreement form. Or simply <a href="http://www.vancouverbiodiesel.org/images/Vancouver_Biodiesel_Cooperative_Membership_Agreement.doc.pdf" target="_blank">download the PDF file</a> and fax it to: 604 874-7252 or send to biodiesel<span class="style10">&lt;&lt;</span>@<span class="style10">&gt;&gt;</span>recyclingalternative . com. <br>
<br>
There is an activation fee of $25. This fee covers your new cardlock
card and a 1-year membership to the coop as well as a one-time
administration fee. In order to purchase biodiesel, YOU MUST BECOME A
MEMBER OF THE COOP.<br>
<br>
Biodiesel requires NO special modifications to your diesel-engine car
or truck. The biodiesel we use is made from 100% recycled waste
vegetable oil (yellow grease) and tallow (from animal fats). As
biodiesel is much cleaner running in your engine, you should monitor
your fuel filter (deposits from previous use of conventional diesel are
flushed out). The more biodiesel you use, the longer lasting your
engine will last.</p>
<p align="left">Enjoy the juice!</p>
[% content %]
[% END %]
21 changes: 1 addition & 20 deletions template/join.html.tt2
@@ -1,22 +1,3 @@
[% WRAPPER "two-column.html.tt2" %]
<p align="center">
<span class="style11">
Join The Co-op!
<br />
<br />
</span>
<span class="style13">
Simply come down to Recycling Alternative at 360 Industrial Avenue in Vancouver and sign up our Memebership Agreement form. Or simply <a href="Vancouver_Biodiesel_Cooperative_Membership_Agreement.pdf" target="_blank">download the PDF file</a> and fax it to: 604 874-7252 or send to biodiesel<span class="style10">&lt;&lt;</span>@<span class="style10">&gt;&gt;</span>recyclingalternative . com.
<br />
<br />
There is an activation fee of $25. This fee covers your new cardlock card and a 1-year membership to the coop as well as a one-time administration fee. In order to purchase biodiesel,
<br />
YOU MUST BECOME A MEMBER OF THE COOP.
</span>
<br />
<br />
<br />
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
[% content %]
[% END %]
44 changes: 8 additions & 36 deletions template/links.html.tt2
@@ -1,45 +1,17 @@
[% WRAPPER wrapper.html.tt2 %]
<p align="center">
<span class="style2">
<strong>LINKS</strong>
<strong>Links</strong>
<span class="style3">.</span>
<br />
<br />
<a href="https://www.socialtext.net/vanbiodiesel/index.cgi?vancouver_biodiesel_co_op_wiki">Vancouver Biodiesel Co-Op Wiki</a>
<br />
<br />
<a href="http://www.homebiodieselkits.com/">http://www.homebiodieselkits.com/</a><br />
Source for small-scale production equipment<br />
<br />
<a href="http://biodiesel.infopop.cc/6/ubb.x?a=cfrm&amp;s=447609751">http://biodiesel.infopop.cc/6/ubb.x?a=cfrm&amp;s=447609751</a><br />
Great forum for general information on Biodiesel and SVO fuel<br />

<br />
<a href="http://www.tdiclub.com/">http://www.tdiclub.com/</a><br />
Forum for TDI and diesel vehicle owners. <br />
<br />
<a href="http://journeytoforever.org/biodiesel_make.html">http://journeytoforever.org/biodiesel_make.html</a><br />
How to make your own Biodiesel.<br />
<br />

<a href="http://www.alternative-energy-news.info/headlines/biofuels/">http://www.alternative-energy-news.info/headlines/biofuels/</a><br />
Up to date information on all Biofuels and other renewable energy technology.<br />
<br />
<a href="http://www.canola-council.org/biodiesel/">http://www.canola-council.org/biodiesel/</a><br />
News concerning the production of a major Biodiesel feedstock in Canada.<br />
<br />
<a href="http://www.4refuel.com/subnews/biodieselvancouverbc.cfm">http://www.4refuel.com/subnews/biodieselvancouverbc.cfm</a><br />

News RE Biodiesel in and around Vancouver.<br />
<br />
<a href="http://www.localb100.com/">http://www.localb100.com/</a><br />
Biodiesel homebrew book by noted Biodiesel advocate &quot;Girl Mark.&quot;<br />
<br />
<a href="http://www.utahbiodieselsupply.com/">http://www.utahbiodieselsupply.com/</a><br />

GREAT online store for Biodiesel production equipment and information.<br />
<br />
[% FOR link IN links %]
<a href="[% link.href %]">[% link.name %]</a><br />
[% IF link.desc %]
[% link.desc %]<br />
[% END %]
<br />
[% END %]
</span>
<br />
</p>
[% END %]
2 changes: 1 addition & 1 deletion template/news.html.tt2
@@ -1,4 +1,4 @@
[% WRAPPER "two-column.html.tt2" %]
<p class="style11" align="left">Co-op News</p>
<p align="left">No news yet.</p>
[% content %]
[% END %]
10 changes: 10 additions & 0 deletions template/wrapper.html.tt2
Expand Up @@ -21,6 +21,16 @@
font-size: 18px;
font-weight: bold;
}
div.wiki h2 {
font-size: 18px;
}
div.wiki h3 {
font-size: 16px;
}
div.wiki {
font-size: 14px;
text-align: left;
}
-->
</style>
</head>
Expand Down
2 changes: 2 additions & 0 deletions todo
@@ -1,2 +1,4 @@
add news RSS
add the join PDF
add google metrics
add twitter

0 comments on commit 8673b1d

Please sign in to comment.