Skip to content
Browse files

Add individual photo page.

  • Loading branch information...
1 parent d3d8b81 commit d4413d3dbed8702243666a162bbe16e1a852ed53 @norm committed Oct 26, 2010
View
38 lib/PubStandards/Views.pm
@@ -25,6 +25,13 @@ method handle_view ( $request! ) {
when ( '/people/' ) {
return $self->render_people_list();
}
+ when ( '/photo/' ) {
+ return $self->render_redirect( '/' );
+ }
+ when ( m{^ /photo/ ( [a-z0-9_-]+ ) $}x ) {
+ my $id = $1;
+ return $self->render_photo( $id );
+ }
when ( m{^ /people/ ( [a-z0-9_-]+ ) $}x ) {
my $name = $1;
return $self->render_person( $name );
@@ -112,10 +119,41 @@ method render_person ( $name ) {
return $self->render_404();
}
+method render_photo ( $photo ) {
+ my $ps = $self->get_parent();
+ my $doc = $ps->get_document( "photo_${photo}" );
+
+ if ( defined $doc ) {
+ my $template = $self->get_template( 'photo' );
+
+ $doc->{'event'} = $ps->get_document( $doc->{'event_document'} );
+
+ foreach my $person ( @{ $doc->{'people'} } ) {
+ my $id = $person->{'username'};
+ my $pdoc = $ps->get_document( "person_${id}" );
+
+ push( @{ $doc->{'users'} }, $pdoc )
+ if defined $pdoc;
+ }
+
+ return $self->render_html_response( $template, $doc );
+ }
+
+ return $self->render_404();
+}
method render_404 () {
my $template = $self->get_template( '404' );
return $self->render_html_response( $template, {}, 404 );
}
+method render_redirect ( Str $path ) {
+ return [
+ 301,
+ [
+ 'Location' => $path,
+ ],
+ [],
+ ];
+}
method render_html_response ( $template, $data, $code=200 ) {
my $headers = [ 'Content-Type' => 'text/html; charset=UTF-8' ];
return $self->render_response( $template, $data, $headers, $code );
View
24 site/london.css
@@ -317,6 +317,30 @@ p#date-held {
color: #666;
}
+.image .title {
+ color: #690;
+ display: block;
+ font-family: "Hoefler Text",
+ "Georgia",
+ serif;
+ font-size: 2em;
+ font-weight: bold;
+ margin-top: 0.25em;
+}
+.image img {
+ display: block;
+}
+.image .shortlink {
+ display: block;
+ margin-top: 0.2em;
+ font-size: 0.8em;
+ color: #999;
+}
+
+.bulleted li {
+ list-style: square outside;
+}
+
#colophon {
width: 30em;
min-width: 550px;
View
29 templates/photo/content.html
@@ -0,0 +1,29 @@
+<div class='image'>
+ <img src="${urls{'photo'}}" alt=''>
+ <span class='title'>${title}</span>
+ <cite>
+ <a href="${urls{'photopage'}}">uploaded to Flickr</a>
+ by <a href="http://www.flickr.com/people/${owner{'nsid'}}">
+ ${owner{'realname'}}</a>
+ </cite>
+ <span class='shortlink'>${urls{'short'}}</span>
+</div>
+
+<p>Taken at <a href="/${event{'slug'}}">${event{'name'}}</a>.</p>
+
+{{
+ if ( @users ) {
+}}
+ <h3>In this photo:</h3>
+ <ul class='bulleted'>{{
+ foreach my $user ( @users ) {
+ my $url = $user->{'url'};
+ my $name = $user->{'name'};
+ }}
+ <li><a href='${url}'>${name}</a></li>
+ {{
+ }
+ }}</ul>
+{{
+ }
+}}
View
0 templates/photo/h2.html
No changes.
View
1 templates/photo/title.html
@@ -0,0 +1 @@
+<title>${title} by ${owner{'realname'}}</title>

0 comments on commit d4413d3

Please sign in to comment.
Something went wrong with that request. Please try again.