Merge branch '0.8.x' into small-fixes

This commit is contained in:
Jeffery To 2009-06-14 15:45:58 +08:00
commit bb3361467c
9 changed files with 158 additions and 106 deletions

View File

@ -207,7 +207,7 @@ class ConversationTree extends NoticeList
// We take responsibility for doing the li // We take responsibility for doing the li
$this->out->elementStart('li', array('class' => 'hentry notice', $this->out->elementStart('li', array('class' => 'hentry notice',
'id' => 'notice-' . $this->notice->id)); 'id' => 'notice-' . $id));
$item = $this->newListItem($notice); $item = $this->newListItem($notice);
$item->show(); $item->show();

View File

@ -82,14 +82,18 @@ class FoafAction extends Action
'http://www.w3.org/2000/01/rdf-schema#', 'http://www.w3.org/2000/01/rdf-schema#',
'xmlns:geo' => 'xmlns:geo' =>
'http://www.w3.org/2003/01/geo/wgs84_pos#', 'http://www.w3.org/2003/01/geo/wgs84_pos#',
'xmlns:bio' =>
'http://purl.org/vocab/bio/0.1/',
'xmlns:sioc' =>
'http://rdfs.org/sioc/ns#',
'xmlns' => 'http://xmlns.com/foaf/0.1/')); 'xmlns' => 'http://xmlns.com/foaf/0.1/'));
// This is the document about the user // This is the document about the user
$this->showPpd('', $this->user->uri); $this->showPpd('', $this->user->uri);
// XXX: might not be a person // Would be nice to tell if they were a Person or not (e.g. a #person usertag?)
$this->elementStart('Person', array('rdf:about' => $this->elementStart('Agent', array('rdf:about' =>
$this->user->uri)); $this->user->uri));
$this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email)); $this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email));
if ($this->profile->fullname) { if ($this->profile->fullname) {
@ -98,8 +102,11 @@ class FoafAction extends Action
if ($this->profile->homepage) { if ($this->profile->homepage) {
$this->element('homepage', array('rdf:resource' => $this->profile->homepage)); $this->element('homepage', array('rdf:resource' => $this->profile->homepage));
} }
if ($this->profile->profileurl) {
$this->element('weblog', array('rdf:resource' => $this->profile->profileurl));
}
if ($this->profile->bio) { if ($this->profile->bio) {
$this->element('rdfs:comment', null, $this->profile->bio); $this->element('bio:olb', null, $this->profile->bio);
} }
// XXX: more structured location data // XXX: more structured location data
if ($this->profile->location) { if ($this->profile->location) {
@ -110,10 +117,7 @@ class FoafAction extends Action
$this->elementEnd('based_near'); $this->elementEnd('based_near');
} }
$this->showMicrobloggingAccount($this->profile, common_root_url());
$avatar = $this->profile->getOriginalAvatar(); $avatar = $this->profile->getOriginalAvatar();
if ($avatar) { if ($avatar) {
$this->elementStart('img'); $this->elementStart('img');
$this->elementStart('Image', array('rdf:about' => $avatar->url)); $this->elementStart('Image', array('rdf:about' => $avatar->url));
@ -129,39 +133,8 @@ class FoafAction extends Action
$this->elementEnd('img'); $this->elementEnd('img');
} }
// Get people user is subscribed to $person = $this->showMicrobloggingAccount($this->profile,
common_root_url(), $this->user->uri, false);
$person = array();
$sub = new Subscription();
$sub->subscriber = $this->profile->id;
$sub->whereAdd('subscriber != subscribed');
if ($sub->find()) {
while ($sub->fetch()) {
if (!empty($sub->token)) {
$other = Remote_profile::staticGet('id', $sub->subscribed);
} else {
$other = User::staticGet('id', $sub->subscribed);
}
if (empty($other)) {
common_debug('Got a bad subscription: '.print_r($sub,true));
continue;
}
$this->element('knows', array('rdf:resource' => $other->uri));
$person[$other->uri] = array(LISTENEE,
$other->id,
$other->nickname,
(empty($sub->token)) ? 'User' : 'Remote_profile');
$other->free();
$other = null;
unset($other);
}
}
$sub->free();
$sub = null;
unset($sub);
// Get people who subscribe to user // Get people who subscribe to user
@ -198,7 +171,15 @@ class FoafAction extends Action
$sub = null; $sub = null;
unset($sub); unset($sub);
$this->elementEnd('Person'); foreach ($person as $uri => $p) {
list($type, $id, $nickname, $cls) = $p;
if ($type == BOTH) {
$this->element('knows', array('rdf:resource' => $uri));
}
}
$this->elementEnd('Agent');
foreach ($person as $uri => $p) { foreach ($person as $uri => $p) {
$foaf_url = null; $foaf_url = null;
@ -207,16 +188,18 @@ class FoafAction extends Action
$foaf_url = common_local_url('foaf', array('nickname' => $nickname)); $foaf_url = common_local_url('foaf', array('nickname' => $nickname));
} }
$profile = Profile::staticGet($id); $profile = Profile::staticGet($id);
$this->elementStart('Person', array('rdf:about' => $uri)); $this->elementStart('Agent', array('rdf:about' => $uri));
if ($type == LISTENER || $type == BOTH) { if ($type == BOTH) {
$this->element('knows', array('rdf:resource' => $this->user->uri)); $this->element('knows', array('rdf:resource' => $this->user->uri));
} }
$this->showMicrobloggingAccount($profile, ($cls == 'User') ? $this->showMicrobloggingAccount($profile,
common_root_url() : null); ($cls == 'User') ? common_root_url() : null,
$uri,
true);
if ($foaf_url) { if ($foaf_url) {
$this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url)); $this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
} }
$this->elementEnd('Person'); $this->elementEnd('Agent');
if ($foaf_url) { if ($foaf_url) {
$this->showPpd($foaf_url, $uri); $this->showPpd($foaf_url, $uri);
} }
@ -237,18 +220,66 @@ class FoafAction extends Action
$this->elementEnd('PersonalProfileDocument'); $this->elementEnd('PersonalProfileDocument');
} }
function showMicrobloggingAccount($profile, $service=null) function showMicrobloggingAccount($profile, $service=null, $useruri=null, $isSubscriber=false)
{ {
$attr = array();
if ($useruri) {
$attr['rdf:about'] = $useruri . '#acct';
}
// Their account // Their account
$this->elementStart('holdsAccount'); $this->elementStart('holdsAccount');
$this->elementStart('OnlineAccount'); $this->elementStart('OnlineAccount', $attr);
if ($service) { if ($service) {
$this->element('accountServiceHomepage', array('rdf:resource' => $this->element('accountServiceHomepage', array('rdf:resource' =>
$service)); $service));
} }
$this->element('accountName', null, $profile->nickname); $this->element('accountName', null, $profile->nickname);
$this->element('homepage', array('rdf:resource' => $profile->profileurl)); $this->element('accountProfilePage', array('rdf:resource' => $profile->profileurl));
if ($useruri) {
$this->element('sioc:account_of', array('rdf:resource'=>$useruri));
}
$person = array();
if ($isSubscriber) {
$this->element('sioc:follows', array('rdf:resource'=>$this->user->uri . '#acct'));
} else {
// Get people user is subscribed to
$sub = new Subscription();
$sub->subscriber = $profile->id;
$sub->whereAdd('subscriber != subscribed');
if ($sub->find()) {
while ($sub->fetch()) {
if (!empty($sub->token)) {
$other = Remote_profile::staticGet('id', $sub->subscribed);
} else {
$other = User::staticGet('id', $sub->subscribed);
}
if (empty($other)) {
common_debug('Got a bad subscription: '.print_r($sub,true));
continue;
}
$this->element('sioc:follows', array('rdf:resource' => $other->uri.'#acct'));
$person[$other->uri] = array(LISTENEE,
$other->id,
$other->nickname,
(empty($sub->token)) ? 'User' : 'Remote_profile');
$other->free();
$other = null;
unset($other);
}
}
$sub->free();
$sub = null;
unset($sub);
}
$this->elementEnd('OnlineAccount'); $this->elementEnd('OnlineAccount');
$this->elementEnd('holdsAccount'); $this->elementEnd('holdsAccount');
return $person;
} }
} }

