]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Moved javascript files under the ikiwiki/ directory, to avoid cluttering the top...
authorJoey Hess <joey@kitenet.net>
Sat, 24 Apr 2010 04:54:59 +0000 (00:54 -0400)
committerJoey Hess <joey@kitenet.net>
Sat, 24 Apr 2010 04:54:59 +0000 (00:54 -0400)
IkiWiki/Plugin/relativedate.pm
IkiWiki/Plugin/toggle.pm
debian/changelog
debian/postinst
underlays/javascript/ikiwiki.js [deleted file]
underlays/javascript/ikiwiki/ikiwiki.js [new file with mode: 0644]
underlays/javascript/ikiwiki/relativedate.js [new file with mode: 0644]
underlays/javascript/ikiwiki/toggle.js [new file with mode: 0644]
underlays/javascript/relativedate.js [deleted file]
underlays/javascript/toggle.js [deleted file]

index 7f006af839e7cf1eb50002c73262e7aac3234291..7e615f7f1685c32a2586cb3a49abfc67acea6828 100644 (file)
@@ -37,9 +37,9 @@ sub include_javascript ($;$) {
        my $page=shift;
        my $absolute=shift;
        
-       return '<script src="'.urlto("ikiwiki.js", $page, $absolute).
+       return '<script src="'.urlto("ikiwiki/ikiwiki.js", $page, $absolute).
                '" type="text/javascript" charset="utf-8"></script>'."\n".
-               '<script src="'.urlto("relativedate.js", $page, $absolute).
+               '<script src="'.urlto("ikiwiki/relativedate.js", $page, $absolute).
                '" type="text/javascript" charset="utf-8"></script>';
 }
 
index f9c89954044e30aefbd5627773e5886fb0941e2d..3319421d923d56c3489b7374edb912be7493027b 100644 (file)
@@ -81,9 +81,9 @@ sub include_javascript ($;$) {
        my $page=shift;
        my $absolute=shift;
        
-       return '<script src="'.urlto("ikiwiki.js", $page, $absolute).
+       return '<script src="'.urlto("ikiwiki/ikiwiki.js", $page, $absolute).
                '" type="text/javascript" charset="utf-8"></script>'."\n".
-               '<script src="'.urlto("toggle.js", $page, $absolute).
+               '<script src="'.urlto("ikiwiki/toggle.js", $page, $absolute).
                '" type="text/javascript" charset="utf-8"></script>';
 }
 
index 0ab04f522864ab2c1bff2bcae802f00b49d01801..f9d012e42faf3cc0adcb45dc76be09694ac20df1 100644 (file)
@@ -1,4 +1,4 @@
-ikiwiki (3.20100422) UNRELEASED; urgency=low
+ikiwiki (3.20100424) UNRELEASED; urgency=low
 
   [ Joey Hess ]
   * tag: Automatic creation of tag pages can now be enabled using
@@ -66,6 +66,9 @@ ikiwiki (3.20100422) UNRELEASED; urgency=low
     (Jelmer Vernooij)
   * Quite a lot of new optimisations, and one major fix to a recent
     performance regression.
+  * Moved javascript files under the ikiwiki/ directory, to avoid cluttering
+    the top of the web root. This is another things that requires a wiki
+    rebuild on upgrade to this version.
 
  -- Joey Hess <joeyh@debian.org>  Sun, 04 Apr 2010 12:17:11 -0400
 
index 810b7cfe04dd518ad1c7bd7c90a41fde5f4d616c..76ad115ac0ddc6512832997ea20d66e2d05fc10a 100755 (executable)
@@ -4,7 +4,7 @@ set -e
 
 # Change this when some incompatible change is made that requires
 # rebuilding all wikis.
-firstcompat=3.20100422
+firstcompat=3.20100424
 
 if [ "$1" = configure ] && \
    dpkg --compare-versions "$2" lt "$firstcompat"; then
