Ronnie has proposed merging lp:~ronnie.vd.c/loco-directory/twidentica into 
lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)

For more details, see:
https://code.launchpad.net/~ronnie.vd.c/loco-directory/twidentica/+merge/51626

Replaces twidenash by own twidentica to support multiple sections of twides on 
one page, and allow to define the amount of twides per section
-- 
https://code.launchpad.net/~ronnie.vd.c/loco-directory/twidentica/+merge/51626
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~ronnie.vd.c/loco-directory/twidentica into lp:loco-directory.
=== removed file 'loco_directory/media/css/twidenash.css'
--- loco_directory/media/css/twidenash.css	2010-09-28 17:21:02 +0000
+++ loco_directory/media/css/twidenash.css	1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-/*
- * twidenash.css
- *
- * twidenash CSS stuff.
- *
- *  Author: Michael Hall      ( mhall119 )
- */
-
-
-ul.twidenash li {
-    list-style-type:  none;
-    clear:            both;
-    padding:          3px;
-    font-size:        100%;
-}
-
-ul.twidenash li img {
-    float:            left;
-    vertical-align:   top;
-    padding-right:    10px;
-}
-
-ul.twidenash li .comment {
-    margin-left:      5px;
-    display:          block;
-    overflow:         auto;
-}
-
-ul.twidenash li .nick {
-    font-weight:      bold;
-}
-
-ul.twidenash li .time {
-    font-size: 0.75em;
-    color: #555;
-}
-

=== added file 'loco_directory/media/css/twidentica.css'
--- loco_directory/media/css/twidentica.css	1970-01-01 00:00:00 +0000
+++ loco_directory/media/css/twidentica.css	2011-02-28 20:43:53 +0000
@@ -0,0 +1,37 @@
+/*
+ * twidenash.css
+ *
+ * twidenash CSS stuff.
+ *
+ *  Author: Michael Hall      ( mhall119 )
+ */
+
+
+.twidentica li {
+    list-style-type:  none;
+    clear:            both;
+    padding:          3px;
+    font-size:        0.75em;
+}
+
+.twidentica li img {
+    float:            left;
+    vertical-align:   top;
+    padding-right:    10px;
+}
+
+.twidentica li .comment {
+    margin-left:      5px;
+    display:          block;
+    overflow:         auto;
+}
+
+.twidentica li .nick {
+    font-weight:      bold;
+}
+
+.twidentica li .time {
+    font-size: 0.75em;
+    color: #555;
+}
+

