Commits

Julian Rosse committed 3b9ad0d

facebookish.picture() etc

Comments (0)

Files changed (5)

sleepy/facebookish.py

         self.uri = d[ "source" ]
         self.thumbnail = d[ "picture" ]
         self.images = d[ "images" ]
+        self.height = d[ "height" ]
+        self.width = d[ "width" ]
+        self.portrait = ( self.height
+                           > self.width )
         self._data = d
 
+def picture( id ):
+    return Picture( cacher( cache_name="facebook_pictures",
+                            key=id,
+                            createfunc=lambda:
+                                        _service()
+                                         .get_object( id )))
+
 class Album( TipeMixin,
              PubUpMixin ):
     sort_key = "updated"
             return "video"
         return self.tipe
 
+    @lazy_property
     def _picture( self ):
         if self.tipe == "photo":
             return picture( self.object_id )
 
-
-
     def _video( self ):
         if self.classification != "youtube":
             return None

sleepy/resource.py

                      .show_entry( self,
                                   **kwargs ))
 
+    def ago_link( self,
+                  **kwargs ):
+        return ( self.tipe
+                     .ago_link( self,
+                                **kwargs ))
+
     def format( self,
                 **kwargs ):
         return ( self.tipe

sleepy/templates/sleepy/facebookish/base.mako

         file="../util.mako" />
 
 <%def
+        name="ago_link( entry,
+                        **kwargs )">
+    ${ util.ago( entry,
+                 name="facebook",
+                 link="http://www.facebook.com/"
+                       + config[ "facebook_user" ]
+                       + "/posts/"
+                       + entry.id
+                              .split( "_" )
+                              [ -1 ] ) }
+</%def>
+<%def
         name="show_entry( col,
                           entry,
                           ago=True,
                           **kwargs )">
     % if ago:
-        ${ util.ago( entry,
-                     name="facebook",
-                     link="http://www.facebook.com/"
-                           + config[ "facebook_user" ]
-                           + "/posts/"
-                           + entry.id
-                                  .split( "_" )
-                                  [ -1 ] ) }
+        ${ ago_link( entry ) }
     % endif
     % if entry.message:
         <p

sleepy/templates/sleepy/twitterish.mako

         file="util.mako" />
 
 <%def
+        name="ago_link( entry,
+                        **kwargs )">
+    ${ util.ago( entry,
+                 name="twitter",
+                 link="http://www.twitter.com/"
+                       + config[ "twitter_user" ]
+                       + "/status/"
+                       + str( entry.id )) }
+</%def>
+<%def
         name="show_entry( col,
                           entry,
                           ago=True,
                           **kwargs )">
     % if ago:
-        ${ util.ago( entry,
-                     name="twitter",
-                     link="http://www.twitter.com/"
-                           + config[ "twitter_user" ]
-                           + "/status/"
-                           + str( entry.id )) }
+        ${ ago_link( entry ) }
     % endif
     % if entry.message:
         <p
                                 kwargs=dict( entry=self,
                                              **kwargs ))
 
+    def ago_link( self,
+                  **kwargs ):
+        return self.render_def( "ago_link",
+                                kwargs=dict( entry=self,
+                                             **kwargs ))
+
 class Tipe( TipeMixin ):
     @lazy_property
     def query_template_uri( self ):