diff --git a/underlays/javascript/ikiwiki.js b/underlays/javascript/ikiwiki.js
deleted file mode 100644 (file)
index aebc5cf..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-// ikiwiki's javascript utility function library
-
-var hooks;
-
-// Run onload as soon as the DOM is ready, if possible.
-// gecko, opera 9
-if (document.addEventListener) {
-       document.addEventListener("DOMContentLoaded", run_hooks_onload, false);
-}
-// other browsers
-window.onload = run_hooks_onload;
-
-var onload_done = 0;
-
-function run_hooks_onload() {
-       // avoid firing twice
-       if (onload_done)
-               return;
-       onload_done = true;
-
-       run_hooks("onload");
-}
-
-function run_hooks(name) {
-       if (typeof(hooks) != "undefined") {
-               for (var i = 0; i < hooks.length; i++) {
-                       if (hooks[i].name == name) {
-                               hooks[i].call();
-                       }
-               }
-       }
-}
-
-function hook(name, call) {
-       if (typeof(hooks) == "undefined")
-               hooks = new Array;
-       hooks.push({name: name, call: call});
-}
-
-function getElementsByClass(cls, node, tag) {
-        if (document.getElementsByClass)
-                return document.getElementsByClass(cls, node, tag);
-        if (! node) node = document;
-        if (! tag) tag = '*';
-        var ret = new Array();
-        var pattern = new RegExp("(^|\\s)"+cls+"(\\s|$)");
-        var els = node.getElementsByTagName(tag);
-        for (i = 0; i < els.length; i++) {
-                if ( pattern.test(els[i].className) ) {
-                        ret.push(els[i]);
-                }
-        }
-        return ret;
-}
diff --git a/underlays/javascript/ikiwiki/ikiwiki.js b/underlays/javascript/ikiwiki/ikiwiki.js
new file mode 100644 (file)
index 0000000..aebc5cf
--- /dev/null
@@ -0,0 +1,54 @@
+// ikiwiki's javascript utility function library
+
+var hooks;
+
+// Run onload as soon as the DOM is ready, if possible.
+// gecko, opera 9
+if (document.addEventListener) {
+       document.addEventListener("DOMContentLoaded", run_hooks_onload, false);
+}
+// other browsers
+window.onload = run_hooks_onload;
+
+var onload_done = 0;
+
+function run_hooks_onload() {
+       // avoid firing twice
+       if (onload_done)
+               return;
+       onload_done = true;
+
+       run_hooks("onload");
+}
+
+function run_hooks(name) {
+       if (typeof(hooks) != "undefined") {
+               for (var i = 0; i < hooks.length; i++) {
+                       if (hooks[i].name == name) {
+                               hooks[i].call();
+                       }
+               }
+       }
+}
+
+function hook(name, call) {
+       if (typeof(hooks) == "undefined")
+               hooks = new Array;
+       hooks.push({name: name, call: call});
+}
+
+function getElementsByClass(cls, node, tag) {
+        if (document.getElementsByClass)
+                return document.getElementsByClass(cls, node, tag);
+        if (! node) node = document;
+        if (! tag) tag = '*';
+        var ret = new Array();
+        var pattern = new RegExp("(^|\\s)"+cls+"(\\s|$)");
+        var els = node.getElementsByTagName(tag);
+        for (i = 0; i < els.length; i++) {
+                if ( pattern.test(els[i].className) ) {
+                        ret.push(els[i]);
+                }
+        }
+        return ret;
+}
diff --git a/underlays/javascript/ikiwiki/relativedate.js b/underlays/javascript/ikiwiki/relativedate.js
new file mode 100644 (file)
index 0000000..5142332
--- /dev/null
@@ -0,0 +1,76 @@
+// Causes html elements in the 'relativedate' class to be displayed
+// as relative dates. The date is parsed from the title attribute, or from
+// the element content.
+
+var dateElements;
+
+hook("onload", getDates);
+
+function getDates() {
+       dateElements = getElementsByClass('relativedate');
+       for (var i = 0; i < dateElements.length; i++) {
+               var elt = dateElements[i];
+               var title = elt.attributes.title;
+               var d = new Date(title ? title.value : elt.innerHTML);
+               if (! isNaN(d)) {
+                       dateElements[i].date=d;
+                       elt.title=elt.innerHTML;
+               }
+       }
+
+       showDates();
+}
+
+function showDates() {
+       for (var i = 0; i < dateElements.length; i++) {
+               var elt = dateElements[i];
+               var d = elt.date;
+               if (! isNaN(d)) {
+                       elt.innerHTML=relativeDate(d);
+               }
+       }
+       setTimeout(showDates,30000); // keep updating every 30s
+}
+
+var timeUnits = new Array;
+timeUnits['minute'] = 60;
+timeUnits['hour'] = timeUnits['minute'] * 60;
+timeUnits['day'] = timeUnits['hour'] * 24;
+timeUnits['month'] = timeUnits['day'] * 30;
+timeUnits['year'] = timeUnits['day'] * 364;
+var timeUnitOrder = ['year', 'month', 'day', 'hour', 'minute'];
+
+function relativeDate(date) {
+       var now = new Date();
+       var offset = date.getTime() - now.getTime();
+       var seconds = Math.round(Math.abs(offset) / 1000);
+
+       // hack to avoid reading just in the future if there is a minor
+       // amount of clock slip
+       if (offset >= 0 && seconds < 30 * timeUnits['minute']) {
+               return "just now";
+       }
+
+       var ret = "";
+       var shown = 0;
+       for (i = 0; i < timeUnitOrder.length; i++) {
+               var unit = timeUnitOrder[i];
+               if (seconds >= timeUnits[unit]) {
+                       var num = Math.floor(seconds / timeUnits[unit]);
+                       seconds -= num * timeUnits[unit];
+                       if (ret)
+                               ret += "and ";
+                       ret += num + " " + unit + (num > 1 ? "s" : "") + " ";
+
+                       if (++shown == 2)
+                               break;
+               }
+               else if (shown)
+                       break;
+       }
+
+       if (! ret)
+               ret = "less than a minute "
+
+       return ret + (offset < 0 ? "ago" : "from now");
+}
diff --git a/underlays/javascript/ikiwiki/toggle.js b/underlays/javascript/ikiwiki/toggle.js
new file mode 100644 (file)
index 0000000..d190b73
--- /dev/null
@@ -0,0 +1,29 @@
+// Uses CSS to hide toggleables, to avoid any flashing on page load. The
+// CSS is only emitted after it tests that it's going to be able
+// to show the toggleables.
+if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
+       document.write('<style type="text/css">div.toggleable { display: none; }</style>');
+       hook("onload", inittoggle);
+}
+
+function inittoggle() {
+       var as = getElementsByClass('toggle');
+       for (var i = 0; i < as.length; i++) {
+               var id = as[i].href.match(/#(\w.+)/)[1];
+               if (document.getElementById(id).className == "toggleable")
+                       document.getElementById(id).style.display="none";
+               as[i].onclick = function() {
+                       toggle(this);
+                       return false;
+               }
+       }
+}
+
+function toggle(s) {
+       var id = s.href.match(/#(\w.+)/)[1];
+       style = document.getElementById(id).style;
+       if (style.display == "none")
+               style.display = "block";
+       else
+               style.display = "none";
+}
diff --git a/underlays/javascript/relativedate.js b/underlays/javascript/relativedate.js
deleted file mode 100644 (file)
index 5142332..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-// Causes html elements in the 'relativedate' class to be displayed
-// as relative dates. The date is parsed from the title attribute, or from
-// the element content.
-
-var dateElements;
-
-hook("onload", getDates);
-
-function getDates() {
-       dateElements = getElementsByClass('relativedate');
-       for (var i = 0; i < dateElements.length; i++) {
-               var elt = dateElements[i];
-               var title = elt.attributes.title;
-               var d = new Date(title ? title.value : elt.innerHTML);
-               if (! isNaN(d)) {
-                       dateElements[i].date=d;
-                       elt.title=elt.innerHTML;
-               }
-       }
-
-       showDates();
-}
-
-function showDates() {
-       for (var i = 0; i < dateElements.length; i++) {
-               var elt = dateElements[i];
-               var d = elt.date;
-               if (! isNaN(d)) {
-                       elt.innerHTML=relativeDate(d);
-               }
-       }
-       setTimeout(showDates,30000); // keep updating every 30s
-}
-
-var timeUnits = new Array;
-timeUnits['minute'] = 60;
-timeUnits['hour'] = timeUnits['minute'] * 60;
-timeUnits['day'] = timeUnits['hour'] * 24;
-timeUnits['month'] = timeUnits['day'] * 30;
-timeUnits['year'] = timeUnits['day'] * 364;
-var timeUnitOrder = ['year', 'month', 'day', 'hour', 'minute'];
-
-function relativeDate(date) {
-       var now = new Date();
-       var offset = date.getTime() - now.getTime();
-       var seconds = Math.round(Math.abs(offset) / 1000);
-
-       // hack to avoid reading just in the future if there is a minor
-       // amount of clock slip
-       if (offset >= 0 && seconds < 30 * timeUnits['minute']) {
-               return "just now";
-       }
-
-       var ret = "";
-       var shown = 0;
-       for (i = 0; i < timeUnitOrder.length; i++) {
-               var unit = timeUnitOrder[i];
-               if (seconds >= timeUnits[unit]) {
-                       var num = Math.floor(seconds / timeUnits[unit]);
-                       seconds -= num * timeUnits[unit];
-                       if (ret)
-                               ret += "and ";
-                       ret += num + " " + unit + (num > 1 ? "s" : "") + " ";
-
-                       if (++shown == 2)
-                               break;
-               }
-               else if (shown)
-                       break;
-       }
-
-       if (! ret)
-               ret = "less than a minute "
-
-       return ret + (offset < 0 ? "ago" : "from now");
-}
diff --git a/underlays/javascript/toggle.js b/underlays/javascript/toggle.js
deleted file mode 100644 (file)
index d190b73..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Uses CSS to hide toggleables, to avoid any flashing on page load. The
-// CSS is only emitted after it tests that it's going to be able
-// to show the toggleables.
-if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
-       document.write('<style type="text/css">div.toggleable { display: none; }</style>');
-       hook("onload", inittoggle);
-}
-
-function inittoggle() {
-       var as = getElementsByClass('toggle');
-       for (var i = 0; i < as.length; i++) {
-               var id = as[i].href.match(/#(\w.+)/)[1];
-               if (document.getElementById(id).className == "toggleable")
-                       document.getElementById(id).style.display="none";
-               as[i].onclick = function() {
-                       toggle(this);
-                       return false;
-               }
-       }
-}
-
-function toggle(s) {
-       var id = s.href.match(/#(\w.+)/)[1];
-       style = document.getElementById(id).style;
-       if (style.display == "none")
-               style.display = "block";
-       else
-               style.display = "none";
-}