Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bmksat/master #5

Open
wants to merge 41 commits into
base: bmksat/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
04ba49e
Baseline requirements met
trowbrsa Nov 4, 2015
6297069
Fixing syntax errors
brittanykohler Nov 4, 2015
de45254
Adding create_task method in database.rb
brittanykohler Nov 4, 2015
e6b0719
Updating home page to show tasks in database
brittanykohler Nov 4, 2015
a00916f
Added post method for tasks, created task form
trowbrsa Nov 5, 2015
934840b
Adding CSS styling
brittanykohler Nov 5, 2015
63f4c50
Adding button styling to home page
brittanykohler Nov 5, 2015
fe32e1c
Added css styling to homepage
trowbrsa Nov 5, 2015
93dc0d5
Added really great floats
trowbrsa Nov 5, 2015
ed65194
Fixing float issue on index page
brittanykohler Nov 5, 2015
7db0b86
Added date complete box
trowbrsa Nov 5, 2015
bb29a14
yes
trowbrsa Nov 5, 2015
4364e42
Trying to add completed date when task is done, but it's still broken
brittanykohler Nov 5, 2015
1ccb3be
Added id method to .each method
trowbrsa Nov 5, 2015
c46b099
Fixing date when marked complete
brittanykohler Nov 5, 2015
e21e583
Fixing styling
brittanykohler Nov 6, 2015
704de8a
Added some really great styling to our grey line
trowbrsa Nov 6, 2015
153e9af
Fixing more style stuff
brittanykohler Nov 6, 2015
9ff3c5d
Rearranging order of completed tasks
brittanykohler Nov 6, 2015
1475ea4
Updating styling
brittanykohler Nov 6, 2015
0695836
Fixed .each statement to accomodate CSS styling
trowbrsa Nov 6, 2015
2763ceb
Added text break for description box and fixed padding
trowbrsa Nov 6, 2015
348ed10
Changed css for complete button
trowbrsa Nov 6, 2015
7f4d7b7
Use Postgres in production (on Heroku)
Hamled Nov 6, 2015
2dbf99d
Fix autoincrement columns for Postgres
Hamled Nov 6, 2015
585cec6
Delete schema functionality
Hamled Nov 6, 2015
f7da508
Trying to add edit functionality, currently broken
brittanykohler Nov 6, 2015
3f53d7b
Merge remote-tracking branch 'upstream/postgres' into bmksat/master
brittanykohler Nov 6, 2015
3a33910
Use sqlite3 in dev, pg in production
brittanykohler Nov 6, 2015
fc40ab2
Adding postgres
brittanykohler Nov 6, 2015
f6984f1
Removing pry
brittanykohler Nov 6, 2015
9cc4ee3
Adding some comments for debugging
brittanykohler Nov 7, 2015
f3e6c5e
Fixing create, delete, mark complete. Still working on update
brittanykohler Nov 8, 2015
ee6c5fd
Fixed update
brittanykohler Nov 8, 2015
15049f3
Fixing css for buttons and links
trowbrsa Nov 8, 2015
fd4d7ed
Styling some more
brittanykohler Nov 8, 2015
95e282e
removing pry
brittanykohler Nov 8, 2015
403c20b
Fixing autopopulation of name and description when updating task
brittanykohler Nov 9, 2015
e2f5863
Removing pry again so that it will work on heroku
brittanykohler Nov 9, 2015
f145558
Adding favicon
brittanykohler Nov 9, 2015
3b80af3
Fixing error when you press delete or mark complete without checking …
brittanykohler Nov 9, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# A sample Gemfile
source "https://rubygems.org"

ruby "2.2.3"

gem 'sinatra'

group :development do
gem 'sqlite3'
gem 'pry'
end

group :production do
gem "pg"
end
32 changes: 32 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.0)
method_source (0.8.2)
pg (0.18.3)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
rack-protection (1.5.3)
rack
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slop (3.6.0)
sqlite3 (1.3.11)
tilt (2.0.1)

PLATFORMS
ruby

DEPENDENCIES
pg
pry
sinatra
sqlite3

BUNDLED WITH
1.10.6
2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require './task-site'
run TaskSite
4 changes: 4 additions & 0 deletions create_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require "./lib/database"

db = TaskList::Database.new("tasklist.db")
db.create_schema
60 changes: 56 additions & 4 deletions lib/database.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,67 @@
require "sqlite3"
require_relative "db_driver"

module TaskList
class Database

def initialize(db_name)
@db = SQLite3::Database.new(db_name)
@db = DBDriver.new(db_name)
end

def delete_schema
@db.delete_schema
end

