commit 46969ff940af19038b5b3255c851716c54382849 Author: jimi Date: Wed Nov 9 16:50:13 2011 -0600 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98e6ef6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.db diff --git a/main.rb b/main.rb new file mode 100644 index 0000000..aa93081 --- /dev/null +++ b/main.rb @@ -0,0 +1,29 @@ +require 'sinatra' +require 'data_mapper' +require 'haml' + +DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/development.db") + +class Task + include DataMapper::Resource + property :id, Serial + property :name, String, required: true + property :completed_at, DateTime +end + +DataMapper.finalize + +get '/' do + @tasks = Task.all + haml :index +end + +post '/' do + Task.create name: params[:task] + redirect '/' +end + +get '/:task' do + @task = params[:task].split('-').join(' ').capitalize + haml :task +end diff --git a/views/index.haml b/views/index.haml new file mode 100644 index 0000000..e913608 --- /dev/null +++ b/views/index.haml @@ -0,0 +1,8 @@ +%h2 My Tasks +%form{ action: '/', method: "POST" } + %input{ type: "text", name: "task" } + %input.button{ type: "submit", value: "New Task >>" } +%h2 My Tasks +%ul.tasks + - @tasks.each do |task| + %li.task= task.name diff --git a/views/layout.haml b/views/layout.haml new file mode 100644 index 0000000..95cedb1 --- /dev/null +++ b/views/layout.haml @@ -0,0 +1,9 @@ +!!! +%html + %head + %meta(charset="utf-8") + %title Just Do It + %link(rel="stylesheet" href="/styles.css") + %body + %h1 Just Do It + = yield diff --git a/views/task.haml b/views/task.haml new file mode 100644 index 0000000..a96bb7a --- /dev/null +++ b/views/task.haml @@ -0,0 +1,2 @@ +%h2 My Tasks += @task