[Rt-commit] [svn] r823 - 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 07:16:36 EDT 2004


Author: autrijus
Date: Tue May  4 07:16:29 2004
New Revision: 823

Added:
   RTx-Atom/html/Atom/0.3/Elements/Entry
Modified:
   RTx-Atom/   (props changed)
   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:
 ----------------------------------------------------------------------
 r4444 at not:  autrijus | 2004-05-04T11:15:32.030744Z
 
 * first try at "Get".
 ----------------------------------------------------------------------


Added: RTx-Atom/html/Atom/0.3/Elements/Entry
==============================================================================
--- (empty file)
+++ RTx-Atom/html/Atom/0.3/Elements/Entry	Tue May  4 07:16:29 2004
@@ -0,0 +1,46 @@
+%# 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 ($entry{HTML_URI}) {
+    <& $ShowLink, Type => 'text/html', URI => "$RT::WebURL$entry{HTML_URI}", Title => $entry{Name} &>
+% }
+    <summary mode="escaped"><% $entry{Description} || $entry{Subject} %></summary>
+    <issued><% $entry{Created} %></issued>
+    <modified><% $entry{LastUpdated} %></modified>
+    <id><% $entry{URI} %></id>
+<%INIT>
+my %URI = (
+    Tickets	=> 'Ticket/Display.html?id=',
+    Templates	=> 'Admin/Global/Template.html?Template=',
+    Scrips	=> 'Admin/Global/Scrip.html?id=',
+    Queues	=> 'Admin/Queues/Modify.html?id=',
+    Users	=> 'Admin/Users/Modify.html?id=',
+    Groups	=> 'Admin/Groups/Modify.html?id=',
+);
+
+my %entry = map { $_ => eval { $Object->$_ } || '' } qw(Id Name Description URI);
+$entry{Created} = eval { $Object->CreatedObj->W3CDTF }
+    || eval { $Object->PrincipalObj->CreatedObj->W3CDTF };
+$entry{LastUpdated} = eval { $Object->LastUpdatedObj->W3CDTF }
+    || eval { $Object->PrincipalObj->LastUpdatedObj->W3CDTF };
+
+if ($URI{$Type}) {
+    $entry{HTML_URI} = $URI{$Type} . $entry{Id};
+    if (my $queue = eval { $Object->Queue } ) {
+	$entry{HTML_URI} =~ s/Global/Queues/;
+	$entry{Params} .= "&Queue=$queue";
+    }
+}
+</%INIT>
+<%ARGS>
+$Object
+$Path
+$BaseURI
+$Now
+$ShowLink
+$ShowEntry
+
+$Type
+$CollectionClass
+$FeedURI
+</%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 07:16:29 2004
@@ -6,7 +6,7 @@
     'alternate'	    => 'HTML',	# loc
     'service.post'  => 'Add',	# loc
     'service.feed'  => 'Index',	# loc
-    'service.edit'  => 'Edit',	# loc
+    'service.edit'  => 'Show',	# loc
 );
 my $class = lc($Class || $TextMap{$Relation} || 'nav');
 my %KeyMap = (

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 07:16:29 2004
@@ -3,3 +3,47 @@
 %# 200: Success.  Body is the object, serialized as an AtomEntry.
 %# 400: Request failed.  Body is error message in text/plain.
 %# 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 &>
+  <content type="text/xml" mode="xml">
+% 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>
+% }
+% $m->print($xml);
+  </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 $struct = $m->comp($handler, id => $id, fields => {})->[2];
+
+require XML::Simple;
+my $xs = XML::Simple->new(RootName => 'object', NoIndent => 0);
+my $xml = $xs->XMLout($struct);
+$xml =~ s/"Not set"/""/g;
+$xml =~ s/" "/"\n"/g;
+</%INIT>
+<%ARGS>
+$ShowLink
+$ShowEntry
+$BaseURI
+$Path
+$CollectionClass
+</%ARGS>

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 07:16:29 2004
@@ -66,7 +66,7 @@
   background-color: #cccccc;
 }
 
