From: Matt S Trout Date: Fri, 11 Feb 2011 07:43:55 +0000 (+0000) Subject: dev mode X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=99cee940efd24af9f0a1beec232ee56c2ef28d66;p=scpubgit%2FSCS.git dev mode --- diff --git a/lib/SCSite.pm b/lib/SCSite.pm index 0809083..43efb3f 100644 --- a/lib/SCSite.pm +++ b/lib/SCSite.pm @@ -21,6 +21,7 @@ sub default_config { ( pages_dir => 'share/pages', template_dir => 'share/templates', + static_dir => 'share/static', feed_id_prefix => 'http://shadow.cat', ) } @@ -118,8 +119,10 @@ sub _render_page { my $zoom = $self->_layout_zoom; my %filters = %{$self->filters}; $zoom->select('.page.title')->replace_content($page->title) - ->select('meta[name=description]')->replace_content($page->description) - ->select('meta[name=keywords]')->replace_content($page->keywords) + ->select('meta[name=description]') + ->set_attribute(content => $page->description) + ->select('meta[name=keywords]') + ->set_attribute(content => $page->keywords) ->select('.main')->replace_content(\$page->body) ->apply(sub { foreach my $fname (sort keys %filters) { @@ -154,4 +157,14 @@ sub run_if_script { $new->run(@_) } +around _run_cli => sub { + my ($orig, $self) = (shift, shift); + if (@_ >= 2 and $_[0] eq 'dev' and $_[1] eq 'server') { + require SCSite::DevMode; + Moo::Role->apply_roles_to_object($self, 'SCSite::DevMode'); + return $self->_run_dev_server(@_[2..$#_]); + } + return $self->$orig(@_); +}; + __PACKAGE__->run_if_script; diff --git a/lib/SCSite/DevMode.pm b/lib/SCSite/DevMode.pm new file mode 100644 index 0000000..cc5bf6a --- /dev/null +++ b/lib/SCSite/DevMode.pm @@ -0,0 +1,32 @@ +package SCSite::DevMode; + +use Plack::App::File; +use Plack::Runner; +use Moo::Role; + +has _static_handler => (is => 'lazy'); + +sub _build__static_handler { + my ($self) = @_; + my $static_dir = $self->config->{static_dir}; + Plack::App::File->new(root => $static_dir)->to_app; +} + +around dispatch_request => sub { + my ($orig, $self) = (shift, shift); + no warnings::illegalproto; + ( + sub (/static/...) { $self->_static_handler }, + $self->$orig(@_) + ) +}; + +sub _run_dev_server { + my ($self, @args) = @_; + my $r = Plack::Runner->new(server => 'Starman', app => $self->to_psgi_app); + $r->parse_options(@args); + $r->set_options(argv => \@args); + $r->run; +} + +1; diff --git a/lib/SCSite/SidebarFilter.pm b/lib/SCSite/SidebarFilter.pm index d5c28ad..9ce5b81 100644 --- a/lib/SCSite/SidebarFilter.pm +++ b/lib/SCSite/SidebarFilter.pm @@ -56,7 +56,7 @@ sub _filter_stream { map { my ($t, @seg) = @$_; sub { $_->select('.sidebar.title')->replace_content($t) ->select('.sidebar.segment')->repeat([ - map { my ($s, @e) = @$_; warn $s; warn @e; sub { + map { my ($s, @e) = @$_; sub { $_->select('.sidebar.subtitle')->replace_content($s) ->select('.sidebar.entries')->repeat_content([ map { my $e = $_; sub { diff --git a/share/templates/layout.html b/share/templates/layout.html index cf54d8b..a099226 100644 --- a/share/templates/layout.html +++ b/share/templates/layout.html @@ -1,32 +1,259 @@ - + + + - page title + + + <meta name="author" content="Mark Keating, Matthew Trout, Chris Jackson, Eden Cardim, Wallace Reis" /> <meta name="description" /> <meta name="keywords" /> + <meta name="copyright" content="2005-08 Shadowcat Systems Limited" /> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> + + <meta name="verify-v1" content="hTwXvcyUXsyPLeSkYcjltDfY2rREn9lw56c76aYfZlo=" /> + <link rel="stylesheet" type="text/css" href="/static/reset.css" /> + <link rel="stylesheet" type="text/css" href="/static/basic.css" /> + <link rel="stylesheet" type="text/css" href="/static/scnavbar.css" /> + <link rel="stylesheet" type="text/css" href="/static/sidebars.css" /> + <link rel="stylesheet" type="text/css" href="/static/maincontent.css" /> + <link rel="stylesheet" type="text/css" href="/static/footer.css" /> + <link rel="stylesheet" type="text/css" href="/static/one_off.css" /> + + <link rel="stylesheet" type="text/css" href="/static/forms.css" /> + <link rel="stylesheet" type="text/css" href="/static/blog.css" /> + <link rel="alternate" type="application/atom+xml" title="Matt S. Trout's Blog" href="/feed/blog/matt-s-trout" /><link rel="alternate" type="application/atom+xml" title="Mark Keating's Blog" href="/feed/blog/mark-keating" /><link rel="alternate" type="application/atom+xml" title="Shadowcat Systems' Blog" href="/feed/blog" /><link rel="alternate" type="application/atom+xml" title="Shadowcat Systems' News" href="/feed/news" /> + +<!--[if lt IE 7]> + <link rel="stylesheet" href="/static/lt_ie7.css" /> +<![endif]--> </head> <body> - <div class="page title">page title</div> - <div> - <ul class="topbar_entries"> - <li><a href="/">Home</a></li> - <li><a href="/about">About</a></li> - <li><a href="/catalyst">Catalyst</a></li> - <li><a href="/servers">Servers</a></li> - <li><a href="/services">Professional Services</a></li> - <li><a href="/blog">Blogs</a></li> - </ul> - <div> - <div class="Sidebar"> - <div class="sidebar block"> - <h4 class="sidebar title"></h4> - <div class="sidebar segment"> - <h5 class="sidebar subtitle"></h5> - <ul class="sidebar entries"> - <li><a class="entry title link"></a></li> + + + <div id="wrap"> + + <div id="wrap2"> + + <!-- TOP NAVBAR --> + + <div id="nav"> + + <div id="title"> <h1 class="header">Shadowcat Systems Limited</h1></div> + <div id="tagline">sufficiently advanced technology</div> + + <div class="left"> + </div> + + <div class="center"> +<!-- <div id="navlinks"> + + <div id="navlinksleft"> + </div> + <div id="navlinkscenter"> + <ul> + <li><a class="line" href="http://paste.scsys.co.uk/">IRC Paste</a></li> + <li><a class="line" href="http://www.catalystframework.org/">Catalyst</a></li> + <li><a class="endright" href="mailto:info@shadowcat.co.uk">Contact</a></li> + </ul> + </div> + <div id="navlinksright"> + </div> + </div> --> + </div> + + <div class="right"> + </div> + + </div> + + <!-- TOP NAVBAR --> + + + <!-- CENTRE CONTENT --> + + <!-- SIDEBLOCKS --> + <div id="sidebar"> + +<div class="Sidebar"> + <div class="sidebar block"> + <div class="h4sidebarnav"> + <h4 class="sidebar title" /> + </div> + <div class="sidebar segment sidebar_segment"> + <div class="textblock"> + <h5 class="sidebar subtitle" + style="padding-left: 10px; color: #444; padding-top: 10px;" + /> + <ul class="sidebar entries"> + <li><a class="entry title link"></a></li> + </ul> + </div> + </div> + <div class="h4sidebar2" /> + </div> +</div> + + <div class="h4sidebarnav"> + <h4 class="sidebar">indexes</h4> + </div> + <div class="sidebar_segment"> + <div class="textblock"> + +<ul> + <li><a href="/resources">Resources Index</a></li> + <li><a href="/archive">Archives Index</a></li> + <li><a href="/news/archive">News Archive Index</a></li> +</ul> + +</div> + </div> + <div class="h4sidebar2"> + + + </div> <div class="h4sidebarnav"> + <h4 class="sidebar">catalan documents</h4> + </div> + <div class="sidebar_segment"> + <div class="textblock"> + +<ul> + <li><a href="/resources/catalan/moose1/">El Moose està volant (1a part)</a></li> + + <li><a href="/resources/catalan/moose2/">El Moose està volant (2a part)</a></li> +</ul> + +</div> + </div> + <div class="h4sidebar2"> + + </div> + +<!-- <div class="botsidebar"> + <div id="submit_buttons"> + <script type="text/javascript"> + digg_bgcolor = '#faa140'; + digg_skin = 'compact'; + </script> + <script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script><br /><br /> + + <script>reddit_url='[URL]'</script> + <script>reddit_title='[TITLE]'</script> + <script language="javascript" src="http://reddit.com/button.js?t=1"></script><br /><br /> + + <a href="http://del.icio.us/post" onclick="window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=700,height=400'); return false;">Save to Delicious</a> + </div> +</div> --> + + </div> + + <!-- SIDEBLOCKS --> + + <div id="nav2"> + <ul> + <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> <li><a href="/news">News</a></li> <li><a href="/catalyst">Catalyst</a></li> <li><a href="/servers">Servers</a></li> <li><a href="/services">Professional Services</a></li> <li><a href="/blog">Blog</a></li> + + </ul> + </div> + + + <div id="header"> + <table bgcolor="#000000" cellpadding="1px" cellspacing="0" width="720" height="110" border="1"> + <tr> + <td colspan="4" width="720" height="30" align="right"> + <h3 class="header2">Shadowcat Systems Supports</h3> + + </td> + </tr> + <tr> + <td width="25%" height="60"> + <a href="http://www.enlightenedperl.org"> +          <img src="/static/images/epo-logo.png" /> + </a> + </td> + <td width="30%" height="60"> + + <a href="http://www.catalystframework.org"> +            + <img src="/static/images/catalyst.png" /> + </a> + </td> + <td width="30%" height="60"> + <a href="http://ironman.enlightenedperl.org"> + <img src="/static/images/ironman-banner.png" /> + </a> + + </td> + <td width="15%" height="60"> + <a href="http://www.dbix-class.org"> +  <img src="/static/images/dbic.png" /> + </a> + </td> + </tr> + <tr> + <td height="20"> + + <a href="http://www.enlightenedperl.org"> +  Enlightened Perl + </a> + </td> + <td> + <a href="http://www.catalystframework.org"> + Catalyst Framework + </a> + </td> + <td> + + <a href="http://ironman.enlightenedperl.org"> + Ironman Competition + </a> + </td> + <td> + <a href="http://www.dbix-class.org"> + DBIx::Class + </a> + </td> + </tr> + + </table> + + </div> + + + + <div id="maincontent" class="main" /> + + + <div id="footer"> + <div id="copyright"> + 131-3 The Barracks, White Cross, South Road, Lancaster, LA1 4XQ<br /> + Company Registration Number: 05420396 <br /> + VAT Number: 868 9313 71 <br /><br /> + + Site & Design © Shadowcat Systems Limited 2005-11 + </div> + </div> + + <div id="footerlinks"> + <ul> + <li><a href="/blog/matt-s-trout">mst's blog</a></li> + + <li><a href="/blog/mark-keating">mdk's blog</a></li> </ul> </div> + </div> + <!-- CENTRE CONTENT --> + + <!-- END WRAP --> + </div> - <div class="main" /> + + <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> + </script> + <script type="text/javascript"> + _uacct = "UA-2382391-1"; + urchinTracker(); + </script> + </body> </html> diff --git a/t/templates/layout.html b/t/templates/layout.html new file mode 100644 index 0000000..cf54d8b --- /dev/null +++ b/t/templates/layout.html @@ -0,0 +1,32 @@ +<html> + <head> + <title class="page title">page title + + + + +
page title
+
+ +
+ +
+ +