View File

@ -76,11 +76,6 @@ class TagAction extends Action
sprintf(_('Feed for tag %s'), $this->tag))); sprintf(_('Feed for tag %s'), $this->tag)));
} }
function showPageNotice()
{
return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
}
function showContent() function showContent()
{ {
$notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);

View File

@ -203,10 +203,20 @@ $(document).ready(function(){
else { else {
li = $("li", xml).get(0); li = $("li", xml).get(0);
if ($("#"+li.id).length == 0) { if ($("#"+li.id).length == 0) {
$("#notices_primary .notices").prepend(document._importNode(li, true)); var notice_irt_value = $('#notice_in-reply-to').val();
$("#notices_primary .notice:first").css({display:"none"}); var notice_irt = '#notices_primary #notice-'+notice_irt_value;
$("#notices_primary .notice:first").fadeIn(2500); if($('body')[0].id == 'conversation') {
NoticeReply(); if(notice_irt_value.length > 0 && $(notice_irt+' .notices').length < 1) {
$(notice_irt).append('<ul class="notices"></ul>');
}
$($(notice_irt+' .notices')[0]).append(document._importNode(li, true));
}
else {
$("#notices_primary .notices").prepend(document._importNode(li, true));
}
$('#'+li.id).css({display:'none'});
$('#'+li.id).fadeIn(2500);
NoticeReply();
} }
} }
$("#notice_data-text").val(""); $("#notice_data-text").val("");
@ -310,4 +320,3 @@ function NoticeAttachments() {
} }
); );
} }

