+2008-10-18 Christopher Blizzard <blizzard@0xdeadbeef.com>
+
+ * whoisi/templates/vimeo-widget.mak: Widget to render vimeo
+ content in person and follow pages.
+
+ * whoisi/templates/follow.mak: Add vimeo to the types we know how
+ to render
+
+ * whoisi/templates/unseen.mak: Add vimeo to the types we know how
+ to render.
+
+ * whoisi/templates/person-widget.mak: Add vimeo to the types we
+ know how to render.
+
+ * whoisi/utils/sites.py (site_value): Put vimeo before youtube in
+ the order in which we render sites.
+
+ * whoisi/controllers.py (Root.getDisplayDepth): Add vimeo display
+ depth so we render the right number of items in various contexts.
+ (Root.rendersite): If the site type if vimeo, use the vimeo
+ template for rendering.
+
+ * whoisi/static/images/sites/vimeo-favicon.png: Icon for vimeo
+ items.
+
+ * tests/nose/test_newsite.py (TestNewSite.test_vimeo): Code to
+ test the vimeo url detection code.
+
+ * services/command/vimeo.py (Vimeo): Class for vimeo url detection
+ and selecting a preferred feed.
+
+ * services/command/newsite.py (NewSiteTryURL.getPreferredFeed): If
+ the url is a vimeo url, pick the perferred feed from the list of
+ feeds left over from scraping the HTML.
+ (NewSiteTryURL.getFeedType): If the url is a vimeo url set the
+ site type to "vimeo."
+
2008-10-18 Christopher Blizzard <blizzard@0xdeadbeef.com>
* whoisi/templates/youtube-widget.mak: Show 3 videos on one line.
from services.command.identica import Identica
from services.command.delicious import Delicious
from services.command.youtube import Youtube
+from services.command.vimeo import Vimeo
from services.command.exceptions import PageNotFoundError, FeedNotFoundError, InvalidFeedError, \
NeedsFeedPickError
from services.command.utils import resolve_relative_url
if d.isDelicious(url):
return d.getPreferredFeed(feeds)
+ # see if it's a vimeo feed
+ v = Vimeo()
+ if v.isVimeo(url):
+ return v.getPreferredFeed(feeds)
+
return None
####
if t.isYoutube(url):
return "youtube"
+ # Check to see if it's a vimeo url
+ t = Vimeo()
+ if t.isVimeo(url):
+ return "vimeo"
+
return "feed"
--- /dev/null
+# Copyright (c) 2008 Christopher Blizzard <blizzard@0xdeadbeef.com>
+#
+# 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
+
+import urlparse
+import re
+
+class Vimeo:
+ def isVimeo(self, url):
+ u = urlparse.urlparse(url)
+ urlparse.clear_cache()
+ host = u[1]
+ path = u[2]
+
+ # forms
+ # http://vimeo.com/abc123/videos/uploaded
+ # http://vimeo.com/abc123
+ try:
+ if host != 'vimeo.com' and host != 'www.vimeo.com':
+ return False
+
+ match = re.match('^/[a-zA-Z0-9]+$', path)
+ if match:
+ print(" This is a vimeo account.")
+ return True
+
+ match = re.match('^/[a-zA-Z0-9]+/videos.*$', path)
+ if match:
+ print(" This is a vimeo account.")
+ return True
+
+ except:
+ pass
+
+ return False
+
+ def getPreferredFeed(self, feeds):
+ for i in range(0, len(feeds)):
+ if re.match('.*videos/rss$', feeds[i][0]):
+ return feeds[i]
+
+ return None
from services.command.identica import Identica
from services.command.delicious import Delicious
from services.command.youtube import Youtube
+from services.command.vimeo import Vimeo
class TestNewSite(unittest.TestCase):
def setUp(self):
x = Youtube()
print("trying not %s" % i)
assert(x.isYoutube(i) == False)
+
+ def test_vimeo(self):
+ """
+ Test that we can detect vimeo urls.
+ """
+ good_urls = ['http://vimeo.com/oldtropes/videos/uploaded',
+ 'http://vimeo.com/user672164/videos/uploaded',
+ 'http://www.vimeo.com/user672164',
+ 'http://vimeo.com/user672164',
+ 'http://vimeo.com/factoryjoe/videos/uploaded']
+
+ bad_urls = ['http://vimeo.com/claysmith/likes',
+ 'http://vimeo.com/claysmith/albums',
+ 'http://something.else/']
+
+ for i in good_urls:
+ x = Vimeo()
+ print("trying %s" % i)
+ assert(x.isVimeo(i))
+
+ for i in bad_urls:
+ x = Vimeo()
+ print("trying not %s" % i)
+ assert(not x.isVimeo(i))
return dict(content=unicode(self.rendersite(s, sh, "full"), "utf-8"))
def getDisplayDepth(self, site_type, render_type):
- depth_matrix = dict(full=dict(flickr=10, picasa=12, twitter=3, identica=3, delicious=3, feed=3, youtube=3),
- edit=dict(flickr=5, picasa=6, twitter=1, identica=1, delicious=1, feed=1, youtube=3),
- search=dict(flickr=5, picasa=6, twitter=1, identica=1, delicious=1, feed=1, youtube=3),
- preview=dict(flickr=5, picasa=6, twitter=3, identica=3, delicious=3, feed=3, youtube=3))
+ depth_matrix = dict(full=dict(flickr=10, picasa=12, twitter=3, identica=3, delicious=3, feed=3, youtube=3, vimeo=3),
+ edit=dict(flickr=5, picasa=6, twitter=1, identica=1, delicious=1, feed=1, youtube=3, vimeo=3),
+ search=dict(flickr=5, picasa=6, twitter=1, identica=1, delicious=1, feed=1, youtube=3, vimeo=3),
+ preview=dict(flickr=5, picasa=6, twitter=3, identica=3, delicious=3, feed=3, youtube=3, vimeo=3))
return depth_matrix[render_type][site_type]
def rendersite(self, site, site_history, display):
template = "whoisi.templates.delicious-widget"
elif site.type == "youtube":
template = "whoisi.templates.youtube-widget"
+ elif site.type == "vimeo":
+ template = "whoisi.templates.vimeo-widget"
else:
return "<div>Oh, crap. Wtf?</div>\n"
<%namespace file="picasa-widget.mak" import="picasa_widget"/>
<%namespace file="delicious-widget.mak" import="delicious_widget"/>
<%namespace file="youtube-widget.mak" import="youtube_widget"/>
+<%namespace file="vimeo-widget.mak" import="vimeo_widget"/>
<%inherit file="master.mak"/>
${delicious_widget(site=site, site_history=cluster, display="time")}
%elif site.type == "youtube":
${youtube_widget(site=site, site_history=cluster, display="time")}
+%elif site.type == "vimeo":
+${vimeo_widget(site=site, site_history=cluster, display="time")}
%endif
%endfor
<%namespace file="linkedin-widget.mak" import="linkedin_widget"/>
<%namespace file="delicious-widget.mak" import="delicious_widget"/>
<%namespace file="youtube-widget.mak" import="youtube_widget"/>
+<%namespace file="vimeo-widget.mak" import="vimeo_widget"/>
<%namespace file="aliases-widget.mak" import="aliases_widget"/>
<%namespace file="site-add-status-widget.mak" import="site_add_status_widget"/>
<%namespace file="site-add-pick-widget.mak" import="site_add_pick_widget"/>
${picasa_widget(site=site, site_history=site_history[site.id], display=display)}
%elif site.type == "youtube":
${youtube_widget(site=site, site_history=site_history[site.id], display=display)}
+ %elif site.type == "vimeo":
+ ${vimeo_widget(site=site, site_history=site_history[site.id], display=display)}
%endif
%endfor
<%namespace file="picasa-widget.mak" import="picasa_widget"/>
<%namespace file="delicious-widget.mak" import="delicious_widget"/>
<%namespace file="youtube-widget.mak" import="youtube_widget"/>
+<%namespace file="vimeo-widget.mak" import="vimeo_widget"/>
<%inherit file="master.mak"/>
${delicious_widget(site=site, site_history=cluster, display="time")}
%elif site.type == "youtube":
${youtube_widget(site=site, site_history=cluster, display="time")}
+%elif site.type == "vimeo":
+${vimeo_widget(site=site, site_history=cluster, display="time")}
%endif
%endfor
--- /dev/null
+# -*- coding: utf-8 -*-
+
+## Copyright (c) 2008 Christopher Blizzard <blizzard@0xdeadbeef.com>
+##
+## 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.
+
+<%!
+from whoisi.utils.follow import is_following_person
+from whoisi.utils.display import short_link_ref
+from whoisi.utils.youtube import youtube_get_user
+import simplejson
+%>
+
+<%def name="vimeo_widget(site, site_history, display)">
+<%
+
+entries_list = site_history
+count = len(site_history)
+needs_refresh = False
+%>
+
+<div class="link-collection-item" site-id="${site.id}" needs-refresh="${needs_refresh}">
+<img src="/static/images/sites/vimeo-favicon.png"/>
+%if display == "time" or display == "follow":
+<a href="/p/${site.personID}">${site.person.name | h}</a>:
+%endif
+<a href="${site.url}">${site.title | h}</a>
+
+<span class="link-action">
+%if display == "edit":
+ <a site-id="${site.id}" class="site-remove" href="">Remove</a>
+%endif
+%if display == "time":
+ %if is_following_person(site.personID):
+ <a class="person-unfollow" person-id="${site.personID}" href="#">Stop Following</a>
+ %else:
+ <a class="person-follow" person-id="${site.personID}" href="#">Follow Person</a>
+ %endif
+%endif
+</span>
+
+<div class="link-collection">
+%for i in range(0, count):
+<%
+thumb = None
+title = None
+
+try:
+ title = entries_list[i].title
+except:
+ title = "Untitled"
+
+try:
+ thumb = simplejson.loads(entries_list[i].display_cache)["thumb"]
+except:
+ thumb = "/static/images/sites/flickr-blank-75x75.png"
+
+%>
+%if display != "preview":
+ <a target="_blank" href="${short_link_ref(entries_list[i].id)}">
+ <img width="80" height="60" src="${thumb}" title="${title| h}"/>
+ </a>
+%else:
+ <a target="_blank" href="${entries_list[i].link}">
+ <img width="80" height="60" src="${thumb}" title="${title | h}"/>
+ </a>
+%endif
+%if int(i+1) % 5 == 0:
+<br/>
+%endif
+%endfor
+</div>
+
+</div>
+</%def>
+
+${vimeo_widget(site=site, site_history=site_history, display=display)}
from whoisi.model import *
def site_value(site):
- types = [ "flickr", "picasa", "youtube", "linkedin", "twitter", "identica", "delicious", "feed" ]
+ types = [ "flickr", "picasa", "vimeo", "youtube", "linkedin", "twitter", "identica", "delicious", "feed" ]
return types.index(site.type)
def reorder_sort(x,y):