# HG changeset patch # User cavaliet # Date 1411658069 -7200 # Node ID 9a854bb09f347a12fb6cfa15ddb6fab743e31679 # Parent 6a7bc9190de564de5313064938da905f9b7a1035 big change : facette urls manages with location search parameters, and not anymore with session info. diff -r 6a7bc9190de5 -r 9a854bb09f34 src/hdalab/static/hdalab/js/gomina.js --- a/src/hdalab/static/hdalab/js/gomina.js Thu Sep 25 12:16:51 2014 +0200 +++ b/src/hdalab/static/hdalab/js/gomina.js Thu Sep 25 17:14:29 2014 +0200 @@ -44,7 +44,7 @@ _rgb.push(Math.floor(_exp*gomNs.gradientEnd[i] + (1-_exp)*gomNs.gradientStart[i])); } } - return "rgb(" + _rgb.join(",") + ")" + return "rgb(" + _rgb.join(",") + ")"; } function polygon_to_gmap(polycoords, dbpedia_uri) { @@ -119,7 +119,7 @@ _curView[_type].push(_label); } updateFilters(); - debouncedSaveChanges(); + //debouncedSaveChanges(); } } @@ -128,7 +128,7 @@ if (_curView.type == 'filter') { _curView[_type].splice(_index,1); updateFilters(); - debouncedSaveChanges(); + //debouncedSaveChanges(); } } @@ -161,7 +161,7 @@ _curView.period[_n] = _int; } updateFilters(); - debouncedSaveChanges(); + //debouncedSaveChanges(); } } } @@ -172,7 +172,7 @@ _curView.period[0] = gomNs.minYear; _curView.period[1] = gomNs.maxYear; updateFilters(); - debouncedSaveChanges(); + //debouncedSaveChanges(); } } @@ -198,7 +198,10 @@ } } -function updateFilters() { +function updateFilters(initial) { + if(typeof initial==="undefined"){ + initial = false; + } var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; if (_curView.type != 'filter') { return; @@ -261,8 +264,12 @@ }).join(""); } $("#renkan-link").attr("href",url_renkan); + if(!initial){ + history.replaceState(null, null, url_renkan.substr(url_renkan.lastIndexOf("?"))); + } $("#filters").html(_htmFilters).hide(); debouncedGetUpdates(); + } function displayContents(contentdata) { @@ -306,16 +313,16 @@ + ' placeholder' + ''; }).join('') - + '

'+gettext("Annotations")+'

' + ( gomNs.sessiondata.annotations[_d.id] && gomNs.sessiondata.annotations[_d.id].texte ? '
'; - if (gomNs.write_allowed) { + /*if (gomNs.write_allowed) { _(gomNs.sessiondata.views).each(function(_view, _k) { if (_view.type == 'list') { _html += '

