Skip to content

Commit

Permalink
project setup
Browse files Browse the repository at this point in the history
download and get ready to rock
  • Loading branch information
naserca committed Aug 29, 2015
1 parent d33ae39 commit 2fd65ed
Show file tree
Hide file tree
Showing 14 changed files with 770 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db/db.sqlite3
18 changes: 18 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# A sample Gemfile
source "https://rubygems.org"

gem 'rake'
gem 'activesupport'

gem 'sinatra'
gem 'sinatra-contrib'
gem 'sinatra-activerecord'

gem 'puma'
gem 'tux'

group :development, :test do
gem 'pry'
gem 'shotgun'
gem 'sqlite3'
end
88 changes: 88 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (4.2.1)
activesupport (= 4.2.1)
builder (~> 3.1)
activerecord (4.2.1)
activemodel (= 4.2.1)
activesupport (= 4.2.1)
arel (~> 6.0)
activesupport (4.2.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.0)
backports (3.6.4)
bond (0.5.1)
builder (3.2.2)
coderay (1.1.0)
i18n (0.7.0)
json (1.8.2)
method_source (0.8.2)
minitest (5.6.1)
multi_json (1.11.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
puma (2.11.3)
rack (>= 1.1, < 2.0)
rack (1.6.1)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rake (10.4.2)
ripl (0.7.1)
bond (~> 0.5.1)
ripl-multi_line (0.3.1)
ripl (>= 0.3.6)
ripl-rack (0.2.1)
rack (>= 1.0)
rack-test (~> 0.6.2)
ripl (>= 0.7.0)
shotgun (0.9.1)
rack (>= 1.0)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sinatra-activerecord (2.0.6)
activerecord (>= 3.2)
sinatra (~> 1.0)
sinatra-contrib (1.4.2)
backports (>= 2.0)
multi_json
rack-protection
rack-test
sinatra (~> 1.4.0)
tilt (~> 1.3)
slop (3.6.0)
sqlite3 (1.3.10)
thread_safe (0.3.5)
tilt (1.4.1)
tux (0.3.0)
ripl (>= 0.3.5)
ripl-multi_line (>= 0.2.4)
ripl-rack (>= 0.2.0)
sinatra (>= 1.2.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)

PLATFORMS
ruby

DEPENDENCIES
activesupport
pry
puma
rake
shotgun
sinatra
sinatra-activerecord
sinatra-contrib
sqlite3
tux
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# finstagram
finstagram tutorial
tutorial for lighthouse labs web fundamentals
22 changes: 22 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'rake'
require "sinatra/activerecord/rake"
require ::File.expand_path('../config/environment', __FILE__)

Rake::Task["db:create"].clear
Rake::Task["db:drop"].clear

# NOTE: Assumes SQLite3 DB
desc "create the database"
task "db:create" do
touch 'db/db.sqlite3'
end

desc "drop the database"
task "db:drop" do
rm_f 'db/db.sqlite3'
end

desc 'Retrieves the current schema version number'
task "db:version" do
puts "Current version: #{ActiveRecord::Migrator.current_version}"
end
Empty file added app/actions.rb
Empty file.
Empty file added app/views/index.html
Empty file.
5 changes: 5 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Require config/environment.rb
require ::File.expand_path('../config/environment', __FILE__)

set :app_file, __FILE__
run Sinatra::Application
19 changes: 19 additions & 0 deletions config/database.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
configure do
# Log queries to STDOUT in development
if Sinatra::Application.development?
ActiveRecord::Base.logger = Logger.new(STDOUT)
end

set :database, {
adapter: "sqlite3",
database: "db/db.sqlite3"
}

# Load all models from app/models, using autoload instead of require
# See http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html
Dir[APP_ROOT.join('app', 'models', '*.rb')].each do |model_file|
filename = File.basename(model_file).gsub('.rb', '')
autoload ActiveSupport::Inflector.camelize(filename), model_file
end

end
31 changes: 31 additions & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'rubygems'
require 'bundler/setup'

require 'active_support/all'

# Load Sinatra Framework (with AR)
require 'sinatra'
require 'sinatra/activerecord'
require 'sinatra/contrib/all' # Requires cookies, among other things

require 'pry'

APP_ROOT = Pathname.new(File.expand_path('../../', __FILE__))
APP_NAME = APP_ROOT.basename.to_s

# Sinatra configuration
configure do
set :root, APP_ROOT.to_path
set :server, :puma

enable :sessions
set :session_secret, ENV['SESSION_KEY'] || 'lighthouselabssecret'

set :views, File.join(Sinatra::Application.root, "app", "views")
end

# Set up the database and models
require APP_ROOT.join('config', 'database')

# Load the routes / actions
require APP_ROOT.join('app', 'actions')
33 changes: 33 additions & 0 deletions db/migrate/0_create_base_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class CreateBaseTables < ActiveRecord::Migration

def change
create_table :users do |t|
t.string :username
t.string :avatar_url
t.string :email
t.string :password
t.timestamps
end

create_table :posts do |t|
t.references :user
t.string :photo_url
t.timestamps
end

create_table :comments do |t|
t.references :user
t.references :post
t.text :text
t.timestamps
end

create_table :likes do |t|
t.references :user
t.references :post
t.timestamps
end

end

end
Empty file added public/stylesheets/app.css
Empty file.
129 changes: 129 additions & 0 deletions public/stylesheets/lib.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
* {
box-sizing: border-box;
}

body, input {
font-family: 'Roboto Condensed', sans-serif;
margin: 0;
color: #244751;
}

a {
color: #8da7b8;
text-decoration: none;
}

label {
display: block;
margin-bottom: .25em;
}

input[type=text], input[type=password], input[type=email] {
border: solid 1px #244751;
padding: .5em;
width: 200px;
font-size: 1em;
}

header {
background-color: #244751;
color: #E8FDFF;
overflow: hidden;
padding: 0 2em;
display: flex;
align-items: baseline;
}

header > .login-info {
margin-left: auto;
}

main {
width: 450px;
margin: 0 auto;
padding: 2em;
}

.new-post {
text-align: center;
margin-bottom: 2em;
}

.new-post > .button {
display: inline-block;
padding: 1em;
width: 100%;
border-radius: 4px;
box-sizing: border-box;
}

.button {
padding: .5em;
background-color: white;
border: solid 1px #244751;
display: inline-block;
}

.post {
margin-bottom: 2em;
}

.post > * {
margin-bottom: 1em;
}

.user-info {
display: flex;
align-items: baseline;
}

.user-info img {
width: 40px;
}

.user-info h2 {
margin: 0 0 0 .5em;
}

.user-info h3 {
margin: 0 0 0 auto;
}

.photo {
display: block;
}

.photo img {
display: block;
width: 100%;
}

.actions {
display: flex;
align-items: baseline;
}

.actions button.user-like {
color: #FF2600;
border-color: #FF2600;
}

.actions .comment-count {
margin-left: auto;
}

.comments {
margin-top: 0;
margin-left: 0;
margin-right: 0;
padding: 0;
list-style-type: none;
}

.form-group {
margin-bottom: 1em;
}

.new-comment input[type="text"] {
width: 100%;
}
Loading

0 comments on commit 2fd65ed

Please sign in to comment.