=== added file 'loco_directory/media/js/jquery-twidentica.js'
--- loco_directory/media/js/jquery-twidentica.js	1970-01-01 00:00:00 +0000
+++ loco_directory/media/js/jquery-twidentica.js	2011-02-28 20:43:53 +0000
@@ -0,0 +1,124 @@
+/*
+ * jQuery Twitter/Identica plugin 0.1.0
+ * Requires jQuery 1.3.2
+ *
+ * Copyright 2011, Ronnie van den Crommenacker
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ */
+ 
+/*
+ * functions parseDate and parseResults are copied and modified from twidenash
+ * See the copyrights for those functions below
+* 
+* 
+* Copyright (c) 2010 Stuart Langridge
+* 
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+* 
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+* 
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*
+* Website: http://code.google.com/p/twidenash/
+*/
+
+
+(function ($) {
+    $.fn.extend({   
+        twidentica: function (options) {
+            var defaults = {
+                use_id: true,               // If true, the id="" of the element will be used
+                hashtag: null,              // The hashtag to search (if use_id = false)
+                amount: 5,                  // Aount of items to get
+                update_interval: 600,       // Does not work yet
+                sources: [                  // The sources to search the hashtag
+                    'http://locoteams.status.net/api/',
+                    'http://identi.ca/api/',
+                    'http://search.twitter.com/'
+                ]
+            };
+            options =  $.extend(defaults, options);
+            
+            function parseDate(created_at) {
+                var date = new Date(),
+                    delta = parseInt((date.getTime() - created_at) / 1000, 10),
+                    pluralize = function (singular, n) {
+                        return n + ' ' + singular + (n === 1 ? '' : 's');
+                    },
+                    date_msg = null;
+                if (delta < 60) {
+                    date_msg = 'less than a minute ago ';
+                } else if (delta < (45 * 60)) {
+                    date_msg = 'about ' + pluralize("minute", parseInt(delta / 60, 10)) + ' ago ';
+                } else if (delta < (24 * 60 * 60)) {
+                    date_msg = 'about ' + pluralize("hour", parseInt(delta / 3600, 10)) + ' ago ';
+                } else {
+                    date_msg = 'about ' + pluralize("day", parseInt(delta / 86400, 10)) + ' ago ';
+                }
+                return date_msg;
+            }
+            
+            function parseResults(element, data) {
+                var exp = /(\b(https?|ftp|file):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|])/gi,
+                    items = [],
+                    result,
+                    item,
+                    r;
+                for (r in data.results) {
+                    if (data.results.hasOwnProperty(r)) {
+                        result = data.results[r];
+                        items.push({ text: result.text, 
+                            id: result.id,
+                            img: result.profile_image_url, 
+                            dt: Date.parse(result.created_at),
+                            user: result.from_user });
+                    }
+                }
+                items.sort(function (a, b) { return b.dt - a.dt; });
+                for (r in items) {
+                    if (items.hasOwnProperty(r)) {
+                        item = items[r];
+                        // TODO: check for other sources datetime
+                        if (element.children().length < options.amount) {
+                            $(element).prepend($('<li><img width="48" src="' + item.img + '"><span class="nick" id="' + item.id + '">' + item.user + '</span><span class="time"> ' + parseDate(item.dt) + ' </span><span class="comment">' + item.text.replace(exp, "<a href='$1' target='_blank'>$1</a>") + '</span></li>').hide().fadeIn('slow'));
+                        }
+                    }
+                }
+            }
+            
+            function fetch(element, url, hashtag, amount) {
+                $.get(url + 'search.json', {q: '#' + hashtag, rpp: amount}, function (data) {
+                    parseResults(element, data);
+                });
+            }
+            
+            return $(this).each(function (i, html_element) {
+                var sources = options.sources,
+                    element = $('<ul>').appendTo(html_element),
+                    hashtag,
+                    s;
+                for (s in sources) {
+                    if (sources.hasOwnProperty(s)) {
+                        hashtag = options.use_id ? $(html_element).attr('id') : options.hashtag;
+                        if (hashtag) {
+                            fetch(element, sources[s], hashtag, options.amount);
+                        }
+                    }
+                }
+            });
+        }
+    });
+}(jQuery));

