From b065448a26f181f2027f51dca187844fb1ef7283 Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Thu, 13 Aug 2015 01:58:07 -0400 Subject: [PATCH] Removed jquery-address Note: The sites javascript doesn't work currently as jquery-address has not yet been replaced by the history api. This however doesn't stop users from viewing the site, the javascript just errors out in the background for users who have it enabled. See TODO.org for more details of what needs to be completed Signed-off-by: Collin J. Doering --- TODO.org | 35 +- js/default.js | 12 +- lib/jquery-address/jquery.address.js | 610 --------------------------- src/site.hs | 4 +- templates/default.html | 3 +- 5 files changed, 23 insertions(+), 641 deletions(-) delete mode 100644 lib/jquery-address/jquery.address.js diff --git a/TODO.org b/TODO.org index 675e81f..5e56a4b 100644 --- a/TODO.org +++ b/TODO.org @@ -35,30 +35,10 @@ See: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history -*** WAIT Modify nav URLs using javascript once page is loaded - - State "WAIT" from "TODO" [2015-08-12 Wed 02:54] \\ - This hasn't been done and doesn't need to be, as the rel attributes on the anchor tags - within the nav are 'picked up' by jquery-address and treated correctly (using the - clientside router). - - If it is indeed enabled then the user can benefit from the SPA functionality of the site. - Otherwise they will be able to browse the site using the original, unmodified links. This is - similar to how the link withing the page-content div work currently, and mainly would have to - be adapted for the navigation. - *** TODO Fix issue with tag and pagination page generation - All URLs are required to work without javascript. Thus there can't be any tricks employed - in javascript to modify urls (the js router rewriting). Currently this happens with the - - - "/blog.html" to "/blog1.html" - - "/tags/general.html" to "/tags/general1.html" - - etc.. - Currently URLs to paginated pages (which includes the blog and tag pages) are broken. They - generate "/tags/*.html" instead of "/tags/*1.html". Also see [[pagination artifact][this issue]]which is related to - this last issue (which when solved would hopefully fix this as well). + generate "/tags/*.html" instead of "/tags/*1.html". -*** TODO Pagination creates an extra unexpected file <> When the blog page and tag pages are paginated an extra file is generated that is not expected. For example, for the paginated blog, "/blog1.html through "/blogN.html" and "/blog.html" are generated. "/blog.html" is not expected to be generated and seems to be an @@ -66,6 +46,19 @@ "/blogN.html"). *** Complete +**** CANCELED Modify nav URLs using javascript once page is loaded + CLOSED: [2015-08-13 Thu 01:47] + - State "CANCELED" from "WAIT" [2015-08-13 Thu 01:47] \\ + As virtual urls are no longer used and normal urls can be set using the HTML5 history api (via history.pushState), all URLs on the page will always be valid. So no modification to the links of any kind needs to take place. + - State "WAIT" from "TODO" [2015-08-12 Wed 02:54] \\ + This hasn't been done and doesn't need to be, as the rel attributes on the anchor tags + within the nav are 'picked up' by jquery-address and treated correctly (using the + clientside router). + + If it is indeed enabled then the user can benefit from the SPA functionality of the site. + Otherwise they will be able to browse the site using the original, unmodified links. This is + similar to how the link withing the page-content div work currently, and mainly would have to + be adapted for the navigation. **** DONE Fix ajax page loading CLOSED: [2015-08-12 Wed 02:41] Pages don't load properly when javascript is enabled. diff --git a/js/default.js b/js/default.js index 4f89cd9..a2b9275 100644 --- a/js/default.js +++ b/js/default.js @@ -144,7 +144,8 @@ _paq.push(['enableLinkTracking']); new_virt_url = routes[i].rewriteVirtualUrl(spec.url); if (new_virt_url === spec.url) { if (spec.hasRedirect) { - $.address.value(new_virt_url); + // TODO: use history API in place of $.address (from jquery-address) + history.pushState(null, "Title", new_virt_url); } else { callback(routes[i].rewriteGetUrl(spec.url), spec.url, routes[i].ajaxCallbacks); } @@ -288,11 +289,12 @@ _paq.push(['enableLinkTracking']); }); }); + // TODO: use history API in place of $.address.change (from jquery-address) // Callback for when the inital page has completely loaded (including images, etc..) - $.address.change(function (event) { - console.log("Change " + event.value); - router.runRouter(event.value); - }); + //$.address.change(function (event) { + // console.log("Change " + event.value); + // router.runRouter(event.value); + //}); // TODO }); } diff --git a/lib/jquery-address/jquery.address.js b/lib/jquery-address/jquery.address.js deleted file mode 100644 index d62f093..0000000 --- a/lib/jquery-address/jquery.address.js +++ /dev/null @@ -1,610 +0,0 @@ -/*! jQuery Address v${version} | (c) 2009, 2013 Rostislav Hristov | jquery.org/license */ -(function ($) { - - $.address = (function () { - - var _trigger = function(name) { - var e = $.extend($.Event(name), (function() { - var parameters = {}, - parameterNames = $.address.parameterNames(); - for (var i = 0, l = parameterNames.length; i < l; i++) { - parameters[parameterNames[i]] = $.address.parameter(parameterNames[i]); - } - return { - value: $.address.value(), - path: $.address.path(), - pathNames: $.address.pathNames(), - parameterNames: parameterNames, - parameters: parameters, - queryString: $.address.queryString() - }; - }).call($.address)); - $($.address).trigger(e); - return e; - }, - _array = function(obj) { - return Array.prototype.slice.call(obj); - }, - _bind = function(value, data, fn) { - $().bind.apply($($.address), Array.prototype.slice.call(arguments)); - return $.address; - }, - _unbind = function(value, fn) { - $().unbind.apply($($.address), Array.prototype.slice.call(arguments)); - return $.address; - }, - _supportsState = function() { - return (_h.pushState && _opts.state !== UNDEFINED); - }, - _hrefState = function() { - return ('/' + _l.pathname.replace(new RegExp(_opts.state), '') + - _l.search + (_hrefHash() ? '#' + _hrefHash() : '')).replace(_re, '/'); - }, - _hrefHash = function() { - var index = _l.href.indexOf('#'); - return index != -1 ? _l.href.substr(index + 1) : ''; - }, - _href = function() { - return _supportsState() ? _hrefState() : _hrefHash(); - }, - _window = function() { - try { - return top.document !== UNDEFINED && top.document.title !== UNDEFINED && top.jQuery !== UNDEFINED && - top.jQuery.address !== UNDEFINED && top.jQuery.address.frames() !== false ? top : window; - } catch (e) { - return window; - } - }, - _js = function() { - return 'javascript'; - }, - _strict = function(value) { - value = value.toString(); - return (_opts.strict && value.substr(0, 1) != '/' ? '/' : '') + value; - }, - _cssint = function(el, value) { - return parseInt(el.css(value), 10); - }, - _listen = function() { - if (!_silent) { - var hash = _href(), - diff = decodeURI(_value) != decodeURI(hash); - if (diff) { - if (_msie && _version < 7) { - _l.reload(); - } else { - if (_msie && !_hashchange && _opts.history) { - _st(_html, 50); - } - _value = hash; - _update(FALSE); - } - } - } - }, - _update = function(internal) { - _st(_track, 10); - return _trigger(CHANGE).isDefaultPrevented() || - _trigger(internal ? INTERNAL_CHANGE : EXTERNAL_CHANGE).isDefaultPrevented(); - }, - _track = function() { - if (_opts.tracker !== 'null' && _opts.tracker !== NULL) { - var fn = $.isFunction(_opts.tracker) ? _opts.tracker : _t[_opts.tracker], - value = (_l.pathname + _l.search + - ($.address && !_supportsState() ? $.address.value() : '')) - .replace(/\/\//, '/').replace(/^\/$/, ''); - if ($.isFunction(fn)) { - fn(value); - } else if ($.isFunction(_t.urchinTracker)) { - _t.urchinTracker(value); - } else if (_t.pageTracker !== UNDEFINED && $.isFunction(_t.pageTracker._trackPageview)) { - _t.pageTracker._trackPageview(value); - } else if (_t._gaq !== UNDEFINED && $.isFunction(_t._gaq.push)) { - _t._gaq.push(['_trackPageview', decodeURI(value)]); - } - } - }, - _html = function() { - var src = _js() + ':' + FALSE + ';document.open();document.writeln(\'' + - _d.title.replace(/\'/g, '\\\'') + ' -