def create_schema
# Put your ruby code here to use the @db variable
# to setup your schema in the databas.
@db.execute('
CREATE TABLE tasks (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
description TEXT NULL,
completed TEXT NULL
);')
end

def create_task(task_name, task_descr)
@db.execute('
INSERT INTO tasks (name, description)
VALUES(?, ?)
;', task_name, task_descr)
end

def get_tasks
@db.execute('
SELECT id, name, description, completed
FROM tasks;')
end

def get_name(checkbox_id)
@db.execute('
SELECT name FROM tasks WHERE id=(?)
;', checkbox_id)
end

def get_descr(checkbox_id)
@db.execute('
SELECT description FROM tasks WHERE id=(?)
;', checkbox_id)
end

def add_completion(checkbox_id)
@db.execute('
UPDATE tasks SET completed=(?) WHERE id=(?)
;', Time.now.strftime("%b-%d-%Y").to_s, checkbox_id)
end

def delete_task(checkbox_id)
@db.execute('
DELETE FROM tasks WHERE id=(?)
;', checkbox_id)
end

def update_task(name, descr, checkbox_id)
@db.execute('
UPDATE tasks SET name=(?), description=(?) WHERE id=(?)
;', name, descr, checkbox_id)
end
end
end
60 changes: 60 additions & 0 deletions lib/db_driver.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Figure out which DB we're using
DB_DRIVER = (ENV["RACK_ENV"] == "production") ? :pg : :sqlite3

require DB_DRIVER.to_s

class DBDriver
def initialize(db_name)
case DB_DRIVER
when :sqlite3
@db = SQLite3::Database.new(db_name)
when :pg
@db = PG::Connection.new(ENV["DATABASE_URL"])
end
end

def execute(query, *args)
case DB_DRIVER
when :sqlite3
return @db.execute(query, *args)
when :pg
# First we need to transform the bound variable placeholders
# because SQLite uses ? and PG uses $1, $2, $3, etc.
# HOWEVER
# We can't actually parse this SQL query! So I'm just going to
# split on each ? and combine them again with the PG style.
# WARNING
# Because I can't parse the SQL query, we might end up replacing
# literal question marks with the variable bind code. :( :( :(
var_num = 0
query = query.split("?").reduce("") do |fixed, orig|
var_str = var_num > 0 ? "$#{var_num}" : ""
var_num += 1

next fixed + var_str + orig
end

# We also need to make sure that we use PG's sequence data type
# because unlike SQLite, it does not integer make primary keys
# autoincrement by default.
query.gsub!(/integer primary key/i, "SERIAL PRIMARY KEY")

return @db.exec_params(query, args).values
end
end

def delete_schema
case DB_DRIVER
when :sqlite3
db_file = @db.database_list[0][2] # maybe there's a better way?
@db.close unless @db.closed?

File.delete(db_file)
when :pg
@db.exec('
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
')
end
end
end
Binary file added public/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
165 changes: 165 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
body {
font-family: 'Open Sans', sans-serif;
background-image: url("../background.png");
/*background-repeat: no-repeat;*/
background-size: cover;
}

hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid;
border-color: #747070;
text-align: center;
margin: auto;
width: 700px;
padding: 0px;
margin-top: 25px;
margin-bottom: 25px;
}

a {
text-decoration: none;
margin:auto;
text-align: center;
font-size: 18px;
color: #EE8788;
}

a:hover { color: #747070}

.task-box {
margin: auto;
width: 300px;
}

.button {
/*background-color: #009999;*/
background-color: color: #FF6E63;
color: white;
width: 130px;
height: 40px;
margin: auto;
font-size: 14px;
/*border-radius: 10px 10px 10px 10px;*/
/*-moz-border-radius: 10px 10px 10px 10px;*/
-webkit-border-radius: 10px 10px 10px 10px;
line-height: 40px;
text-align: center;
}

h1 {
text-align: center;
font-family: Didot;
font-size: 40px;
/*color: white;*/
}

.input-task {
width: 300px;
opacity: 0.6;
font-size: 14px;
}

.input-descr {
width: 300px;
height: 100px;
padding-top: 0;
padding-left: 0;
opacity: 0.6;
font-size: 14px;
}

.list {
margin: auto;
width: 400px;
/*padding-top: 20px;*/
}

.task {
font-weight: bolder;
}

.checkbox {
float: left;
margin-top: 5px;
}

.everything {
display: block;
float: none;
background-color: #ffffff;
opacity: 0.6;
border-radius: 5px 5px 5px 5px;
padding: 10px;
margin: 15px;
word-wrap: break-word;
}

.completed {
font-size: 12px;
margin-top: 10px;
margin-bottom: 25px;
}

.date {
/*padding-left: 30px;*/
font-size: 10px;
}

/*button for completed task submit*/
.mark-complete {
margin-left: 15px;
}

.done {
color: #666666;
text-decoration: line-through;
}

.modify-task {
background-color: transparent;
border: none;
font-size: 16px;
color: #EE8788;
font-family: 'Open Sans', sans-serif;
text-align: center;
margin: auto;
}

#create-new-task {
padding-right: 5px;
}

.modify-task:hover { color: #747070 }

.pipe {
color: #747070;
}

#submit-task {
/*background-color: #009999;*/
background-color: #EE8788;
color: white;
width: 70px;
height: 30px;
margin: auto;
font-size: 14px;
-webkit-border-radius: 10px 10px 10px 10px;
text-align: center;
padding-bottom: 3px;
/*border-style: solid;
border-color: black;
border-width: 1px;*/
}

submit:focus {outline:0 !important;}

.center {
text-align: center;
}

.edit-task {
font-size: 13px;
}
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/notebooks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading