Changeset 18
- Timestamp:
- 06/11/08 02:07:20 (4 months ago)
- Files:
-
- trunk/Glob.pm (modified) (14 diffs)
- trunk/Tagtools.pm (modified) (1 diff)
- trunk/templates/footer (modified) (1 diff)
- trunk/templates/header (modified) (3 diffs)
- trunk/templates/post/print (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Glob.pm
r12 r18 11 11 LockDirectory => "/var/lib/glob/sessionlock", 12 12 }; 13 use Calendar::Simple;14 13 use Tagtools; 15 14 … … 26 25 sub additional_data { 27 26 my $r = shift; 28 if ($r->params->{format} =~ /rss|xml/ ) {27 if ($r->params->{format} =~ /rss|xml/ and $r->model_class) { 29 28 $r->model_class->process($r); 30 29 my $ja = $r->{params}{lang} eq "ja"; … … 35 34 ); 36 35 my @posts = @{$r->objects || []}; 37 if (!@posts or !$posts[0]->isa("Glob::Post")) {@posts = @{$r->{template_args}{posts}||[]}}; 36 if (!@posts or !( 37 $posts[0]->isa("Glob::Post") or $posts[0]->isa("Glob::Comment") 38 )) { 39 @posts = @{$r->{template_args}{posts}||[]} 40 }; 38 41 # This is a hack 39 42 if ($ja) { @posts = grep { $_->content_jp} @posts } … … 44 47 for my $item (@posts) { 45 48 my $c; 46 $t->process(\do {$ja ? $item->content_jp : $item->content}, {}, \$c); 49 if ($item->isa("Glob::Comment")) { 50 $c = $item->content; 51 } else { 52 $t->process(\do {$ja ? $item->content_jp : $item->content}, {}, \$c); 53 } 47 54 $c ||= $t->error; 48 $rss->add_item( title => ($ja ? $item->title_jp : $item->title), 49 link => URI->new(Glob->config->{uri_base}."post/view/".$item->id.($ja?"?lang=ja":""))->canonical, 55 my $title = $item->isa("Glob::Comment") ? "New comment from '".$item->author."' on '".$item->post->title."'" :($ja ? $item->title_jp : $item->title) ; 56 my $author = $item->can("author") ? $item->author : Glob->config->{author}; 57 my $postid = ($item->isa("Glob::Comment") ? $item->post->id: $item->id); 58 $rss->add_item( title => $title, 59 link => URI->new(Glob->config->{uri_base}."post/view/".$postid.($ja?"?lang=ja":""))->canonical, 50 60 description => $c, 51 author => Glob->config->{author},61 author => $author, 52 62 dc => { 53 creator => Glob->config->{author},54 subject => join " ", $item->tags63 creator => $author, 64 subject => ($item->can("tags") && join " ", $item->tags), 55 65 }, 56 66 pubDate => $item->posted->strftime("%a, %d %b %Y %H:%M:%S %z") … … 72 82 73 83 use Maypole::Constants; 74 sub p arse_path {84 sub preprocess_path { 75 85 my $r = shift; 76 86 my $p = $r->path; 77 if (!$p ) {87 if (!$p or $p eq "/") { 78 88 $r->path("/post/recent"); 79 89 } elsif ($p =~ /blosxom|bryar/) { # Grandfather … … 83 93 $r->path("/post/recent"); 84 94 } 85 $r->SUPER::p arse_path;95 $r->SUPER::preprocess_path; 86 96 } 87 97 … … 94 104 sub authenticate { 95 105 my ($self,$r)=@_; 106 return DECLINED if $r->{path} =~ /plagnet/; 96 107 return DECLINED if $r->{path} =~ /static/; 97 108 $r->get_user(); … … 215 226 $sm->ready(); 216 227 my $res = $sm->test($r->params->{content}); 217 if ($res->is_spam ) {228 if ($res->is_spam or !defined $r->params->{parent}) { 218 229 $r->content_type("text/plain"); 219 230 $r->output("I think you're a spammer, because your comment: ". 231 (!$r->params->{parent} ? "doesn't contain the magic cookie\n":""). 220 232 join("\n", $res->describe_hits)); 221 233 return; … … 241 253 my $self = shift; 242 254 my $tag = "date:".$self->posted->ymd; 243 $self->add_to_system_tags({ tag => Glob::SystemTag->find_or_create({name255 $self->add_to_system_tags({system_tag => Glob::SystemTag->find_or_create({name 244 256 =>$tag}) }); 245 257 } … … 254 266 __PACKAGE__->set_up_table("comment"); 255 267 use Class::DBI::utf8; 268 use Class::DBI::Plugin::RetrieveAll; 269 __PACKAGE__->retrieve_all_sort_field("posted desc"); 256 270 Glob::Comment->has_a("post" => "Glob::Post"); 257 271 Glob::Post->has_many("comments" => "Glob::Comment", {order_by => "posted"}); … … 260 274 deflate => 'datetime', 261 275 ); 276 277 sub recent :Exported { 278 my ($self, $r) = @_; 279 my $it = $self->retrieve_all; 280 my @objs; 281 push @objs, $it->next for 0..19; 282 $r->objects(\@objs); 283 } 262 284 263 285 package Glob::Tag; … … 282 304 Glob->config->{posts_per_page}, $page); 283 305 $r->{template_args}{pager} = $pager; 284 if (! $r->objects) {306 if (!($tag = $r->objects->[0])) { 285 307 $tag = $self->search(name => $r->{args}->[0])->first; 286 } else { 287 $tag = $r->objects->[0]; # Should hardly happen 308 if (!$tag) { warn "Couldn't find a tag, even after searching" } 288 309 } 289 310 $r->{template_args}{tag} = $tag; … … 341 362 FROM post, system_tagging 342 363 WHERE system_tagging.post = post.id 343 AND system_tagging. tag = ?364 AND system_tagging.system_tag = ? 344 365 ORDER BY post.posted DESC 345 366 / … … 353 374 $r->{template_args}{pager} = $pager; 354 375 355 if (!$r->objects) { 376 if (!$r->objects or !$r->objects->[0]) { 377 warn "Looking for tag ".$r->{args}[0]; 356 378 $tag = $self->search(name => $r->{args}->[0])->first; 357 379 } else { 380 warn "Getting a tag by ID?"; 358 381 $tag = $r->objects->[0]; # Should hardly happen 359 382 } 383 warn "No tag" unless $tag; 360 384 $r->{template_args}{tag} = $tag; 361 385 $r->{template_args}{tags} = [$tag]; # For selector trunk/Tagtools.pm
r15 r18 1 1 package Tagtools; 2 use warnings; 2 3 use Lingua::EN::Inflect::Number qw(to_PL); 3 4 use URI::Escape; trunk/templates/footer
r9 r18 3 3 <div id="rhs"> 4 4 <div class="rhstitle">Language</div> 5 <a href="?lang=ja"><img src=" /ja.gif" alt="Japanese" title="Japanese"></a>6 <a href="?lang=en"><img src=" /en.gif" alt="English" title="English"></a>5 <a href="?lang=ja"><img src="http://static.simon-cozens.org/blog/ja.gif" alt="Japanese" title="Japanese"></a> 6 <a href="?lang=en"><img src="http://static.simon-cozens.org/blog/en.gif" alt="English" title="English"></a> 7 7 8 8 <hr> trunk/templates/header
r13 r18 5 5 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> 6 6 <title> Simon Cozens [%IF post; " - "; post.title |html; END %]</title> 7 <link rel="stylesheet" type="text/css" href="http://simon-cozens.org/style/site.css"/> 7 <link rel="stylesheet" type="text/css" href="http://static.simon-cozens.org/www/style/site.css"/> 8 <link rel="stylesheet" type="text/css" href="http://static.simon-cozens.org/www/style/niftyCorners.css"/> 8 9 <link rel="stylesheet" type="text/css" href="http://blog.simon-cozens.org/static/blog.css"/> 9 <meta name="ICBM" content=" 51.585, -0.57861">10 <meta name="ICBM" content="35.3816, 136.263"> 10 11 <meta name="DC.title" content="Where Everybody's Crazy - Simon Cozens' Blog"> 11 12 <link rel="alternate" type="application/rdf+xml" title="RSS" … … 27 28 urchinTracker(); 28 29 </script> 29 <script type="text/javascript" src="http://s imon-cozens.org/style/niftycube.js"></script>30 <script type="text/javascript" src="http://static.simon-cozens.org/www/style/niftycube.js"></script> 30 31 31 32 <script type="text/javascript"> … … 60 61 <div id="container"> 61 62 <div id="main"> 63 <p> I'm a missionary in Japan. The name of my mission agency is 64 WEC International. That's supposedly <a href="http://www.wec-int.org/">Worldwide 65 Evangelisation for Christ</a>, but I think I have a better 66 idea about what it stands for... 67 </p> trunk/templates/post/print
r2 r18 2 2 <h1> [%post.title %] </h1> 3 3 [% post.content %] 4 <hr> 5 <p> 6 <a href="[%base%]/post/view/[%post.id%]">Full version</a> 7 - [% SET comments = post.comments; 8 IF comments; comments.size; ELSE; 0; END; " Comment"; "s" IF NOT 9 comments OR comments.size != 1; 10 "</A>"; 11 %] 12 </p> 4 13 </body></html>
