Anonymous avatar Anonymous committed b1f2800

more updates

Comments (0)

Files changed (11)

_local/feeder/fetch_delicious.py

 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #
-
+from datetime import datetime 
 from xml.etree import ElementTree as ET
 
 from simplecouchdb import Server
 
 
 def main():
-    posts = delicious.get_all()
-    print posts[0]
+    d = DateTimeProperty()
+    #posts = delicious.get_all()
+    tree = ET.parse('delicious.xml')
+    root = tree.getroot()
+    posts = []
+    for post in root:
+        entry = {}
+        for k, v in post.attrib.items():
+            if k == 'tag':
+                v = v.split(' ')
+            entry[k] = v
+        posts.append(entry)
+
+    for item in posts:
+        created_at = d._to_python(item['time'])
+        print created_at
+        link = FeedItem(
+                resource = 'delicious',
+                created_at = created_at,
+                fetched = datetime.utcnow(),
+                item = item)
+        print link._doc
+        link.save()
 
 if __name__ == '__main__':
     main()

_local/feeder/fetch_twitter.py

 
 def main():
     for i in xrange(1, 17):
-        page = twitter.user_timeline(page=str(i))
+        page = twitter.user_timeline(page=i)
         for item in page:
             created_at = datetime.datetime.utcfromtimestamp(
                     calendar.timegm(rfc822.parsedate_tz(item['created_at'])))
                     created_at = created_at,
                     fetched = datetime.datetime.utcnow(),
                     item = item)
-            tweet.save()
+            tweet.save() 
         time.sleep(1)
-                    
-   
+       
 
 if __name__ == '__main__':
     main()

_local/feeder/resources/delicious.py

 except ImportError:
     import json
 
+from simplecouchdb.schema import *
 
 __version__ = '0.1'
 USER_AGENT = 'benoitc.org/%s' % __version__
 
+d = DateTimeProperty()
 
 class DeliciousResource(Resource):
 
 
     def get_all(self):
         rst = self.get('/v1/posts/all', meta='yes')
-        tree = ET.XML(str(rst))
+        tree = ET.XML(rst.encode('utf-8', 'replace'))
+
         posts = []
         for post in tree:
-            tag = post.get('tag', '')
-            post['tag'] = tag.split(' ')
-            post['time'] = DateTimeProperty.to_python(post['time'])
+            tag = post.attrib.get('tag', '')
+            if tag:
+                post.attrib['tag'] = tag.split(' ')
+            if 'time' in post.attrib:
+                post.attrib['time'] = d._to_python(post.attrib['time'])
             posts.append(post.attrib)
 
         return posts
Add a comment to this file

_local/feeder/resources/delicious.pyc

Binary file modified.

_local/feeder/resources/twitter.py

         return self.get('/statuses/replies.json')
 
     def user_timeline(self, headers=None, **kwargs):
-        return self.get('/statuses/user_timeline.json') 
+        return self.get('/statuses/user_timeline.json', headers=headers,
+                **kwargs) 
Add a comment to this file

_local/feeder/resources/twitter.pyc

Binary file modified.

lib/helpers/template2.js

 //
 
 function template(str, data) {
-    return new EJS({text: str}).render(data);
+    html = new EJS({text: str}).render(data);
+    return html;
 }
 
 

lib/templates/feeds/head.html

     <link rel="home index" href="http://benoitc.org/" type="text/html">
     <link rel="me author" href="http://benoitc.org/apropos.html" type="text/html">
 
-    <link rel="stylesheet" href="<%= assets %>/css/screen.css?20090126" type="text/css" media="screen, projection" />
+    <link rel="stylesheet" href="<%= assets %>/css/screen.css" type="text/css" media="screen, projection" />
 
     <script src="/_utils/script/json2.js"></script>
     <script src="/_utils/script/jquery.js"></script>
 
 
 </head>
-test
+
+
 <body>
+    <header>
+        <h1>
+            <a rel="me author" href="<%= assets %>/about.html">Benoît Chesneau</a>
+        </h1>
+    </header>
+    <section id="items">
+

lib/templates/feeds/row.html

+<% if (day_change) { %>
+<h2 class="date"><%= last_day %></h2>
+<% } %>
+<article>
+    <header>
+    <h2><a href="<%= item.url %>"><%= resource_title %></a></h2>
+    </header>
+    
+    <p><%= item.text %></p>
+    
+</article>

lib/templates/feeds/tail.html

-<footer>
-    <p> Benoît Chesneau</p>    
-</footer>
+
+    </section>
+    <footer>
+        <p> Benoît Chesneau</p>    
+    </footer>
 </body>
 </html>

views/twitter/map.js

 function(doc) {
     if (doc.doc_type == "FeedItem" && (doc.resource && doc.resource == "twitter")) {
         
-        url = "http://twitter.com/benoitc/status" + doc.item.id;
+        url = "http://twitter.com/benoitc/status/" + doc.item.id;
         emit(doc.created_at, {
-                text: doc.text,
-                created_at: doc.created_at,
-                url: url });
+                text: doc.item.text,
+                created_at: doc.item.created_at,
+                url: url,
+                source: "twitter"
+        });
     }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.