tags and XRDS

Starting the process of remote subscriptions.

First, add the capacity to mint tags. May in the future want to allow
some kind of UUID or URL for unique URIs. New config options for tag
authority and date, and a function for minting tags.

Store URIs in the DB. If the admin changes his/her tag config, this
shouldn't change the URIs in the DB. Unless they really want to make
that happen.

Generate an XRDS document with the appropriate URLs for microblogging.
Also, redefined some stuff in openmicroblogging.txt. And moved the file.

darcs-hash:20080522183421-84dde-fe46f32e4050f2c4b6c850334103007ed7feabf7.gz
This commit is contained in:
Evan Prodromou 2008-05-22 14:34:21 -04:00
parent 41f0135780
commit eecd611f67
7 changed files with 104 additions and 28 deletions

69
actions/xrds.php Normal file
View File

@ -0,0 +1,69 @@
<?php
/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('LACONICA')) { exit(1); }
define('OPENMICROBLOGGING01', 'http://openmicroblogging.org/protocol/0.1');
class XrdsAction extends Action {
function handle($args) {
parent::handle($args);
$nickname = $this->trimmed('nickname');
$user = User::staticGet('nickname', $nickname);
if (!$user) {
common_user_error(_t('No such user.'));
return;
}
$this->show_xrds($user);
}
function show_xrds($user) {
header('Content-Type: application/rdf+xml');
common_start_xml();
common_element_start('xrds:XRDS', array('xmlns:xrds' => 'xri://$xrds',
'xmlns' => 'xri://$xrd*($v*2.0)'));
common_element_start('XRD');
$this->show_service(OPENMICROBLOGGING01.'/identifier',
$user->uri);
# XXX: decide whether to include user's ID/nickname in postNotice URL
foreach (array('requestToken', 'userAuthorization',
'accessToken', 'postNotice',
'updateProfile') as $type) {
$this->show_service(OPENMICROBLOGGING01.'/'.$type,
common_local_url(strtolower($type)));
}
common_element_end('XRD');
common_element_end('xrds:XRDS');
common_end_xml();
}
function show_service($type, $uri) {
common_element_start('Service');
common_element('Type', $type);
common_element('URI', $uri);
common_element_end('Service');
}
}

View File

