[Slashdotjp-dev 1216] [744] Add plugins/Journal/journal_update_slashbox. pl to create topjournal blocks

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2008年 9月 12日 (金) 22:40:36 JST


Revision: 744
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=slashdotjp&view=rev&rev=744
Author:   tach
Date:     2008-09-12 22:40:36 +0900 (Fri, 12 Sep 2008)

Log Message:
-----------
Add plugins/Journal/journal_update_slashbox.pl to create topjournal blocks

Modified Paths:
--------------
    slashjp/branches/2.5.0.192/debian/changelog
    slashjp/branches/2.5.0.192/plugins/Journal/PLUGIN

Added Paths:
-----------
    slashjp/branches/2.5.0.192/plugins/Journal/journal_update_slashbox.pl
    slashjp/branches/2.5.0.192/plugins/Journal/templates/topjournals;portald;default


-------------- next part --------------
Modified: slashjp/branches/2.5.0.192/debian/changelog
===================================================================
--- slashjp/branches/2.5.0.192/debian/changelog	2008-09-10 07:25:18 UTC (rev 743)
+++ slashjp/branches/2.5.0.192/debian/changelog	2008-09-12 13:40:36 UTC (rev 744)
@@ -10,8 +10,9 @@
   * Use $user->{currentSkin} at $slashdb->getTemplateByName()
     - Fix: slashDisplay() option 'Skin' does not applied
   * Add logcheck ignore rule for SearchEst
+  * Add plugins/Journal/journal_update_slashbox.pl to create topjournal blocks
 
- -- Taku YASUI <tach****@osdn*****>  Mon,  8 Sep 2008 11:58:09 +0000
+ -- Taku YASUI <tach****@osdn*****>  Fri, 12 Sep 2008 13:40:01 +0000
 
 slash (2.5.0.192-16) unstable; urgency=low
 

Modified: slashjp/branches/2.5.0.192/plugins/Journal/PLUGIN
===================================================================
--- slashjp/branches/2.5.0.192/plugins/Journal/PLUGIN	2008-09-10 07:25:18 UTC (rev 743)
+++ slashjp/branches/2.5.0.192/plugins/Journal/PLUGIN	2008-09-12 13:40:36 UTC (rev 744)
@@ -7,6 +7,7 @@
 htdoc=journal.pl
 requiresplugin=Messages
 task=journal_fix.pl
+task=journal_update_slashbox.pl
 topic=images/topics/journaltopic.png
 template=templates/bluebox;journal;default
 template=templates/data;journal;default
@@ -27,3 +28,4 @@
 template=templates/rsslink_journal;journal;default
 template=templates/searchusers;journal;default
 template=templates/slashdot;journal;default
+template=templates/topjournals;portald;default

Added: slashjp/branches/2.5.0.192/plugins/Journal/journal_update_slashbox.pl
===================================================================
--- slashjp/branches/2.5.0.192/plugins/Journal/journal_update_slashbox.pl	                        (rev 0)
+++ slashjp/branches/2.5.0.192/plugins/Journal/journal_update_slashbox.pl	2008-09-12 13:40:36 UTC (rev 744)
@@ -0,0 +1,55 @@
+#!/usr/bin/perl -w
+# This code is a part of Slash, and is released under the GPL.
+# Copyright (C) 2008 OSDN Corporation.
+#
+# $Id: journal_fix.pl 153 2007-07-04 08:10:36Z tach $
+
+use Data::Dumper;
+use strict;
+
+use Slash::Constants ':slashd';
+use Slash::Utility;
+
+use vars qw( %task $me);
+
+$task{$me}{timespec} = '* * * * *'; # should happen every minute?
+$task{$me}{fork} = SLASHD_NOWAIT;
+$task{$me}{code} = sub {
+	my($virtual_user, $constants, $slashdb, $user) = @_;
+	my $force = $constants->{task_options}{force} || undef;
+	my $block_suffix = '_topjournals';
+	my $skins = $slashdb->getSkins();
+
+	foreach my $skin (values(%$skins)) {
+		my $name = "$skin->{name}$block_suffix";
+		my $block = $slashdb->getBlock($name);
+		unless ($block) {
+			slashdLog("Could not get block \"$name\", skipped");
+			next;
+		}
+		my $tids = [ $slashdb->getAllChildrenTids($skin->{nexus}) ];
+		my $where = '1=1';
+		$where .= 'AND tid IN ('.join(',', @$tids).')' if ($skin->{skid} != $constants->{mainpage_skid});
+		next if ($slashdb->sqlCount('journals', $where . ($force ? '' : "AND date > '$block->{last_update}'")) < 1);
+
+		slashdLog("Start updating block \"$name\"") if (verbosity() >= 3);
+		my $result = $slashdb->sqlSelectAllHashrefArray(
+			'nickname AS author,jid,description AS title',
+			'users_journal JOIN users USING (uid) JOIN journals on (users_journal.jid=journals.id)',
+			$where,
+			'ORDER BY users_journal.date DESC LIMIT 20',
+		);
+		map { $_->{'link'} = "$constants->{absolutedir}/~" . strip_paramattr($_->{author}) . "/journal/". $_->{jid} } @$result;
+
+		my $str = "<ul>\n";
+		foreach my $item (@$result) {
+			$str .= slashDisplay('topjournals', { 'item' => $item }, { Return => 1, Nocomm => 1, Page => 'portald' });
+		}
+		$str .= "\n</ul>";
+		$slashdb->setBlock($name, { block => $str });
+
+		slashdLog("Updated block \"$name\"") if (verbosity() >= 2);
+	}
+};
+
+1;


Property changes on: slashjp/branches/2.5.0.192/plugins/Journal/journal_update_slashbox.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: slashjp/branches/2.5.0.192/plugins/Journal/templates/topjournals;portald;default
===================================================================
--- slashjp/branches/2.5.0.192/plugins/Journal/templates/topjournals;portald;default	                        (rev 0)
+++ slashjp/branches/2.5.0.192/plugins/Journal/templates/topjournals;portald;default	2008-09-12 13:40:36 UTC (rev 744)
@@ -0,0 +1,21 @@
+__skin__
+default
+__description__
+default rss template for slash system
+__title__
+default rss template
+__page__
+portald
+__lang__
+en_US
+__name__
+topjournals
+__template__
+<li>
+	<a href="[% constants.absolutedir %]/~[% item.author | strip_attribute %]/journal/">[[% item.author | strip_attribute %]]</a>
+	<a href="[% item.link | strip_attribute %]">[% item.title | strip_notags %]</a>
+</li>
+__seclev__
+10000
+__version__
+


Slashdotjp-dev メーリングリストの案内
アーカイブの一覧に戻る