[Rt-commit] [svn] r800 - in rt: . branches/rt-3.3/html/REST/2.0 branches/rt-3.3/html/REST/2.0/Elements branches/rt-3.3/html/REST/2.0/NoAuth branches/rt-3.3/html/REST/2.0/Search

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Sat May 1 17:39:51 EDT 2004


Author: autrijus
Date: Sat May  1 17:39:50 2004
New Revision: 800

Added:
   rt/branches/rt-3.3/html/REST/2.0/NoAuth/index.css
Modified:
   rt/   (props changed)
   rt/branches/rt-3.3/html/REST/2.0/Elements/Link
   rt/branches/rt-3.3/html/REST/2.0/NoAuth/feed.css
   rt/branches/rt-3.3/html/REST/2.0/Search/index
   rt/branches/rt-3.3/html/REST/2.0/autohandler
   rt/branches/rt-3.3/html/REST/2.0/dhandler
   rt/branches/rt-3.3/html/REST/2.0/index
Log:
 ----------------------------------------------------------------------
 r4363 at not:  autrijus | 2004-05-01T21:39:51.608519Z
 
 * Index page implemented using multiple "Feed" services.
 * Lots of cute, little icons placed with CSS.
 * Much better preparation for autodiscovery; PostURI is now handled with "/type.new".
 ----------------------------------------------------------------------


Modified: rt/branches/rt-3.3/html/REST/2.0/Elements/Link
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/Elements/Link	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/Elements/Link	Sat May  1 17:39:50 2004
@@ -1,6 +1,6 @@
 %# Make a HTML link and an Atom link
-<html:link class="html" rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" />
 <link rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" />
+<html:link class="html" rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" />
 <%ARGS>
 $Relation => "alternate"
 $Type => "application/x.atom+xml"

Modified: rt/branches/rt-3.3/html/REST/2.0/NoAuth/feed.css
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/NoAuth/feed.css	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/NoAuth/feed.css	Sat May  1 17:39:50 2004
@@ -6,11 +6,10 @@
 }
 
 info {
-  margin:20px;
-  background:yellow;
-  text-align:center;
+  margin:10px 0px 10px 0px;
+  background:#003366;
   display:block;
-  padding:10px;
+  padding:3px;
   font-size:85%;
 }
 
@@ -31,21 +30,67 @@
     content: attr(title)
 }
 
-feed>link.html[rel!="alternate"] {
-  padding: 3pt;
+feed>link.html {
+  padding: 5px;
   border:solid 1px #dddddd;
   font-size: 90%;
 }
 
 feed>link.html[rel="alternate"] {
-  display: block;
   text-align: left;
+  border: none;
+  padding: 0px;
 }
 
 link.html[rel="alternate"]:before {
   content: "HTML";
   background-color: #003366;
-  color: #c9c9ff;
+  color: #ccccff;
+  padding: 1px 5px 1px 5px;
+  font-size: xx-small;
+}
+
+feed>link.html[rel="service.post"] {
+  text-align: left;
+  border: none;
+  padding: 0px;
+}
+
+link.html[rel="service.post"]:before {
+  content: "Post";
+  font-weight: bold;
+  background-color: #66ee66;
+  color: #000000;
+  padding: 1px 5px 1px 5px;
+  font-size: xx-small;
+}
+
+feed>link.html[rel="service.feed"] {
+  text-align: left;
+  border: none;
+  padding: 0px;
+}
+
+link.html[rel="service.feed"]:before {
+  content: "Index";
+  background-color: #cccccc;
+  color: #000000;
+  padding: 1px 5px 1px 5px;
+  font-size: xx-small;
+}
+
+feed>link.html[rel="service.edit"] {
+  display: block;
+  text-align: left;
+  border: none;
+  padding: 0px;
+}
+
+link.html[rel="service.edit"]:before {
+  content: "Edit";
+  font-weight: bold;
+  background-color: #cccc66;
+  color: #000033;
   padding: 1px 5px 1px 5px;
   font-size: xx-small;
 }
@@ -61,7 +106,7 @@
   background:#eeeeee;
 }
 
-id, modified, generator, created, issued, url {
+id, modified, created, generator, issued, url {
   display:none;
 }
 
@@ -86,8 +131,8 @@
   border-top:dotted 1px #999999;
   display:block;
   background:#ffffff;
-  padding:5px 0px 10px 0px;
-  margin:10px 10px 35px 10px;
+  padding:5px 0px 0px 0px;
+  margin:5px 5px 0px 10px;
   
 }
 
@@ -101,3 +146,7 @@
   font-size:80%;
   margin-top:25px;
 }
+
+name {
+  font-weight: bold;
+}

