This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
blarghhhh.rb
282 lines (251 loc) · 6.09 KB
/
blarghhhh.rb
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
require "haml"
require "sass"
require "httparty"
require "sinatra"
require "rdiscount"
require "dalli"
set :base_uri, 'http://github.com/api/v2/json'
set :userid, 'zzak'
set :repoid, 'blog.zacharyscott.net'
#set :userid, ENV['GITHUB_USER']
#set :repoid, ENV['GITHUB_REPO']
set :public, File.dirname(__FILE__) + '/public'
set :cache, Dalli::Client.new(
ENV['MEMCACHE_SERVERS'],
:username => ENV['MEMCACHE_USERNAME'],
:password => ENV['MEMCACHE_PASSWORD'],
:expires_in => 300)
set :views, File.dirname(__FILE__)
get '/' do
@info = settings.cache.fetch("info") do
HTTParty.get("#{settings.base_uri}/repos/show/#{settings.userid}/#{settings.repoid}")
end
@user = settings.cache.fetch("user") do
HTTParty.get("#{settings.base_uri}/user/show/#{settings.userid}")
end
@blobs = settings.cache.fetch("blobs") do
HTTParty.get("#{settings.base_uri}/blob/all/#{settings.userid}/#{settings.repoid}/master")
end
haml :index
end
get '/show/:post/:sha' do
@info = settings.cache.fetch("info") do
HTTParty.get("#{settings.base_uri}/repos/show/#{settings.userid}/#{settings.repoid}")
end
@user = settings.cache.fetch("user") do
HTTParty.get("#{settings.base_uri}/user/show/#{settings.userid}")
end
markdown = settings.cache.fetch("#{params[:sha]}") do
HTTParty.get("#{settings.base_uri}/blob/show/#{settings.userid}/#{settings.repoid}/#{params[:sha]}").to_s
end
@post = RDiscount.new(markdown).to_html
@history = settings.cache.fetch("#{params[:sha]}-history") do
HTTParty.get("#{settings.base_uri}/commits/list/#{settings.userid}/#{settings.repoid}/master/#{params[:post]}").to_hash
end
haml :show
end
get '/stylesheet.css' do
content_type 'text/css', :charset => 'utf-8'
sass :stylesheet
end
__END__
@@layout
!!!html
%html{:lang=>"en"}
%head
%meta{:charset=>"utf-8"}
%title
= "#{@info["repository"]["name"]} | #{@info["repository"]["description"]}"
%link{:rel=>"stylesheet", :href=>"/stylesheet.css", :type=>"text/css"}
%body
#header
= haml(:header, :layout=>false)
#content
#main
= yield
#sidebar
= haml(:sidebar, :layout=>false)
= haml(:footer, :layout=>false)
@@index
- @blobs["blobs"].each_pair do |key, value|
%h1{:class=>"post_title"}
%a{:href=>"/show/#{key}/#{value}"}= key
@@header
%ul#blog_stats
%li
%a{:href=>"https://github.com/#{settings.userid}/#{settings.repoid}/commits/master.atom"}
%img{:src=>"/images/rss2.png"}
%li
%a{:href=>"https://github.com/#{settings.userid}/#{settings.repoid}/watchers"}
= @info["repository"]["watchers"]
%img{:src=>"/images/watchers.png"}
%li
%a{:href=>"https://github.com/#{settings.userid}/#{settings.repoid}/network"}
= @info["repository"]["forks"]
%img{:src=>"/images/forks.png"}
%h1
%a{:href=>"#{@info["repository"]["homepage"]}"}
= @info["repository"]["name"]
%p= @info["repository"]["description"]
@@footer
#footer
Official blog repo at
%a{:href=>"#{@info["repository"]["url"]}"}
github
Powered by
%a{:href=>"http://github.com/zzak/blarghhhh"}
blarghhhh
@@sidebar
%img#avatar{:src=>"http://www.gravatar.com/avatar/#{@user["user"]["gravatar_id"]}"}
%h1#username
= @user["user"]["name"]
%a{:href=>"http://github.com/#{settings.userid}/followers"}
%sup
= @user["user"]["followers_count"]
%img{:src=>"/images/watchers.png"}
%ul#user_stats
%li
%a{:href=>@user["user"]["blog"]}
%img{:src=>"/images/home.png"}
%li
%a{:href=>"http://github.com/#{@user["user"]["login"]}"}
%img{:src=>"/images/code.png"}
%li
%a{:href=>"mailto:#{@user["user"]["email"]}"}
%img{:src=>"/images/mail.png"}
%h2#location= @user["user"]["location"]
@@show
#post_info
%h2 Author
%p#author_name
By
%a{:href=>"http://github.com/#{@history["commits"][0]["author"]["login"]}"}
= @history["commits"][0]["author"]["name"]
%h2 Last Update
%p#authored_date
= @history["commits"][0]["authored_date"].strftime("%A %B %d %Y at %I:%M%p")
%h2#history_button History
#history
- @history["commits"].each do |commit|
.commit
%p.commit_message= commit["message"]
%p.commit_date= commit["authored_date"].strftime("%A %B %d %Y at %I:%M%p")
#post
= @post
@@stylesheet
*
margin: 0
padding: 0
border: 0
outline: 0
body
color: #EEEEEE
background-color: #2F2F2F
font-family: "Lucida Grande", "Lucida Sans Unicode", "Garuda"
a:link, a:visited
color: #5F5F5F
a:hover, a:active
color: #8F8F8F
h1 a, h2 a
text-decoration: none
#header
clear: both
padding: 20px
min-height: 40px
h1
text-align: right
p
float: right
ul
list-style-type: none
#blog_stats
float: right
font-size: .8em
text-align: right
margin: 10px 0 0 15px
a
text-decoration: none
#content
clear: both
width: 98%
margin: 10px auto
#main
width: 80%
float: left
h1
line-height: 1.3em
#sidebar
margin-top: 100px
width: 19%
float: right
h1
font-size: 1.1em
text-align: right
sup
font-size: .8em
h2
font-size: 1em
color: #4F4F4F
text-align: right
ul
list-style-type: none
margin-left: 20px
#user_stats
text-align: right
li
float: right
margin-right: 10px
#avatar
float: left
#location
clear: both
.page_header
margin: 20px
.post_title
line-height: 30px
margin-bottom: 25px
#post_info
float: right
width: 25%
background: #3F3F3F
padding: 20px
color: #EEEEEE
a:link, a:visited
color: #EEE
a:hover, a:active
color: FFF
h2
text-align: right
color: #2F2F2F
#authored_date
font-size: 14px
#post
float: left
width: 68%
ul
list-style-position: inside
margin-left: 20px
p
line-height: 1.3em
margin: 10px 0px
pre
background: #3F3F3F
overflow: auto
overflow-Y: hidden
#history_button
cursor: pointer
#history
line-height: 17px
.commit
margin-bottom: 10px
.commit_date
font-size: 12px
color: #5F5F5F
#footer
clear: both
text-align: center
font-size: .8em
a:link, a:visited
color: #9F9F9F
a:hover, a:active
color: #EEE