[Slashdotjp-dev 553] CVS update: slashjp/plugins/Zoo

Zurück zum Archiv-Index

Tatsuki SUGIURA sugi****@users*****
2006年 7月 12日 (水) 21:24:23 JST


Index: slashjp/plugins/Zoo/zoo.pl
diff -u slashjp/plugins/Zoo/zoo.pl:1.6 slashjp/plugins/Zoo/zoo.pl:1.7
--- slashjp/plugins/Zoo/zoo.pl:1.6	Wed Jul 12 20:42:07 2006
+++ slashjp/plugins/Zoo/zoo.pl	Wed Jul 12 21:24:23 2006
@@ -2,7 +2,7 @@
 # This code is a part of Slash, and is released under the GPL.
 # Copyright 1997-2005 by Open Source Technology Group. See README
 # and COPYING for more information, or see http://slashcode.com/.
-# $Id: zoo.pl,v 1.6 2006/07/12 11:42:07 sugi Exp $
+# $Id: zoo.pl,v 1.7 2006/07/12 12:24:23 sugi Exp $
 
 use strict;
 use Slash 2.003;	# require Slash 2.3.x
@@ -11,9 +11,10 @@
 use Slash::Utility;
 use Slash::Zoo;
 use Slash::XML;
+use Digest::SHA1;
 use vars qw($VERSION);
 
-($VERSION) = ' $Revision: 1.6 $ ' =~ /\$Revision:\s+([^\s]+)/;
+($VERSION) = ' $Revision: 1.7 $ ' =~ /\$Revision:\s+([^\s]+)/;
 
 sub main {
 	my $zoo		= getObject('Slash::Zoo');
@@ -374,6 +375,61 @@
 	});
 }
 
+sub _foaf {
+	my( $entries, $uid, $type) = @_;
+	my $constants	= getCurrentStatic();
+	my $form	= getCurrentForm();
+	my $reader	= getObject('Slash::DB', { db_type => 'reader' });
+	my $user	= $reader->getUser($uid, ['nickname', 'realemail','homepage', 'journal_last_entry_date', 'emaildisplay']);
+	my $nickname	= $user->{nickname};
+	my $userpage	= "$constants->{rootdir}/~" . fixparam($nickname) . "/";
+
+
+	# basic foaf:Person
+	my $person = {
+			nick		=> $nickname,
+			holdsAccount => {
+				OnlineAccount => {
+					accountName => $nickname,
+					page => $userpage,
+					accountServiceHomepage => $constants->{rootdir},
+				},
+			}
+		};
+
+	# add various field is defined
+	# email address depending on display setting
+	$person->{mbox_sha1sum} = Digest::SHA1::sha1_hex('mailto:' . $user->{realemail}) if $user->{realemail} && $user->{emaildisplay} >= 1;
+        $person->{mbox} = "mailto:" . $user->{realemail} if $user->{realemail} && $user->{emaildisplay} >= 2; 
+	$person->{homepage} = $user->{homepage} if $user->{homepage};
+	$person->{weblog} = $userpage . "journal/" if $user->{journal_last_entry_date};
+
+	# add person's relationship
+	my @knows; 
+	for my $entry (@$entries) {
+		my $p = $reader->getUser( $entry->[0] , ['nickname','realemail','emaildisplay'] );
+		my $other = { Person => {
+			nick		=> $p->{nickname},
+			seeAlso		=> "$constants->{rootdir}/~" . fixparam($p->{nickname}) . "/$type.rdf",
+		}};
+		$other->{Person}{mbox_sha1sum} = Digest::SHA1::sha1_hex("mailto:" . $p->{realemail}) if $p->{emaildisplay} >= 1;
+		push @knows, $other;
+	
+	}
+	$person->{knows} = \@knows;
+
+	# output RDF
+	$type = $type eq "foaf" ? "Friends and Foes" : $type;
+	xmlDisplay("foaf" ,{
+		Document => {
+			title	=> "FOAF File for $nickname, with $type",
+			maker   => "Slashcode zoo.pl $VERSION",
+		},
+		Person => $person, 
+		
+	});
+}
+
 sub testSocialized {
 	my($zoo, $constants, $user) = @_;
 	return 0 if $user->{is_admin};


Slashdotjp-dev メーリングリストの案内
Zurück zum Archiv-Index