File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ module .exports = {
2+ for : (expiration , work ) ->
3+ lastResult = null
4+ lastModified = null
5+ return (complete ) ->
6+ if lastModified? and (new Date ).getTime () - expiration < lastModified
7+ complete lastResult
8+ else
9+ work (data ) ->
10+ lastResult = data
11+ lastModified = (new Date ).getTime ()
12+ complete lastResult
13+ }
Original file line number Diff line number Diff line change 1+ date = require ' date-utils'
2+ moment = require ' moment'
3+
4+ Event = (data ) ->
5+ this .title = data .summary
6+ this .location = data .location
7+ this .details = data .description
8+ this .when = determineDate (data .start , data .end )
9+ this .url = createEventUrl data .uid
10+
11+ determineDate = (start , end ) ->
12+ start = moment (start)
13+ end = moment (end)
14+ date = moment (new Date (start .native ())).add (' hours' , - 6 ).format (' ddd, MMM D' )
15+
16+ return date if start .diff (end, ' days' ) == - 1
17+
18+ date + start .add (' hours' , - 6 ).format (' h:mma CST' )
19+
20+ createEventUrl = (id ) ->
21+ id = id .split (' @' )[0 ]
22+ id = new Buffer (id
+ ' [email protected] ' ).
toString (
' base64' ).
replace (
' ==' ,
' ' )
23+
24+ module .exports = Event
Original file line number Diff line number Diff line change 1+ moment = require ' moment'
2+
3+ Message = (data ) ->
4+ this .subject = data .title .$t
5+ this .body = formatContent data .summary .$t
6+ this .author = data .author .name
7+ this .timeago = moment (new Date (data .updated )).fromNow ()
8+ this .url = data .link .href
9+
10+ striphtml = (value ) ->
11+ value .replace (/ <(?:. | \n )*? >/ gm , ' ' )
12+
13+ formatContent = (content ) ->
14+ content = striphtml (content).trim ()
15+ content += ' \u 2026' if / [\w ] $ / i .test content
16+ content
17+
18+ module .exports = Message
Original file line number Diff line number Diff line change 1+ moment = require ' moment'
2+
3+ Tweet = (data ) ->
4+ this .created_by = data .from_user
5+ this .tweet = data .text
6+ this .timeago = moment (new Date (data .created_at )).fromNow ()
7+ this .created_at = data .created_at
8+
9+ module .exports = Tweet
You can’t perform that action at this time.
0 commit comments