diff --git a/actions/xrds.php b/actions/xrds.php new file mode 100644 index 0000000000..4a9c3454c2 --- /dev/null +++ b/actions/xrds.php @@ -0,0 +1,69 @@ +. + */ + +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'); + } +} \ No newline at end of file diff --git a/db/stoica.sql b/db/stoica.sql index 6f43cd2214..e9aa1f998e 100644 --- a/db/stoica.sql +++ b/db/stoica.sql @@ -36,6 +36,7 @@ create table user ( nickname varchar(64) unique key comment 'nickname or username, duped in profile', password varchar(255) comment 'salted password, can be null for OpenID users', 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', modified timestamp comment 'date this record was modified' ); @@ -44,7 +45,9 @@ create table user ( create table remote_profile ( 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', modified timestamp comment 'date this record was modified' ); @@ -64,6 +67,7 @@ create table subscription ( create table notice ( id integer auto_increment primary key comment 'unique identifier', 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', /* XXX: cache rendered content. */ url varchar(255) comment 'URL of any attachment (image, video, bookmark, whatever)', diff --git a/doc/README b/doc/README index 546e4320bf..7bde309169 100644 --- a/doc/README +++ b/doc/README @@ -3,4 +3,11 @@ This package requires PHP 5.x and the following PHP Pear libraries: - DB_DataObject - Validate - 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. + + diff --git a/doc/TODO b/doc/TODO index 25f2731edb..c5f692b43b 100644 --- a/doc/TODO +++ b/doc/TODO @@ -53,6 +53,8 @@ + public stream link in top menu + dump, fix, undump database + release 0.2 +- YADIS document link on showstream +- YADIS document - subscribe remote - add subscriber remote - send remote notice diff --git a/doc/openlisten.txt b/doc/openmicroblogging.txt similarity index 91% rename from doc/openlisten.txt rename to doc/openmicroblogging.txt index b3208c24f5..77c52a10fe 100644 --- a/doc/openlisten.txt +++ b/doc/openmicroblogging.txt @@ -69,45 +69,28 @@ Discovery The remote service recovers a YADIS document from the profile URL, as 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 - -The service must include the following 5 URLs. [*]_ - -omb:requestToken +http://openmicroblogging.org/protocol/0.1/requestToken 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 -omb:accessToken +http://openmicroblogging.org/protocol/0.1/accessToken Access Token URL, as in OAuth 1.0 -omb:postNotice +http://openmicroblogging.org/protocol/0.1/postNotice Post Notice URL, as defined below. -omb:updateProfile +http://openmicroblogging.org/protocol/0.1/updateProfile Update Profile URL, as defined below. -It must also include the following URI: - -omb:identifier +http://openmicroblogging.org/protocol/0.1/identifier identifier URI for the user with this profile URL. - -Here, omb: is the namespace prefix for: - http://openmicroblogging.org/xmlns/0.1 - -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 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. +If any of the URIs is unavailable, the remote service MUST stop +processing. Authorization ============= diff --git a/lib/common.php b/lib/common.php index 50d0110e28..9328d33e9f 100644 --- a/lib/common.php +++ b/lib/common.php @@ -39,6 +39,10 @@ $config = array('name' => 'Just another Laconica microblog', 'server' => 'localhost', 'path' => '/'), + 'tag' => + array('authority' => 'INVALID TAG', + 'date' => 'PUT A DATE HERE', + 'prefix' => ''), 'license' => array('url' => 'http://creativecommons.org/license/by/3.0/', 'title' => 'Creative Commons Attribution 3.0', diff --git a/lib/util.php b/lib/util.php index 3be29651c4..83c0964f59 100644 --- a/lib/util.php +++ b/lib/util.php @@ -432,6 +432,13 @@ function common_notice_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 function _t($str) {