Skip to content

Commit 1b6e78f

Browse files
committed
Added initial Sinatra skelatn
0 parents  commit 1b6e78f

30 files changed

+3351
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.env
2+
.bundle
3+
/db/*.db
4+
/db/*.sqlite3
5+
/db/*.sqlite
6+
/db/*.sqlite3-journal
7+
.DS_Store
8+
public/assets

Gemfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# A sample Gemfile
2+
source "https://rubygems.org"
3+
4+
gem 'rake'
5+
gem 'activesupport'
6+
gem 'json'
7+
8+
gem 'sinatra'
9+
gem 'sinatra-contrib', :git => '[email protected]:sinatra/sinatra-contrib.git'
10+
gem 'sinatra-activerecord'
11+
12+
gem 'puma'
13+
gem 'tux'
14+
15+
group :development, :test do
16+
gem 'pry'
17+
gem 'shotgun'
18+
gem 'sqlite3'
19+
gem 'faker'
20+
end

Gemfile.lock

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
GIT
2+
remote: [email protected]:sinatra/sinatra-contrib.git
3+
revision: d856355561dd5b1e1e80f493d6df6806afac1b63
4+
specs:
5+
sinatra-contrib (1.4.4)
6+
backports (>= 2.0)
7+
multi_json
8+
rack-protection
9+
rack-test
10+
sinatra (~> 1.4.0)
11+
tilt (>= 1.3, < 3)
12+
13+
GEM
14+
remote: https://rubygems.org/
15+
specs:
16+
activemodel (4.2.1)
17+
activesupport (= 4.2.1)
18+
builder (~> 3.1)
19+
activerecord (4.2.1)
20+
activemodel (= 4.2.1)
21+
activesupport (= 4.2.1)
22+
arel (~> 6.0)
23+
activesupport (4.2.1)
24+
i18n (~> 0.7)
25+
json (~> 1.7, >= 1.7.7)
26+
minitest (~> 5.1)
27+
thread_safe (~> 0.3, >= 0.3.4)
28+
tzinfo (~> 1.1)
29+
arel (6.0.0)
30+
backports (3.6.4)
31+
bond (0.5.1)
32+
builder (3.2.2)
33+
coderay (1.1.0)
34+
faker (1.4.3)
35+
i18n (~> 0.5)
36+
i18n (0.7.0)
37+
json (1.8.3)
38+
method_source (0.8.2)
39+
minitest (5.7.0)
40+
multi_json (1.11.0)
41+
pry (0.10.1)
42+
coderay (~> 1.1.0)
43+
method_source (~> 0.8.1)
44+
slop (~> 3.4)
45+
puma (2.11.3)
46+
rack (>= 1.1, < 2.0)
47+
rack (1.6.1)
48+
rack-protection (1.5.3)
49+
rack
50+
rack-test (0.6.3)
51+
rack (>= 1.0)
52+
rake (10.4.2)
53+
ripl (0.7.1)
54+
bond (~> 0.5.1)
55+
ripl-multi_line (0.3.1)
56+
ripl (>= 0.3.6)
57+
ripl-rack (0.2.1)
58+
rack (>= 1.0)
59+
rack-test (~> 0.6.2)
60+
ripl (>= 0.7.0)
61+
shotgun (0.9.1)
62+
rack (>= 1.0)
63+
sinatra (1.4.6)
64+
rack (~> 1.4)
65+
rack-protection (~> 1.4)
66+
tilt (>= 1.3, < 3)
67+
sinatra-activerecord (2.0.6)
68+
activerecord (>= 3.2)
69+
sinatra (~> 1.0)
70+
slop (3.6.0)
71+
sqlite3 (1.3.10)
72+
thread_safe (0.3.5)
73+
tilt (2.0.1)
74+
tux (0.3.0)
75+
ripl (>= 0.3.5)
76+
ripl-multi_line (>= 0.2.4)
77+
ripl-rack (>= 0.2.0)
78+
sinatra (>= 1.2.1)
79+
tzinfo (1.2.2)
80+
thread_safe (~> 0.1)
81+
82+
PLATFORMS
83+
ruby
84+
85+
DEPENDENCIES
86+
activesupport
87+
faker
88+
json
89+
pry
90+
puma
91+
rake
92+
shotgun
93+
sinatra
94+
sinatra-activerecord
95+
sinatra-contrib!
96+
sqlite3
97+
tux

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Sinatra
2+
=============
3+
4+
Brought to you by Lighthouse Labs
5+
6+
## Getting Started
7+
8+
1. `bundle install`
9+
2. `shotgun -p 3000 -o 0.0.0.0`
10+
3. Visit `http://localhost:3000/` in your browser

Rakefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'rake'
2+
require "sinatra/activerecord/rake"
3+
require ::File.expand_path('../config/environment', __FILE__)
4+
5+
Rake::Task["db:create"].clear
6+
Rake::Task["db:drop"].clear
7+
8+
# NOTE: Assumes SQLite3 DB
9+
desc "create the database"
10+
task "db:create" do
11+
touch 'db/db.sqlite3'
12+
end
13+
14+
desc "drop the database"
15+
task "db:drop" do
16+
rm_f 'db/db.sqlite3'
17+
end
18+
19+
desc 'Retrieves the current schema version number'
20+
task "db:version" do
21+
puts "Current version: #{ActiveRecord::Migrator.current_version}"
22+
end

app/actions.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Homepage (Root path)
2+
get '/' do
3+
erb :index
4+
end
5+

app/models/.keep

Whitespace-only changes.

app/models/user.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class User < ActiveRecord::Base
2+
end

app/views/index.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="title_search">
2+
<h1 class="col-lg-12" id="title">Instagram Feed</h1>
3+
4+
5+
</div>
6+

app/views/layout.erb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<link rel="stylesheet" type="text/css" href="/stylesheets/bootstrap.min.css">
5+
<link rel="stylesheet" href="/stylesheets/application.css">
6+
7+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
8+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
9+
<script src="/javascript/application.js"></script>
10+
11+
12+
<title>Instagram Feed</title>
13+
</head>
14+
<body class="bg-success">
15+
<container>
16+
<%= yield %>
17+
</container>
18+
</body>
19+
</html>

config.ru

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Require config/environment.rb
2+
require ::File.expand_path('../config/environment', __FILE__)
3+
4+
set :app_file, __FILE__
5+
run Sinatra::Application

config/database.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
configure do
2+
# Log queries to STDOUT in development
3+
if Sinatra::Application.development?
4+
ActiveRecord::Base.logger = Logger.new(STDOUT)
5+
end
6+
7+
set :database, {
8+
adapter: "sqlite3",
9+
database: "db/db.sqlite3"
10+
}
11+
12+
# Load all models from app/models, using autoload instead of require
13+
# See http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html
14+
Dir[APP_ROOT.join('app', 'models', '*.rb')].each do |model_file|
15+
filename = File.basename(model_file).gsub('.rb', '')
16+
autoload ActiveSupport::Inflector.camelize(filename), model_file
17+
end
18+
19+
end

config/environment.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'rubygems'
2+
require 'bundler/setup'
3+
4+
require 'active_support/all'
5+
6+
# Load Sinatra Framework (with AR)
7+
require 'sinatra'
8+
require 'sinatra/activerecord'
9+
require 'sinatra/contrib/all' # Requires cookies, among other things
10+
11+
require 'pry'
12+
13+
APP_ROOT = Pathname.new(File.expand_path('../../', __FILE__))
14+
APP_NAME = APP_ROOT.basename.to_s
15+
16+
# Sinatra configuration
17+
configure do
18+
set :root, APP_ROOT.to_path
19+
set :server, :puma
20+
21+
enable :sessions
22+
set :session_secret, ENV['SESSION_KEY'] || 'lighthouselabssecret'
23+
24+
set :views, File.join(Sinatra::Application.root, "app", "views")
25+
end
26+
27+
# Set up the database and models
28+
require APP_ROOT.join('config', 'database')
29+
30+
# Load the routes / actions
31+
require APP_ROOT.join('app', 'actions')

db/migrate/.keep

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CreateUsersTable < ActiveRecord::Migration
2+
def change
3+
create_table :users do |t|
4+
t.string :name
5+
t.string :email
6+
t.string :password
7+
end
8+
end
9+
end

db/schema.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# encoding: UTF-8
2+
# This file is auto-generated from the current state of the database. Instead
3+
# of editing this file, please use the migrations feature of Active Record to
4+
# incrementally modify your database, and then regenerate this schema definition.
5+
#
6+
# Note that this schema.rb definition is the authoritative source for your
7+
# database schema. If you need to create the application database on another
8+
# system, you should be using db:schema:load, not running all the migrations
9+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
10+
# you'll amass, the slower it'll run and the greater likelihood for issues).
11+
#
12+
# It's strongly recommended that you check this file into your version control system.
13+
14+
ActiveRecord::Schema.define(version: 20150609154353) do
15+
16+
create_table "users", force: :cascade do |t|
17+
t.string "name"
18+
t.string "email"
19+
t.string "password"
20+
end
21+
22+
end

db/seeds.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'faker'
2+
3+
USERS = 10
4+
5+
user_list = []
6+
7+
User.create!(
8+
name: 'Logan',
9+
10+
password: 'test',
11+
)
12+
13+
USERS.times do
14+
user_list << User.create!(
15+
name: Faker::Name.name,
16+
email: Faker::Internet.email,
17+
password: 'test'
18+
)
19+
end
19.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)