Michael Hall has proposed merging 
lp:~mhall119/loco-directory/fixes-599708_and_599831 into lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)
Related bugs:
  #599708 displaying the #locoteams last 5 dents/tweets on main page
  https://bugs.launchpad.net/bugs/599708
  #599831 Show upcoming global events on mainpage
  https://bugs.launchpad.net/bugs/599831


Mainpage:
1) Add Global Events table, plus count of upcoming Team events
2) Add top 5 tweets/dents tagged with #locoteams

Global Event Details:
1) Add top 5 tweets/dents tagged with the global event's microbloghashtag (if 
set)
-- 
https://code.launchpad.net/~mhall119/loco-directory/fixes-599708_and_599831/+merge/32717
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~mhall119/loco-directory/fixes-599708_and_599831 into lp:loco-directory.
=== modified file 'loco_directory/common/views.py'
--- loco_directory/common/views.py	2010-07-29 18:55:25 +0000
+++ loco_directory/common/views.py	2010-08-15 20:43:41 +0000
@@ -7,7 +7,12 @@
 from django.conf import settings
 
 def index(request):
-    context = {}
+    from events.models import GlobalEvent, TeamEvent
+    team_event_list = TeamEvent.objects.next_events()[:5]
+    global_event_list = GlobalEvent.objects.next_events()[:2]
+    context = {'team_event_list': team_event_list,
+               'global_event_list': global_event_list,}
+
     return render_to_response('index.html', context,
         RequestContext(request))
 

=== added file 'loco_directory/media/css/twidenash.css'
--- loco_directory/media/css/twidenash.css	1970-01-01 00:00:00 +0000
+++ loco_directory/media/css/twidenash.css	2010-08-15 20:43:41 +0000
@@ -0,0 +1,20 @@
+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;
+}
+
+ul.twidenash li .nick {
+    font-weight: bold;
+}
+

=== added file 'loco_directory/media/js/twidenash.js'
--- loco_directory/media/js/twidenash.js	1970-01-01 00:00:00 +0000
+++ loco_directory/media/js/twidenash.js	2010-08-15 20:43:41 +0000
@@ -0,0 +1,85 @@
+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://search.twitter.com/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.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++) {
+                if (data.results[i].text == twidenash.items[j].text) {
+                    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;
+                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 exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i;
+                span.innerHTML = twidenash.items[i].text.replace(exp,"<a href='$1' target='_blank'>$1</a>");
+                li.appendChild(img);
+                li.appendChild(nick);
+                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	2010-06-24 19:18:57 +0000
+++ loco_directory/templates/events/global_event_detail.html	2010-08-15 20:43:41 +0000
@@ -1,6 +1,11 @@
 {% extends "base.html" %}
 {% load i18n %}
 
+{% block extrahead %}
+{{block.super}}
+        <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidenash.css" />
+{% endblock %}
+
 {% block title %}{% trans global_event_object.name %}{% endblock %}
 
 {% block sub_nav_links %}

=== modified file 'loco_directory/templates/events/global_event_detail.inc.html'
--- loco_directory/templates/events/global_event_detail.inc.html	2010-06-18 18:31:05 +0000
+++ loco_directory/templates/events/global_event_detail.inc.html	2010-08-15 20:43:41 +0000
@@ -1,10 +1,18 @@
 {% load i18n %}
-<article class="main-content">
+<article class="minor-content">
 
 <h2>{{global_event_object.name}}</h2>
 {% include "events/global_event_detail_basic.inc.html" %}
 </article>
 
+{% 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>
+</article>
+{% endif %}
+
 <hr class="divide" />
 
 {% if global_event_object.teamevent_set.all %}

=== modified file 'loco_directory/templates/index.html'
--- loco_directory/templates/index.html	2010-07-16 16:16:30 +0000
+++ loco_directory/templates/index.html	2010-08-15 20:43:41 +0000
@@ -3,6 +3,11 @@
 
 {% block sub_nav %}{% endblock %}
 
+{% block extrahead %}
+{{block.super}}
+        <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidenash.css" />
+{% endblock %}
+
 {% block content %}
 
   <h1>{% trans "Ubuntu LoCo Team Directory" %}</h1>
@@ -13,22 +18,42 @@
           {% trans "If there are no teams in your country/region/area, you will be able to add a team in the near future." %}
         </p>
         </article>
-
 		<hr class="divide" />
 
-		<article class="main-content">
+		<article class="minor-content">
         <h2><a title="{% trans "Show all Events" %}" href="{% url event-list %}">{% trans "Events" %}</a></h2>
-        <p>{% trans "List of all Ubuntu LoCo Events, with full information such as location, attendees, teams, and more." %}</p>
+            <p>{% trans "List of all Ubuntu LoCo Events, with full information such as location, attendees, teams, and more." %}</p>
+            <h3>{% trans "Upcoming Global Events" %}
+            {% if global_event_list %}
+            <a class="global_event_ical" href="{% url global-event-list-ical %}">
+            <img src="/media/images/ical.png" title="{% trans "Global Events as ical" %}"/></a></h3>
+
+            <p>{% trans "Select a global event below to see more information about it:" %}</p>
+
+            {% include "events/global_event_list.inc.html" %}
+
+            {% else %}
+            </h3><p>{% trans "There are currently no LoCo Global Events" %}</p>
+            {% endif %}
+            
+            <br />
+            {% if team_event_list %}
+            <h3><a href="{% url event-list %}">{{ team_event_list.count }} {% trans "Upcoming Team Events" %}</a>
+            <a class="teams_event_ical" href="{% url teams-event-list-ical %}">
+            <img src="/media/images/ical.png" title="{% trans "Team Events as ical" %}"/></a></h3>
+            {% else %}
+            <p>{% trans "There are currently no LoCo Team Events" %}</p>
+            {% endif %}
+        </article>
+
+		<article class="minor-content alone">
+        <h2>{% trans "Microblogging" %} #locoteams</h2>
+        <p><script src="{{MEDIA_URL}}js/twidenash.js?locoteams"></script></p>
         </article>
 
 		<hr class="divide" />
 
 		<article class="minor-content">
-        <h2><a title="{% trans "Show all Venues" %}" href="{% url venue-list %}">{% trans "Venues" %}</a></h2>
-        <p>{% trans "List of all Ubuntu LoCo Venues." %}</p>
-        </article>
-
-		<article class="minor-content">
         <h2>{% trans "Coming Soon!" %}</h2>
         <p>
           {% trans "Future additions to this site will include:" %}

_______________________________________________
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