=== removed file 'loco_directory/media/js/twidenash.js'
--- loco_directory/media/js/twidenash.js	2010-09-28 17:21:02 +0000
+++ loco_directory/media/js/twidenash.js	1970-01-01 00:00:00 +0000
@@ -1,140 +0,0 @@
-/*
-* 
-* Copyright (c) 2010 Stuart Langridge
-* 
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-* 
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-* 
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-* THE SOFTWARE.
-*
-* Website: http://code.google.com/p/twidenash/
-*/
-
-/*
-* With modification by Michael Hall for use in loco.ubuntu.com
-*/
-
-twidenash = {
-    init: function() {
-        if (!twidenash.hashtag) return;
-        // request hashtag search values for both twitter and identica
-        twidenash.callbacks = 0;
-        twidenash.items = [];
-        twidenash.add_script("http://locoteams.status.net/api/search.json?"; +
-           "callback=twidenash.cb&rpp=10&q=%23" + twidenash.hashtag);
-        twidenash.add_script("http://identi.ca/api/search.json?"; +
-           "callback=twidenash.cb&rpp=10&q=%23" + twidenash.hashtag);
-        twidenash.add_script("http://search.twitter.com/search.json?"; +
-           "callback=twidenash.cb&rpp=10&q=%23" + twidenash.hashtag);
-        twidenash.printed = 0;
-    },
-    add_script: function(url) {
-        var scr = document.createElement("script");
-        scr.src = url;
-        document.getElementsByTagName("head")[0].appendChild(scr);
-    },
-    cb: function(data) {
-        for (var i=0; i<data.results.length; i++) {
-            var dupe = false;
-            for (var j=0; j<twidenash.items.length; j++) {
-                // Strip characters that may be specific to networks
-                var comp1 = data.results[i].text.replace(/[♺\!\#\@]/g, '');
-                var comp2 = twidenash.items[j].text.replace(/[♺\!\#\@]/g, '');
-                var compdate = Date.parse(data.results[i].created_at);
-                var datediff = Math.abs(Date.parse(data.results[i].created_at) - twidenash.items[j].dt)
-                if (comp1 == comp2 && datediff < 120000) {
-                    dupe = true;
-                    break;
-                }
-            }
-            if (dupe) continue;
-            twidenash.items.push({ text: data.results[i].text, 
-                img: data.results[i].profile_image_url, 
-                dt: Date.parse(data.results[i].created_at),
-                user: data.results[i].from_user })
-        }
-        twidenash.callbacks += 1;
-        if (twidenash.callbacks == 2) {
-            twidenash.items.sort(function(a,b) { return b.dt - a.dt });
-            var ul = document.createElement("ul");
-            ul.className = "twidenash";
-            for (i=0; i<twidenash.items.length && twidenash.printed < 5; i++) {
-                var li = document.createElement("li");
-                var img = document.createElement("img");
-                img.src = twidenash.items[i].img;
-                img.width = 48;
-                var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
-                var delta = parseInt((relative_to.getTime() - twidenash.items[i].dt) / 1000);
-                var pluralize = function (singular, n) {
-                    return '' + n + ' ' + singular + (n == 1 ? '' : 's');
-                };
-                if(delta < 60) {
-                     date_msg = 'less than a minute ago ';
-                } else if(delta < (45*60)) {
-                    date_msg = 'about ' + pluralize("minute", parseInt(delta / 60)) + ' ago ';
-                } else if(delta < (24*60*60)) {
-                    date_msg = 'about ' + pluralize("hour", parseInt(delta / 3600)) + ' ago ';
-                } else {
-                    date_msg = 'about ' + pluralize("day", parseInt(delta / 86400)) + ' ago ';
-                }
-                var span = document.createElement("span");
-                span.className = 'comment';
-                var nick = document.createElement("span");
-                nick.className = 'nick';
-                nick.appendChild(document.createTextNode(twidenash.items[i].user));
-                var time = document.createElement("span");
-                time.className = 'time';
-                time.appendChild(document.createTextNode(" ( "+ date_msg +" ) "));
-                
-                var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
-                span.innerHTML = twidenash.items[i].text.replace(exp,"<a href='$1' target='_blank'>$1</a>");
-                li.appendChild(img);
-                li.appendChild(nick);
-                li.appendChild(time);
-                li.appendChild(span);
-                ul.appendChild(li);
-                twidenash.printed++;
-            }
-            twidenash.scriptelement.parentNode.insertBefore(ul, twidenash.scriptelement);
-        }
-    },
-    cache_scriptname: function() {
-        // called before page load so we can find our own name
-        var scr = document.getElementsByTagName("script");
-        var url = scr[scr.length-1].getAttribute("src");
-        if (!url) {
-            var twidenash_script = document.getElementById("twidenash_script");
-            if (twidenash_script) url = twidenash_script.getAttribute("src");
-        }
-        if (url && url.lastIndexOf('?') != -1) {
-            twidenash.hashtag = url.substr(url.lastIndexOf('?')+1);
-            if (twidenash_script) {
-                twidenash.scriptelement = twidenash_script;
-            } else {
-                twidenash.scriptelement = scr[scr.length-1];
-            }
-        }
-    }
-};
-(function(i) {var u =navigator.userAgent;var e=/*@cc_on!@*/false; var st = 
-setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;
-if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10);}},10);}
-else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
-document.addEventListener("DOMContentLoaded",i,false); } else if(e){     (
-function(){var t=document.createElement('doc:rdy');try{t.doScroll('left');
-i();t=null;}catch(e){st(arguments.callee,0);}})();}else{window.onload=i;}})(twidenash.init);
-twidenash.cache_scriptname();
-

=== modified file 'loco_directory/templates/events/global_event_detail.html'
--- loco_directory/templates/events/global_event_detail.html	2011-02-17 20:05:03 +0000
+++ loco_directory/templates/events/global_event_detail.html	2011-02-28 20:43:53 +0000
@@ -2,13 +2,15 @@
 {% load i18n %}
 
 {% block extrahead %}{{ block.super }}
-        <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidenash.css" />
+        <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidentica.css" />
         <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language={% trans 'en' %}&region={% trans 'US' %}"></script>
         <script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_packed.js";></script>
         <script type="text/javascript" src="{{MEDIA_URL}}js/jquery-ubuntu-maps.js"></script>
