# HG changeset patch # User cavaliet # Date 1390298311 -3600 # Node ID 56db9b2c61e8371d620bfb1dd546bde782393373 # Parent 9182b3f86f6e8e03ccb1060f4e7d1e24cef79e5b# Parent a92d31a49cd833256f3d517607b3e34226b6fe85 Merge with a92d31a49cd833256f3d517607b3e34226b6fe85 diff -r 9182b3f86f6e -r 56db9b2c61e8 .hgtags --- a/.hgtags Tue Jan 21 10:57:47 2014 +0100 +++ b/.hgtags Tue Jan 21 10:58:31 2014 +0100 @@ -82,3 +82,8 @@ e084f8e85722bc153e197a4ad9e591f4d4377f55 V00.48 be7b275b5bdb9be46f50daf9a6a552b1bcc67987 V00.49 f15e17caefdfd55bd5126e0cf012c3fae1c2b3d6 V00.50 +fb1d0e116be9b422991964f5c114d09c39e5f42b V00.51 +3d3e82c4ed55f8dad32d23eb4cf8cfdca7fb04db V00.52 +ca638a0ba37216a647d2eb0bf7b013b8e7fef098 V00.53 +ca638a0ba37216a647d2eb0bf7b013b8e7fef098 V00.53 +0e35b7460395bc4c6e2d6df07422292a2f9b22cc V00.53 diff -r 9182b3f86f6e -r 56db9b2c61e8 .settings/org.eclipse.core.resources.prefs --- a/.settings/org.eclipse.core.resources.prefs Tue Jan 21 10:57:47 2014 +0100 +++ b/.settings/org.eclipse.core.resources.prefs Tue Jan 21 10:58:31 2014 +0100 @@ -36,4 +36,5 @@ encoding//src/jocondelab/views/ajax.py=utf-8 encoding//src/jocondelab/views/back_office.py=utf-8 encoding//src/jocondelab/views/front_office.py=utf-8 +encoding//src/jocondelab/views/i18n.py=utf-8 encoding//virtualenv/web/env/venv_jocondelab/lib/python2.7/site-packages/django/conf/locale/vi/formats.py=utf-8 diff -r 9182b3f86f6e -r 56db9b2c61e8 sbin/sync/config.py.tmpl diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/__init__.py --- a/src/jocondelab/__init__.py Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/__init__.py Tue Jan 21 10:58:31 2014 +0100 @@ -1,4 +1,4 @@ -VERSION = (0, 50, 0, "final", 0) +VERSION = (0, 52, 0, "final", 0) def get_version(): diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/config.py.tmpl --- a/src/jocondelab/config.py.tmpl Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/config.py.tmpl Tue Jan 21 10:58:31 2014 +0100 @@ -81,6 +81,9 @@ # Make this unique, and don't share it with anybody. SECRET_KEY = '%(secret_key)s' +#use etags +USE_ETAGS = False + #LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../../run/log/log.txt")) LOG_FILE = '%(log_file)s' LOG_LEVEL = logging.DEBUG @@ -143,3 +146,11 @@ } } +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'unique-snowflake' + } +} + +CACHE_MIDDLEWARE_SECONDS = 600 diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/settings.py --- a/src/jocondelab/settings.py Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/settings.py Tue Jan 21 10:58:31 2014 +0100 @@ -106,6 +106,9 @@ # Make this unique, and don't share it with anybody. SECRET_KEY = '' +#use etags +USE_ETAGS = False + # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', @@ -114,6 +117,7 @@ ) MIDDLEWARE_CLASSES = ( + 'django.middleware.cache.UpdateCacheMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', @@ -122,6 +126,7 @@ 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.cache.FetchFromCacheMiddleware', ) ROOT_URLCONF = 'jocondelab.urls' @@ -265,6 +270,8 @@ # 24 hours DB_QUERY_CACHE_TIME DB_QUERY_CACHE_TIME = 86400 +CACHE_MIDDLEWARE_SECONDS = 600 + from config import * # @UnusedWildImport if not "SRC_BASE_URL" in locals(): diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/static/jocondelab/css/front-common.css --- a/src/jocondelab/static/jocondelab/css/front-common.css Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/static/jocondelab/css/front-common.css Tue Jan 21 10:58:31 2014 +0100 @@ -532,6 +532,12 @@ font-style: italic; margin-top: 5px; } +/* error page */ +.http-error { + font-size: 18px; margin: 10px 0; +} + + /* Smaller screens adaptation */ @media screen and (max-width: 720px) { diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/static/jocondelab/js/front-common.js --- a/src/jocondelab/static/jocondelab/js/front-common.js Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/static/jocondelab/js/front-common.js Tue Jan 21 10:58:31 2014 +0100 @@ -387,6 +387,7 @@ var max_scroll_pages = 3, currentpage; function loadMorePages(query) { + console.log("loadMorePages currentpage = " + currentpage); $(".load-more").hide(); $win.off("scroll.ajaxload"); $(".notice-list").empty(); @@ -413,11 +414,13 @@ var loadingnext = false, page_count = parseInt($(".notice-list").attr("data-page-count")), max_page = Math.min(currentpage + max_scroll_pages, page_count); + console.log('scrollLoad max_page = ' + max_page); $(".load-more").hide().off("click").click(function() { loadMorePages(query); return false; }); $win.on("scroll.ajaxload", function() { + console.log('$win.on("scroll.ajaxload") max_page = ' + max_page); if (loadingnext || currentpage >= max_page) { return; } @@ -428,7 +431,9 @@ } var winbottom = $win.scrollTop() + $win.height(), databottom = dbo.top + $datablock.height(); - if (winbottom >= databottom) { + console.log('AJAX currentpage ? loadingnext = ' + loadingnext); + if (winbottom >= databottom && !loadingnext) { + console.log('AJAX currentpage LOAD'); loadingnext = true; $(".loading-please-wait").show(); $.ajax({ @@ -436,13 +441,24 @@ data: _({ page: ++currentpage }).extend(query), dataType: "html", success: function(html) { - $datablock.append(html); - loadingnext = false; - bindResultsMouseover(); - $(".loading-please-wait").hide(); - if (currentpage >= max_page && currentpage < page_count) { - $(".load-more").show(); - } + console.log('$datablock.append(html); more = ' + (currentpage >= max_page && currentpage < page_count)); + console.log("HTML == '' ? ", (html==""), (html.trim()==""), typeof html); + if(html.trim()!=""){ + console.log(" APPEND HTML"); + $datablock.append(html); + loadingnext = false; + bindResultsMouseover(); + $(".loading-please-wait").hide(); + if (currentpage >= max_page && currentpage < page_count) { + console.log(' $(".load-more").show();'); + $(".load-more").show(); + } + } + else{ + $(".load-more").hide(); + $(".loading-please-wait").hide(); + console.log(" NOTHING HTML"); + } } }); } @@ -450,6 +466,7 @@ }; window.loadSearchResults = function(query) { + console.log('window.loadSearchResults'); $(".hide-on-search").hide(); $win.off("scroll.ajaxload"); $(".wiki-info img").off("load error"); diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/static/jocondelab/js/front-search.js --- a/src/jocondelab/static/jocondelab/js/front-search.js Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/static/jocondelab/js/front-search.js Tue Jan 21 10:58:31 2014 +0100 @@ -30,6 +30,7 @@ // Check if a dom element is the current viewport // el is dom element, not jquery object function isElementInViewport(el) { + console.log("isElementInViewport"); var rect = el.getBoundingClientRect(); return ( rect.top >= 0 && @@ -40,9 +41,11 @@ } var myTimeOut = false; window.startTimeOut = function(){ - myTimeOut = setInterval(function(){ testIfLastLiInViewport() }, 3000); + console.log("window.startTimeOut"); + myTimeOut = setInterval(function(){ console.log("setInterval"); testIfLastLiInViewport() }, 3000); } function testIfLastLiInViewport(){ + console.log("testIfLastLiInViewport"); var el = $($(".results ul")[0]).children().last()[0]; if( (typeof el!=="undefined") && isElementInViewport(el) ) { // Last li is visible, so we have to call next page manually @@ -56,11 +59,13 @@ } if (window.addEventListener) { + console.log("addEventListener 1"); //addEventListener('DOMContentLoaded', testIfLastLiInViewport(), false); addEventListener('load', startTimeOut(), false); //addEventListener('scroll', testIfLastLiInViewport(), false); //addEventListener('resize', testIfLastLiInViewport(), false); } else if (window.attachEvent) { + console.log("addEventListener 2"); //attachEvent('DOMContentLoaded', testIfLastLiInViewport()); attachEvent('load', startTimeOut()); //attachEvent('scroll', testIfLastLiInViewport()); diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/templates/400.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jocondelab/templates/400.html Tue Jan 21 10:58:31 2014 +0100 @@ -0,0 +1,12 @@ +{% extends "jocondelab/front_base.html" %} +{% load i18n %} + +{% block title %}JocondeLab » {% trans 'Erreur 404' %}{% endblock %} + +{% block breadcrumbs %}{% trans 'Erreur 404' %}{% endblock %} + +{% block main %} +
+{% trans "Cette page n'est pas disponible" %} +
+{% endblock %} diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/templates/403.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jocondelab/templates/403.html Tue Jan 21 10:58:31 2014 +0100 @@ -0,0 +1,12 @@ +{% extends "jocondelab/front_base.html" %} +{% load i18n %} + +{% block title %}JocondeLab » {% trans 'accès interdit' %}{% endblock %} + +{% block breadcrumbs %}{% trans 'accès interdit' %}{% endblock %} + +{% block main %} +
+{% trans "L'accès à cette page est protégé" %} +
+{% endblock %} diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/templates/404.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jocondelab/templates/404.html Tue Jan 21 10:58:31 2014 +0100 @@ -0,0 +1,12 @@ +{% extends "jocondelab/front_base.html" %} +{% load i18n %} + +{% block title %}JocondeLab » {% trans 'Mauvaise requête' %}{% endblock %} + +{% block breadcrumbs %}{% trans 'Mauvaise requête' %}{% endblock %} + +{% block main %} +
+{% trans "Erreur dans la requête" %} +
+{% endblock %} diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/templates/500.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jocondelab/templates/500.html Tue Jan 21 10:58:31 2014 +0100 @@ -0,0 +1,92 @@ +{% load static %} + + + + + + + + + JocondeLab » Erreur d'application + + + + + + +
+
+

