[Debtags-commits] [svn] r1982 - in web/trunk: . js

Enrico Zini enrico at costa.debian.org
Mon Oct 2 21:26:40 UTC 2006


Author: enrico
Date: Mon Oct  2 21:26:39 2006
New Revision: 1982

Modified:
   web/trunk/edit.html
   web/trunk/js/debtags.js
   web/trunk/js/test.html
   web/trunk/main.css
Log:
Implemented receiving package data

Modified: web/trunk/edit.html
==============================================================================
--- web/trunk/edit.html	(original)
+++ web/trunk/edit.html	Mon Oct  2 21:26:39 2006
@@ -22,26 +22,33 @@
 
 function setPackage(p)
 {
-	pkg = p;
-
-	render("pkgname", pkg);
-	// TODO: get origtags
-	origtags.addAll(["use::editing", "implemented-in::c++"]);
-	// TODO: get short and long description
-	// TODO: validate package name
-	updateAll();
-
-	fireSUGGQuery(pkg, function(tags){
-			suggested = new Array();
-			for (i in tags)
-				suggested.push(tags[i][0]);
-			updateSuggested();
-	}, function(tags) {
-			suggested = new Array();
-			for (i in tags)
-				suggested.push(tags[i][0]);
-			updateSuggested();
-	}, true);
+	firePKGQuery(p, function(){}, function(ts, sdesc, ldesc){
+		// Validate package name
+		if (sdesc == null) return;
+
+		pkg = p;
+		render("pkgname", pkg);
+
+		origtags = ts.copy();
+		tags = origtags.copy();
+
+		render("pkgsdesc", sdesc);
+		render("pkgldesc", ldesc);
+
+		updateAll();
+
+		fireSUGGQuery(pkg, function(tags){
+				suggested = new Array();
+				for (i in tags)
+					suggested.push(tags[i][0]);
+				updateSuggested();
+		}, function(tags) {
+				suggested = new Array();
+				for (i in tags)
+					suggested.push(tags[i][0]);
+				updateSuggested();
+		}, true);
+	});
 }
 
 function addTag(tag)
@@ -218,10 +225,8 @@
 
 	<div id="editor">
 		<div id="curpackage">
-			<p><span id="pkgname"> </span> - <b>SHORTDESC</b></p>
-			<div class="ldesc">
-				LONGDESC
-			</div>
+			<p><span id="pkgname"> </span> - <span id="pkgsdesc"> </span></p>
+			<div id="pkgldesc"> </div>
 			<a href="http://packages.debian.org/PACKAGE">Debian page</a>
 			<a href="http://packages.qa.debian.org/PACKAGE">Debian QA page</a>
 			<div id="curpatch">

Modified: web/trunk/js/debtags.js
==============================================================================
--- web/trunk/js/debtags.js	(original)
+++ web/trunk/js/debtags.js	Mon Oct  2 21:26:39 2006
@@ -172,6 +172,44 @@
 	);
 }
 
+function firePKGQuery(pkg, progressFunc, finalFunc, async)
+{
+	var packageDataRegexp = new RegExp("^(\\S+) (\\S*) (.+)$");
+  var runDecoded = function(fun, lines){
+		if (lines.length == 0)
+			return fun(null, null, null);
+
+		var fields = packageDataRegexp(lines.shift());
+		if (!fields || fields.length < 4)
+			return fun(null, null, null);
+
+		var ts = new Tagset();
+		ts.addAll(fields[2].split(","));
+
+		// Format the long description into HTML
+		for (i in lines)
+		{
+			// Trim leading and trailing spaces
+			lines[i] = lines[i].replace(/^[ \t]/, "");
+			lines[i] = lines[i].replace(/[ \t]$/, "");
+			// Format paragraph breaks
+			if (lines[i] == "") lines[i] = "</p><p>";
+			lines[i] = lines[i].replace(/^[*+-][ \t]+/, "<li>");
+		}
+		lines = "<p>"+lines.join("\n")+"</p>";
+		return fun(ts, fields[3], lines);
+	};
+	runRequest(QUERY_BASE + "/pkg/"+pkg,
+		function(lines) {
+			runDecoded(progressFunc, lines);
+		},
+		function(lines) {
+			runDecoded(finalFunc, lines);
+		},
+		async
+	);
+}
+
 //
 // Debtags infrastructure
 //

Modified: web/trunk/js/test.html
==============================================================================
--- web/trunk/js/test.html	(original)
+++ web/trunk/js/test.html	Mon Oct  2 21:26:39 2006
@@ -181,6 +181,16 @@
   ensure("should have a result", t != null);
   ensure("should have more than 10 tags inside", t.length > 10);
 
+var count = 0;
+var tset = null;
+var sdesc = null;
+var ldesc = null;
+firePKGQuery("debtags", function(t, s, l){++count;}, function(t, s, l){++count; tset=t; sdesc=s; ldesc=l;}, false);
+  ensure_equals("sync query has no partial events", count, 1);
+  ensure("should have tags in the result", tset != null);
+  ensure("should have sdesc in the result", sdesc != null);
+  ensure("should have ldesc in the result", ldesc != null);
+
 /*
 var a = {};
 a["antani"] = "blinda";

Modified: web/trunk/main.css
==============================================================================
--- web/trunk/main.css	(original)
+++ web/trunk/main.css	Mon Oct  2 21:26:39 2006
@@ -116,6 +116,11 @@
 	font-weight: bold;
 }
 
+#pkgldesc {
+	margin-left: 2em;
+	margin-right: 2em;
+}
+
 #atfacets {
 	float: right;
 	width: 33%;



More information about the Debtags-commits mailing list