+        <script type="text/javascript" src="{{MEDIA_URL}}js/jquery-twidentica.js"></script>
         <script type="text/javascript"> 
         //<![CDATA[
         $(function(){
+            $('.twidentica').twidentica();
             $('#venue-map').showLocations({markers_url:'{% url global-event-locations global_event_id=global_event_object.id %}',
                                            marker_icon: '{{ MEDIA_URL }}/img/marker.png'});
         });

=== modified file 'loco_directory/templates/events/global_event_detail.inc.html'
--- loco_directory/templates/events/global_event_detail.inc.html	2011-02-17 20:05:03 +0000
+++ loco_directory/templates/events/global_event_detail.inc.html	2011-02-28 20:43:53 +0000
@@ -100,7 +100,7 @@
 {% if global_event_object.microbloghashtag %}
     <article class="minor-content alone">
     <h2>{% trans "Microblogging" %} #{{global_event_object.microbloghashtag}}</h2>
-    <p><script src="{{MEDIA_URL}}js/twidenash.js?{{global_event_object.microbloghashtag}}"></script></p>
+    <div class="twidentica" id="{{ global_event_object.microbloghashtag }}"></div>
     </article>
 {% endif %}
 

=== modified file 'loco_directory/templates/index.html'
--- loco_directory/templates/index.html	2011-02-18 03:16:32 +0000
+++ loco_directory/templates/index.html	2011-02-28 20:43:53 +0000
@@ -7,8 +7,16 @@
 {% endblock %}
 
 {% block extrahead %}{{block.super}}
-        <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidenash.css" />
+        <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidentica.css" />
         <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/continents.css" />
+        <script type="text/javascript" src="{{MEDIA_URL}}js/jquery-twidentica.js"></script>
+        <script type="text/javascript"> 
+        //<![CDATA[
+            $(function() {
+                $('.twidentica').twidentica();
+            });
+        //]]>
+        </script>
 {% endblock %}
 
 {% block content %}
@@ -79,7 +87,7 @@
 
 <article class="minor-content alone">
     <h2>{% trans "Microblogging" %} #locoteams</h2>
-    <p><script src="{{MEDIA_URL}}js/twidenash.js?locoteams"></script></p>
+    <div class="twidentica" id="locoteams"></div>
 </article>
 
 {% endblock %}

=== modified file 'loco_directory/templates/teams/team_detail.html'
--- loco_directory/templates/teams/team_detail.html	2011-02-19 14:16:30 +0000
+++ loco_directory/templates/teams/team_detail.html	2011-02-28 20:43:53 +0000
@@ -14,16 +14,20 @@
 
 
 {% block extrahead %}{{ block.super }}
-<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidenash.css" />
+<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidentica.css" />
 {% if team.flickr_id or team.picasa_id or team.pixie_id %}
 <script type="text/javascript" src="{{MEDIA_URL}}jquery/jquery.js"></script>
 <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.lightbox-0.5.min.js"></script>
 <link rel="stylesheet" href="{{MEDIA_URL}}css/jquery.lightbox-0.5.css" type="text/css" media="screen" />
 <script type="text/javascript" src="{{MEDIA_URL}}js/jquery-flickr.js"></script>
+<script type="text/javascript" src="{{MEDIA_URL}}js/jquery-twidentica.js"></script>
+{% endif %}
 <script type="text/javascript"> 
 $(function() {
     var perPage = '16';
-{% endif %}
+    $('.twidentica').twidentica();
+
+
 {% if team.flickr_id %}
     $('#flickr').flickr({ key: "{{ flickr_api_key }}", id: "{{ team.flickr_id }}", amount: perPage });
 {% endif %}
@@ -65,9 +69,9 @@
         $("a.lightbox").lightBox();
     });
 {% endif %}
-{% if team.flickr_id or team.picasa_id or team.pixie_id %}
 });
 
+{% if team.flickr_id or team.picasa_id or team.pixie_id %}
 </script>
 <style type="text/css"> 
 div#flickr a.lightbox img {
@@ -208,7 +212,7 @@
 {% if team.microbloghashtag %}
 <article class="minor-content alone">
     <h2>{% trans "Microblogging" %} #{{team.microbloghashtag}}</h2>
-    <p><script src="{{MEDIA_URL}}js/twidenash.js?{{team.microbloghashtag}}"></script></p>
+    <div class="twidentica" id="{{ team.microbloghashtag }}"></div>
 </article>
 {% endif %}
 

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to