@ -36,6 +36,7 @@ create table user (
nickname varchar(64) unique key comment 'nickname or username, duped in profile', nickname varchar(64) unique key comment 'nickname or username, duped in profile',
password varchar(255) comment 'salted password, can be null for OpenID users', password varchar(255) comment 'salted password, can be null for OpenID users',
email varchar(255) unique key comment 'email address for password recovery etc.', email varchar(255) unique key comment 'email address for password recovery etc.',
uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
created datetime not null comment 'date this record was created', created datetime not null comment 'date this record was created',
modified timestamp comment 'date this record was modified' modified timestamp comment 'date this record was modified'
); );
@ -44,7 +45,9 @@ create table user (
create table remote_profile ( create table remote_profile (
id integer primary key comment 'foreign key to profile table' references profile (id), id integer primary key comment 'foreign key to profile table' references profile (id),
url varchar(255) unique key comment 'URL we use for updates from this profile (distinct from "home page" url)', uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
postnoticeurl varchar(255) comment 'URL we use for posting notices',
updateprofileurl varchar(255) comment 'URL we use for updates to this profile',
created datetime not null comment 'date this record was created', created datetime not null comment 'date this record was created',
modified timestamp comment 'date this record was modified' modified timestamp comment 'date this record was modified'
); );
@ -64,6 +67,7 @@ create table subscription (
create table notice ( create table notice (
id integer auto_increment primary key comment 'unique identifier', id integer auto_increment primary key comment 'unique identifier',
profile_id integer not null comment 'who made the update' references profile (id), profile_id integer not null comment 'who made the update' references profile (id),
uri varchar(255) unique key comment 'universally unique identifier, usually a tag URI',
content varchar(140) comment 'update content', content varchar(140) comment 'update content',
/* XXX: cache rendered content. */ /* XXX: cache rendered content. */
url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)', url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)',

View File

@ -3,4 +3,11 @@ This package requires PHP 5.x and the following PHP Pear libraries:
- DB_DataObject - DB_DataObject
- Validate - Validate
- XMLWriter - XMLWriter
- Auth_Yadis from OpenIDEnabled (not the PEAR version!). I decided
to use the openidenabled.com version since it's more widely
implemented, seems to be better supported, and it may make sense to
use the openidenabled.com libraries for OpenID auth sometime in the
future. Note that this is no longer distributed separately; it's only
in the openidenabled.com OpenID PHP tarball.

View File

@ -53,6 +53,8 @@
+ public stream link in top menu + public stream link in top menu
+ dump, fix, undump database + dump, fix, undump database
+ release 0.2 + release 0.2
- YADIS document link on showstream
- YADIS document
- subscribe remote - subscribe remote
- add subscriber remote - add subscriber remote
- send remote notice - send remote notice

View File

@ -69,45 +69,28 @@ Discovery
The remote service recovers a YADIS document from the profile URL, as The remote service recovers a YADIS document from the profile URL, as
described in YADIS 1.0. described in YADIS 1.0.
The remote service looks for a service of this type: The remote service looks for the URIs of Service of these types:
http://openmicroblogging.org/protocol/0.1 http://openmicroblogging.org/protocol/0.1/requestToken
The service must include the following 5 URLs. [*]_
omb:requestToken
Request Token URL, as in OAuth 1.0 Request Token URL, as in OAuth 1.0
omb:userAuthorization http://openmicroblogging.org/protocol/0.1/userAuthorization
User Authorization URL, as in OAuth 1.0 User Authorization URL, as in OAuth 1.0
omb:accessToken http://openmicroblogging.org/protocol/0.1/accessToken
Access Token URL, as in OAuth 1.0 Access Token URL, as in OAuth 1.0
omb:postNotice http://openmicroblogging.org/protocol/0.1/postNotice
Post Notice URL, as defined below. Post Notice URL, as defined below.
omb:updateProfile http://openmicroblogging.org/protocol/0.1/updateProfile
Update Profile URL, as defined below. Update Profile URL, as defined below.
It must also include the following URI: http://openmicroblogging.org/protocol/0.1/identifier
omb:identifier
identifier URI for the user with this profile URL. identifier URI for the user with this profile URL.
Here, omb: is the namespace prefix for:
http://openmicroblogging.org/xmlns/0.1 If any of the URIs is unavailable, the remote service MUST stop
processing.
The YADIS URI defined for the service can be ignored.
.. [*] I decided to use a separate namespace with 5 elements to enable
having different providers for general OAuth and specific OµB. A
future version of this document may have a mode that allows a
single URL defined in the <URI> element with an additional URL
parameter like 'action=requesttoken', 'action=userauthorization' or
something similar. But that simplifies the YADIS doc at the expense
of the rest of the protocol.
Authorization Authorization
============= =============

View File

@ -39,6 +39,10 @@ $config =
array('name' => 'Just another Laconica microblog', array('name' => 'Just another Laconica microblog',
'server' => 'localhost', 'server' => 'localhost',
'path' => '/'), 'path' => '/'),
'tag' =>
array('authority' => 'INVALID TAG',
'date' => 'PUT A DATE HERE',
'prefix' => ''),
'license' => 'license' =>
array('url' => 'http://creativecommons.org/license/by/3.0/', array('url' => 'http://creativecommons.org/license/by/3.0/',
'title' => 'Creative Commons Attribution 3.0', 'title' => 'Creative Commons Attribution 3.0',

View File

@ -432,6 +432,13 @@ function common_notice_form() {
common_element_end('form'); common_element_end('form');
} }
function common_mint_tag($extra) {
global $config;
return
'tag:'.$config['tag']['authority'].','.
$config['tag']['date'].':'$config['tag']['prefix'].$extra;
}
// XXX: set up gettext // XXX: set up gettext
function _t($str) { function _t($str) {