Added: rt/branches/rt-3.3/html/REST/2.0/NoAuth/index.css
==============================================================================
--- (empty file)
+++ rt/branches/rt-3.3/html/REST/2.0/NoAuth/index.css	Sat May  1 17:39:50 2004
@@ -0,0 +1,33 @@
+<& feed.css &>
+
+feed {
+  display:block;
+  text-align:left;
+}
+
+feed>link.html[rel="alternate"] {
+  display:block;
+  text-align:center;
+}
+
+link[rel="service.feed"] {
+  text-align:left;
+  border-top:dotted 1px #999999;
+  display:block;
+  background:#ffffff;
+  padding:5px 0px 0px 0px;
+  margin:5px 5px 0px 10px;
+}
+
+link[rel="service.feed"]:before {
+  content: attr(title);
+  font-size:150%;
+  color:#000000;
+  text-align:left;
+  font-weight:bold;
+}
+
+link.html[rel="service.feed"] {
+  display:inline;
+}
+

Modified: rt/branches/rt-3.3/html/REST/2.0/Search/index
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/Search/index	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/Search/index	Sat May  1 17:39:50 2004
@@ -14,25 +14,28 @@
     <&|/l, $page, int(($TotalFound-1)/$rows)+1&>Page [_1] of [_2]</&>
     (<&|/l, $TotalFound&>[_1] Total</&>)
   </tagline>
-  <& $Link, Relation => "alternate", Type => 'text/html', URI => $RT::WebURL, Title => loc("Homepage") &>
   <id>rt-fsck.com://<% $RT::rtname %>/<% $Path %></id>
-  <link rel="service.post" type="application/x.atom+xml" href="<% $FeedURI %>/new"/>
-  <link rel="service.feed" type="application/x.atom+xml" href="<% $FeedURI %>"/>
-  <modified><% $modified %></modified>
+  <& $Link, Relation => "service.feed", URI => $BaseURI, Title => loc("Homepage") &>
+  <& $Link, Relation => "service.post", URI => "$FeedURI.new", Title => loc("Create"). ": ". loc($Type) &>
+%# XXX - The URI below is incorrect; should point to collection URL
+  <& $Link, Type => 'text/html', URI => $RT::WebURL, Title => loc($Type) &>
+  <modified><% $Now->W3CDTF %></modified>
   <generator url="http://www.bestpractical.com/rt/" version="<% $RT::VERSION %>">RT</generator>
 % foreach my $entry (@entries) {
   <entry>
-    <title mode="escaped"><% $entry->{Name} %></title>
+    <title mode="escaped"><% $entry->{Name} || "#$entry->{Id}" %></title>
     <summary mode="escaped"><% $entry->{Description} %></summary>
     <modified><% $entry->{LastUpdated} %></modified>
     <issued><% $entry->{Created} %></issued>
     <created><% $entry->{Created} %></created>
     <id>rt-fsck.com://<% $RT::rtname %>/<% $Path %>/<% $entry->{Id} %></id>
-    <& $Link, Relation => "alternate", Type => 'text/html', URI => "$RT::WebURL$entry->{URI}", Title => $entry->{Name} &>
-    <link rel="service.edit" type="application/x.atom+xml" href="<% $FeedURI %>/<% $entry->{Id} %>"/>
-    <content type="text/plain" mode="escaped"><% $entry->{Content} %></content>
+    <& $Link, Relation => "service.edit", URI => "$FeedURI/$entry->{Id}", Title => loc("Edit"). ": $entry->{Name}" &>
+% if ($entry->{URI}) {
+    <& $Link, Type => 'text/html', URI => "$RT::WebURL$entry->{URI}", Title => $entry->{Name} &>
+% }
   </entry>
 % }
+  <info></info>
 % if ($page > 1) {
   <& $Link, URI => "$FeedURI?$prev", Title => loc("Previous Page"), Relation => 'prev', &>
 % }
@@ -41,8 +44,6 @@
 % }
 </feed>
 <%INIT>
-$r->content_type('text/xml');
-
 my %URI = (
     Tickets	=> 'Ticket/Display.html?id=',
     Templates	=> 'Admin/Global/Template.html?Template=',
@@ -51,9 +52,6 @@
     Users	=> 'Admin/Users/Modify.html?id=',
     Groups	=> 'Admin/Groups/Modify.html?id=',
 );
-my $BaseURI = "$RT::WebPath/REST/2.0";
-my $FeedURI = "$BaseURI/\l$Type";
-my $Link = "$BaseURI/Elements/Link";
 
 my $List = $CollectionClass->new($session{CurrentUser});
 $List->UnLimit;
@@ -64,23 +62,22 @@
 $rows = $TotalFound if $rows <= 0;
 $page = 1 if $page <= 0;
 