View File

@ -575,20 +575,32 @@ class Action extends HTMLOutputter // lawsuit
/** /**
* Show page notice block. * Show page notice block.
* *
* Only show the block if a subclassed action has overrided
* Action::showPageNotice(), or an event handler is registered for
* the StartShowPageNotice event, in which case we assume the
* 'page_notice' definition list is desired. This is to prevent
* empty 'page_notice' definition lists from being output everywhere.
*
* @return nothing * @return nothing
*/ */
function showPageNoticeBlock() function showPageNoticeBlock()
{ {
$this->elementStart('dl', array('id' => 'page_notice', $rmethod = new ReflectionMethod($this, 'showPageNotice');
'class' => 'system_notice')); $dclass = $rmethod->getDeclaringClass()->getName();
$this->element('dt', null, _('Page notice'));
$this->elementStart('dd'); if ($dclass != 'Action' || Event::hasHandler('StartShowPageNotice')) {
if (Event::handle('StartShowPageNotice', array($this))) {
$this->showPageNotice(); $this->elementStart('dl', array('id' => 'page_notice',
Event::handle('EndShowPageNotice', array($this)); 'class' => 'system_notice'));
$this->element('dt', null, _('Page notice'));
$this->elementStart('dd');
if (Event::handle('StartShowPageNotice', array($this))) {
$this->showPageNotice();
Event::handle('EndShowPageNotice', array($this));
}
$this->elementEnd('dd');
$this->elementEnd('dl');
} }
$this->elementEnd('dd');
$this->elementEnd('dl');
} }
/** /**

View File

@ -71,7 +71,6 @@ $config =
array('name' => 'Just another Laconica microblog', array('name' => 'Just another Laconica microblog',
'server' => $_server, 'server' => $_server,
'theme' => 'default', 'theme' => 'default',
'skin' => 'default',
'path' => $_path, 'path' => $_path,
'logfile' => null, 'logfile' => null,
'logo' => null, 'logo' => null,

View File

@ -110,4 +110,32 @@ class Event {
} }
return ($result !== false); return ($result !== false);
} }
/**
* Check to see if an event handler exists
*
* Look to see if there's any handler for a given event, or narrow
* by providing the name of a specific plugin class.
*
* @param string $name Name of the event to look for
* @param string $plugin Optional name of the plugin class to look for
*
* @return boolean flag saying whether such a handler exists
*
*/
public static function hasHandler($name, $plugin=null) {
if (array_key_exists($name, Event::$_handlers)) {
if (isset($plugin)) {
foreach (Event::$_handlers[$name] as $handler) {
if (get_class($handler[0]) == $plugin) {
return true;
}
}
} else {
return true;
}
}
return false;
}
} }

View File

