public
Description: rash. ruby, sinatra, twitter & hashtags.
Homepage:
Clone URL: git://github.com/webs/rash.git
rash / rash.rb
100644 164 lines (136 sloc) 3.465 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Welcome in Rash.
# http://github.com/webs/rash - released under the MIT licence
%w(rubygems sinatra haml sass rfeedparser).each { |dependency| require dependency }
 
configure do
  Title = "rash - display a twitter hashtag"
  Name = "#rash"
  Tagline = "twitter hashtag !"
  Hashtag = "rash"
  TwitterSearchUrl = "http://search.twitter.com/search.atom?q=%23"
  Footer = "blah blah, blah."
  set_option :haml, :format => :html4
end
 
get '/' do
  header 'Content-Type' => 'text/html; charset=utf-8'
  tag = params[:tag] || Hashtag
  @introduction = "Welcome! To display your tweets here, just put the <a href='http://hashtags.org/'>hashtag</a> <strong>##{tag}</strong> in your tweets. Enjoy."
  pf = FeedParser.parse(TwitterSearchUrl + tag)
  @entries = pf.entries
  haml :home
end
 
get '/rash.css' do
  header 'Content-Type' => 'text/css; charset=utf-8'
  sass :stylesheet
end
 
use_in_file_templates!
 
__END__
@@ layout
!!! strict
%html
%head
%title= Title
%link{:rel => 'stylesheet', :href => '/rash.css', :type => 'text/css'}
%body
#container
#head
%span.title= Name
%span.subtitle= Tagline
.intro
%p
= @introduction
%br
Or check out some of these:
%a{:href => '/?tag=sinatra', :title => '#sinatra'} #sinatra
%a{:href => '/?tag=ruby', :title => '#ruby'} #ruby
%a{:href => '/?tag=github', :title => '#github'} #github
= yield
.footer
= Footer
%br/
%img{:src=>'http://search.twitter.com/images/powered-by-twitter-sig.gif?1216137693', :title => 'Powered by Twitter!'}
and by
%a{:href=>'http://github.com/webs/rash'}= "rash"
 
@@ home
- for entry in @entries
.twit
- url_pattern = /(http[s]?:\/\/[-\w\.]+[\d+]?[\/\w\/_\.\~]*[\?\S+]?)/
- entry['title'].gsub!(url_pattern, '<a class="url" href="\1">\1</a>')
- entry['title'].gsub!(/\#(\w+)/, '<a class="hashtag" href="/?tag=\1">#\1</a>')
%p= entry['title']
%span
^- from
%a{:href=>entry['href']}= entry['author']
on
- nicetime = Time.parse(entry['published_time'].to_s).strftime('%d/%m/%Y at %H:%M:%S')
%a{:href=>entry['link']}= nicetime
 
 
@@ stylesheet
html
:background #000000 url(http://oseflol.com/images/bg_twitter_black.gif) fixed no-repeat top left
:color #000
:font-family Helvetica Neue, Helvetica, Arial, sans-serif
:padding 0em
 
 
body
:margin-left 2.6em
:margin-top 1.8em
:margin-bottom 1em
:margin-right 1em
:line-height 1.4em
:font-size .9em
 
 
#container
:width 755px
:margin 0 auto
:padding 15px 0
:text-align left
:position relative
 
 
#head
:top 0px
:position fixed
:padding 10px
:padding-top 25px
:background-color #202020
:opacity 0.98
:width 755px
 
.title
:font-size 70px
:font-weight bold
:color white
:margin 0
:padding 0
 
 
.subtitle
:color white
:font-size 18px
 
 
.intro
:margin-top 40px
:color white
 
a
:color white
 
.footer
:margin-top 10px
:font-size 10px
:color grey
 
a
:color white
 
.twit
:margin-top 20px
:margin-bottom 20px
:padding 10px
 
p
:font-size 30px
:color white
:font-weight bold
:line-height 1.1em
:margin 0
:margin-bottom 5px
 
span
:font-size 18px
:color white
a
:color white
 
.hashtag
:border-bottom 1px dashed #fff
:color #777
:text-decoration none
 
.url
:border-bottom 1px dashed #fff
:color #aaa
:text-decoration none