Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a39d643

Browse filesBrowse files
committed
Fixes #1
1 parent 54a07e6 commit a39d643
Copy full SHA for a39d643

File tree

1 file changed

+18
-3
lines changed
Filter options

1 file changed

+18
-3
lines changed

‎app.rb

Copy file name to clipboardExpand all lines: app.rb
+18-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
require 'sinatra'
22
require 'githubchart'
33

4+
COLOR_SCHEMES = {
5+
default: ['#eeeeee', '#d6e685', '#8cc665', '#44a340', '#1e6823'],
6+
halloween: ['#EEEEEE', '#FFEE4A', '#FFC501', '#FE9600', '#03001C'],
7+
teal: ['#EEEEEE', "#7FFFD4", "#76EEC6", "#66CDAA", "#458B74"]
8+
}
9+
410
get '/' do
511
send_file File.join(settings.public_folder, 'index.html')
612
end
713

8-
914
get '/:username' do
15+
#default color scheme used by github
1016
headers 'Content-Type' => "image/svg+xml"
11-
1217
username = params[:username].chomp('.svg') #Chomp off the .svg extension to be backwards compatible
13-
1418
svg = GithubChart.new(user: username).svg
19+
stream do |out|
20+
out << svg
21+
end
22+
end
1523

24+
get '/:scheme/:username' do
25+
#example: ghchart.rshah.io/teal/2016rshah
26+
#if scheme is not recognized, it will bounce back to the default color scheme
27+
headers 'Content-Type' => "image/svg+xml"
28+
username = params[:username].chomp('.svg')
29+
scheme = COLOR_SCHEMES[params[:scheme].to_sym] #must correspond to the color schemes specified above
30+
svg = GithubChart.new(user: username, colors: scheme).svg
1631
stream do |out|
1732
out << svg
1833
end

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.