--- a/src/egonomy/settings.py Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/settings.py Mon Mar 17 16:17:30 2014 +0100
@@ -111,6 +111,7 @@
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
+ "django.core.context_processors.request",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
--- a/src/egonomy/templates/egonomy_annotate_picture.html Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/templates/egonomy_annotate_picture.html Mon Mar 17 16:17:30 2014 +0100
@@ -87,8 +87,8 @@
{% endif %}
{% endif %}
<ul class="share">
- <li><a title="Partager sur Twitter" href="#" class="tool twitter"></a></li>
- <li><a title="Partager sur Facebook" href="#" class="tool facebook"></a></li>
+ <li><a title="Partager sur Twitter" target="_blank" href="https://twitter.com/share?url={{ request.build_absolute_uri|urlencode }}" class="tool twitter"></a></li>
+ <li><a title="Partager sur Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={{ request.build_absolute_uri|urlencode }}" class="tool facebook"></a></li>
</ul>
</div>
<div class="info box-edition">
--- a/src/egonomy/templates/egonomy_view_fragment.html Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/templates/egonomy_view_fragment.html Mon Mar 17 16:17:30 2014 +0100
@@ -92,8 +92,8 @@
{% endif %}
{% endif %}
<ul class="share">
- <li><a title="Partager sur Twitter" href="#" class="tool twitter"></a></li>
- <li><a title="Partager sur Facebook" href="#" class="tool facebook"></a></li>
+ <li><a title="Partager sur Twitter" target="_blank" href="https://twitter.com/share?url={{ request.build_absolute_uri|urlencode }}" class="tool twitter"></a></li>
+ <li><a title="Partager sur Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={{ request.build_absolute_uri|urlencode }}" class="tool facebook"></a></li>
</ul>
</div>
<div class="info box-edition clearfix">
--- a/src/egonomy/templates/partial/collection_in_list.html Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/templates/partial/collection_in_list.html Mon Mar 17 16:17:30 2014 +0100
@@ -1,11 +1,12 @@
{% load static %}
{% load i18n %}
{% load thumbnail %}
+{% load absurl %}
{# we suppose here that "col" has been defined #}
<div class="tools toggle">
<ul class="clearfix">
- <li><a title="Partager sur Twitter" class="tool twitter" href="#"></a></li>
- <li><a title="Partager sur Facebook" class="tool facebook" href="#"></a></li>
+ <li><a title="Partager sur Twitter" class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'view_collection' collection_pk=col.pk %}"></a></li>
+ <li><a title="Partager sur Facebook" class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'view_collection' collection_pk=col.pk %}"></a></li>
<!--li><a title="Enregistrer" class="tool save" href="#"></a></li-->
</ul>
</div>
--- a/src/egonomy/templates/partial/fragment_in_list.html Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/templates/partial/fragment_in_list.html Mon Mar 17 16:17:30 2014 +0100
@@ -1,4 +1,5 @@
{% load i18n %}
+{% load absurl %}
{# we suppose here that "frg" has been defined #}
{% with fragment=frg.object|default:frg %}{# frg.object in search case, frg otherwise #}
<a draggable="true" data-title="{{ fragment.title }}" data-description="{% trans 'Fragment from' %} {{ fragment.image.metadata.titre|default:_('No title') }} {% trans 'Annotated by' %} {{ fragment.author }}"
@@ -18,8 +19,8 @@
</div>
<div class="tools-2">
<ul class="clearfix">
- <li><a class="tool twitter" href="#" title="{% trans 'Share on Twitter'%}"></a></li>
- <li><a class="tool facebook" href="#" title="{% trans 'Share on Facebook'%}"></a></li>
+ <li><a class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'view_fragment' fragment_pk=frg.pk %}" title="{% trans 'Share on Twitter'%}"></a></li>
+ <li><a class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'view_fragment' fragment_pk=frg.pk %}" title="{% trans 'Share on Facebook'%}"></a></li>
{% if user.is_authenticated %}
<li><a class="tool plus open-popin additemtocollection" data-type="fragment" data-id="{{ frg.pk }}" href="#add-to-collection" title="{% trans 'Add to a collection'%}"></a></li>
{% else %}
--- a/src/egonomy/templates/partial/image_in_list.html Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/templates/partial/image_in_list.html Mon Mar 17 16:17:30 2014 +0100
@@ -1,6 +1,7 @@
{% load static %}
{% load i18n %}
{% load thumbnail %}
+{% load absurl %}
{# we suppose here that "img" has been defined #}
<a draggable="true" data-title="{{ img.metadata.titre|default:_('No title') }}" data-description="{% trans 'Author' %} : {{ img.metadata.auteur|default:_('Not documented') }}"
href="{% url 'annotate_picture' image_id=img.id %}{% if search %}?search={{ search }}&index_search={{ offset_search|add:forloop.counter0 }}&nb_results={{ nb_results }}{% endif %}">
@@ -32,8 +33,8 @@
</a>
<div class="tools-2">
<ul class="clearfix">
- <li><a class="tool twitter" href="#" title="{% trans 'Share on Twitter'%}"></a></li>
- <li><a class="tool facebook" href="#" title="{% trans 'Share on Facebook'%}"></a></li>
+ <li><a class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'annotate_picture' image_id=img.id %}" title="{% trans 'Share on Twitter'%}"></a></li>
+ <li><a class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'annotate_picture' image_id=img.id %}" title="{% trans 'Share on Facebook'%}"></a></li>
{% if user.is_authenticated %}
<li><a class="tool plus open-popin additemtocollection" data-type="image" data-id="{{ img.id }}" href="#add-to-collection" title="{% trans 'Add to a collection'%}"></a></li>
{% else %}
--- a/src/egonomy/templates/partial/item_in_collection_geographical.html Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/templates/partial/item_in_collection_geographical.html Mon Mar 17 16:17:30 2014 +0100
@@ -1,6 +1,7 @@
{% load static %}
{% load i18n %}
{% load thumbnail %}
+{% load absurl %}
<li class="subcol-fourth geo-item" id="item{{ item.pk }}">
{% ifequal item.content_type.model "fragment" %}
{% with fragment=item.content_object %}
@@ -21,8 +22,8 @@
</div>
<div class="tools-2">
<ul class="clearfix">
- <li><a class="tool twitter" href="#" title="{% trans 'Share on Twitter'%}"></a></li>
- <li><a class="tool facebook" href="#" title="{% trans 'Share on Facebook'%}"></a></li>
+ <li><a class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'view_fragment' fragment_pk=fragment.pk %}" title="{% trans 'Share on Twitter'%}"></a></li>
+ <li><a class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'view_fragment' fragment_pk=fragment.pk %}" title="{% trans 'Share on Facebook'%}"></a></li>
<li>{% if user.is_authenticated %}
<a class="tool plus open-popin additemtocollection" data-type="fragment" data-id="{{ fragment.pk }}" href="#add-to-collection" title="{% trans 'Add to a collection' %}"></a>
{% else %}
@@ -67,8 +68,8 @@
</div>
<div class="tools-2">
<ul class="clearfix">
- <li><a class="tool twitter" href="#" title="{% trans 'Share on Twitter'%}"></a></li>
- <li><a class="tool facebook" href="#" title="{% trans 'Share on Facebook'%}"></a></li>
+ <li><a class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'annotate_picture' image_id=img.id %}" title="{% trans 'Share on Twitter'%}"></a></li>
+ <li><a class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'annotate_picture' image_id=img.id %}" title="{% trans 'Share on Facebook'%}"></a></li>
<li>{% if user.is_authenticated %}
<a class="tool plus open-popin additemtocollection" data-type="image" data-id="{{ img.id }}" href="#add-to-collection" title="{% trans 'Add to a collection' %}"></a>
{% else %}
--- a/src/egonomy/templates/partial/item_in_collection_list.html Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/templates/partial/item_in_collection_list.html Mon Mar 17 16:17:30 2014 +0100
@@ -1,6 +1,7 @@
{% load static %}
{% load i18n %}
{% load thumbnail %}
+{% load absurl %}
{% ifequal item.content_type.model "fragment" %}
<li class="clearfix horizontal item-masonry">
{% with fragment=item.content_object %}
@@ -18,8 +19,8 @@
</a>
<div class="tools toggle">
<ul class="clearfix">
- <li><a class="tool twitter" href="#" title="{% trans 'Share on Twitter'%}"></a></li>
- <li><a class="tool facebook" href="#" title="{% trans 'Share on Facebook'%}"></a></li>
+ <li><a class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'view_fragment' fragment_pk=fragment.pk %}" title="{% trans 'Share on Twitter'%}"></a></li>
+ <li><a class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'view_fragment' fragment_pk=fragment.pk %}" title="{% trans 'Share on Facebook'%}"></a></li>
<li>{% if user.is_authenticated %}
<a class="tool plus open-popin additemtocollection" data-type="fragment" data-id="{{ fragment.pk }}" href="#add-to-collection" title="{% trans 'Add to a collection' %}"></a>
{% else %}
@@ -79,8 +80,8 @@
{% endif %}
<div class="tools toggle">
<ul class="clearfix">
- <li><a class="tool twitter" href="#" title="{% trans 'Share on Twitter'%}"></a></li>
- <li><a class="tool facebook" href="#" title="{% trans 'Share on Facebook'%}"></a></li>
+ <li><a class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'annotate_picture' image_id=img.id %}" title="{% trans 'Share on Twitter'%}"></a></li>
+ <li><a class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'annotate_picture' image_id=img.id %}" title="{% trans 'Share on Facebook'%}"></a></li>
<li>{% if user.is_authenticated %}
<a class="tool plus open-popin additemtocollection" data-type="image" data-id="{{ img.id }}" href="#add-to-collection" title="{% trans 'Add to a collection' %}"></a>
{% else %}
--- a/src/egonomy/templates/partial/item_in_collection_mosaic.html Fri Mar 14 16:27:58 2014 +0100
+++ b/src/egonomy/templates/partial/item_in_collection_mosaic.html Mon Mar 17 16:17:30 2014 +0100
@@ -1,6 +1,7 @@
{% load static %}
{% load i18n %}
{% load thumbnail %}
+{% load absurl %}
<li class="item-masonry" data-keywords="{{ item.content_object.tag_list|join:',' }}">
<div class="curtain"></div>
<div class="visuel-project">
@@ -23,8 +24,8 @@
<h4>{{ fragment.author }}</h4>
</div>
<ul class="clearfix">
- <li><a class="tool twitter" href="#" title="{% trans 'Share on Twitter'%}"></a></li>
- <li><a class="tool facebook" href="#" title="{% trans 'Share on Facebook'%}"></a></li>
+ <li><a class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'view_fragment' fragment_pk=fragment.pk %}" title="{% trans 'Share on Twitter'%}"></a></li>
+ <li><a class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'view_fragment' fragment_pk=fragment.pk %}" title="{% trans 'Share on Facebook'%}"></a></li>
<li>{% if user.is_authenticated %}
<a class="tool plus open-popin additemtocollection" data-type="fragment" data-id="{{ fragment.pk }}" href="#add-to-collection" title="{% trans 'Add to a collection' %}"></a>
{% else %}
@@ -66,8 +67,8 @@
<h4>{{ img.metadata.auteur }}</h4>
</div>
<ul class="clearfix">
- <li><a class="tool twitter" href="#" title="{% trans 'Share on Twitter'%}"></a></li>
- <li><a class="tool facebook" href="#" title="{% trans 'Share on Facebook'%}"></a></li>
+ <li><a class="tool twitter" target="_blank" href="https://twitter.com/share?url={% absurl 'annotate_picture' image_id=img.id %}" title="{% trans 'Share on Twitter'%}"></a></li>
+ <li><a class="tool facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={% absurl 'annotate_picture' image_id=img.id %}" title="{% trans 'Share on Facebook'%}"></a></li>
<li>{% if user.is_authenticated %}
<a class="tool plus open-popin additemtocollection" data-type="image" data-id="{{ img.id }}" href="#add-to-collection" title="{% trans 'Add to a collection' %}"></a>
{% else %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/egonomy/templatetags/absurl.py Mon Mar 17 16:17:30 2014 +0100
@@ -0,0 +1,30 @@
+from django.contrib.sites.models import Site
+from django.template import Library
+from django.template.defaulttags import URLNode, url
+import urlparse
+
+
+register = Library()
+
+class AbsoluteURLNode(URLNode):
+ def render(self, context):
+ path = super(AbsoluteURLNode, self).render(context)
+ try:
+ request=context['request']
+ if request.is_secure():
+ domain = "https://%s" % Site.objects.get_current().domain
+ else:
+ domain = "http://%s" % Site.objects.get_current().domain
+ except:
+ domain = "http://%s" % Site.objects.get_current().domain
+ return urlparse.urljoin(domain, path)
+
+@register.simple_tag
+def absurl(parser, token, node_cls=AbsoluteURLNode):
+ """Just like {% url %} but ads the domain of the current site."""
+ node_instance = url(parser, token)
+ return node_cls(view_name=node_instance.view_name,
+ args=node_instance.args,
+ kwargs=node_instance.kwargs,
+ asvar=node_instance.asvar)
+absurl = register.tag(absurl)
\ No newline at end of file