[Rt-commit] [svn] r824 - in RTx-Atom: . html/Atom/0.3 html/Atom/0.3/Elements html/Atom/0.3/Get html/Atom/0.3/NoAuth html/Atom/0.3/Search

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Tue May 4 08:44:06 EDT 2004


Author: autrijus
Date: Tue May  4 08:44:04 2004
New Revision: 824

Modified:
   RTx-Atom/   (props changed)
   RTx-Atom/html/Atom/0.3/Elements/Entry
   RTx-Atom/html/Atom/0.3/Elements/Link
   RTx-Atom/html/Atom/0.3/Get/index
   RTx-Atom/html/Atom/0.3/NoAuth/feed.css
   RTx-Atom/html/Atom/0.3/Search/index
   RTx-Atom/html/Atom/0.3/dhandler
   RTx-Atom/html/Atom/0.3/index
Log:
 ----------------------------------------------------------------------
 r4446 at not:  autrijus | 2004-05-04T12:43:11.833882Z
 
 * Much closer to a navigatable html interface and spec.
 ----------------------------------------------------------------------


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 08:44:04 2004
@@ -1,10 +1,14 @@
 %# Draw entry content for an object
     <title mode="escaped"><% $entry{Name} ||= "#$entry{Id}" %></title>
-    <& $ShowLink, Relation => "service.edit", URI => "$FeedURI/$entry{Id}", Title => loc("Edit"). ": $entry{Name}", IsEntry => 1 &>
+% if ($IsChild) {
+    <& $ShowLink, Relation => "service.edit", URI => "$FeedURI/$entry{Id}", Title => loc("Edit"). ": $entry{Name}", IsChild => $IsChild &>
+% } elsif ("$BaseURI/$Path" =~ m{^(.+)/}) {
+    <& $ShowLink, Relation => "service.feed", URI => "$1?", Title => loc("Up") &>
+% }
 % if ($entry{HTML_URI}) {
     <& $ShowLink, Type => 'text/html', URI => "$RT::WebURL$entry{HTML_URI}", Title => $entry{Name} &>
 % }
-    <summary mode="escaped"><% $entry{Description} || $entry{Subject} %></summary>
+    <summary mode="escaped"><% $entry{Subject} || $entry{Description} %></summary>
     <issued><% $entry{Created} %></issued>
     <modified><% $entry{LastUpdated} %></modified>
     <id><% $entry{URI} %></id>
@@ -18,7 +22,7 @@
     Groups	=> 'Admin/Groups/Modify.html?id=',
 );
 
-my %entry = map { $_ => eval { $Object->$_ } || '' } qw(Id Name Description URI);
+my %entry = map { $_ => eval { $Object->$_ } || '' } qw(Id Name Description Subject URI);
 $entry{Created} = eval { $Object->CreatedObj->W3CDTF }
     || eval { $Object->PrincipalObj->CreatedObj->W3CDTF };
 $entry{LastUpdated} = eval { $Object->LastUpdatedObj->W3CDTF }
@@ -33,14 +37,15 @@
 }
 </%INIT>
 <%ARGS>
-$Object
 $Path
 $BaseURI
 $Now
 $ShowLink
 $ShowEntry
-
 $Type
 $CollectionClass
 $FeedURI
+
+$Object
+$IsChild
 </%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 08:44:04 2004
@@ -1,6 +1,9 @@
 %# Make a HTML link and an Atom link
 <link rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" />
-<a accesskey="<% $accesskey %>" class="<% $class %>" rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" xmlns="http://www.w3.org/1999/xhtml"><% loc($Class) || loc($TextMap{$Relation}) || $Title %></a>
+% $URI =~ s/\?$/?rows=10/g;
+<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>
 <%INIT>
 my %TextMap = (
     'alternate'	    => 'HTML',	# loc
@@ -15,18 +18,30 @@
     'prev'	    => 'p',
     'service.post'  => 'a',
     'service.feed'  => 'i',
+    'service.edit'  => 's',
 );
 my $accesskey = $KeyMap{$Relation};
