finally senseetive api
authorcavaliet
Fri, 05 Jul 2013 16:30:00 +0200
changeset 226 d602d53379e7
parent 225 5313fc069b1b
child 227 9b88517060d7
finally senseetive api
integration/v2/css/style.css
integration/v2/js/main.js
src/egonomy/static/egonomy/css/style.css
src/egonomy/static/egonomy/js/main.js
src/egonomy/templates/egonomy_create_fragment.html
src/egonomy/views.py
--- a/integration/v2/css/style.css	Thu Jul 04 17:15:49 2013 +0200
+++ b/integration/v2/css/style.css	Fri Jul 05 16:30:00 2013 +0200
@@ -206,7 +206,7 @@
 .list-key-search a{ background-image: url(../img/icon-search.png);}
 .list-key-add a{background-image: url(../img/icons-15.png); background-position: right 6px top -53px !important; }
 .list-keywords li{display: inline-block; float: left; margin: 0 8px 8px 0;}
-.list-keywords a{color: #7F7F7F; font-family: 'Lato'; font-size: 12px; display: inline-block; height: 28px; line-height: 28px; padding: 0 30px 0 6px;background-position: right 4px center; background-repeat: no-repeat; background-color: #fff;}
+.list-keywords a{color: #7F7F7F !important; font-family: 'Lato'; font-size: 12px; display: inline-block; height: 28px; line-height: 28px; padding: 0 30px 0 6px;background-position: right 4px center; background-repeat: no-repeat; background-color: #fff;}
 .list-keywords a:hover{-webkit-box-shadow: none;-moz-box-shadow: none;box-shadow: none;}
 .filters{padding: 10px 0; text-align: center;}
 .filters li{background-color: #FFFFFF;display: inline-block;font-family: 'Lato';font-size: 12px;height: 20px;line-height: 20px;margin-bottom: 2px;position: relative;text-align: left;width: 200px;}
--- a/integration/v2/js/main.js	Thu Jul 04 17:15:49 2013 +0200
+++ b/integration/v2/js/main.js	Fri Jul 05 16:30:00 2013 +0200
@@ -42,8 +42,7 @@
 		});
 		$('.list-key-add a').bind('click', function(e){
 			e.preventDefault();
-			var tag = $(this).attr('data-tag');
-			keywordsTagIt.tagit("createTag", tag);
+			keywordsTagIt.tagit("createTag", $(this).attr('data-tag'));
 		});
 	}
 
--- a/src/egonomy/static/egonomy/css/style.css	Thu Jul 04 17:15:49 2013 +0200
+++ b/src/egonomy/static/egonomy/css/style.css	Fri Jul 05 16:30:00 2013 +0200
@@ -206,7 +206,7 @@
 .list-key-search a{ background-image: url(../img/icon-search.png);}
 .list-key-add a{background-image: url(../img/icons-15.png); background-position: right 6px top -53px !important; }
 .list-keywords li{display: inline-block; float: left; margin: 0 8px 8px 0;}
-.list-keywords a{color: #7F7F7F; font-family: 'Lato'; font-size: 12px; display: inline-block; height: 28px; line-height: 28px; padding: 0 30px 0 6px;background-position: right 4px center; background-repeat: no-repeat; background-color: #fff;}
+.list-keywords a{color: #7F7F7F !important; font-family: 'Lato'; font-size: 12px; display: inline-block; height: 28px; line-height: 28px; padding: 0 30px 0 6px;background-position: right 4px center; background-repeat: no-repeat; background-color: #fff;}
 .list-keywords a:hover{-webkit-box-shadow: none;-moz-box-shadow: none;box-shadow: none;}
 .filters{padding: 10px 0; text-align: center;}
 .filters li{background-color: #FFFFFF;display: inline-block;font-family: 'Lato';font-size: 12px;height: 20px;line-height: 20px;margin-bottom: 2px;position: relative;text-align: left;width: 200px;}
--- a/src/egonomy/static/egonomy/js/main.js	Thu Jul 04 17:15:49 2013 +0200
+++ b/src/egonomy/static/egonomy/js/main.js	Fri Jul 05 16:30:00 2013 +0200
@@ -42,8 +42,7 @@
 		});
 		$('.list-key-add a').bind('click', function(e){
 			e.preventDefault();
-			var tag = $(this).attr('data-tag');
-			keywordsTagIt.tagit("createTag", tag);
+			keywordsTagIt.tagit("createTag", $(this).attr('data-tag'));
 		});
 	}
 
