# HG changeset patch # User ymh # Date 1373474864 -7200 # Node ID a7f4a418d5af71f7c6c2f10e82f005d7493eb720 # Parent 33fd91a414cc01ebb2d95dfa44df47ba3d50d40f can directly paste wikipedia urls diff -r 33fd91a414cc -r a7f4a418d5af src/core/settings.py --- a/src/core/settings.py Wed Jul 10 17:34:14 2013 +0200 +++ b/src/core/settings.py Wed Jul 10 18:47:44 2013 +0200 @@ -18,6 +18,9 @@ REPR_CONTEXT = getattr(settings,'REPR_CONTEXT' , 'http://data.culture.fr/thesaurus/resource/ark:/67717/T523') SREP_CONTEXT = getattr(settings,'SREP_CONTEXT' , 'http://data.culture.fr/thesaurus/resource/ark:/67717/T507') -WIKIPEDIA_VERSION_PERMALINK_TEMPLATE = getattr(settings, 'WIKIPEDIA_VERSION_PERMALINK_TEMPLATE', "http://fr.wikipedia.org/w/index.php?oldid=%s") +WIKIPEDIA_BASE_URL = getattr(settings, "WIKIPEDIA_BASE_URL", "http://fr.wikipedia.org/") +WIKIPEDIA_PAGE_URL = getattr(settings, "WIKIPEDIA_PAGE_URL", WIKIPEDIA_BASE_URL+"wiki") +WIKIPEDIA_API_URL = getattr(settings, "WIKIPEDIA_API_URL", WIKIPEDIA_BASE_URL +"w/api.php") +WIKIPEDIA_VERSION_PERMALINK_TEMPLATE = getattr(settings, 'WIKIPEDIA_VERSION_PERMALINK_TEMPLATE', WIKIPEDIA_BASE_URL +"w/index.php?oldid=%s") diff -r 33fd91a414cc -r a7f4a418d5af src/core/wp_utils.py --- a/src/core/wp_utils.py Wed Jul 10 17:34:14 2013 +0200 +++ b/src/core/wp_utils.py Wed Jul 10 18:47:44 2013 +0200 @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- from .models import Term, TermLabel, TERM_URL_STATUS_DICT +from core.models.term import TERM_WK_LINK_SEMANTIC_LEVEL_DICT from django.conf import settings from django.utils.http import urlquote +from urlparse import urlparse from wikitools import api, wiki import logging -from core.models.term import TERM_WK_LINK_SEMANTIC_LEVEL_DICT +import urllib2 logger = logging.getLogger(__name__) site = None @@ -172,6 +174,10 @@ if not label: label = term.label + elif label.startswith(settings.WIKIPEDIA_PAGE_URL): + url_parts = urlparse(label) + label = urllib2.unquote(str(url_parts.path.split('/')[-1])).decode("utf-8") + wp_res = query_wikipedia_title(site, label=label) new_label = wp_res['new_label'] alternative_label= wp_res['alternative_label'] diff -r 33fd91a414cc -r a7f4a418d5af src/jocondelab/__init__.py --- a/src/jocondelab/__init__.py Wed Jul 10 17:34:14 2013 +0200 +++ b/src/jocondelab/__init__.py Wed Jul 10 18:47:44 2013 +0200 @@ -1,4 +1,4 @@ -VERSION = (0, 9, 0, "final", 0) +VERSION = (0, 10, 0, "final", 0) def get_version(): diff -r 33fd91a414cc -r a7f4a418d5af src/jocondelab/settings.py --- a/src/jocondelab/settings.py Wed Jul 10 17:34:14 2013 +0200 +++ b/src/jocondelab/settings.py Wed Jul 10 18:47:44 2013 +0200 @@ -183,8 +183,10 @@ } } -WIKIPEDIA_API_URL = "http://fr.wikipedia.org/w/api.php" -WIKIPEDIA_VERSION_PERMALINK_TEMPLATE = "http://fr.wikipedia.org/w/index.php?oldid=%s" +WIKIPEDIA_BASE_URL = "http://fr.wikipedia.org/" +WIKIPEDIA_PAGE_URL = WIKIPEDIA_BASE_URL + "wiki" +WIKIPEDIA_API_URL = WIKIPEDIA_BASE_URL +"w/api.php" +WIKIPEDIA_VERSION_PERMALINK_TEMPLATE = WIKIPEDIA_BASE_URL + "w/index.php?oldid=%s" DBPEDIA_URI_TEMPLATE = "http://fr.dbpedia.org/resource/%s" JOCONDE_IMG_BASE_URL = "http://www.culture.gouv.fr/Wave/image/joconde" JOCONDE_NOTICE_BASE_URL = "http://www.culture.gouv.fr/public/mistral/joconde_fr?ACTION=CHERCHER&FIELD_98=REF&VALUE_98="