forked from ga-wdi-exercises/wdinstagram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85fbd9a
commit 1ec0388
Showing
70 changed files
with
1,325 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
get '/' do | ||
@entries = Entry.all | ||
erb :index | ||
end | ||
|
||
get '/new' do | ||
erb :new | ||
end | ||
|
||
get '/:id' do | ||
@entry = Entry.find(params[:id]) | ||
erb :show | ||
end | ||
|
||
post '/' do | ||
@entry = Entry.create(params[:entry]) | ||
redirect "/#{@entry.id}" | ||
# Same as redirect "/artists/" + @artist.id.to_s | ||
end | ||
|
||
get '/:id/edit' do | ||
@entry = Entry.find(params[:id]) | ||
erb :edit | ||
end | ||
|
||
put "/:id" do | ||
@entry = Entry.find(params[:id]) | ||
@entry.update(params[:entry]) | ||
redirect "/#{@entry.id}" | ||
end | ||
|
||
delete '/:id' do | ||
@entry = Entry.find(params[:id]) | ||
@entry.destroy | ||
redirect "/" | ||
end | ||
|
||
get '/:author' do | ||
@author = Entry.find_by(author:"") | ||
@entries = Entry.find(params[:author]) | ||
erb :author | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
DROP TABLE IF EXISTS entries; | ||
|
||
CREATE TABLE entries ( | ||
id SERIAL PRIMARY KEY, | ||
author TEXT, | ||
photo_url TEXT, | ||
date_taken TEXT, | ||
caption TEXT | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
require 'bundler/setup' | ||
require "pry" | ||
require 'active_record' | ||
require 'pry' | ||
|
||
require_relative "../db/connection" | ||
require_relative "connection" | ||
require_relative "../models/entry" | ||
|
||
Entry.destroy_all | ||
|
||
eich = Entry.create( | ||
author: "Brendan Eich", | ||
photo_url: "http://cnet4.cbsistatic.com/hub/i/r/2012/02/26/24cf0440-f0e6-11e2-8c7c-d4ae52e62bcc/resize/370xauto/434f5240b3a3752f41c966b9987f723d/20120226_Brendan_Eich_001.jpg", | ||
date_taken: "March, 2013", | ||
caption: "Sunny") | ||
matz = Entry.create( | ||
author: "Yukihiro Matsumoto", | ||
photo_url: "http://i.ytimg.com/vi/IGG4l_QEzog/maxresdefault.jpg", | ||
date_taken: "April, 2013", | ||
caption: "Woah") | ||
rossum = Entry.create( | ||
author: "Guido van Rossum", | ||
photo_url: "https://upload.wikimedia.org/wikipedia/commons/6/66/Guido_van_Rossum_OSCON_2006.jpg", | ||
date_taken: "March, 2013", | ||
caption: "Beer") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Entry < ActiveRecord::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* -----------------------------------*/ | ||
/* --- RESETS ---*/ | ||
/* -----------------------------------*/ | ||
|
||
/* http://meyerweb.com/eric/tools/css/reset/ | ||
v2.0 | 20110126 | ||
License: none (public domain) | ||
*/ | ||
|
||
html, body, div, span, applet, object, iframe, | ||
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | ||
a, abbr, acronym, address, big, cite, code, | ||
del, dfn, em, img, ins, kbd, q, s, samp, | ||
small, strike, strong, sub, sup, tt, var, | ||
b, u, i, center, | ||
dl, dt, dd, ol, ul, li, | ||
fieldset, form, label, legend, | ||
table, caption, tbody, tfoot, thead, tr, th, td, | ||
article, aside, canvas, details, embed, | ||
figure, figcaption, footer, header, hgroup, | ||
menu, nav, output, ruby, section, summary, | ||
time, mark, audio, video { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
font-size: 100%; | ||
font: inherit; | ||
vertical-align: baseline; | ||
} | ||
/* HTML5 display-role reset for older browsers */ | ||
article, aside, details, figcaption, figure, | ||
footer, header, hgroup, menu, nav, section { | ||
display: block; | ||
} | ||
body { | ||
line-height: 1; | ||
} | ||
ol, ul { | ||
list-style: none; | ||
} | ||
blockquote, q { | ||
quotes: none; | ||
} | ||
blockquote:before, blockquote:after, | ||
q:before, q:after { | ||
content: ''; | ||
content: none; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
} | ||
|
||
/* -----------------------------------*/ | ||
/* --- BORDER BOX ---*/ | ||
/* -----------------------------------*/ | ||
|
||
/* apply a natural box layout model to all elements, but allowing components to change */ | ||
html { | ||
box-sizing: border-box; | ||
} | ||
*, *:before, *:after { | ||
box-sizing: inherit; | ||
} | ||
|
||
/* -----------------------------------*/ | ||
/* --- GLOBAL ---*/ | ||
/* -----------------------------------*/ | ||
|
||
|
||
body, ul { | ||
background-color: #ecf0f1; | ||
font-family: 'Arimo', serif; | ||
font-size: 1.2em; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
li { | ||
margin: .2em; | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
color: #e67e22; | ||
} | ||
|
||
img { | ||
border: 1px dashed #e67e22; | ||
padding: 5px; | ||
width: 10em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<h1>Author's Posts | ||
<a href="/new">(+)</a> | ||
</h1> | ||
|
||
<ul> | ||
<% @entries.each do |entry| %> | ||
<li> | ||
<a href='/<%= entry.id %>'><%= entry.author %></a> | ||
</li> | ||
|
||
<li> | ||
<%= entry.date_taken %> | ||
</li> | ||
|
||
<li> | ||
<img src='<%= entry.photo_url %>'> | ||
</li> | ||
|
||
<li> | ||
<%= entry.caption %> | ||
</li> | ||
|
||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h3>Editing Entry</h3> | ||
|
||
<form action="/<%= @entry.id %>" method="post"> | ||
<input type="hidden" name="_method" value="put"> <!-- for REST --> | ||
<input value="<%= @entry.author %>" name="entry[author]" placeholder="Author's Name" type="text"> | ||
<input value="<%= @entry.photo_url %>" name="entry[photo_url]" placeholder="Photo URL" type="text"> | ||
<input value="<%= @entry.date_taken %>" name="entry[date_taken]" placeholder="Date Taken" type="text"> | ||
<input value="<%= @entry.caption %>" name="entry[caption]" placeholder="caption" type="text"> | ||
<input type="submit" value="Update"> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<ul> | ||
<li> | ||
<h1>Entries | ||
<a href="/new">(+)</a> | ||
</h1> | ||
</li> | ||
<% @entries.each do |entry| %> | ||
<li> | ||
<a href='/<%= entry.author %>'><%= entry.author %></a> | ||
</li> | ||
|
||
<li> | ||
<%= entry.date_taken %> | ||
</li> | ||
|
||
<li> | ||
<a href='/<%= entry.id %>'><img src='<%= entry.photo_url %>'></a> | ||
</li> | ||
|
||
<li> | ||
<%= entry.caption %> | ||
</li> | ||
|
||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Document</title> | ||
<link href='http://fonts.googleapis.com/css?family=Arimo:400,700' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="/styles.css"> | ||
</head> | ||
|
||
<body> | ||
<%= yield %> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h3>Creating New Entry</h3> | ||
|
||
<form method="post" action="/"> | ||
<input name="entry[author]" placeholder="Author's Name" type="text"> | ||
<input name="entry[photo_url]" placeholder="Photo URL" type="text"> | ||
<input name="entry[date_taken]" placeholder="date_taken" type="text"> | ||
<input name="entry[caption]" placeholder="caption" type="text"> | ||
<input type="submit"> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<ul> | ||
<li> | ||
<h2><%= @entry.author %></h2> | ||
</li> | ||
|
||
<li> | ||
<img src='<%= @entry.photo_url %>'> | ||
</li> | ||
|
||
<li> | ||
<a href="/<%= @entry.id %>/edit">Edit Entry</a> | ||
</li> | ||
|
||
<li> | ||
<form method="post" action="/<%= @entry.id %>"> | ||
<input name="_method" value="delete" type="hidden"> | ||
<input type="submit" value="Delete Entry"> | ||
</form> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | ||
# | ||
# If you find yourself ignoring temporary files generated by your text editor | ||
# or operating system, you probably want to add a global ignore instead: | ||
# git config --global core.excludesfile '~/.gitignore_global' | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
!/log/.keep | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
source 'https://rubygems.org' | ||
|
||
|
||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | ||
gem 'rails', '4.2.3' | ||
# Use postgresql as the database for Active Record | ||
gem 'pg' | ||
# Use SCSS for stylesheets | ||
gem 'sass-rails', '~> 5.0' | ||
# Use Uglifier as compressor for JavaScript assets | ||
gem 'uglifier', '>= 1.3.0' | ||
# Use CoffeeScript for .coffee assets and views | ||
gem 'coffee-rails', '~> 4.1.0' | ||
# See https://github.com/rails/execjs#readme for more supported runtimes | ||
# gem 'therubyracer', platforms: :ruby | ||
|
||
# Use jquery as the JavaScript library | ||
gem 'jquery-rails' | ||
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks | ||
gem 'turbolinks' | ||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder | ||
gem 'jbuilder', '~> 2.0' | ||
# bundle exec rake doc:rails generates the API under doc/api. | ||
gem 'sdoc', '~> 0.4.0', group: :doc | ||
|
||
# Use ActiveModel has_secure_password | ||
# gem 'bcrypt', '~> 3.1.7' | ||
|
||
# Use Unicorn as the app server | ||
# gem 'unicorn' | ||
|
||
# Use Capistrano for deployment | ||
# gem 'capistrano-rails', group: :development | ||
|
||
group :development, :test do | ||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console | ||
gem 'byebug' | ||
|
||
# Access an IRB console on exception pages or by using <%= console %> in views | ||
gem 'web-console', '~> 2.0' | ||
|
||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring | ||
gem 'spring' | ||
end | ||
|
Oops, something went wrong.