r20260 - in /scripts/qa: pkginfo.cgi qareport-chlog.cgi templates/by_category templates/by_category.js

tincho at users.alioth.debian.org tincho at users.alioth.debian.org
Wed May 21 22:30:33 UTC 2008


Author: tincho
Date: Wed May 21 22:30:33 2008
New Revision: 20260

URL: http://svn.debian.org/wsvn/?sc=1&rev=20260
Log:
First draft of a full-info baloon; generalising ajax routines in the way

Added:
    scripts/qa/pkginfo.cgi   (with props)
Modified:
    scripts/qa/qareport-chlog.cgi
    scripts/qa/templates/by_category
    scripts/qa/templates/by_category.js

Added: scripts/qa/pkginfo.cgi
URL: http://svn.debian.org/wsvn/scripts/qa/pkginfo.cgi?rev=20260&op=file
==============================================================================
--- scripts/qa/pkginfo.cgi (added)
+++ scripts/qa/pkginfo.cgi Wed May 21 22:30:33 2008
@@ -1,0 +1,85 @@
+#!/usr/bin/perl
+# vim:ts=4:sw=4:et:ai:sts=4
+# $Id: qareport-chlog.cgi 15720 2008-02-27 09:13:49Z dmn $
+#
+# Dump all info about a package
+#
+# Copyright Martín Ferrari <martin.ferrari at gmail.com>, 2008
+# Released under the terms of the GNU GPL 2
+use strict;
+use warnings;
+
+use DebianQA::Cache;
+use DebianQA::Config qw(read_config %CFG);
+
+use CGI ':fatalsToBrowser';
+use CGI ();
+use Date::Parse ();
+use File::Find ();
+use List::Util qw(max);
+use POSIX qw(locale_h);
+use Template ();
+
+read_config();
+
+my $cgi = new CGI;
+
+my $pkg = $cgi->param('pkg') or exit 0;
+my $cache = read_cache(consolidated => "");
+
+my @modified;
+# Find recent template files
+File::Find::find( { wanted => sub {
+            my $mtime = (stat)[9];
+            push @modified, $mtime if(-f _);
+        } }, $CFG{qareport_cgi}{templates_path} );
+my $script_date = '$Date: 2008-05-04 12:11:11 -0300 (dom, 04 may 2008) $';
+push @modified, Date::Parse::str2time(
+    join(' ', (split(/ /, $script_date))[1..3]));
+push @modified, (stat $CFG{common}{cache_dir} . "/consolidated")[9];
+
+my $last_modified = max @modified;
+
+if($ENV{GATEWAY_INTERFACE}) {
+    my $htmlp = $cgi->Accept("text/html");
+    my $xhtmlp = $cgi->Accept("application/xhtml+xml");
+
+    my $ims = $cgi->http('If-Modified-Since');
+    $ims = Date::Parse::str2time($ims) if $ims;
+
+    if($ims and $ims >= $last_modified) {
+        print $cgi->header('text/html', '304 Not modified');
+        exit 0;
+    }
+
+    my $old_locale = setlocale(LC_TIME);
+    setlocale(LC_TIME, "C");
+    print $cgi->header(
+        -content_type   => (
+                'text/plain; charset=utf-8'
+#                ($xhtmlp and $xhtmlp > $htmlp)
+#                ? 'application/xhtml+xml; charset=utf-8'
+#                : 'text/html; charset=utf-8'
+            ),
+        -last_modified   => POSIX::strftime(
+            "%a, %d %b %Y %T %Z",
+            localtime($last_modified),
+        )
+    );
+    setlocale(LC_TIME, $old_locale);
+}
+
+use Data::Dumper;
+foreach(qw(svn watch archive bts)) {
+    my $text = "$_\n", "-"x78, "\n";
+    $text .= Dumper($cache->{$_}{$pkg}) . "\n";
+    $text =~ s/&/&amp;/g;
+    $text =~ s/'/&apos;/g;
+    $text =~ s/"/&quot;/g;
+    $text =~ s/</&lt;/g;
+    $text =~ s/>/&gt;/g;
+    $text =~ s{\r?\n}{<br/>}g;
+    print qq(<code style="white-space: pre">$text</code>);
+}
+exit 0;
+

Propchange: scripts/qa/pkginfo.cgi
------------------------------------------------------------------------------
    svn:executable = *