-a.edit {
+a.show {
   background-color: #cccc66;
   color: #000033;
   font-weight: bold;
@@ -83,7 +83,7 @@
   background:#eeeeee;
 }
 
-id, modified, created, generator, issued, url {
+id, modified, created, generator, issued, url, object {
   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 07:16:29 2004
@@ -13,48 +13,40 @@
     <url><% $RT::WebURL %></url>
   </author>
   <tagline mode="escaped">
+% if ($TotalFound) {
     <&|/l, $page, int(($TotalFound-1)/$rows)+1&>Page [_1] of [_2]</&>
     (<&|/l, $TotalFound&>[_1] Total</&>)
+% }
   </tagline>
-  <& $Link, Relation => "service.feed", URI => $BaseURI, Title => loc("Homepage") &>
-  <& $Link, Relation => "service.post", URI => "$FeedURI!add", 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) &>
+  <& $ShowLink, Relation => "service.feed", URI => $BaseURI, Title => loc("Homepage") &>
+  <& $ShowLink, Relation => "service.post", URI => "$FeedURI!add", Title => loc("Create"). ": ". loc($Type) &>
+% # XXX - The URI below is incorrect; should point to collection URL
+  <& $ShowLink, 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} || "#$entry->{Id}" %></title>
-    <& $Link, Relation => "service.edit", URI => "$FeedURI/$entry->{Id}", Title => loc("Edit"). ": $entry->{Name}", IsEntry => 1 &>
-% if ($entry->{HTML_URI}) {
-    <& $Link, Type => 'text/html', URI => "$RT::WebURL$entry->{HTML_URI}", Title => $entry->{Name} &>
+% while (my $obj = $List->Next) {
+    <& $ShowEntry, %ARGS, Object => $obj &>
 % }
-    <summary mode="escaped"><% $entry->{Description} %></summary>
-    <issued><% $entry->{Created} %></issued>
-    <modified><% $entry->{LastUpdated} %></modified>
-    <id><% $entry->{URI} %></id>
   </entry>
-% }
   <info></info>
 % if ($page > 1) {
-  <& $Link, URI => "$FeedURI?$prev", Title => loc("Previous Page"), Relation => 'prev', &>
+  <& $ShowLink, URI => "$FeedURI?$prev", Title => loc("Previous Page"), Relation => 'prev', &>
 % }
 % if (($page * $rows) < $TotalFound) {
-  <& $Link, URI => "$FeedURI?$next", Title => loc("Next Page"), Relation => 'next', &>
+  <& $ShowLink, URI => "$FeedURI?$next", Title => loc("Next Page"), Relation => 'next', &>
 % }
 </feed>
 <%INIT>
-my %URI = (
-    Tickets	=> 'Ticket/Display.html?id=',
-    Templates	=> 'Admin/Global/Template.html?Template=',
-    Scrips	=> 'Admin/Global/Scrip.html?id=',
-    Queues	=> 'Admin/Queues/Modify.html?id=',
-    Users	=> 'Admin/Users/Modify.html?id=',
-    Groups	=> 'Admin/Groups/Modify.html?id=',
-);
 
 my $List = $CollectionClass->new($session{CurrentUser});
-$List->UnLimit;
+
+if (defined($rows) and $List->isa('RT::Tickets')) {
+    $List->FromSQL( $query || "Type = 'ticket'" );
+}
+else {
+    $List->UnLimit;
+}
 $List->RowsPerPage($rows) if $rows > 0;
 $List->GotoPage($page - 1) if $page > 0;
 
@@ -62,26 +54,6 @@
 $rows = $TotalFound if $rows <= 0;
 $page = 1 if $page <= 0;
 
-my @entries;
-
-while (my $entry = $List->Next) {
-    my %entry = map { $_ => eval { $entry->$_ } || '' }
-	qw(Id Name Description URI);
-    $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{HTML_URI} = $URI{$Type} . $entry{Id};
-	if (my $queue = eval { $entry->Queue } ) {
-	    $entry{HTML_URI} =~ s/Global/Queues/;
-	    $entry{Params} .= "&Queue=$queue";
-	}
-    }
-    push @entries, \%entry;
-}
-
 my %query;
 while (my ($k, $v) = each %ARGS) {
     $query{$k} = $v if $k eq lc($k);
@@ -93,14 +65,15 @@
 <%ARGS>
 $Path
 $BaseURI
-$Link
 $Now
+$ShowLink
+$ShowEntry
 
 $Type
 $CollectionClass
 $FeedURI
 
-$rows => 10
+$rows => undef
 $page => 1
 $query => undef
 </%ARGS>

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 07:16:29 2004
@@ -191,7 +191,8 @@
 
 $ARGS{Path} = $path;
 $ARGS{BaseURI} = $BaseURI;
-$ARGS{Link} = "/Atom/0.3/Elements/Link";
+$ARGS{ShowLink} = "/Atom/0.3/Elements/Link";
+$ARGS{ShowEntry} = "/Atom/0.3/Elements/Entry";
 $ARGS{Now} = RT::Date->new($session{CurrentUser});
 $ARGS{Now}->SetToNow;
 

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 07:16:29 2004
@@ -8,12 +8,12 @@
     <url><% $RT::WebURL %></url>
   </author>
   <modified><% $Now->W3CDTF %></modified>
-  <& $Link, Type => 'text/html', URI => $RT::WebURL, Title => loc("Homepage") &>
+  <& $ShowLink, Type => 'text/html', URI => $RT::WebURL, Title => loc("Homepage") &>
 % foreach my $type (@{$m->comp('Elements/Introspect', Want => 'TopLevelCollections')}) {
   <entry>
     <title><% loc($type) %></title>
-    <& $Link, Class => "Index", URI => "$BaseURI/$type", Title => loc($type), IsEntry => 1 &>
-    <& $Link, Relation => 'service.post', URI => "$BaseURI/$type!add", Title => loc("Create") . ": " . loc($type) &>
+    <& $ShowLink, Class => "Index", URI => "$BaseURI/$type?rows=all", Title => loc($type), IsEntry => 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>
     <modified><% $Now->W3CDTF %></modified>
@@ -24,6 +24,6 @@
 <%ARGS>
 $Path
 $BaseURI
-$Link
+$ShowLink
 $Now
 </%ARGS>


More information about the Rt-commit mailing list