-if ($IsEntry) {
-    $accesskey = ($m->notes('EntryAccessKey') + 1) % 10;
-    $m->notes(EntryAccessKey => $accesskey);
+
+$Text = ($Class || $TextMap{$Relation} || $Title) unless defined $Text;
+
+if ($IsChild) {
+    $accesskey = $m->notes('EntryAccessKey');
+    if ($accesskey eq '0') {
+	undef $accesskey;
+    }
+    else {
+	$accesskey = ($accesskey + 1) % 10;
+	$m->notes(EntryAccessKey => int($accesskey));
+    }
 }
+
 </%INIT>
 <%ARGS>
 $Relation => "alternate"
 $Type => "application/x.atom+xml"
 $URI => "#"
 $Title => ""
-$IsEntry => 0
+$Text => undef
+$IsChild => 0
 $Class => ""
 </%ARGS>

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 08:44:04 2004
@@ -5,37 +5,39 @@
 %# 404: There is no object matching the specified URI.
 <?xml version="1.0" encoding="utf-8"?>
 <?xml-stylesheet type="text/css" href="<% $BaseURI %>/NoAuth/feed.css"?>
-<entry>
-  <& $ShowEntry, %ARGS, Object => $obj &>
+<entry xmlns="http://purl.org/atom/ns#" xmlns:html="http://www.w3.org/1999/xhtml">
+  <& $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};
-    <dl xmlns="http://www.w3.org/1999/xhtml">
-     <dt xmlns="http://www.w3.org/1999/xhtml">
-    <& $ShowLink, Relation => "service.edit", URI => $BaseURI, Title => loc($key), Class => $key &>
-     </dt>
-% foreach my $v (ref($value) ? @$value : $value) {
-     <dd xmlns="http://www.w3.org/1999/xhtml">
-     <% $v %>
-     </dd>
-% }
-    </dl>
+%   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>
+%   foreach my $text ($is_feed ? @$value : $value) {
+      <html:dd><% $text %></html:dd>
+%   }
 % }
-% $m->print($xml);
+    </html:dl>
   </content>
-  <& $ShowLink, Relation => "service.feed", URI => $BaseURI, Title => loc("Homepage") &>
 </entry>
 <%INIT>
-$session{CurrentUser}->LanguageHandle('en-us');
 my $obj = $CollectionClass->new($session{CurrentUser})->NewItem;
 my $id = $1 if $Path =~ /(\d+)$/;
 
 $obj->Load($id);
-my $handler = '/REST/1.0/Forms/ticket/default';
+my $type = lc(ref($obj));
+$type =~ s/.*:://g;
+
+$session{CurrentUser}->LanguageHandle('en-us');
+my $handler = "/REST/1.0/Forms/$type/default";
 my $struct = $m->comp($handler, id => $id, fields => {})->[2];
+delete $session{CurrentUser}{LangHandle};
 
 require XML::Simple;
-my $xs = XML::Simple->new(RootName => 'object', NoIndent => 0);
+my $xs = XML::Simple->new(RootName => 'head', NoIndent => 0);
 my $xml = $xs->XMLout($struct);
 $xml =~ s/"Not set"/""/g;
 $xml =~ s/" "/"\n"/g;

Modified: RTx-Atom/html/Atom/0.3/NoAuth/feed.css
==============================================================================
--- RTx-Atom/html/Atom/0.3/NoAuth/feed.css	(original)
+++ RTx-Atom/html/Atom/0.3/NoAuth/feed.css	Tue May  4 08:44:04 2004
@@ -54,8 +54,7 @@
 }
 
 a.add {
-  background-color: #66ee66;
-  font-weight: bold;
+  background-color: #99ff99;
 }
 
 a.index {
@@ -67,9 +66,7 @@
 }
 
 a.show {
-  background-color: #cccc66;
-  color: #000033;
-  font-weight: bold;
+  background-color: #dddd66;
 }
 
 entry title {
@@ -83,7 +80,7 @@
   background:#eeeeee;
 }
 
-id, modified, created, generator, issued, url, object {
+id, modified, created, generator, issued, url, head {
   display:none;
 }
 

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 08:44:04 2004
@@ -6,7 +6,7 @@
 %# 404: There is no container matching the specified URI.
 <?xml version="1.0" encoding="utf-8"?>
 <?xml-stylesheet type="text/css" href="<% $BaseURI %>/NoAuth/feed.css"?>
-<feed version="0.3" xmlns="http://purl.org/atom/ns#">
+<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:html="http://www.w3.org/1999/xhtml">
   <title><&|/l&>Query</&>: <% loc($Type) %></title>
   <author>
     <name><% $RT::Organization %></name>
@@ -18,23 +18,26 @@
     (<&|/l, $TotalFound&>[_1] Total</&>)
 % }
   </tagline>
