Skip to content
Browse files

Merge pull request #13 from tupton/permalinks

Permalinks
  • Loading branch information...
2 parents 390ee64 + 0d73fc9 commit 9f0569e04518b3fad79a2d5d373b50613693e155 @mbulman committed Feb 8, 2012
Showing with 21 additions and 6 deletions.
  1. +3 −1 facebook.coffee
  2. +3 −3 store.coffee
  3. +5 −1 twitter.coffee
  4. +10 −1 ui.coffee
View
4 facebook.coffee
@@ -48,11 +48,13 @@ class Collector
created: new Date(item.created_time).getTime(),
name: item.from.name,
message: item.message,
+ # TODO better way to get permalink?
+ source: item.actions[0].link,
})
# TODO
#else
#console.log("Unknown fb item:", item)
- retval
+ return retval
exports.Collector = Collector
View
6 store.coffee
@@ -10,9 +10,9 @@ class Store
this._setupDb()
addItems: (items) ->
- s = @db.prepare('INSERT INTO items (type,created,name,message) VALUES(?,?,?,?)')
+ s = @db.prepare('INSERT INTO items (type,created,name,message,source) VALUES(?,?,?,?,?)')
for item in items
- s.run(item.type, item.created, item.name, item.message)
+ s.run(item.type, item.created, item.name, item.message, item.source)
s.finalize()
getItems: (cb) ->
@@ -28,7 +28,7 @@ class Store
_setupDb: ->
@db.serialize =>
- @db.run("CREATE TABLE items (type, created, name, message)")
+ @db.run("CREATE TABLE items (type, created, name, message, source)")
@db.run("CREATE INDEX type_idx ON items (type)")
@db.run("CREATE INDEX created_idx ON items (created)")
@db.run("CREATE INDEX name_idx ON items (name)")
View
6 twitter.coffee
@@ -38,12 +38,16 @@ class Collector
type: null,
created: new Date(item.created_at).getTime(),
name: item.user.name,
- message: item.text
+ message: item.text,
+ source: this._createTwitterStatusLink(item.user.screen_name, item.id_str)
})
@store.addItems(items)
return
+ _createTwitterStatusLink: (name, id) ->
+ return 'http://twitter.com/#!/' + name + '/status/' + id
+
exports.Collector = Collector
View
11 ui.coffee
@@ -41,9 +41,18 @@ _drawItems = (parent, items) ->
_drawItem = (item) ->
d = document.createElement('div')
d.className = 'p'
+
+ date = new Date(item.created)
+ date_str = date.toDateString() + ' ' + date.toLocaleTimeString()
+
+ permalink = date_str
+ if item.source != null
+ permalink = """
+ <a href="#{item.source}">#{date_str}</a>
+ """
d.innerHTML = """
<span class="u">#{item.name}</span>
- <span class="d">#{new Date(item.created).toLocaleString()}</span>
+ <span class="d">#{permalink}</span>
<div class="m">#{item.message}</div>
"""
return d

0 comments on commit 9f0569e

Please sign in to comment.
Something went wrong with that request. Please try again.