Skip to content

Commit 85e5719

Browse files
committed
added tweets
1 parent 8e9a6fc commit 85e5719

File tree

5 files changed

+58
-16
lines changed

5 files changed

+58
-16
lines changed

app.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ app.configure 'production', () ->
2020
app.set 'views', path.join(__dirname, '/views')
2121
app.set 'view engine', 'jade'
2222

23-
app.get '/', data.loadMessages, (req, res) ->
23+
app.get '/', data.load('tweets', 'messages'), (req, res) ->
2424
res.render 'plug', res.data
2525

2626
app.listen port

data.coffee

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,26 @@ rest = require 'restler'
44
fetchMessages = (cb) ->
55
rest.get('http://groups.google.com/group/kc-nodejs/feed/atom_v1_0_topics.xml').on('complete', (data) -> cb(parser(data).items))
66

7+
fetchTweets = (cb) ->
8+
rest.get('http://search.twitter.com/search.json?q=%40nodekc').on('complete', (data) -> cb(data))
9+
710
module.exports = {
8-
loadMessages: (req, res, next) ->
11+
load: (keys...) ->
12+
that = this
13+
return (req, res, next) ->
14+
finished = []
15+
res.data or= {}
16+
keys.forEach (key) ->
17+
that[key] res.data, (k) ->
18+
finished.push k
19+
next() if finished.length == keys.length
20+
21+
messages: (data, cb) ->
922
fetchMessages (items) ->
10-
res.data = {
11-
messages: items
12-
}
13-
14-
next()
23+
data.messages = items
24+
cb 'messages'
25+
tweets: (data, cb) ->
26+
fetchTweets (result) ->
27+
data.tweets = result
28+
cb 'tweets'
1529
}

public/css/app.css

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ a {
4040
margin-top: 15px;
4141
margin-left: 10px;
4242
height: 160px;
43+
overflow: auto;
4344
}
4445
#panels li.panel ul {
4546
padding: 0;
@@ -49,12 +50,22 @@ a {
4950
#panels li.panel h2 {
5051
font-size: 0.6em;
5152
}
52-
#panels li.panel a {
53+
#panels li.panel a.message {
5354
font-size: 0.5em;
5455
}
55-
#panels li.panel p {
56+
#panels li.panel p.teaser {
5657
font-size: 0.5em;
5758
margin: 0;
5859
text-indent: 0.4em;
5960
padding: 0;
6061
}
62+
#panels li.panel.tweets p.tweet {
63+
font-size: 1em;
64+
}
65+
#panels li.panel.tweets span {
66+
font-size: 0.5em;
67+
color: #ccc;
68+
margin-bottom: 5px;
69+
margin-left: 3px;
70+
text-decoration: underline;
71+
}

public/css/app.styl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,28 @@ a
3737
margin-top 15px
3838
margin-left 10px
3939
height 160px
40+
overflow auto
4041
ul
4142
padding 0
4243
margin-left 10px
4344
list-style-type none
4445
h2
4546
font-size .6em
46-
a
47+
a.message
4748
font-size .5em
48-
p
49+
p.teaser
4950
font-size .5em
5051
margin 0
5152
text-indent .4em
5253
padding 0
53-
54+
li.panel.tweets
55+
p.tweet
56+
font-size 1em
57+
span
58+
font-size .5em
59+
color #ccc
60+
margin-bottom 5px
61+
margin-left 3px
62+
text-decoration underline
63+
64+

views/layout.jade

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ html(lang="en")
2727
ul
2828
each item in messages
2929
li
30-
a(href=item.guid)#{item.title}
30+
a.message(href=item.guid)#{item.title}
3131
p.teaser #{item.desc}
32-
li.panel
33-
h2 Twitter Mentions
34-
p None yet
32+
li.panel.tweets
33+
h2 Tweets
34+
a(href='http://twitter.com/nodekc') @nodekc
35+
36+
ul
37+
each item in tweets.results
38+
li
39+
p.tweet #{item.text}
40+
span #{item.created_at}
3541
li.panel
3642
h2 Members
3743
p Unknown

0 commit comments

Comments
 (0)