JocondeLab

+ +
+
+
+ + +
+
+

+ Erreur d'application. +

+
+ +
+ + + diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/templates/jocondelab/base.html --- a/src/jocondelab/templates/jocondelab/base.html Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/templates/jocondelab/base.html Tue Jan 21 10:58:31 2014 +0100 @@ -10,7 +10,7 @@ {% block title %}JOCONDELAB-BO{% endblock %} {% block js_import %} - + diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/templates/jocondelab/front_base.html --- a/src/jocondelab/templates/jocondelab/front_base.html Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/templates/jocondelab/front_base.html Tue Jan 21 10:58:31 2014 +0100 @@ -10,7 +10,7 @@ {% block title %}JocondeLab{% endblock %} {% block js_import %} - + diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/urls.py --- a/src/jocondelab/urls.py Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/urls.py Tue Jan 21 10:58:31 2014 +0100 @@ -3,6 +3,7 @@ TermLinkSemanticLevelEdition, ThesaurusTree, TermListTableView) from jocondelab.views.front_office import (SearchView, NoticeView, GeoView, FrontTermListView) from jocondelab.views.ajax import (ContributeView, VoteView) +from jocondelab.views.i18n import cached_javascript_catalog from core import urls as core_urls from django.conf.urls import patterns, include, url from django.contrib import admin @@ -22,7 +23,7 @@ url(r'^logout/$', 'django.contrib.auth.views.logout_then_login', name='joconde_logout'), url(r'^admin/', include(admin.site.urls)), url(r'^i18n/', include('django.conf.urls.i18n')), - url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), + url(r'^jsi18n/$', cached_javascript_catalog, js_info_dict, name="i18n_javascript_catalog"), url(r'^bo/$', login_required(TermListView.as_view()), name='bo_home'), url(r'^bo/term/list/table$', login_required(TermListTableView.as_view()), name='term_list_table'), url(r'^bo/term/(?P\d+)/$', login_required(TermEditView.as_view()), name='term'), diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/views/front_office.py --- a/src/jocondelab/views/front_office.py Tue Jan 21 10:57:47 2014 +0100 +++ b/src/jocondelab/views/front_office.py Tue Jan 21 10:58:31 2014 +0100 @@ -177,6 +177,8 @@ else: paginator = JocondeFrontPaginator(qs.values_list('id', flat=True).order_by('id').distinct(), npp, count_qs) context["page_count"] = paginator.num_pages + logger.debug("PAGE COUNT = ") + logger.debug(context["page_count"]) ids = paginator.page(min(int(page),paginator.num_pages)) if paginator.count: count_log = math.log10(paginator.count) @@ -188,6 +190,8 @@ context["count"] = paginator.count - (paginator.count % 10**(int(count_log)-1) ) else: context["count"] = paginator.count + logger.debug("COUNT = ") + logger.debug(context["count"]) # Now that we have the list of ids ns = Notice.objects.filter(pk__in=ids).extra(select={'relative_url': '"core_noticeimage"."relative_url"'}).filter(image=True).filter(images__main=True).order_by('id') diff -r 9182b3f86f6e -r 56db9b2c61e8 src/jocondelab/views/i18n.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jocondelab/views/i18n.py Tue Jan 21 10:58:31 2014 +0100 @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +''' +Created on Jan 21, 2014 + +@author: ymh +''' +from django.utils import timezone +from django.views.decorators.http import last_modified +from django.views.i18n import javascript_catalog + +last_modified_date = timezone.now() +@last_modified(lambda req, **kw: last_modified_date) +def cached_javascript_catalog(request, domain='djangojs', packages=None): + return javascript_catalog(request, domain, packages) \ No newline at end of file diff -r 9182b3f86f6e -r 56db9b2c61e8 web/404.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/404.html Tue Jan 21 10:58:31 2014 +0100 @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + JocondeLab » Erreur 404 + + + + + + +
+
+

JocondeLab

+ +
+
+
+ + +
+
+

+ La page demandée n'est pas disponible. +

+
+ +
+ + + diff -r 9182b3f86f6e -r 56db9b2c61e8 web/500.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/500.html Tue Jan 21 10:58:31 2014 +0100 @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + JocondeLab » Erreur d'application + + + + + + +
+
+

JocondeLab

+ +
+
+
+ + +
+
+

+ Erreur sur le serveur. +

+
+ +
+ + +