summary refs log tree commit diff stats
path: root/web/web.rb
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-11-30 04:12:45 +0000
committerStar Rauchenberger <fefferburbia@gmail.com>2023-11-30 04:12:45 +0000
commit460edd4191229635e86c0e3781a361126c140ca9 (patch)
tree019e4e087cd1535125d99ab3cf3a430ed63fce76 /web/web.rb
parent9fc4c06bb40ff3d74031f1dd07e0352f965fc01e (diff)
parent83437f5895fd4f110694e66c9d939ff492bc2e1b (diff)
downloadlingo-460edd4191229635e86c0e3781a361126c140ca9.tar.gz
lingo-460edd4191229635e86c0e3781a361126c140ca9.tar.bz2
lingo-460edd4191229635e86c0e3781a361126c140ca9.zip
Merge branch 'main' of /srv/git/lingo into main
Diffstat (limited to 'web/web.rb')
-rw-r--r--web/web.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/web/web.rb b/web/web.rb new file mode 100644 index 0000000..15c088e --- /dev/null +++ b/web/web.rb
@@ -0,0 +1,44 @@
1require 'rack/cache'
2require 'yaml'
3
4require 'rubygems'
5require 'bundler/setup'
6Bundler.require :default
7
8use Rack::Cache
9
10config = YAML.load(open("config.yml"))
11db = Sequel.connect("sqlite://#{config["database"]}")
12
13class LingoScore < Sequel::Model
14end
15
16get '/' do
17 @scores = LingoScore.reverse_order(:score)
18
19 haml :index
20end
21
22post '/update' do
23 if params[:secret_code] != config["secret_code"] then
24 403
25 else
26 if LingoScore.where(user_id: params[:user_id]).count == 0
27 score = LingoScore.new(score: 0)
28 else
29 score = LingoScore.first(user_id: params[:user_id])
30 end
31 score.username = params[:username]
32 score.avatar_url = CGI.unescape(params[:avatar_url])
33 score.score += 1
34 score.save
35
36 201
37 end
38end
39
40get '/style.css' do
41 cache_control :public, :max_age => 36000
42
43 scss :style
44end