summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-05-22 14:34:21 -0400
committerEvan Prodromou <evan@prodromou.name>2008-05-22 14:34:21 -0400
commiteecd611f678febabe1d62d5cf9b0bc152caf7596 (patch)
tree72c75722a2ceb82ba6418187ad90353dc4121542
parent41f013578024a1ce558bde4030a0171e2895ed09 (diff)
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
-rw-r--r--actions/xrds.php69
-rw-r--r--db/stoica.sql6
-rw-r--r--doc/README9
-rw-r--r--doc/TODO2
-rw-r--r--doc/openmicroblogging.txt (renamed from doc/openlisten.txt)35
-rw-r--r--lib/common.php4
-rw-r--r--lib/util.php7
7 files changed, 104 insertions, 28 deletions
diff --git a/actions/xrds.php b/actions/xrds.php
new file mode 100644
index 000000000..4a9c3454c
--- /dev/null
+++ b/actions/xrds.php
@@ -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');
+ }
+} \ No newline at end of file
diff --git a/db/stoica.sql b/db/stoica.sql
index 6f43cd221..e9aa1f998 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 546e4320b..7bde30916 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 25f2731ed..c5f692b43 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
index b3208c24f..77c52a10f 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 <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.
+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 50d0110e2..9328d33e9 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 3be29651c..83c0964f5 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) {