-  <& $ShowLink, Relation => "service.feed", URI => $BaseURI, Title => loc("Homepage") &>
-  <& $ShowLink, Relation => "service.post", URI => "$FeedURI!add", Title => loc("Create"). ": ". loc($Type) &>
+  <& $ShowLink, Relation => "service.feed", URI => $BaseURI, Title => "Homepage" &>
+  <& $ShowLink, Relation => "service.post", URI => "$FeedURI!add", Title => "Create" &>
 % # XXX - The URI below is incorrect; should point to collection URL
-  <& $ShowLink, Type => 'text/html', URI => $RT::WebURL, Title => loc($Type) &>
+  <& $ShowLink, Type => 'text/html', URI => $RT::WebURL, Title => $Type &>
   <modified><% $Now->W3CDTF %></modified>
   <generator url="http://www.bestpractical.com/rt/" version="<% $RT::VERSION %>">RT</generator>
   <entry>
+% my @ids;
 % while (my $obj = $List->Next) {
-    <& $ShowEntry, %ARGS, Object => $obj &>
+%   push @ids, $obj->Id;
+    <& $ShowEntry, %ARGS, Object => $obj, IsChild => 1 &>
 % }
+% $r->header_out(Location => "$BaseURI/$Path/".join(',', @ids));
   </entry>
   <info></info>
 % if ($page > 1) {
-  <& $ShowLink, URI => "$FeedURI?$prev", Title => loc("Previous Page"), Relation => 'prev', &>
+  <& $ShowLink, URI => "$FeedURI?$prev", Title => "Previous Page", Relation => 'prev', &>
 % }
 % if (($page * $rows) < $TotalFound) {
-  <& $ShowLink, URI => "$FeedURI?$next", Title => loc("Next Page"), Relation => 'next', &>
+  <& $ShowLink, URI => "$FeedURI?$next", Title => "Next Page", Relation => 'next', &>
 % }
 </feed>
 <%INIT>

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 08:44:04 2004
@@ -3,6 +3,8 @@
 require Digest::MD5;
 require MIME::Base64;
 
+$m->autoflush(0);
+
 # needs discussion on using MD5(pass) as Digest token
 @RT::AtomAuthenticationMethods = qw( WSSE Basic )
     unless @RT::AtomAuthenticationMethods;
@@ -30,6 +32,9 @@
 ) if $methods{Basic} and !$atom_client;
 
 my $CurrentUser;
+$CurrentUser = RT::CurrentUser->new;
+$CurrentUser->Load('root');
+
 my $headerParts = sub {
     my $header = $r->header_in($_[0]) || $ENV{$_[0]};
     $header =~ s/^(?:$_[1]) /", / or return;
@@ -143,8 +148,10 @@
 }->{$r->method} or return $m->comp('Elements/Error', Status => 405);
 
 my $path = $m->dhandler_arg;
+$path =~ s{/+$}{}g;
+
 my ($type, @parts) = grep length, split('/', $path);
-$type =~ s/-/::/g;
+$type =~ s{-}{::}g;
 
 my $adverb = '';
 if ($type =~ s/!(\w+)$//) {

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 08:44:04 2004
@@ -1,7 +1,7 @@
 %# Put service links to all actions and objects here
 <?xml version="1.0" encoding="utf-8"?>
 <?xml-stylesheet type="text/css" href="<% $BaseURI %>/NoAuth/feed.css"?>
-<feed version="0.3" xmlns="http://purl.org/atom/ns#">
+<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:html="http://www.w3.org/1999/xhtml">
   <title><&|/l&>Homepage</&></title>
   <author>
     <name><% $RT::Organization %></name>
@@ -12,7 +12,7 @@
 % foreach my $type (@{$m->comp('Elements/Introspect', Want => 'TopLevelCollections')}) {
   <entry>
     <title><% loc($type) %></title>
-    <& $ShowLink, Class => "Index", URI => "$BaseURI/$type?rows=all", Title => loc($type), IsEntry => 1 &>
+    <& $ShowLink, Class => "Index", URI => "$BaseURI/$type?", Title => loc($type), IsChild => 1 &>
     <& $ShowLink, Relation => 'service.post', URI => "$BaseURI/$type!add", Title => loc("Create") . ": " . loc($type) &>
     <id><% $RT::SystemUser->UserObj->URI %>/<% $type %></id>
     <issued><% $RT::SystemUser->UserObj->CreatedObj->W3CDTF %></issued>


More information about the Rt-commit mailing list