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

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Wed May 5 19:35:06 EDT 2004


Author: autrijus
Date: Wed May  5 19:35:05 2004
New Revision: 835

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/Search/index
   RTx-Atom/html/Atom/0.3/dhandler
Log:
 ----------------------------------------------------------------------
 r4474 at not:  autrijus | 2004-05-05T22:48:14.233017Z
 
 * Handle Accept-Charset do return a legacy encoding representation.
 ----------------------------------------------------------------------
 r4475 at not:  autrijus | 2004-05-05T23:11:47.656666Z
 
 * Correctly encode ustrings.
 * Will now explicitly die if we support none of the encodings requested.
 ----------------------------------------------------------------------
 r4476 at not:  autrijus | 2004-05-05T23:25:22.948801Z
 
 * Further improve autodiscovery by limitink all Atom links to use absolute
   member IDs, instead of human-readable text, as their title="".  The human-
   readable title is still available from <html:link>.
 ----------------------------------------------------------------------


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	Wed May  5 19:35:05 2004
@@ -1,12 +1,12 @@
 %# 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 => $entry{Name}, IsChild => $IsChild &>
+    <& $ShowLink, Relation => "service.edit", URI => "$FeedURI/$entry{Id}", Id => $entry{Id}, Title => $entry{Name}, IsChild => $IsChild &>
 % } elsif ("$BaseURI/$Path" =~ m{^(.+)/}) {
-    <& $ShowLink, Relation => "service.feed", URI => "$1?", Title => "_Up" &>
+    <& $ShowLink, Relation => "service.feed", URI => "$1?", Id => "_up", Title => "Up" &>
 % }
 % if ($entry{HTML_URI}) {
-    <& $ShowLink, Type => 'text/html', URI => "$RT::WebURL$entry{HTML_URI}", Title => $entry{Name} &>
+    <& $ShowLink, Type => 'text/html', URI => "$RT::WebURL$entry{HTML_URI}", Id => $entry{Id}, Title => $entry{Name} &>
 % }
     <summary mode="escaped"><% $entry{Subject} || $entry{Description} %></summary>
     <issued><% $entry{Created} %></issued>

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	Wed May  5 19:35:05 2004
@@ -1,8 +1,7 @@
 %# Make a HTML link and an Atom link
-<link rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" />
+<link rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Id || $Title %>" />
 % return if $session{AtomClient};
 % $URI =~ s/\?$/?rows=10/g;
-% $Title =~ s/^_//;
 % $Title = loc($Class) . ' - ' . loc($Title);
 <html:link rel="<% $Relation %>" type="<% $Type %>" href="<% $URI %>" title="<% $Title %>" />
 % return unless length $Text;
@@ -43,6 +42,7 @@
 $Relation => "alternate"
 $Type => "application/x.atom+xml"
 $URI => "#"
+$Id => ""
 $Title => ""
 $Text => undef
 $IsChild => 0

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	Wed May  5 19:35:05 2004
@@ -18,8 +18,8 @@
     (<&|/l, $TotalFound&>[_1] Total</&>)
 % }
   </tagline>
-  <& $ShowLink, Relation => "service.feed", URI => $BaseURI, Title => "_Up" &>
-  <& $ShowLink, Relation => "service.post", URI => "$FeedURI!add", Title => $Type &>
+  <& $ShowLink, Relation => "service.feed", URI => $BaseURI, Id => '_up', Title => "Up" &>
+  <& $ShowLink, Relation => "service.post", URI => "$FeedURI!add", Id => '!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>

Modified: RTx-Atom/html/Atom/0.3/dhandler
==============================================================================
--- RTx-Atom/html/Atom/0.3/dhandler	(original)
+++ RTx-Atom/html/Atom/0.3/dhandler	Wed May  5 19:35:05 2004
@@ -14,12 +14,32 @@
 my %methods = map {($_ => 1)} @RT::AtomAuthenticationMethods;
 
 my %accept = map { $_ => 1 } $r->header_in('Accept') =~ m{([^\s,]+/[^;,]+)}g;
+my @encodings = $r->header_in('Accept-Charset') =~ m{([^\s,]+[^;,]*)}g;
 my $atom_client = $accept{'application/x.atom+xml'};
 
 my $header_out = sub {
     $ENV{FCGI_ROLE} ? $r->header_out(@_) : $r->headers_out->add(@_);
 };
 
+my $http_charset;
+if (@encodings) {
+    require Encode;
+    my $is_fatal = 1;
+    foreach my $encoding (@encodings) {
+	$is_fatal = 0 if $encoding eq '*';
+	my $enc = Encode::find_encoding($encoding) or next;
+	if ($enc->name eq 'utf8') {
+	    $is_fatal = 0;
+	    last;
+	}
+	$http_charset = $encoding;
+	$m->notes('encoding', $encoding);
+	last;
+    }
+    return $m->comp('Elements/Error', Status => 406) if $is_fatal and !$http_charset;
+}
+$http_charset ||= 'utf-8';
+
 $header_out->(
     'WWW-Authenticate' => qq(WSSE realm="$realm", profile="UsernameToken")
 ) if $methods{WSSE} and $atom_client;
@@ -228,7 +248,7 @@
     last;
 }
 
-$r->content_type("$content_type; charset=utf-8");
+$r->content_type("$content_type; charset=$http_charset");
 $session{AtomClient} = $atom_client;
 
 if (!$class) {
@@ -244,6 +264,14 @@
     FeedURI => "$BaseURI/$type",
 );
 </%INIT>
+<%FILTER>
+if (my $encoding = $m->notes('encoding')) {
+    require Encode;
+    s/encoding="utf-8"/encoding="$encoding"/;
+    Encode::_utf8_off($_);
+    Encode::from_to($_, 'utf-8', $encoding, Encode::FB_XMLCREF());
+}
+</%FILTER>
 <%FLAGS>
 inherit	=> undef
 </%FLAGS>


More information about the Rt-commit mailing list