@ -170,7 +170,7 @@ class Rss10Action extends Action
$this->elementStart('rdf:Seq'); $this->elementStart('rdf:Seq');
foreach ($this->notices as $notice) { foreach ($this->notices as $notice) {
$this->element('sioct:MicroblogPost', array('rdf:resource' => $notice->uri)); $this->element('rdf:li', array('rdf:resource' => $notice->uri));
} }
$this->elementEnd('rdf:Seq'); $this->elementEnd('rdf:Seq');
@ -197,14 +197,19 @@ class Rss10Action extends Action
$profile = Profile::staticGet($notice->profile_id); $profile = Profile::staticGet($notice->profile_id);
$nurl = common_local_url('shownotice', array('notice' => $notice->id)); $nurl = common_local_url('shownotice', array('notice' => $notice->id));
$creator_uri = common_profile_uri($profile); $creator_uri = common_profile_uri($profile);
$this->elementStart('item', array('rdf:about' => $notice->uri)); $this->elementStart('item', array('rdf:about' => $notice->uri,
'rdf:type' => 'http://rdfs.org/sioc/types#MicroblogPost'));
$title = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content)); $title = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
$this->element('title', null, $title); $this->element('title', null, $title);
$this->element('link', null, $nurl); $this->element('link', null, $nurl);
$this->element('description', null, $profile->nickname."'s status on ".common_exact_date($notice->created)); $this->element('description', null, $profile->nickname."'s status on ".common_exact_date($notice->created));
if ($notice->rendered) {
$this->element('content:encoded', null, common_xml_safe_str($notice->rendered));
}
$this->element('dc:date', null, common_date_w3dtf($notice->created)); $this->element('dc:date', null, common_date_w3dtf($notice->created));
$this->element('dc:creator', null, ($profile->fullname) ? $profile->fullname : $profile->nickname); $this->element('dc:creator', null, ($profile->fullname) ? $profile->fullname : $profile->nickname);
$this->element('sioc:has_creator', array('rdf:resource' => $creator_uri)); $this->element('foaf:maker', array('rdf:resource' => $creator_uri));
$this->element('sioc:has_creator', array('rdf:resource' => $creator_uri.'#acct'));
$this->element('laconica:postIcon', array('rdf:resource' => $profile->avatarUrl())); $this->element('laconica:postIcon', array('rdf:resource' => $profile->avatarUrl()));
$this->element('cc:licence', array('rdf:resource' => common_config('license', 'url'))); $this->element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
$this->elementEnd('item'); $this->elementEnd('item');
@ -216,15 +221,15 @@ class Rss10Action extends Action
foreach ($this->creators as $uri => $profile) { foreach ($this->creators as $uri => $profile) {
$id = $profile->id; $id = $profile->id;
$nickname = $profile->nickname; $nickname = $profile->nickname;
$this->elementStart('sioc:User', array('rdf:about' => $uri)); $this->elementStart('foaf:Agent', array('rdf:about' => $uri));
$this->element('foaf:nick', null, $nickname); $this->element('foaf:nick', null, $nickname);
if ($profile->fullname) { if ($profile->fullname) {
$this->element('foaf:name', null, $profile->fullname); $this->element('foaf:name', null, $profile->fullname);
} }
$this->element('sioc:id', null, $id); $this->element('foaf:holdsAccount', array('rdf:resource' => $uri.'#acct'));
$avatar = $profile->avatarUrl(); $avatar = $profile->avatarUrl();
$this->element('sioc:avatar', array('rdf:resource' => $avatar)); $this->element('foaf:depiction', array('rdf:resource' => $avatar));
$this->elementEnd('sioc:User'); $this->elementEnd('foaf:Agent');
} }
} }
@ -239,7 +244,7 @@ class Rss10Action extends Action
'xmlns:dc' => 'xmlns:dc' =>
'http://purl.org/dc/elements/1.1/', 'http://purl.org/dc/elements/1.1/',
'xmlns:cc' => 'xmlns:cc' =>
'http://web.resource.org/cc/', 'http://creativecommons.org/ns#',
'xmlns:content' => 'xmlns:content' =>
'http://purl.org/rss/1.0/modules/content/', 'http://purl.org/rss/1.0/modules/content/',
'xmlns:foaf' => 'xmlns:foaf' =>
@ -253,10 +258,10 @@ class Rss10Action extends Action
'xmlns' => 'http://purl.org/rss/1.0/')); 'xmlns' => 'http://purl.org/rss/1.0/'));
$this->elementStart('sioc:Site', array('rdf:about' => common_root_url())); $this->elementStart('sioc:Site', array('rdf:about' => common_root_url()));
$this->element('sioc:name', null, common_config('site', 'name')); $this->element('sioc:name', null, common_config('site', 'name'));
$this->elementStart('sioc:container_of'); $this->elementStart('sioc:space_of');
$this->element('sioc:Container', array('rdf:about' => $this->element('sioc:Container', array('rdf:about' =>
$channel['url'])); $channel['url']));
$this->elementEnd('sioc:container_of'); $this->elementEnd('sioc:space_of');
$this->elementEnd('sioc:Site'); $this->elementEnd('sioc:Site');
} }

View File

@ -70,30 +70,3 @@ function theme_path($relative, $theme=null)
return common_path('theme/'.$theme.'/'.$relative); return common_path('theme/'.$theme.'/'.$relative);
} }
} }
/**
* Gets the full URL of a file in a skin dir based on its relative name
*
* @param string $relative relative path within the theme, skin directory
* @param string $theme name of the theme; defaults to current theme
* @param string $skin name of the skin; defaults to current theme
*
* @return string URL of the file
*/
function skin_path($relative, $theme=null, $skin=null)
{
if (!$theme) {
$theme = common_config('site', 'theme');
}
if (!$skin) {
$skin = common_config('site', 'skin');
}
$server = common_config('theme', 'server');
if ($server) {
return 'http://'.$server.'/'.$theme.'/skin/'.$skin.'/'.$relative;
} else {
return common_path('theme/'.$theme.'/skin/'.$skin.'/'.$relative);
}
}