-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpomodoro.rb
More file actions
93 lines (73 loc) · 1.95 KB
/
pomodoro.rb
File metadata and controls
93 lines (73 loc) · 1.95 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
require "rubygems"
require "bundler"
Bundler.setup
require 'rubygems'
require 'sinatra'
require 'haml'
require 'erb'
require 'dm-core'
require 'dm-validations'
require 'dm-aggregates'
require 'fileutils'
require 'task'
DataMapper::setup(:default, {
:adapter => "sqlite",
:database => "pomodoro"
})
get '/' do
erb :pomodoro
end
post '/tasks' do
@task = Task.create(params)
end
get '/tasks' do
@tasks = Task.all
erb :index
end
get '/tasks/:id' do
@task = Task.first( :offset => params['id'].to_i )
erb :task
end
put '/tasks/:id' do
@task = Task.get( params[:id] )
params[:status] = '' if params[:status].blank?
if @task
@task.update(:name => params[:name],
:number_of_pomodoros => params[:number_of_pomodoros],
:number_of_interuptions => params[:number_of_interuptions],
:status => params[:status])
end
erb :task
end
get '/test' do
erb :'pomodoro_test'
end
delete '/tasks/:id' do
Task.first( :offset => params['id'].to_i ).destroy
end
# Static files
get '/css/layout.css' do
headers 'Content-Type' => 'text/css; charset=utf-8'
File.read(File.join(File.dirname(__FILE__), 'css', 'layout.css' ))
end
get '/js/pmdr.js' do
headers 'Content-Type' => 'text/javascript; charset=utf-8'
File.read(File.join(File.dirname(__FILE__), 'js', 'pmdr.js' ))
end
get '/js/jquery.js' do
headers 'Content-Type' => 'text/javascript; charset=utf-8'
File.read(File.join(File.dirname(__FILE__), 'js', 'jquery.js' ))
end
#test
get '/css/JSSpec.css' do
headers 'Content-Type' => 'text/css; charset=utf-8'
File.read(File.join(File.dirname(__FILE__), 'css', 'JSSpec.css' ))
end
get '/js/JSSpec.js' do
headers 'Content-Type' => 'text/javascript; charset=utf-8'
File.read(File.join(File.dirname(__FILE__), 'js', 'JSSpec.js' ))
end
get '/js/diff_match_patch.js' do
headers 'Content-Type' => 'text/javascript; charset=utf-8'
File.read(File.join(File.dirname(__FILE__), 'js', 'diff_match_patch.js' ))
end