[Rt-commit] [svn] r826 - in RTx-Atom: . html/Atom/0.3
html/Atom/0.3/Elements html/Atom/0.3/Get html/Atom/0.3/Search
lib/RTx
autrijus at pallas.eruditorum.org
autrijus at pallas.eruditorum.org
Tue May 4 10:44:49 EDT 2004
Author: autrijus
Date: Tue May 4 10:44:42 2004
New Revision: 826
Modified:
RTx-Atom/ (props changed)
RTx-Atom/html/Atom/0.3/Elements/Entry
RTx-Atom/html/Atom/0.3/Elements/Error
RTx-Atom/html/Atom/0.3/Elements/Link
RTx-Atom/html/Atom/0.3/Get/index
RTx-Atom/html/Atom/0.3/Search/index
RTx-Atom/html/Atom/0.3/dhandler
RTx-Atom/html/Atom/0.3/index
RTx-Atom/lib/RTx/Atom.pm
Log:
----------------------------------------------------------------------
r4450 at not: autrijus | 2004-05-04T13:16:10.947367Z
* Return "Allow" on a 405.
" Return "Content-Location", not "Location", on a successful Search.
----------------------------------------------------------------------
r4451 at not: autrijus | 2004-05-04T13:16:56.885675Z
* use "Content-Location" as Search's response.
----------------------------------------------------------------------
r4452 at not: autrijus | 2004-05-04T13:44:21.258818Z
* Avoid most large and/or expensive <html:tag> when the client only cares
about the atom part.
----------------------------------------------------------------------
r4453 at not: autrijus | 2004-05-04T14:20:23.669107Z
* Fleshed out the schema and serialization format.
----------------------------------------------------------------------
r4454 at not: autrijus | 2004-05-04T14:21:25.900548Z
* We are definitely not application/xhtml+xml, no matter how you look at it.
----------------------------------------------------------------------
r4456 at not: autrijus | 2004-05-04T14:43:38.469946Z
* The "Title" key to atom's Link element must not be localized now.
* All three verbs now generate LinkToolbar-friendly html links.
----------------------------------------------------------------------
Modified: RTx-Atom/html/Atom/0.3/Elements/Entry
==============================================================================
--- RTx-Atom/html/Atom/0.3/Elements/Entry (original)
+++ RTx-Atom/html/Atom/0.3/Elements/Entry Tue May 4 10:44:42 2004
@@ -1,9 +1,9 @@
%# Draw entry content for an object
<title mode="escaped"><% $entry{Name} ||= "#$entry{Id}" %></title>
% if ($IsChild) {
- <& $ShowLink, Relation => "service.edit", URI => "$FeedURI/$entry{Id}", Title => loc("Edit"). ": $entry{Name}", IsChild => $IsChild &>
+ <& $ShowLink, Relation => "service.edit", URI => "$FeedURI/$entry{Id}", Title => $entry{Name}, IsChild => $IsChild &>
% } elsif ("$BaseURI/$Path" =~ m{^(.+)/}) {
- <& $ShowLink, Relation => "service.feed", URI => "$1?", Title => loc("Up") &>
+ <& $ShowLink, Relation => "service.feed", URI => "$1?", Title => "Up" &>
% }
% if ($entry{HTML_URI}) {
<& $ShowLink, Type => 'text/html', URI => "$RT::WebURL$entry{HTML_URI}", Title => $entry{Name} &>
Modified: RTx-Atom/html/Atom/0.3/Elements/Error
==============================================================================
--- RTx-Atom/html/Atom/0.3/Elements/Error (original)
+++ RTx-Atom/html/Atom/0.3/Elements/Error Tue May 4 10:44:42 2004
@@ -1,6 +1,6 @@
<%INIT>
$r->content_type('text/html');
-$r->status($Status);
+$r->header_out($ARGS{$_}) for sort keys %ARGS;
$m->abort($Status) unless $ENV{FCGI_ROLE};
</%INIT>
<%ARGS>
Modified: RTx-Atom/html/Atom/0.3/Elements/Link
==============================================================================
--- RTx-Atom/html/Atom/0.3/Elements/Link (original)
+++ RTx-Atom/html/Atom/0.3/Elements/Link Tue May 4 10:44:42 2004
@@ -1,9 +1,11 @@
%# Make a HTML link and an Atom link
<link rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" />
+% return if $session{AtomClient};
% $URI =~ s/\?$/?rows=10/g;
+% $Title = loc($Class) . ' - ' . loc($Title);
<html:link rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" />
% return unless length $Text;
-<html:a accesskey="<% $accesskey %>" class="<% $class %>" rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% loc($Title) %>"><% $Text %></html:a>
+<html:a accesskey="<% $accesskey %>" class="<% $class %>" rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>"><% $Text %></html:a>
<%INIT>
my %TextMap = (
'alternate' => 'HTML', # loc
@@ -11,7 +13,7 @@
'service.feed' => 'Index', # loc
'service.edit' => 'Show', # loc
);
-my $class = lc($Class || $TextMap{$Relation} || 'nav');
+my $class = lc($Class ||= $TextMap{$Relation} || 'nav');
my %KeyMap = (
'alternate' => 'h',
'next' => 'n',
Modified: RTx-Atom/html/Atom/0.3/Get/index
==============================================================================
--- RTx-Atom/html/Atom/0.3/Get/index (original)
+++ RTx-Atom/html/Atom/0.3/Get/index Tue May 4 10:44:42 2004
@@ -9,13 +9,13 @@
<& $ShowEntry, %ARGS, Object => $obj, IsChild => 0 &>
<content type="text/xml" mode="xml">
<% $xml|n %>
-% $m->print($xml);
<html:dl>
% foreach my $key (keys %$struct) {
% my $value = $struct->{$key};
% my $is_feed = ref($value);
% my $sym = $is_feed ? '/' : '.';
<html:dt><& $ShowLink, Relation => "service.".($is_feed ? 'feed' : 'edit'), URI => "$BaseURI/$Path$sym$key", Title => $key, IsChild => 1, Text => $key &></html:dt>
+% next if $session{AtomClient};
% foreach my $text ($is_feed ? @$value : $value) {
<html:dd><% $text %></html:dd>
% }
Modified: RTx-Atom/html/Atom/0.3/Search/index
==============================================================================
--- RTx-Atom/html/Atom/0.3/Search/index (original)
+++ RTx-Atom/html/Atom/0.3/Search/index Tue May 4 10:44:42 2004
@@ -19,7 +19,7 @@
% }
</tagline>
<& $ShowLink, Relation => "service.feed", URI => $BaseURI, Title => "Homepage" &>
- <& $ShowLink, Relation => "service.post", URI => "$FeedURI!add", Title => "Create" &>
+ <& $ShowLink, Relation => "service.post", URI => "$FeedURI!add", Title => $Type &>
% # XXX - The URI below is incorrect; should point to collection URL
<& $ShowLink, Type => 'text/html', URI => $RT::WebURL, Title => $Type &>
<modified><% $Now->W3CDTF %></modified>
@@ -57,9 +57,11 @@
$page = 1 if $page <= 0;
if ($TotalFound) {
- $r->header_out(Location => "$BaseURI/$Path/".join(',', map $_->Id, @$List));
+ $r->header_out('Content-Location' => "$BaseURI/$Path/".join(',', map $_->Id, @$List));
}
+return if $r->method eq 'HEAD';
+
my %query;
while (my ($k, $v) = each %ARGS) {
$query{$k} = $v if $k eq lc($k);
Modified: RTx-Atom/html/Atom/0.3/dhandler
==============================================================================
--- RTx-Atom/html/Atom/0.3/dhandler (original)
+++ RTx-Atom/html/Atom/0.3/dhandler Tue May 4 10:44:42 2004
@@ -135,15 +135,21 @@
}
$session{CurrentUser} = $CurrentUser;
+my $lang = $CurrentUser->LanguageHandle->language_tag;
+$lang = "en, $lang" unless $lang =~ /^en\b/;
+$header_out->('Content-Language', $lang);
-my $verb = {
+my %Methods = (
GET => 'Get',
HEAD => 'Get',
POST => 'Add',
PUT => 'Put',
DELETE => 'Remove',
OPTIONS => 'Describe',
-}->{$r->method} or return $m->comp('Elements/Error', Status => 405);
+);
+
+my $verb = $Methods{$r->method}
+ or return $m->comp('Elements/Error', Status => 405, Allow => join(', ', sort keys %Methods));
my $path = $m->dhandler_arg;
$path =~ s{/+$}{}g;
@@ -155,7 +161,7 @@
if ($type =~ s/!(\w+)$//) {
$adverb = $1;
$verb = 'Describe' if $verb eq 'Get';
- $m->comp('Elements/Error', Status => 405)
+ $m->comp('Elements/Error', Status => 405, Allow => 'Add, Describe')
unless $verb =~ /Add|Describe/;
}
@@ -203,7 +209,6 @@
my @types = qw(
application/x.atom+xml
- application/xhtml+xml
application/xml
);
my $content_type = 'text/xml'; # fallback
@@ -214,6 +219,7 @@
}
$r->content_type("$content_type; charset=utf-8");
+$session{AtomClient} = $atom_client;
if (!$class) {
return $m->comp('index', %ARGS) if $path =~ /index|^\W*$/i;
Modified: RTx-Atom/html/Atom/0.3/index
==============================================================================
--- RTx-Atom/html/Atom/0.3/index (original)
+++ RTx-Atom/html/Atom/0.3/index Tue May 4 10:44:42 2004
@@ -8,12 +8,13 @@
<url><% $RT::WebURL %></url>
</author>
<modified><% $Now->W3CDTF %></modified>
- <& $ShowLink, Type => 'text/html', URI => $RT::WebURL, Title => loc("Homepage") &>
+ <& $ShowLink, Type => 'text/html', URI => $RT::WebURL, Title => "Homepage" &>
% foreach my $type (@{$m->comp('Elements/Introspect', Want => 'TopLevelCollections')}) {
<entry>
<title><% loc($type) %></title>
- <& $ShowLink, Class => "Index", URI => "$BaseURI/$type?", Title => loc($type), IsChild => 1 &>
- <& $ShowLink, Relation => 'service.post', URI => "$BaseURI/$type!add", Title => loc("Create") . ": " . loc($type) &>
+ <& $ShowLink, Relation => "service.feed", URI => "$BaseURI/$type?", Title => $type, IsChild => 1 &>
+ <& $ShowLink, Relation => 'service.post', URI => "$BaseURI/$type!add", Title => $type &>
+ <& $ShowLink, Type => "text/html", URI => $BaseURI, Title => $type &>
<id><% $RT::SystemUser->UserObj->URI %>/<% $type %></id>
<issued><% $RT::SystemUser->UserObj->CreatedObj->W3CDTF %></issued>
<modified><% $Now->W3CDTF %></modified>
Modified: RTx-Atom/lib/RTx/Atom.pm
==============================================================================
--- RTx-Atom/lib/RTx/Atom.pm (original)
+++ RTx-Atom/lib/RTx/Atom.pm Tue May 4 10:44:42 2004
@@ -48,7 +48,7 @@
/Atom/0.3/RT-Tickets # FeedURI
/Atom/0.3/RT-Tickets!add # PostURI (Container)
/Atom/0.3/RT-Tickets/15 # EditURI (Object)
- /Atom/0.3/RT-Tickets/15.Subject # EditURI (Property)
+ /Atom/0.3/RT-Tickets/15.Subject # EditURI (Attribute)
/Atom/0.3/RT-Tickets/15!update # PostURI (Object)
/Atom/0.3/RT-Tickets/15!comment # PostURI (Object)
/Atom/0.3/RT-Tickets/15!correspond # PostURI (Object)
@@ -97,9 +97,11 @@
200 OK
<entry>
- ...
- <link rel="service.edit" href="#Name" />
- <link rel="service.edit" href="#EmailAddress" />
+ <content type="text/xml" mode="xml">
+ <head Name="" EmailAddress="" ...>
+ ...
+ </head>
+ </content>
</entry>
POST /Atom/0.3/Users!add
@@ -111,12 +113,18 @@
GET /Atom/0.3/RT-Users/20
200 OK
- ...<id>rt-fsck.com://some-id</id>...
+ <entry>
+ <content type="text/xml" mode="xml">
+ <head Name="autrijus" EmailAddress="autrijus at example.com" ...>
+ ...
+ </head>
+ </content>
+ </entry>
HEAD /Atom/0.3/Groups?query=HasMember%3D'root'&rows=all
200 OK
- Location: /Atom/0.3/RT-Groups/1,2,3,5,8,13
+ Content-Location: /Atom/0.3/RT-Groups/1,2,3,5,8,13
OPTIONS /Atom/0.3/RT-Groups/1,2,3,5,8,13
@@ -129,13 +137,16 @@
200 OK
<entry>
- <link rel="service.feed" href="#Members" />
- <link rel="service.post" href="#Members.add" />
- <link rel="service.post" href="#Members.remove" />
+ <content type="text/xml" mode="xml">
+ <head ...>
+ ...
+ <Members add="Members-add" remove="Members-remove" />
+ </head>
+ </content>
</entry>
POST /Atom/0.3/RT-Groups/1,2,3,5,8,13!update
- Members.add=30
+ Members-add=30
207 Multiple Status
...<status><code>200</code><text>Member added</text>...
@@ -149,10 +160,11 @@
Search for objects within an container.
-Possible query parameters: I<rows>, I<page>, I<query>, I<columns>.
+Possible query parameters: I<rows> (mandatory), I<page>, I<query>,
+I<columns>. Additional query parameters may also be available.
-If entries are found, the C<Location> header is set to a URL pointing
-to the ResultSet.
+If entries are found, the C<Content-Location> header is set to a URL
+pointing to the ResultSet.
200: Success. Body is the result serialized as an AtomFeed.
400: Request failed. Body is the error message.
@@ -189,17 +201,24 @@
Clients without I<DELETE> support may use I<POST EditURI> instead, with an
empty entry element as the request body.
-=head2 Describe - I<OPTIONS PostURI>
+=head2 Describe - I<OPTIONS PostURI>, I<OPTIONS EditURI>, I<OPTIONS FeedURI>
+
+On a container's PostURI, returns the schema of objects acceptable by this
+container.
+
+On an object's PostURI, returns the schema acceptable by the specified I<adverb>.
-On a container, returns the schema of objects acceptable by this container.
+On I<EditURI>, returns the schema of the object or the property, which is a
+I<GET> without actual contents.
-On an object, returns the schema acceptable by the specified I<adverb>.
+On I<FeedURI>, returns the schema of available query parameters and their types.
200: Success. Body is the requested schema.
400: Request failed. Body is the error message.
404: There is no container matching the specified URI.
-Clients without I<OPTIONS> support may use I<GET PostURI> instead.
+Clients without I<OPTIONS> support may use I<GET> instead with no query
+parameters.
=head2 Add - I<POST PostURI> (Container)
More information about the Rt-commit
mailing list