Modified: scripts/qa/qareport-chlog.cgi
URL: http://svn.debian.org/wsvn/scripts/qa/qareport-chlog.cgi?rev=20260&op=diff
==============================================================================
--- scripts/qa/qareport-chlog.cgi (original)
+++ scripts/qa/qareport-chlog.cgi Wed May 21 22:30:33 2008
@@ -56,7 +56,9 @@
 $text =~ s{\bCPAN#(\d+)\b}
 {<a href="http://rt.cpan.org/Ticket/Display.html?id=$1">CPAN#$1</a>}gm;
 
-print qq(<a style="float: right; margin: 0 0 1pt 1pt; clear: none;" href="javascript:more_chlog('$pkg', '$rel')">reload</a>\n);
+print qq(<a style="float: right; margin: 0 0 1pt 1pt; clear: none;"
+    href="javascript:async_get( '${pkg}_${rel}_chlog_balloon',
+        'qareport-chlog.cgi?pkg=$pkg;rel=$rel')">reload</a>\n);
 print qq(<code style="white-space: pre">$text</code>);
 
 exit 0;

Modified: scripts/qa/templates/by_category
URL: http://svn.debian.org/wsvn/scripts/qa/templates/by_category?rev=20260&op=diff
==============================================================================
--- scripts/qa/templates/by_category (original)
+++ scripts/qa/templates/by_category Wed May 21 22:30:33 2008
@@ -117,6 +117,14 @@
             [% IF pkg.svn.section AND pkg.svn.section != "main" %]
             <span class="section-$pkg.svn.section">[$pkg.svn.section]</span>
             [% END #IF %]
+            <span class="pkg-moreinfo popup" >[more]
+                <span id="${pkg.name}_moreinfo_balloon" class="balloon">
+                    <a href="javascript:async_get(
+                    '${pkg.name}_moreinfo_balloon',
+                    'pkginfo.cgi?pkg=$pkg.name')">Click for full
+                    info</a>
+                </span>
+            </span>
             [% IF ! params.hide_binaries
                 AND pkg.svn.binaries AND pkg.svn.binaries.size
                 AND (
@@ -135,8 +143,10 @@
             [% chlog_url = BLOCK %][% pkg.svn.dir | format("$wsvn_url")
             %]/debian/changelog?op=file&amp;rev=0&amp;sc=0[% END %]
             <span class="popup svn-rel"><a href="$chlog_url">$svn_ver</a><span
-                    id="${pkg.svn.dir}_rel_chlog_baloon" class="balloon"><a
-                        href="javascript:more_chlog('$pkg.svn.dir','rel')">[%
+                    id="${pkg.svn.dir}_rel_chlog_balloon" class="balloon"><a
+                        href="javascript:async_get(
+                        '${pkg.svn.dir}_rel_chlog_balloon',
+                        'qareport-chlog.cgi?pkg=$pkg.svn.dir;rel=rel')" >[%
                         pkg.svn.changer | html %] &mdash; [% pkg.svn.date |
                         html %]</a>
             </span></span>
@@ -144,8 +154,10 @@
             [% IF svn_un_ver AND (svn_un_ver != svn_ver) %]
             <span class="popup svn-unrel"><a
                     href="$chlog_url">($svn_un_ver)</a><span
-                    id="${pkg.svn.dir}_unrel_chlog_baloon" class="balloon"><a
-                        href="javascript:more_chlog('$pkg.svn.dir','unrel')">[%
+                    id="${pkg.svn.dir}_unrel_chlog_balloon" class="balloon"><a
+                        href="javascript:async_get(
+                        '${pkg.svn.dir}_unrel_chlog_balloon',
+                        'qareport-chlog.cgi?pkg=$pkg.svn.dir;rel=unrel')" >[%
                         pkg.svn.un_changer | html %] &mdash; [% pkg.svn.un_date
                         | html %]</a></span></span>[% END #IF %]
             [% check_maint(pkg, "svn") %]

Modified: scripts/qa/templates/by_category.js
URL: http://svn.debian.org/wsvn/scripts/qa/templates/by_category.js?rev=20260&op=diff
==============================================================================
--- scripts/qa/templates/by_category.js (original)
+++ scripts/qa/templates/by_category.js Wed May 21 22:30:33 2008
@@ -3,7 +3,7 @@
     var el = document.getElementById(id);
     el.style.display = (el.style.display == 'none' ? 'table-row-group' : 'none');
 }
-function more_chlog(pkg,rel)
+function async_get(id, url)
 {
     var xml;
     if (window.XMLHttpRequest) {
@@ -14,21 +14,18 @@
 	alert("Your browser lacks the needed ability to use Ajax. Sorry.");
 	return false;
     }
-
-    xml.open('GET', 'qareport-chlog.cgi?pkg='+pkg+';rel='+rel);
-
+    xml.open('GET', url);
     xml.onreadystatechange = function() {
-	ajaxStateChanged(xml, pkg, rel);
+	ajaxStateChanged(xml, id);
     };
-
     xml.send('');
 }
-function ajaxStateChanged(xml, pkg, rel)
+function ajaxStateChanged(xml, id)
 {
-    var el = document.getElementById(pkg+'_'+rel+'_chlog_baloon');
+    var el = document.getElementById(id);
     if( !el )
     {
-	alert('Element "'+pkg+'_'+rel+'_chlog_baloon'+'" not found');
+	alert('Element "' + id + '" not found');
 	return false;
     }
     if( xml.readyState <= 1 )




More information about the Pkg-perl-cvs-commits mailing list