Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pin single page added.

bibtex parser for pin content from RE module !
  • Loading branch information...
commit a5013ac7eeb5e2d9f2a186c277e11ac3091f6481 1 parent d6b5cf9
@danieleguido authored
View
10 glue/__init__.py
@@ -32,6 +32,16 @@ def whosdaddy( level=2 ):
#
+# BIBTEX JSON PARSER
+# ==================
+#
+def bibtex( reference ):
+ reference = re.sub('(\w+)\s*=\s*\{+',r'"\1":"', reference )
+ reference = re.sub('\}+(?=\s*[,\}+])','"', reference )
+ reference = re.sub('@(\w+)\s*\{([^,]*)',r'{"bibtext_key":"\2","\1": "\2"', reference )
+ return json.loads( reference )
+
+#
# REQUEST VALIDATION
# ==================
#
View
7 glue/models.py
@@ -2,7 +2,7 @@
from django.contrib.auth.models import User
from django.db import models
-
+from glue import bibtex
class Geo( models.Model): # geo spot, with zoom
@@ -81,6 +81,11 @@ class Meta:
def __unicode__(self):
return "%s (%s) a.k.a. %s" % (self.slug, self.language, self.title)
+ # use this function if and only if the pin content is in bibtex (CLEAN) format
+ def bib( self ):
+ return bibtex( self.content )
+
+
def json( self ):
return{
'id': self.id,
View
8 glue/templatetags/extras.py
@@ -1,6 +1,7 @@
import re, json
from django import template
+
register = template.Library()
@@ -11,8 +12,5 @@
# =============
#
@register.filter
-def bibtex( reference ):
- reference = re.sub('(\w+)\s*=\s*\{+',r'"\1":"', reference )
- reference = re.sub('\}+(?=\s*[,\}+])','"', reference )
- reference = re.sub('@(\w+)\s*\{([^,]*)',r'{"bibtext_key":"\2","\1": "\2"', reference )
- return json.loads( reference )
+def split( value, pattern=',' ):
+ return re.split( pattern, value)
View
107 templates/walt/index.html
@@ -47,7 +47,7 @@ <h2 style="border-width:0px">{% trans "series" %} ( {{ series.count }} )</h2>
{% for pin in walt.wander.pins.all|slice:":10" %}
<div class="item">
- <h3>#{{ pin.id }} {{ pin.title }} </h3>
+ <h3><a href="{% url walt_pin pin.slug %}"><!-- #{{ pin.id }} --> {{ pin.title }} </a></h3>
<div class="metadata"><span class="date">{% if pin.date %}{{ pin.date }}{% else %}{{ pin.date_last_modified }}{% endif %}</span>
{% for tag in pin.tags.all %}
<a href="{% url walt_tag tag.type|lower tag.slug %}" class="tag" alt="{{ tag.name }} ( {{ tag.type }} )">{{ tag.name }}</a>
@@ -85,7 +85,7 @@ <h2 style="border-width:0px">{% trans "series" %} ( {{ series.count }} )</h2>
{% for pin in walt.ask.pins.all|slice:":10" %}
<div class="item">
- <h3>#{{ pin.id }} {{ pin.title }} </h3>
+ <h3><a href="{% url walt_pin pin.slug %}"><!-- #{{ pin.id }} --> {{ pin.title }} </a></h3>
<div class="metadata"><span class="date">{% if pin.date %}{{ pin.date }}{% else %}{{ pin.date_last_modified }}{% endif %}</span>
{% for tag in pin.tags.all %}
<a href="{% url walt_tag tag.type|lower tag.slug %}" class="tag" alt="{{ tag.name }} ( {{ tag.type }} )">{{ tag.name }}</a>
@@ -114,7 +114,7 @@ <h2 style="border-width:0px">{% trans "series" %} ( {{ series.count }} )</h2>
</div>
<div class="grid_3">
- <a href="{% url walt_w %}"><h2>{{ walt.learn.title }}
+ <a href="{% url walt_l %}"><h2>{{ walt.learn.title }}
<div class="description">
{{ walt.learn.abstract }} ( {{ walt.learn.pins.count }} )
</div>
@@ -122,79 +122,70 @@ <h2 style="border-width:0px">{% trans "series" %} ( {{ series.count }} )</h2>
</a>
<div class="items">
{% for pin in walt.learn.pins.all|slice:":10" %}
- {{ pin.mimetype }}
- {% ifequal pin.mimetype "text/x-bibtex" %}
- {{ pin.content|bibtex }}
- {% endifequal %}
- {{ pin.content }}
+
+ {% ifequal pin.mimetype "text/x-bibtex" %}
+ {% with bibtex=pin.bib %}
+ <div class="item">
+ <h4>{{ bibtex.author }}</h4>
+ <h3><a href="{% url walt_pin pin.slug %}"><!-- #{{ pin.id }}-->{{ bibtex.title }}</a></h3>
+ <div class="metadata">
+ <p>{{ bibtex.publisher }}, {{ bibtex.year }}</p>
+ {% for tag in bibtex.keywords|split %}
+ <a href="#" class="tag" alt="{{ tag }}">{{ tag }}</a>
+ {% if not forloop.last %},{%endif %}
+ {% endfor %}
+ <p><a href="{% url admin:glue_pin_change pin.id %}">&rarr; {% trans "edit" %}</a></p>
+ </div>
+ <blockquote>
+ {% if bibtex.abstract %} {{ bibtex.abstract }} {% endif %}
+
+ {{ pin.abstract }}
+
+ </blockquote>
+
+ </div>
+ {% endwith %}
+ {% endifequal %}
+
{% endfor %}
- <div class="item">
- <h4>C Dollerup</h4>
- <h3>Tales and Translation: The Grimm Tales from Pan-Germanic narratives to shared international fairytales</h3>
- <div class="metadata">C Dollerup - 1999 - books.google.com
- <a href="#" class="tag">video</a>, <a href="#" class="tag">documentaire</a>, <a href="#" class="tag">ontology</a>
- </div>
- <blockquote>
- Dealing with the most translated work of German literature, the Tales of the brothers Grimm
- (1812-1815), this book discusses their history, notably in relation to Denmark and
- subsequently other nations from 1816 to 1986. The Danish intelligentsia responded\
- </blockquote>
- </div>
- <div class="item">
- <h4>T Honkela, V Pulkki, T Kohonen</h4>
- <h3>Contextual relations of words in Grimm tales analyzed by self-organizing map</h3>
- <div class="metadata">Proceedings of ICANN-95, …, 1995 - users.ics.aalto.fi
- <a href="#" class="tag">video</a>, <a href="#" class="tag">documentaire</a>, <a href="#" class="tag">ontology</a>
- </div>
- <blockquote>
- Dealing with the most translated work of German literature, the Tales of the brothers Grimm
- (1812-1815), this book discusses their history, notably in relation to Denmark and
- subsequently other nations from 1816 to 1986. The Danish intelligentsia responded\
- </blockquote>
- </div>
+
</div>
</div>
<div class="grid_3 omega">
- <h2>{{ walt.try.title }}
- <div class="description">
- {{ walt.try.abstract }} ( {{ walt.try.pins.count }} )
- </div>
- </h2>
+ <a href="{% url walt_t %}"><h2>{{ walt.try.title }}
+ <div class="description">
+ {{ walt.try.abstract }} ( {{ walt.try.pins.count }} )
+ </div>
+ </h2>
+ </a>
<div class="items">
{% for pin in walt.try.pins.all|slice:":10" %}
<div class="item">
- <h3>{{ pin.title }}</h3>
- <div class="metadata"><span class="date">{{ pin.ref_date }}</span>
- <a href="#" class="tag">video</a>, <a href="#" class="tag">documentaire</a>, <a href="#" class="tag">ontology</a>
+ <h3><a href="{% url walt_pin pin.slug %}"><!-- #{{ pin.id }} -->{{ pin.title }} </a></h3>
+ <div class="metadata"><span class="date">{% if pin.date %}{{ pin.date }}{% else %}{{ pin.date_last_modified }}{% endif %}</span>
+ {% for tag in pin.tags.all %}
+ <a href="{% url walt_tag tag.type|lower tag.slug %}" class="tag" alt="{{ tag.name }} ( {{ tag.type }} )">{{ tag.name }}</a>
+ {% if not forloop.last %},{%endif %}
+ {% endfor %}
+ <p><a href="{% url admin:glue_pin_change pin.id %}">&rarr; {% trans "edit" %}</a></p>
</div>
<blockquote>
{{ pin.abstract }}
</blockquote>
- <a class="external" href="{{ pin.permalink}}">tabletonet</a>
- <div class="comment">
- <a href="#" class="author">b.s.</a> Très bel exemple de vidéo avec graphisme intégré, dans une très belle interface interactive et dynamique...
- </div>
-
- </div>
- {% endfor %}
- <div class="item">
-
- <h3>Table2Net</h3>
- <div class="metadata"><span class="date">20 Feb. 2013</span>
- <a href="#" class="tag">video</a>, <a href="#" class="tag">documentaire</a>, <a href="#" class="tag">ontology</a>
- </div>
- <blockquote>
- Table to net permet
+ {{ pin.content|safe }}
+ <a class="external" href="{{ pin.permalink}}">&rarr; {{ pin.permalink}}</a>
- </blockquote>
- <a class="external" href="#medialab tool">tabletonet</a>
+ {% for child in pin.children.all|slice:":10" %}
<div class="comment">
- <a href="#" class="author">b.s.</a> Très bel exemple de vidéo avec graphisme intégré, dans une très belle interface interactive et dynamique...
+ <a href="#" class="author"> </a> {{ child.abstract }}
</div>
+ {% endfor %}
</div>
+ {% endfor %}
+
</div>
</div>
</div>
View
64 templates/walt/pin.html
@@ -0,0 +1,64 @@
+{% extends "walt/middle.html" %}
+{% load i18n %}
+{% load extras %}
+{% block page %}
+ <div class="grid_12">
+ <div class="grid_3 alpha">
+ <h2>{% trans "previous in serie" %}</h2>
+ </div>
+ <div class="grid_6">
+ {% ifequal pin.mimetype "text/x-bibtex" %}
+ {% with bibtex=pin.bib %}
+ <div class="item">
+ <h4>{{ bibtex.author }}</h4>
+ <h3>{{ bibtex.title }}</h3>
+ <div class="metadata">
+ <p>{{ bibtex.publisher }}, {{ bibtex.year }}</p>
+ {% for tag in bibtex.keywords|split %}
+ <a href="#" class="tag" alt="{{ tag }}">{{ tag }}</a>
+ {% if not forloop.last %},{%endif %}
+ {% endfor %}
+ <p><a href="{% url admin:glue_pin_change pin.id %}">&rarr; {% trans "edit" %}</a></p>
+ </div>
+ <blockquote>
+ {% if bibtex.abstract %}<p> {{ bibtex.abstract }} </p>{% endif %}
+
+ {{ pin.abstract }}
+
+ </blockquote>
+
+ </div>
+ {% endwith %}
+ {% else %}
+
+ <div class="item">
+
+ <h3>#{{ pin.id }} {{ pin.title }} </h3>
+ <div class="metadata"><span class="date">{% if pin.date %}{{ pin.date }}{% else %}{{ pin.date_last_modified }}{% endif %}</span>
+ {% for tag in pin.tags.all %}
+ <a href="{% url walt_tag tag.type|lower tag.slug %}" class="tag" alt="{{ tag.name }} ( {{ tag.type }} )">{{ tag.name }}</a>
+ {% if not forloop.last %},{%endif %}
+ {% endfor %}
+ <p><a href="{% url admin:glue_pin_change pin.id %}">&rarr; {% trans "edit" %}</a></p>
+ </div>
+ <blockquote>
+ {{ pin.abstract }}
+
+ </blockquote>
+ {{ pin.content|safe }}
+ <a class="external" href="{{ pin.permalink}}">&rarr; {{ pin.permalink}}</a>
+
+ {% for child in pin.children.all|slice:":10" %}
+ <div class="comment">
+ <a href="#" class="author"> </a> {{ child.abstract }}
+ </div>
+ {% endfor %}
+
+ </div>
+ {% endifequal %}
+ </div>
+ <div class="grid_3 omega">
+ <h2>{% trans "next in serie" %}</h2>
+ </div>
+ </div>
+{% endblock %}
View
73 templates/walt/walt.html
@@ -1,6 +1,6 @@
{% extends "walt/middle.html" %}
{% load i18n %}
-
+{% load extras %}
{% block page %}
<!-- div class="grid_12">
@@ -43,30 +43,55 @@ <h2 style="border-width:0px">Protocols</h2>
<div class="items">
{% for pin in page.pins.all|slice:":10" %}
- <div class="item">
-
- <h3>#{{ pin.id }} {{ pin.title }} </h3>
- <div class="metadata"><span class="date">{% if pin.date %}{{ pin.date }}{% else %}{{ pin.date_last_modified }}{% endif %}</span>
- {% for tag in pin.tags.all %}
- <a href="{% url walt_tag tag.type|lower tag.slug %}" class="tag" alt="{{ tag.name }} ( {{ tag.type }} )">{{ tag.name }}</a>
- {% if not forloop.last %},{%endif %}
- {% endfor %}
- <p><a href="{% url admin:glue_pin_change pin.id %}">&rarr; {% trans "edit" %}</a></p>
- </div>
- <blockquote>
- {{ pin.abstract }}
+ {% ifequal pin.mimetype "text/x-bibtex" %}
+ {% with bibtex=pin.bib %}
+ <div class="item">
+ <h4>{{ bibtex.author }}</h4>
+ <h3>{{ bibtex.title }}</h3>
+ <div class="metadata">
+ <p>{{ bibtex.publisher }}, {{ bibtex.year }}</p>
+ {% for tag in bibtex.keywords|split %}
+ <a href="#" class="tag" alt="{{ tag }}">{{ tag }}</a>
+ {% if not forloop.last %},{%endif %}
+ {% endfor %}
+ <p><a href="{% url admin:glue_pin_change pin.id %}">&rarr; {% trans "edit" %}</a></p>
+ </div>
+ <blockquote>
+ {% if bibtex.abstract %}<p> {{ bibtex.abstract }} </p>{% endif %}
+
+ {{ pin.abstract }}
+
+ </blockquote>
- </blockquote>
- {{ pin.content|safe }}
- <a class="external" href="{{ pin.permalink}}">&rarr; {{ pin.permalink}}</a>
-
- {% for child in pin.children.all|slice:":10" %}
- <div class="comment">
- <a href="#" class="author"> </a> {{ child.abstract }}
- </div>
- {% endfor %}
-
- </div>
+ </div>
+ {% endwith %}
+ {% else %}
+
+ <div class="item">
+
+ <h3>#{{ pin.id }} {{ pin.title }} </h3>
+ <div class="metadata"><span class="date">{% if pin.date %}{{ pin.date }}{% else %}{{ pin.date_last_modified }}{% endif %}</span>
+ {% for tag in pin.tags.all %}
+ <a href="{% url walt_tag tag.type|lower tag.slug %}" class="tag" alt="{{ tag.name }} ( {{ tag.type }} )">{{ tag.name }}</a>
+ {% if not forloop.last %},{%endif %}
+ {% endfor %}
+ <p><a href="{% url admin:glue_pin_change pin.id %}">&rarr; {% trans "edit" %}</a></p>
+ </div>
+ <blockquote>
+ {{ pin.abstract }}
+
+ </blockquote>
+ {{ pin.content|safe }}
+ <a class="external" href="{{ pin.permalink}}">&rarr; {{ pin.permalink}}</a>
+
+ {% for child in pin.children.all|slice:":10" %}
+ <div class="comment">
+ <a href="#" class="author"> </a> {{ child.abstract }}
+ </div>
+ {% endfor %}
+
+ </div>
+ {% endifequal %}
{% endfor %}
</div>
View
3  walt/urls.py
@@ -27,4 +27,7 @@
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
+
+ # all the rest. pins.
+ url(r'^(?P<pin_slug>[a-zA-Z\d\-]+)/', 'walt.views.pin', name='walt_pin'),
)
View
7 walt/views.py
@@ -55,6 +55,13 @@ def tag( request, tag_type, tag_slug ):
return render_to_response( "walt/index.html", RequestContext(request, data ) )
+def pin( request, pin_slug ):
+ data = sc( request, tags=[ "tags" ] )
+ data['pin'] = get_object_or_404( Pin, language=data['language'], slug=pin_slug )
+ data['series'] = Serie.objects.filter( frame__pin__slug=pin_slug ).distinct()
+
+ return render_to_response( "walt/pin.html", RequestContext(request, data ) )
+
def _walt( data, slug ):
data['page'] = get_object_or_404( Page, language=data['language'], slug=slug )
data['series'] = Serie.objects.filter( frame__pin__page__slug=slug ).distinct()
Please sign in to comment.
Something went wrong with that request. Please try again.