Permalink
Browse files

...monster checkin...

  • Loading branch information...
1 parent 29df998 commit 34764ebabd973ae32227f030441206d93b61bed2 @lnostdal committed Dec 16, 2011
View
@@ -72,6 +72,8 @@ found in jQuery. E.g., append, prepend, before and after:
http://api.jquery.com/category/manipulation/dom-insertion-inside/
http://api.jquery.com/category/manipulation/dom-insertion-outside/
+Code that blocks (I/O to DB etc.) is tagged with: [blocking]
+
## License
View
@@ -1,14 +1,24 @@
(defproject symbolicweb "1.0.0-SNAPSHOT"
:description "SymbolicWeb: WUI for Clojure"
:dependencies [[org.clojure/clojure "1.4.0-master-SNAPSHOT"]
+ [org.clojure/math.numeric-tower "0.0.2-SNAPSHOT"]
;; Yay, EPOLL() based handling of HTTP.
[aleph "0.2.1-SNAPSHOT"]
[overtone/at-at "0.2.1"]
+ ;;[clache "0.7.0"] ;; Caching.
+ ;;[unk "0.9.3"]
+ [org.apache.commons/collections "3.2.1"]
+
+ ;; JSON.
+ [cheshire "2.0.5-SNAPSHOT"]
+
[hiccup "0.3.7"]
[enlive "1.2.0-alpha1"]
+ [ring/ring-core "1.0.0-RC4"]
+
[org.clojure/java.jdbc "0.1.2-SNAPSHOT"]
- [ring "1.0.0-RC1"]
- [postgresql/postgresql "9.1-901.jdbc4"]]
+ [postgresql/postgresql "9.1-901.jdbc4"]
+ [c3p0/c3p0 "0.9.1.2"]] ;; DB connection pooling.
:jvm-opts ["-server" "-XX:+TieredCompilation"])
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <!-- Do want; http://blog.chromium.org/2009/09/introducing-google-chrome-frame.html -->
+ <meta http-equiv="X-UA-Compatible" content="chrome=1" />
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+
+ <title>SymbolicWeb</title>
+
+ <!-- [LRN] Notifications for show-Notification (sticky.clj). -->
+ <link href="/js/common/sticky/sticky.css" rel="stylesheet" type="text/css" />
+
+ <!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script> --> <!-- [LRN] -->
+ <script src="/js/common/jquery-1.7.1.min.js" type="text/javascript"></script>
+
+ <!-- [LRN] Notifications for show-Notification (sticky.clj). -->
+ <script src="/js/common/sticky/sticky.js" type="text/javascript"></script>
+
+ <!-- [LRN] SHA256 one-way hash for make-HashedInput (text_input.clj). -->
+ <script src="/js/common/sw/jquery.sha256/jquery.sha256.js" type="text/javascript"></script>
+
+ <!-- [LRN] These two <script> elements bootstrap SW. -->
+ <script type="text/javascript">
+ // [LRN] Switched to non-sync (A)JAX request here because this must be loaded before sw-ajax.js is loaded.
+ // [LRN] TODO: We could probably make a single async call here, but it must return both the bootstrap and the sw-ajax.js
+ // content in one go -- or in the right order if separate responses.
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: "/sw?page=sw-js-bootstrap&args=" + encodeURIComponent(window.location.search),
+ dataType: "script"
+ });
+ </script>
+ </head>
+
+ <body id="_body"> <!-- Setting ID allows SW to treat this as a widget via e.g. make-PostHTMLTemplate. -->
+ </body>
+</html>
@@ -1,13 +0,0 @@
-# SHA256
-
-jQuery SHA256 is a plugin based on the Javascript SHA256 implementation by [Angel Marin and Paul Johnston](http://anmar.eu.org/projects/jssha2/). It enables SHA256 hashing of a value and also generation of a keyed-Hash Message Authentication Code (HMAC) using a key along with the value.
-
-* Requires jQuery 1.3+
-* Docs: [http://code.alexweber.com.br/jquery/sha256](http://code.alexweber.com.br/jquery/sha256)
-
-
-## License
-
-The SHA256 plugin is Distributed under the terms of new [BSD License](http://www.opensource.org/licenses/bsd-license.php).
-
-Copyright (c) 2009 [Alex Weber](http://alexweber.com.br)
@@ -1,159 +0,0 @@
-/**
- * SHA256 Hash Algorithm Plugin
- *
- * @version 1.0 (06/09/2009)
- * @requires jQuery v1.2.6+
- * @author Alex Weber <alexweber.com.br>
- * @copyright Copyright (c) 2008-2009, Alex Weber
- * @see http://anmar.eu.org/projects/jssha2/
- * @see http://pajhome.org.uk/crypt/md5
- *
- * Distributed under the terms of the new BSD License
- * http://www.opensource.org/licenses/bsd-license.php
- */
-
-/**
- * This plugin is based on the following work:
- *
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
- * in FIPS 180-2
- * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- *
- */
-
-(function($) {
- var chrsz = 8; // bits per input character. 8 - ASCII; 16 - Unicode
-
- var safe_add = function(x, y) {
- var lsw = (x & 0xFFFF) + (y & 0xFFFF);
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- return (msw << 16) | (lsw & 0xFFFF);
- }
-
- var S = function(X, n) {
- return ( X >>> n ) | (X << (32 - n));
- }
-
- var R = function(X, n) {
- return ( X >>> n );
- }
-
- var Ch = function(x, y, z) {
- return ((x & y) ^ ((~x) & z));
- }
-
- var Maj = function(x, y, z) {
- return ((x & y) ^ (x & z) ^ (y & z));
- }
-
- var Sigma0256 = function(x) {
- return (S(x, 2) ^ S(x, 13) ^ S(x, 22));
- }
-
- var Sigma1256 = function(x) {
- return (S(x, 6) ^ S(x, 11) ^ S(x, 25));
- }
-
- var Gamma0256 = function(x) {
- return (S(x, 7) ^ S(x, 18) ^ R(x, 3));
- }
-
- var Gamma1256 = function (x) {
- return (S(x, 17) ^ S(x, 19) ^ R(x, 10));
- }
-
-
- var core_sha256 = function(m, l) {
- var K = new Array(0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0xFC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x6CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2);
- var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19);
- var W = new Array(64);
- var a, b, c, d, e, f, g, h, i, j;
- var T1, T2;
- /* append padding */
- m[l >> 5] |= 0x80 << (24 - l % 32);
- m[((l + 64 >> 9) << 4) + 15] = l;
- for ( var i = 0; i<m.length; i+=16 ) {
- a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7];
- for ( var j = 0; j<64; j++) {
- if (j < 16) {
- W[j] = m[j + i];
- }else{
- W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
- }
- T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);
- T2 = safe_add(Sigma0256(a), Maj(a, b, c));
- h = g; g = f; f = e; e = safe_add(d, T1); d = c; c = b; b = a; a = safe_add(T1, T2);
- }
- HASH[0] = safe_add(a, HASH[0]); HASH[1] = safe_add(b, HASH[1]); HASH[2] = safe_add(c, HASH[2]); HASH[3] = safe_add(d, HASH[3]);
- HASH[4] = safe_add(e, HASH[4]); HASH[5] = safe_add(f, HASH[5]); HASH[6] = safe_add(g, HASH[6]); HASH[7] = safe_add(h, HASH[7]);
- }
- return HASH;
- }
-
- var str2binb = function(str) {
- var bin = Array();
- var mask = (1 << chrsz) - 1;
- for(var i = 0; i < str.length * chrsz; i += chrsz){
- bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32);
- }
- return bin;
- }
-
- var binb2hex = function(binarray) {
- //var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
- //var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
- var hex_tab = "0123456789abcdef";
- var str = "";
- for (var i = 0; i < binarray.length * 4; i++) {
- str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
- }
- return str;
- }
-
- var core_hmac_sha256 = function(key, data) {
- var bkey = str2binb(key);
- if(bkey.length > 16) {
- bkey = core_sha1(bkey, key.length * chrsz);
- }
- var ipad = Array(16), opad = Array(16);
- for(var i = 0; i < 16; i++) {
- ipad[i] = bkey[i] ^ 0x36363636;
- opad[i] = bkey[i] ^ 0x5C5C5C5C;
- }
- var hash = core_sha256(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
- return core_sha256(opad.concat(hash), 512 + 256);
- }
-
- var prep = function(string){
- string = typeof string == 'object' ? $(string).val() : string.toString();
- return string;
- }
-
- // standard sha256 implementation: var x = $.sha256(value);
- // standard sha266hmac implementation: varx = $.sha256hmac(value1, value2);
- $.extend({
- sha256 : function(string){
- string = prep(string);
- return binb2hex(core_sha256(str2binb(string),string.length * chrsz));
- },
- sha256hmac : function(key, data){
- key = prep(key);
- data = prep(data);
- return binb2hex(core_hmac_sha256(key, data));
- },
- sha256config : function(bits){
- chrsz = parseInt(bits) || 8;
- }
- });
- // alternative sha256 implementation: var x = value.sha256();
- $.fn.sha256 = function (bits) {
- // change bits
- $.sha256config(bits);
- var string = prep($(this).val());
- var val = $.sha256(string);
- // reset bits, this was a one-time operation
- $.sha256config(8);
- return val;
- };
-})(jQuery);
@@ -1,15 +0,0 @@
-/**
- * SHA256 Hash Algorithm Plugin
- *
- * @version 1.0 (06/09/2009)
- * @requires jQuery v1.2.6+
- * @author Alex Weber <alexweber.com.br>
- * @copyright Copyright (c) 2008-2009, Alex Weber
- * @see http://anmar.eu.org/projects/jssha2/
- * @see http://pajhome.org.uk/crypt/md5
- *
- * Distributed under the terms of the new BSD License
- * http://www.opensource.org/licenses/bsd-license.php
- *
- */
-(function(f){var m=8;var k=function(q,t){var s=(q&65535)+(t&65535);var r=(q>>16)+(t>>16)+(s>>16);return(r<<16)|(s&65535)};var e=function(r,q){return(r>>>q)|(r<<(32-q))};var g=function(r,q){return(r>>>q)};var a=function(q,s,r){return((q&s)^((~q)&r))};var d=function(q,s,r){return((q&s)^(q&r)^(s&r))};var h=function(q){return(e(q,2)^e(q,13)^e(q,22))};var b=function(q){return(e(q,6)^e(q,11)^e(q,25))};var p=function(q){return(e(q,7)^e(q,18)^g(q,3))};var l=function(q){return(e(q,17)^e(q,19)^g(q,10))};var c=function(r,s){var E=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298);var t=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225);var q=new Array(64);var G,F,D,C,A,y,x,w,v,u;var B,z;r[s>>5]|=128<<(24-s%32);r[((s+64>>9)<<4)+15]=s;for(var v=0;v<r.length;v+=16){G=t[0];F=t[1];D=t[2];C=t[3];A=t[4];y=t[5];x=t[6];w=t[7];for(var u=0;u<64;u++){if(u<16){q[u]=r[u+v]}else{q[u]=k(k(k(l(q[u-2]),q[u-7]),p(q[u-15])),q[u-16])}B=k(k(k(k(w,b(A)),a(A,y,x)),E[u]),q[u]);z=k(h(G),d(G,F,D));w=x;x=y;y=A;A=k(C,B);C=D;D=F;F=G;G=k(B,z)}t[0]=k(G,t[0]);t[1]=k(F,t[1]);t[2]=k(D,t[2]);t[3]=k(C,t[3]);t[4]=k(A,t[4]);t[5]=k(y,t[5]);t[6]=k(x,t[6]);t[7]=k(w,t[7])}return t};var j=function(t){var s=Array();var q=(1<<m)-1;for(var r=0;r<t.length*m;r+=m){s[r>>5]|=(t.charCodeAt(r/m)&q)<<(24-r%32)}return s};var n=function(s){var r="0123456789abcdef";var t="";for(var q=0;q<s.length*4;q++){t+=r.charAt((s[q>>2]>>((3-q%4)*8+4))&15)+r.charAt((s[q>>2]>>((3-q%4)*8))&15)}return t};var o=function(s,v){var u=j(s);if(u.length>16){u=core_sha1(u,s.length*m)}var q=Array(16),t=Array(16);for(var r=0;r<16;r++){q[r]=u[r]^909522486;t[r]=u[r]^1549556828}var w=c(q.concat(j(v)),512+v.length*m);return c(t.concat(w),512+256)};var i=function(q){q=typeof q=="object"?f(q).val():q.toString();return q};f.extend({sha256:function(q){q=i(q);return n(c(j(q),q.length*m))},sha256hmac:function(q,r){q=i(q);r=i(r);return n(o(q,r))},sha256config:function(q){m=parseInt(q)||8}});f.fn.sha256=function(r){f.sha256config(r);var q=i(f(this).val());var s=f.sha256(q);f.sha256config(8);return s}})(jQuery);
@@ -1,3 +1,6 @@
+"use strict"; // http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
+
+
/*
For this file to bootstrap correctly the following variables must be bound:
@@ -11,18 +14,17 @@
/// swGetCurrentHash ///
////////////////////////
+var swGetCurrentHash;
if($.browser.mozilla)
- swGetCurrentHash =
- function(){
+ swGetCurrentHash = function(){
if((window.location.hash).length > 1)
// https://bugzilla.mozilla.org/show_bug.cgi?id=378962 *sigh*
return "#" + window.location.href.split("#")[1].replace(/%27/g, "'");
else
return "#";
};
else
- swGetCurrentHash =
- function(){
+ swGetCurrentHash = function(){
return location.hash;
};
@@ -38,6 +40,7 @@ var swURL, swDURL;
var res = [window.location.protocol, "//",
(function(){ if(dynamic_p) return(_sw_dynamic_subdomain); else return(""); })(),
window.location.host,
+ // TODO: Document this.
(function(){
var str = "";
for(var p = window.location.pathname.split("/"), i = 0; i < (p.length - 1); i++)
@@ -66,7 +69,7 @@ var swURL, swDURL;
/// swAjax ///
//////////////
-swAjax =
+var swAjax =
(function(){
var queue = new Array();
var timer = false;
@@ -90,18 +93,7 @@ swAjax =
return function(params, callback_data, after_fn){
if(queue.push(function(){
- /*
- var url = [window.location.protocol, "//",
- window.location.host,
- window.location.pathname,
- "/sw",
- "?_sw_request_type=ajax",
- "&_sw_viewport_id=", _sw_viewport_id,
- params].join('');
- */
-
var url = swURL(["&_sw_request_type=ajax", params].join(''));
-
var options = {
type: (function(){
// http://bit.ly/1z3xEu
@@ -116,11 +108,16 @@ swAjax =
data: callback_data,
cache: false,
dataType: "script",
- // TODO: 500 should be configurable.
- beforeSend: function(){ if(!timer){ timer = setTimeout(displaySpinner, 500); }},
+ beforeSend: function(){ if(!timer){ timer = setTimeout(displaySpinner, 500); }}, // TODO: 500 should be configurable.
+ error: function(xhr, ajax_options, thrown_error){
+ $.sticky("<b>SymbolicWeb: HTTP 500</b><br/>Something went wrong. Check <b>console.error</b> for details.<br/><br/>Developers have been notified of this event.");
+ handleRestOfQueue();
+ },
complete: handleRestOfQueue
};
+
if(after_fn) options.success = after_fn;
+
$.ajax(options);
}) == 1) // if()..
queue[0]();
@@ -132,16 +129,14 @@ swAjax =
/// swComet ///
///////////////
-_sw_comet_response = false;
+var _sw_comet_response = false;
-swComet =
+var swComet =
(function(){
function callback(){
if(_sw_comet_response)
_sw_comet_response = false, swComet('&do=ack');
else
- // FIXME: This stuff never happen for Webkit (it doesn't seem to be a big problem atm. though),
- // or Opera (when random subdomains are used).
setTimeout("swComet('');", 1000);
}
@@ -153,9 +148,9 @@ swComet =
complete: callback});
}
- // This returns what is assigned to the "swComet = ..." part above.
+ // This finally returns what is assigned to the "swComet = ..." part above.
if($.browser.mozilla || $.browser.webkit)
- // Stop "throbbing of doom".
+ // Stops "throbbing of doom".
return function(params){ setTimeout(function(){ doIt(params); }, 0); };
else
return doIt;
@@ -259,5 +254,6 @@ function swRun(code_id, async_p, func){
/////////////
$(window).load(function(){
- swComet("&do=refresh&hash=" + encodeURIComponent(encodeURIComponent(swGetCurrentHash().substr(1))));
+ // &hash=" + encodeURIComponent(encodeURIComponent(swGetCurrentHash().substr(1))));
+ swComet("&do=refresh");
});
Oops, something went wrong.

0 comments on commit 34764eb

Please sign in to comment.