1) { - _urlParam.sessionkey = _tab[1]; + var _urlParam = { + period: [ gomNs.minYear, gomNs.maxYear ], + country: [], + tag: [] + }; + if (document.location.search) { + var p = decodeURIComponent(getURLParameter("period")); + if(p!="null"){ + p = p.split(","); } - } - $.getJSON(gomNs.urls['session_info'], _urlParam, function(data) { - gomNs.sessionid = data.sessionid; - if (data.sessionkey) { - gomNs.sessionkey = data.sessionkey; + else{ + p = [ gomNs.minYear, gomNs.maxYear ]; } - gomNs.write_allowed = data.write_allowed; - if (data.write_allowed) { - $("#partagerw").show(); - } else { - $("#partagerw").hide(); + var c = decodeURIComponent(getURLParameter("country")); + if(c!="null"){ + c = c.split(","); + c = c.filter(function(n){ return n!="" }); + } + else{ + c = []; } - var _baseUrl = document.location.href.split("#")[0]; - gomNs.hash = "#" + data.sessionid + (data.sessionkey ? (':' + data.sessionkey) : ''); - document.location.hash = gomNs.hash; - gomNs.sessiondata = typeof data.data == "string" ? JSON.parse(data.data) : (typeof data.data == "object" ? data.data : {}); - if (!gomNs.sessiondata.title) { - gomNs.sessiondata.title = gettext('Nouvelle session'); + var t = decodeURIComponent(getURLParameter("label")); + if(t!="null"){ + t = t.split(","); + t = t.filter(function(n){ return n!="" }); + } + else{ + t = []; } - if (!gomNs.sessiondata.views) { - gomNs.sessiondata.views = []; - } - if (!gomNs.sessiondata.views.length) { - addView( 'filter', gettext('Mes resultats de recherche') ); - addView( 'list', gettext('Ma liste') ); - } - if (!gomNs.sessiondata.annotations) { - gomNs.sessiondata.annotations = {}; + _urlParam.period = p; + _urlParam.country = c; + _urlParam.tag = t; + } + // Not getting session info anymore, build data object + var data = { + data: { + view: 0, + views: [ + { + type: "filter", + period: _urlParam.period, + country: _urlParam.country, + tag: _urlParam.tag + } + ] } - if (data.write_allowed) { - $("#bloc_gestvue").show(); - } else { - $("#bloc_gestvue").hide(); + }; + + /*gomNs.sessionid = data.sessionid; + if (data.sessionkey) { + gomNs.sessionkey = data.sessionkey; + } + gomNs.write_allowed = data.write_allowed; + if (data.write_allowed) { + $("#partagerw").show(); + } else { + $("#partagerw").hide(); + }*/ + //var _baseUrl = document.location.href.split("#")[0]; + //gomNs.hash = "#" + data.sessionid + (data.sessionkey ? (':' + data.sessionkey) : ''); + //document.location.hash = gomNs.hash; + gomNs.sessiondata = typeof data.data == "string" ? JSON.parse(data.data) : (typeof data.data == "object" ? data.data : {}); + /*if (!gomNs.sessiondata.title) { + gomNs.sessiondata.title = gettext('Nouvelle session'); + }*/ + if (!gomNs.sessiondata.views) { + gomNs.sessiondata.views = []; + } + /*if (!gomNs.sessiondata.views.length) { + addView( 'filter', gettext('Mes resultats de recherche') ); + addView( 'list', gettext('Ma liste') ); + } + if (!gomNs.sessiondata.annotations) { + gomNs.sessiondata.annotations = {}; + } + if (data.write_allowed) { + $("#bloc_gestvue").show(); + } else { + $("#bloc_gestvue").hide(); + } + $("#sessionname").html(_.escape(gomNs.sessiondata.title) + + ( data.write_allowed ? '' : ' ('+gettext("lecture seule")+')' ) ); + gomNs.hrefinterval = setInterval(function() { + if (document.location.hash != gomNs.hash) { + clearInterval(gomNs.hrefinterval); + getInitialView(); } - $("#sessionname").html(_.escape(gomNs.sessiondata.title) - + ( data.write_allowed ? '' : ' ('+gettext("lecture seule")+')' ) ); - gomNs.hrefinterval = setInterval(function() { - if (document.location.hash != gomNs.hash) { - clearInterval(gomNs.hrefinterval); - getInitialView(); - } - }, 500); - displayViewList(); - showView(); - }); + }, 500);*/ + //displayViewList(); + showView(true); } -function changeSessionTitle(title) { +/*function changeSessionTitle(title) { gomNs.sessiondata.title = title; $("#sessionname").html(_.escape(gomNs.sessiondata.title)); debouncedSaveChanges(); -} +}*/ -function addView(viewtype, viewname) { +/*function addView(viewtype, viewname) { var _content = { type: viewtype, name: viewname, @@ -639,10 +694,9 @@ } gomNs.sessiondata.views.push(_content); debouncedSaveChanges(); -} +}*/ function animLoad() { - //console.log("animLoad"); var _d = $("#waiting"), _w = _d.width(), _h = _d.height(), @@ -718,7 +772,7 @@ + '

' }).join(''); $("#dates").html(_html); - $("#apartager").click(function() { + /*$("#apartager").click(function() { var _pu = $("#partageurls"); if (_pu.is(":visible")) { $(this).removeClass("actif"); @@ -744,8 +798,8 @@ } }); return false; - }) - $("#partagero").click(function() { + });*/ + /*$("#partagero").click(function() { $("#partagero").addClass("actif"); $("#partagerw").removeClass("actif"); var _url = document.location.href.split("#")[0] + "#" + gomNs.sessionid; @@ -760,7 +814,7 @@ $("#zc-partageinput").val( _url.replace(/^(.{30}).{3,1000}(.{20})$/,'$1 … $2') ); gomNs.clip.setText( _url ); return false; - }); + });*/ $(".handle").draggable({ "axis" : "x", "containment" : "parent", @@ -780,11 +834,11 @@ "margin-left" : (_h1v>_h0v ? "0" : "-20px") }) updateFilters(); - debouncedSaveChanges(); + //debouncedSaveChanges(); } } }); - $("#sessionname").click(function() { + /*$("#sessionname").click(function() { if (gomNs.write_allowed && !$(this).children().length) { var _el = document.createElement('input'); _el.value = gomNs.sessiondata.title; @@ -799,15 +853,15 @@ _el.focus(); _el.select(); } - }); - $("#titrevue").keyup(function() { + });*/ + /*$("#titrevue").keyup(function() { var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; _curView.name = $(this).val(); $("#view_" + gomNs.sessiondata.view + " a").html(_.escape(_curView.name)) $("#bloc_gestvue h2").html(gettext('Gerer la vue')+' "' + _.escape(_curView.name) + '"'); debouncedSaveChanges(); - }); - $("#notes").click(function() { + });*/ + /*$("#notes").click(function() { if (gomNs.write_allowed) { if (this.children[0].tagName == 'UL') { var _el = document.createElement('textarea'), @@ -823,11 +877,7 @@ _el.select(); } } - }); -/* gomNs.disChart = d3.select("#disciplines") - .append("svg:svg") - .attr("width", 475) - .attr("height", 120); */ + });*/ getInitialView(); $(".barrebloc").click(function() { $(this).next().slideToggle(); @@ -841,7 +891,7 @@ + '" />' }); _html + ''; - $("#gestvue").append(_html); + /*$("#gestvue").append(_html); $("#nouvellevue").click(function() { $("#plusdevues").slideToggle(); return false; @@ -875,7 +925,7 @@ displayViewList(); } return false; - }); + });*/ $(" #tagform ").submit(function() { return false; }); diff -r 6a7bc9190de5 -r 9a854bb09f34 src/hdalab/templates/facettes.html --- a/src/hdalab/templates/facettes.html Thu Sep 25 12:16:51 2014 +0200 +++ b/src/hdalab/templates/facettes.html Thu Sep 25 17:14:29 2014 +0200 @@ -27,7 +27,7 @@ gomNs.languageCode = '{{LANGUAGE_CODE}}'; gomNs.urls = { 'filter': "{% url 'filter' %}", - 'session_info': "{% url 'session_info' %}", + {% comment %}'session_info': "{% url 'session_info' %}",{% endcomment %} 'countries': "{% static 'hdalab/lib/countries.geo.json' %}", 'tag_search': "{% url 'tag_search' %}", 'datasheet': "{% url 'notice' 'ID' %}", @@ -41,7 +41,7 @@ {% block main_content %}
-

{% trans "Recherche par facettes" %} :

+

{% trans "Recherche par facettes" %}

@@ -54,27 +54,6 @@ {% endfor %}
-
{% trans "Partager la session" %}
-
- -
- - -
-
-
-

{% trans "Mes vues :"%}

- - + -
-
@@ -98,7 +77,7 @@
-
+

{% trans "Pays" %}

@@ -141,12 +120,12 @@
-
+

{% trans "Disciplines artistiques" %}

diff -r 6a7bc9190de5 -r 9a854bb09f34 src/hdalab/urls.py --- a/src/hdalab/urls.py Thu Sep 25 12:16:51 2014 +0200 +++ b/src/hdalab/urls.py Thu Sep 25 17:14:29 2014 +0200 @@ -58,7 +58,7 @@ urlpatterns += patterns('hdalab.views.ajax', (r'^a/filter$', 'filter', {}, 'filter'), - (r'^a/sessioninfo$', 'sessioninfo', {}, 'session_info'), + #(r'^a/sessioninfo$', 'sessioninfo', {}, 'session_info'), (r'^a/tagsearch$', 'tagsearch', {}, 'tag_search'), (r'^a/catsearch$', 'catsearch', {}, 'cat_search'), (r'^a/cattree$', 'cattree', {}, 'cat_tree'),