-my $now = RT::Date->new($session{CurrentUser});
-$now->SetToNow;
-my $modified = $now->W3CDTF;
-
 my @entries;
 
 while (my $entry = $List->Next) {
     my %entry = map { $_ => eval { $entry->$_ } || '' }
-	qw(Id Name Description Content);
-    $entry{Created} = $entry->CreatedObj->W3CDTF;
-    $entry{Created} =~ s/ /T/;
-    $entry{LastUpdated} = $entry->LastUpdatedObj->W3CDTF;
-    $entry{LastUpdated} =~ s/ /T/;
-    $entry{URI} = $URI{$Type} . $entry{Id};
-    if (my $queue = eval { $entry->Queue } ) {
-	$entry{URI} =~ s/Global/Queues/;
-	$entry{Params} .= "&Queue=$queue";
+	qw(Id Name Description);
+    $entry{Created} = eval { $entry->CreatedObj->W3CDTF }
+	|| eval { $entry->PrincipalObj->CreatedObj->W3CDTF };
+    $entry{LastUpdated} = eval { $entry->LastUpdatedObj->W3CDTF }
+	|| eval { $entry->PrincipalObj->LastUpdatedObj->W3CDTF };
+
+    if ($URI{$Type}) {
+	$entry{URI} = $URI{$Type} . $entry{Id};
+	if (my $queue = eval { $entry->Queue } ) {
+	    $entry{URI} =~ s/Global/Queues/;
+	    $entry{Params} .= "&Queue=$queue";
+	}
     }
     push @entries, \%entry;
 }
@@ -95,10 +92,15 @@
 </%INIT>
 <%ARGS>
 $Path
+$BaseURI
+$Link
+$Now
+
 $Type
 $CollectionClass
+$FeedURI
 
-$rows => 3
+$rows => 10
 $page => 1
 $query => undef
 </%ARGS>

Modified: rt/branches/rt-3.3/html/REST/2.0/autohandler
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/autohandler	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/autohandler	Sat May  1 17:39:50 2004
@@ -4,6 +4,7 @@
 % if ($path =~ $RT::WebNoAuthRegex ) {
 %     $r->content_type('text/css') if $path =~ /\.css$/i;
 %     $r->content_type('text/xml') if $path =~ /\.xsl$/i;
+%     $r->content_type('image/png') if $path =~ /\.png$/i;
 %     $m->call_next(%ARGS);
 %     $m->abort();
 % }

Modified: rt/branches/rt-3.3/html/REST/2.0/dhandler
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/dhandler	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/dhandler	Sat May  1 17:39:50 2004
@@ -140,25 +140,32 @@
 
 my $class;
 foreach my $key (keys %INC) {
-    $key =~ m{^RTx?(?:/.+)?/($type).pm}i or next;
-    $type = $1;
-    $class = $key;
-    $class =~ s{.pm$}{}i;
+    $key =~ m{^(RTx?(?:/.+)?/($type)).pm$}i or next;
+    ($class, $type) = ($1, $2);
     $class =~ s{/}{::}g;
     $class->can('UnLimit') or (undef $class, next);
     last;
 }
 
+my $BaseURI = "$RT::WebPath/REST/2.0";
+$ARGS{Path} = $path;
+$ARGS{BaseURI} = $BaseURI;
+$ARGS{Link} = "$BaseURI/Elements/Link";
+$ARGS{Now} = RT::Date->new($session{CurrentUser});
+$ARGS{Now}->SetToNow;
+
+$r->content_type('text/xml; charset=utf-8');
+
 if (!$class) {
-    return $m->comp('index') if $path =~ /index|^\W*$/i;
+    return $m->comp('index', %ARGS) if $path =~ /index|^\W*$/i;
     return $m->comp('Error/index', Status => 404);
 }
 
 $m->comp(
     'Search/index', %ARGS,
-    Path => $path,
     Type => $type,
     CollectionClass => $class,
+    FeedURI => "$BaseURI/\L$type",
 );
 </%INIT>
 <%FLAGS>

Modified: rt/branches/rt-3.3/html/REST/2.0/index
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/index	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/index	Sat May  1 17:39:50 2004
@@ -1 +1,36 @@
-%# XXX - Put service links to all actions and objects here
+%# Put service links to all actions and objects here
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/css" href="<% $BaseURI %>/NoAuth/index.css"?>
+<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>
+    <url><% $RT::WebURL %></url>
+  </author>
+  <& $Link, Type => 'text/html', URI => $RT::WebURL, Title => loc("Homepage") &>
+% foreach my $type (sort @types) {
+  <& $Link, Relation => 'service.feed', URI => "$BaseURI/\L$type", Title => loc($type) &>
+  <& $Link, Relation => 'service.post', URI => "$BaseURI/\L$type.new", Title => loc("Create") . ": " . loc($type) &>
+% }
+  <modified><% $Now->W3CDTF %></modified>
+  <generator url="http://www.bestpractical.com/rt/" version="<% $RT::VERSION %>">RT</generator>
+</feed>
+<%INIT>
+my @types;
+foreach my $key (keys %INC) {
+    $key =~ m{^(RTx?(?:/.+)?/([^_/]+)).pm$}i or next;
+    my ($class, $type) = ($1, $2);
+    $class =~ s{/}{::}g;
+    $class->can('UnLimit') or (undef $class, next);
+    push @types, $type;
+}
+</%INIT>
+<%ARGS>
+$Path
+$BaseURI
+$Link
+$Now
+</%ARGS>


More information about the Rt-commit mailing list