diff --git a/pinry/core/static/core/js/pinry.js b/pinry/core/static/core/js/pinry.js index 0d899c1..6f46836 100644 --- a/pinry/core/static/core/js/pinry.js +++ b/pinry/core/static/core/js/pinry.js @@ -41,13 +41,22 @@ function loadData(tag) { if (tag !== undefined) { globalTag = tag; + window.history.pushState(tag, 'Pinry - Tag - '+tag, '/pins/tag/'+tag+'/'); + } else if (url(2) == 'tag') { + tag = url(3); + globalTag = tag; + window.history.pushState(tag, 'Pinry - Tag - '+tag, '/pins/tag/'+tag+'/'); } - if (tag !== undefined && page != 0) { + if (tag !== undefined) { $('#pins').html(''); page = 0; - if (tag != null) $('.tags').html('' + tag + ' x'); - else $('.tags').html(''); + if (tag != null) + $('.tags').html('' + tag + ' x'); + else { + $('.tags').html(''); + window.history.pushState(tag, 'Pinry - Recent Pins', '/pins/'); + } } var loadURL = apiURL+(page*30); diff --git a/pinry/core/templates/core/base.html b/pinry/core/templates/core/base.html index 6380ffb..bf1dca9 100644 --- a/pinry/core/templates/core/base.html +++ b/pinry/core/templates/core/base.html @@ -52,10 +52,10 @@ + {% endcompress %} - diff --git a/pinry/pins/urls.py b/pinry/pins/urls.py index 9864a71..bae91be 100644 --- a/pinry/pins/urls.py +++ b/pinry/pins/urls.py @@ -3,6 +3,7 @@ from django.conf.urls import patterns, url urlpatterns = patterns('pinry.pins.views', url(r'^$', 'recent_pins', name='recent-pins'), + url(r'^tag/.+/$', 'recent_pins', name='tag'), url(r'^new-pin/$', 'new_pin', name='new-pin'), - url(r'^delete-pin/(?P\d*)/$', 'delete_pin', name='delete-pin'), + url(r'^delete-pin/(?P\d+)/$', 'delete_pin', name='delete-pin'), ) diff --git a/pinry/vendor/static/vendor/js-url/1.7.2/js-url.js b/pinry/vendor/static/vendor/js-url/1.7.2/js-url.js new file mode 100644 index 0000000..9511849 --- /dev/null +++ b/pinry/vendor/static/vendor/js-url/1.7.2/js-url.js @@ -0,0 +1,78 @@ +/****************************************** + * Websanova.com + * + * Resources for web entrepreneurs + * + * @author Websanova + * @copyright Copyright (c) 2012 Websanova. + * @license This websanova JavaScript url is dual licensed under the MIT and GPL licenses. + * @link http://www.websanova.com + * @github http://github.com/websanova/js-url + * @version 1.7.2 + * + ******************************************/ + +window.url = (function() { + function isNumeric(arg) { + return !isNaN(parseFloat(arg)) && isFinite(arg); + } + + return function url(arg, url) { + var _ls = url || window.location.toString(); + + if(_ls.substring(0,2) === '//') _ls = 'http:' + _ls; + else if(_ls.split('://').length === 1) _ls = 'http://' + _ls; + + url = _ls.split('/'); + var _l = {auth:''}, host = url[2].split('@'); + + if(host.length === 1) host = host[0].split(':'); + else{ _l.auth = host[0]; host = host[1].split(':'); } + + _l.protocol=url[0], _l.hostname=host[0], _l.port=(host[1]||'80'), _l.pathname='/' + url.slice(3, url.length).join('/').split('?')[0].split('#')[0]; + var _p = _l.pathname; + if(_p.split('.').length === 1 && _p[_p.length-1] !== '/') _p += '/'; + var _h = _l.hostname, _hs = _h.split('.'), _ps = _p.split('/'); + + if(!arg) return _ls; + else if(arg === 'hostname') return _h; + else if(arg === 'domain') return _hs.slice(-2).join('.'); + else if(arg === 'tld') return _hs.slice(-1).join('.'); + else if(arg === 'sub') return _hs.slice(0, _hs.length - 2).join('.'); + else if(arg === 'port') return _l.port || '80'; + else if(arg === 'protocol') return _l.protocol.split(':')[0]; + else if(arg === 'auth') return _l.auth; + else if(arg === 'user') return _l.auth.split(':')[0]; + else if(arg === 'pass') return _l.auth.split(':')[1] || ''; + else if(arg === 'path') return _p; + else if(arg[0] === '.') + { + arg = arg.substring(1); + if(isNumeric(arg)) {arg = parseInt(arg); return _hs[arg < 0 ? _hs.length + arg : arg-1] || ''; } + } + else if(isNumeric(arg)){ arg = parseInt(arg); return _ps[arg < 0 ? _ps.length - 1 + arg : arg] || ''; } + else if(arg === 'file') return _ps.slice(-1)[0]; + else if(arg === 'filename') return _ps.slice(-1)[0].split('.')[0]; + else if(arg === 'fileext') return _ps.slice(-1)[0].split('.')[1] || ''; + else if(arg[0] === '?' || arg[0] === '#') + { + var params = _ls, param = null; + + if(arg[0] === '?') params = (params.split('?')[1] || '').split('#')[0]; + else if(arg[0] === '#') params = (params.split('#')[1] || ''); + + if(!arg[1]) return params; + + arg = arg.substring(1); + params = params.split('&'); + + for(var i=0,ii=params.length; i