--- a/src/egonomy/models.py Thu Dec 05 17:11:24 2013 +0100
+++ b/src/egonomy/models.py Mon Feb 24 18:22:07 2014 +0100
@@ -105,7 +105,28 @@
@property
def tag_list(self):
# tags in list
- return self.tags.split(",")
+ a = self.tags.split(",")
+ tl = []
+ # Some tags are http://fr.wikipedia(...) urls, so we have to extract the label
+ for t in a:
+ if t[:29] == "http://fr.wikipedia.org/wiki/":
+ t = t[29:].replace("_"," ")
+ tl.append(t)
+ return tl
+
+ @property
+ def tag_list_linked(self):
+ # tags in list
+ a = self.tags.split(",")
+ tl = []
+ # Some tags are http://fr.wikipedia(...) urls, so we have to extract the label
+ for t in a:
+ u = ""
+ if t[:29] == "http://fr.wikipedia.org/wiki/":
+ u = t
+ t = t[29:].replace("_"," ")
+ tl.append({"label": t, "url": u})
+ return tl
def get_viewbox_info(self):
Binary file src/egonomy/static/egonomy/css/images/wikipedia_fr_logo.png has changed
--- a/src/egonomy/static/egonomy/css/style.css Thu Dec 05 17:11:24 2013 +0100
+++ b/src/egonomy/static/egonomy/css/style.css Mon Feb 24 18:22:07 2014 +0100
@@ -373,6 +373,43 @@
#info_fragment h3{ font-size: 1.4em; }
#info_fragment .desc{ font-size: 0.8em; }
+/* wikipedia logo */
+.logo_wikipedia{
+ width: 18px; height: 12px; background: url(images/wikipedia_fr_logo.png); float: right; opacity: 0.6;
+}
+.clean-linked-list .logo_wikipedia{
+ margin-left: 3px;
+ margin-top: 7px;
+}
+.clean-linked-list{
+ background-color: #FFFFFF;
+ background-position: right 4px center;
+ background-repeat: no-repeat;
+ color: #7F7F7F !important;
+ display: -ms-flexbox;
+ display: -webkit-flex;
+ display: flex;
+ font-family: 'Lato';
+ font-size: 12px;
+ height: 28px;
+ line-height: 28px;
+ padding: 0 30px 0 6px;
+ background-image: url("../img/icon-search.png");
+}
+.clean-linked-list a{
+ height: 28px;
+ line-height: 28px;
+ /*padding: 0 30px 0 6px;
+ background-image: url("../img/icon-search.png");*/
+}
+.clean-linked-list:hover{
+ box-shadow: none;
+}
+.clean-linked-list a{
+ background: none;
+ padding: 0;
+}
+
/* tests */
.svg_over_image{
opacity: 0;
--- a/src/egonomy/static/egonomy/js/main.js Thu Dec 05 17:11:24 2013 +0100
+++ b/src/egonomy/static/egonomy/js/main.js Mon Feb 24 18:22:07 2014 +0100
@@ -38,7 +38,38 @@
//tag it
if($('.tag-it').length){
var keywordsTagIt = $('.tag-it').tagit({
- allowSpaces : true
+ allowSpaces : true,
+ tagSource: function(search, showChoices){
+ $.ajax({
+ url : "http://fr.wikipedia.org/w/api.php",
+ dataType: "jsonp",
+ data : {
+ action: "opensearch",
+ search: search.term,
+ format: "json",
+ limit: 10
+ },
+ success:function(data){
+ var datas = data[1];
+ var n = datas.length;
+ var choices = [];
+ for(var i=0;i<n;i++){
+ var l = data[1][i];
+ choices.push({ label:l, value:( 'http://fr.wikipedia.org/wiki/' + l.replace(" ","_")) });
+ }
+ showChoices(choices);
+ }
+ });
+ },
+ beforeTagAdded: function(event, ui) {
+ if($(ui.tag.children()[0]).hasClass("tagit-label")){
+ var tagit_label = $(ui.tag.children()[0]).html();
+ if(tagit_label.substr(0, 29) == 'http://fr.wikipedia.org/wiki/'){
+ var label = tagit_label.substr(29).replace("_"," ");
+ $(ui.tag.children()[0]).html(label + ' <a href="' + tagit_label + '" target="_blank"><span class="logo_wikipedia f-right"> </span></a>');
+ }
+ }
+ }
});
$('.list-key-add a').bind('click', function(e){
e.preventDefault();
--- a/src/egonomy/templates/egonomy_view_fragment.html Thu Dec 05 17:11:24 2013 +0100
+++ b/src/egonomy/templates/egonomy_view_fragment.html Mon Feb 24 18:22:07 2014 +0100
@@ -154,8 +154,19 @@
<th class="va-top">{% trans "Fragment's keywords" %} :</th>
<td>
<ul class="list-key-search no-before list-keywords clearfix">
- {% for t in fragment.tag_list %}
- {% if t != "" %}<li><a data-tag="{{ t }}" class="box-shadow-2" href='{% url "all_fragments" %}?field=all&search="{{ t }}"'>{{ t }}</a></li>{% endif %}
+ {% for t in fragment.tag_list_linked %}
+ {% if t.label != "" %}
+ {% if t.url != "" %}
+ <li>
+ <span class="box-shadow-2 clean-linked-list">
+ <a data-tag="{{ t.label }}" href='{% url "all_fragments" %}?field=all&search="{{ t.label }}"'>{{ t.label }}</a>
+ <a href="{{ t.url }}" target="_blank"><span class="logo_wikipedia"> </span></a>
+ </span>
+ </li>
+ {% else %}
+ <li><a data-tag="{{ t.label }}" class="box-shadow-2" href='{% url "all_fragments" %}?field=all&search="{{ t.label }}"'>{{ t.label }}</a></li>
+ {% endif %}
+ {% endif %}
{% endfor %}
</ul>
</td>