diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-09-28 12:01:00 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-09-28 12:01:00 +0200 |
commit | d6e7022470c46d93ca441ecaf23b8846893fc013 (patch) | |
tree | 29169f0e207b7fe3a65859ef56dfc5f1112bbfc7 | |
parent | b96d65fcdda5e1993bf9744ae747633f684a0c60 (diff) | |
download | Chimère-d6e7022470c46d93ca441ecaf23b8846893fc013.tar.bz2 Chimère-d6e7022470c46d93ca441ecaf23b8846893fc013.zip |
Fix share of point of interest
-rw-r--r-- | chimere/static/chimere/js/base.js | 4 | ||||
-rw-r--r-- | chimere/static/chimere/js/jquery.chimere.js | 9 | ||||
-rw-r--r-- | chimere/templates/chimere/detail.html | 14 | ||||
-rw-r--r-- | chimere/templates/chimere/detail_description.html | 14 | ||||
-rw-r--r-- | chimere/templates/chimere/main_map.html | 1 | ||||
-rw-r--r-- | chimere/views.py | 37 |
6 files changed, 54 insertions, 25 deletions
diff --git a/chimere/static/chimere/js/base.js b/chimere/static/chimere/js/base.js index fd1158a..0cf3f35 100644 --- a/chimere/static/chimere/js/base.js +++ b/chimere/static/chimere/js/base.js @@ -129,7 +129,9 @@ function share_link_update(){ $('.share_link').unbind('click').click(function(){ update_permalink(); var href = $(this).attr('href'); - var url = get_share_url; + var url = ''; + if (area_name) url += "/" + area_name; + url += get_share_url; var classes = $(this).attr('class').split(' '); prefix = 'share_id_'; var share_id; diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js index f69565a..dbbc97d 100644 --- a/chimere/static/chimere/js/jquery.chimere.js +++ b/chimere/static/chimere/js/jquery.chimere.js @@ -314,6 +314,7 @@ function transformCoordToLonLat(coord) { } settings[map_id] = $.extend({}, defaults); settings[map_id]._revision = 0; + settings[map_id].load_start = Date.now(); if ( options ) $.extend(settings[map_id], options); @@ -747,7 +748,6 @@ function transformCoordToLonLat(coord) { } }); $("#permalink").click(methods.update_permalink); - return; /* @@ -1691,7 +1691,12 @@ function transformCoordToLonLat(coord) { } if (!data.features){ data.features = []; - if (ids != '0') methods.displayMessage(labels['no_marker_message']); + var laps = Math.floor( + (Date.now() - settings[map_id].load_start)/1000 + ); // arbitrary time for too fast load + if (ids != '0' && laps > 4){ + methods.displayMessage(labels['no_marker_message']); + } } if (data.zoom_need_reload){ settings[map_id]._zoom_need_reload = data.zoom_need_reload; diff --git a/chimere/templates/chimere/detail.html b/chimere/templates/chimere/detail.html index 5bac2b5..eaca0e8 100644 --- a/chimere/templates/chimere/detail.html +++ b/chimere/templates/chimere/detail.html @@ -61,20 +61,6 @@ {%endif%} <div class="full-description"> {% include "chimere/detail_description.html" %} - {% if extra_categories %} - <h4>{% trans "Also appears in:" %}</h4> - <ul class="extra-categories"> - {% for category in extra_categories %} - <li>{% if category.menu_icon.image %} - <img src="{{category.menu_icon.image.url}}"> - {% elif category.icon.image %} - <img src="{{category.icon.image.url}}"> - {% endif %} - {{category.name}} - </li> - {% endfor %} - </ul> - {% endif %} </div> <div id='detail_footer'> <div id='detail-action-bar'> diff --git a/chimere/templates/chimere/detail_description.html b/chimere/templates/chimere/detail_description.html index 5cd0891..623272d 100644 --- a/chimere/templates/chimere/detail_description.html +++ b/chimere/templates/chimere/detail_description.html @@ -9,3 +9,17 @@ {% for property in properties %}{% if property.value %} <div class='properties' id='{{property.propertymodel.getAttrName}}'><strong>{{property.propertymodel.name}}</strong> : {% if 'http://' in property.value or 'https://' in property.value %}<a href='{{ property.value|sanitize:""}}'>{%endif%}{{ property.value|sanitize:"p b i br hr strong em span:style a:href:target ul li ol h1 h2 h3 h4 table td tr th"|safe}}{% if 'http://' in property.value or 'https://' in property.value %}</a>{%endif%}</div> {%endif%}{% endfor %} +{% if extra_categories %} +<h4>{% trans "Also appears in:" %}</h4> +<ul class="extra-categories"> + {% for category in extra_categories %} + <li>{% if category.menu_icon.image %} + <img src="{{category.menu_icon.image.url}}"> + {% elif category.icon.image %} + <img src="{{category.icon.image.url}}"> + {% endif %} + {{category.name}} + </li> + {% endfor %} +</ul> +{% endif %} diff --git a/chimere/templates/chimere/main_map.html b/chimere/templates/chimere/main_map.html index a7a7a2b..d7f7d98 100644 --- a/chimere/templates/chimere/main_map.html +++ b/chimere/templates/chimere/main_map.html @@ -15,6 +15,7 @@ <!-- var default_error_message = "{% trans "Error while loading the page... Refresh the page. If the problem persist contact the webmaster." %}"; var edit_url = "{% url 'editmarker' area_name|add:"/" %}"; + var area_name = "{{area_name}}"; // --> </script> <script src="{{ STATIC_URL }}saclay/js/interface.js?ver={{SACLAY_VERSION}}" type="text/javascript"></script> diff --git a/chimere/views.py b/chimere/views.py index 421c03e..b6c03b8 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -1011,14 +1011,35 @@ def getTinyfiedUrl(request, parameters, area_name=''): if not url.startswith('http'): url = get_base_uri(request) + url url = re.sub("([^:])\/\/", "\g<1>/", url) - text = response_dct['area'].name - if 'current_feature' in parameters: - for item in parameters.split('&'): - if 'current_feature' in item: - try: - text = str(models.Marker.objects.get(id=item.split('=')[1])) - except (IndexError, models.Marker.DoesNotExist): - pass + current_site = get_current_site(request) + map_name = current_site.name + if response_dct['area']: + map_name += " - " + response_dct["area"].name + + text = "" + item_id = parameters.split(';')[4] + if item_id and "-" in item_id: + cls = None + if item_id.startswith('point-'): + cls = models.Marker + elif item_id.startswith('route-'): + cls = models.Route + elif item_id.startswith('polygon-'): + cls = models.Polygon + item_id = item_id.split("-")[1] + if cls: + try: + text = str(cls.objects.get(id=item_id)) + text = str( + _("Share a point of interest on the map {}: ") + ).format(map_name) + text + except (cls.DoesNotExist): + pass + if not text: + text = str( + _("Share a point of interest on the map {}") + ).format(map_name) + data["urn"] = urlquote(urn) data["url"] = urlquote(url) data["text"] = urlquote(text) |