--- a/src/egonomy/templates/egonomy_create_fragment.html	Thu Jul 04 17:15:49 2013 +0200
+++ b/src/egonomy/templates/egonomy_create_fragment.html	Fri Jul 05 16:30:00 2013 +0200
@@ -138,6 +138,9 @@
                     <p class="null">{% trans "No collection" %}</p>
                 </div>
                 </form>
+                <div id="info_tag" style="display:none;">
+                    <p>coucou</p>
+                </div>
             </article>
 {% endblock %}
 
@@ -166,7 +169,7 @@
                                 if(n>0){
                                     s = '<div id="tabs" style="height: 320px;"><ul><li><a href="#tabs-1">Mots-clés</a></li><li><a href="#tabs-2">Images</a></li></ul>'
                                         + '<div id="tabs-1" style="overflow-y: scroll; overflow-x: hidden; height: 250px;">'
-                                        + '<ul class="list-key-add list-keywords no-before clearfix">';
+                                        + '<ul class="list-key-add list-keywords no-before clearfix imgs-over addable-tags">';
                                     var images = data["images"];
                                     var m = images.length;
                                     for(var i=0;i<n;i++){
@@ -182,20 +185,20 @@
                                             }
                                         }
                                         //s += '<li><span class="clickable addable_tag" data="' + img_urls + '">' + keywords[i] + '</span></li>';
-                                        s += '<li><a class="box-shadow-2" data="' + img_urls + '" data-tag="' + keywords[i] + '" href="#">' + keywords[i] + '</a></li>';
+                                        s += '<li><a class="box-shadow-2" data-img-urls="' + img_urls + '" data-tag="' + keywords[i] + '" href="#">' + keywords[i] + '</a></li>';
                                     }
-                                    s += '</ul><span id="senseetive_tags" class="right clickable">+ {% trans 'Add all Senseetive keywords to yours' %}</span>'
-                                        +'</div><div id="tabs-2" style="overflow-y: scroll; overflow-x: hidden; height: 250px;">'
+                                    s += '</ul></div>'
+                                        +'<div id="tabs-2" style="overflow-y: scroll; overflow-x: hidden; height: 250px;">'
                                         +'<ul>';
                                     // Add pictures
                                     for(var i=0;i<m;i++){
                                         s += '<li class="senapi_li"><img src="' + images[i].url_width + '" class="senapi_img" alt="' + images[i].title + '"/>'
                                            + '<span class="senapi_text">' + images[i].title + '</span>'
-                                           + '<br/><span class="senapi_tags">';
+                                           + '<br/><span class="senapi_tags addable-tags">';
                                         kws = images[i]["keywords"];
                                         var nb_kws = kws.length;
                                         for(var k=0;k<nb_kws;k++){
-                                            s += ((k==0) ? "" : ", ") + '<span class="clickable addable_tag">' + kws[k] + '</span>';
+                                            s += ((k==0) ? "" : ", ") + '<a data-tag="' + kws[k] + '" href="#">' + kws[k] + '</a>';
                                         }
                                         s +='</span></li>';
                                     }
@@ -204,10 +207,16 @@
                                     $("#senseetive_holder").html(s);
                                     // Init tabs
                                     $("#tabs").tabs();
+                                    // Init tags behaviour
+                                    $('.addable-tags a').bind('click', function(e){
+							            e.preventDefault();
+							            // $('.tag-it') is already initialised
+							            $('.tag-it').tagit("createTag", $(this).attr('data-tag'));
+							        });
                                     // Functions to show tag's images
-                                    $("#add_senseetive_tags .addable_tag").hover(
+                                    $(".imgs-over a").hover(
                                         function(e){
-                                            urls = $(this).attr("data").split(",");
+                                            urls = $(this).attr("data-img-urls").split(",");
                                             var s = "";
                                             var n = urls.length;
                                             for(i=0;i<n;i++){
--- a/src/egonomy/views.py	Thu Jul 04 17:15:49 2013 +0200
+++ b/src/egonomy/views.py	Fri Jul 05 16:30:00 2013 +0200
@@ -400,7 +400,7 @@
     # 50d0574a0300000f102a5177 pigment)
     # 50d0574a03000021102a5177 Gabor
     files = {
-              'image0':open(png_file_path, 'rb').read(),
+              'image0': (uid + '.png', open(png_file_path, 'rb').read()),
     }
     params = {
               "xaction":"contents.read",
@@ -412,7 +412,7 @@
               "requestfieldname":"image0"
     }
     # We make the request
-    req = requests.post(url=settings.SENSEETIVE_API_URL, data=params, files=files, verify=False)
+    req = requests.post(url=settings.SENSEETIVE_API_URL, data=params, files=files, verify=False)#, headers=headers)
     resp = req.json()
     # Now that we have a response, we can remove the svg and png files
     try: