-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
64 lines (54 loc) · 1.48 KB
/
app.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
$:.unshift File.dirname(__FILE__)
require 'bundler/setup'
Bundler.require(:default) if defined?(Bundler)
require 'lib/simple_opml'
require 'lib/reader'
error do
halt 404
end
not_found do
slim :not_found
end
get '/' do
@q = ''
slim :index
end
get '/search' do
q = params[:q]
redirect '/' if q.to_s.empty?
redirect '/' + q
end
get '/*/watched/export' do |u|
@u = Temple::Utils::escape_html u
@repos = Octokit.watched(@u).reject{|r| r.owner == @u}
opml = SimpleOPML.new("GitHub #{@u}'s watched repositories")
@repos.each do |r|
opml.add("#{r.url}/commits/master", "#{r.url}/commits/master.atom", "#{r.name}:master Recent Commits")
end
content_type 'application/xml'
attachment "github_#{@u}_watched_repositories_#{Date.today.strftime('%Y%m%d')}.xml"
opml.to_s
end
get '/*/watched' do |u|
@u = Temple::Utils::escape_html u
@repos = Octokit.watched(@u).reject{|r| r.owner == @u}
@readers = ReaderManager.load
slim :watched
end
get '/*/export' do |u|
@u = Temple::Utils::escape_html u
@followings = Octokit.following(@u)
opml = SimpleOPML.new("GitHub #{@u}'s followings")
@followings.each do |f|
opml.add("https://github.com/#{f}", "https://github.com/#{f}.atom", "#{f}'s Activity")
end
content_type 'application/xml'
attachment "github_#{@u}_followings_#{Date.today.strftime('%Y%m%d')}.xml"
opml.to_s
end
get '/*' do |u|
@u = Temple::Utils::escape_html u
@followings = Octokit.following(@u)
@readers = ReaderManager.load
slim :user
end