├── .gitignore ├── README.md ├── views ├── story.slim ├── stories.slim ├── components │ ├── _footer.slim │ └── _head.slim ├── layout.slim └── index.slim ├── config.ru ├── Rakefile ├── models └── story.rb ├── public └── images │ └── favicon.ico ├── Gemfile ├── config ├── database.yml └── environments.rb ├── db ├── migrate │ └── 20160409212805_create_stories.rb └── schema.rb ├── app.rb ├── LICENSE └── Gemfile.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HerStory-App -------------------------------------------------------------------------------- /views/story.slim: -------------------------------------------------------------------------------- 1 | h1= @story.title 2 | p= @story.story -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | require './app' 2 | 3 | run Sinatra::Application -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require './app' 2 | require 'sinatra/activerecord/rake' -------------------------------------------------------------------------------- /models/story.rb: -------------------------------------------------------------------------------- 1 | class Story < ActiveRecord::Base 2 | 3 | end -------------------------------------------------------------------------------- /public/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/empowerhack/HerStory-App/HEAD/public/images/favicon.ico -------------------------------------------------------------------------------- /views/stories.slim: -------------------------------------------------------------------------------- 1 | h1 Stories 2 | 3 | ul 4 | - @stories.each do |story| 5 | li: a href="#{story.id}" #{story.title} -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "sinatra" 4 | gem "activerecord" 5 | gem "sinatra-activerecord" 6 | gem "pg" 7 | 8 | gem "slim" 9 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: postgresql 3 | database: development 4 | username: <%= ENV['PG_USER'] %> 5 | password: <%= ENV['PG_PASS'] %> 6 | host: localhost -------------------------------------------------------------------------------- /views/components/_footer.slim: -------------------------------------------------------------------------------- 1 | script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous" -------------------------------------------------------------------------------- /views/layout.slim: -------------------------------------------------------------------------------- 1 | doctype html 2 | html locale="en" xml:lang="en" lang="en" 3 | head 4 | == slim :'components/_head' 5 | 6 | body 7 | #content.container-fluid 8 | == yield 9 | 10 | footer 11 | == slim :'components/_footer' -------------------------------------------------------------------------------- /db/migrate/20160409212805_create_stories.rb: -------------------------------------------------------------------------------- 1 | class CreateStories < ActiveRecord::Migration 2 | def up 3 | create_table :stories do |t| 4 | t.integer :user_id 5 | t.string :title 6 | t.text :story 7 | t.timestamp :date_created 8 | end 9 | end 10 | 11 | def down 12 | drop_table :models 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /config/environments.rb: -------------------------------------------------------------------------------- 1 | configure :production, :development do 2 | db = URI.parse(ENV['DATABASE_URL'] || 'postgres://localhost/herstory') 3 | 4 | ActiveRecord::Base.establish_connection( 5 | :adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme, 6 | :host => db.host, 7 | :username => db.user, 8 | :password => db.password, 9 | :database => db.path[1..-1], 10 | :encoding => 'utf8' 11 | ) 12 | end -------------------------------------------------------------------------------- /app.rb: -------------------------------------------------------------------------------- 1 | require 'sinatra' 2 | require 'sinatra/activerecord' 3 | require './config/environments' 4 | 5 | require './models/story' 6 | require 'slim' 7 | 8 | get '/' do 9 | slim :index 10 | end 11 | 12 | post '/submit' do 13 | @model = Story.new(params[:story]) 14 | 15 | if @model.save 16 | redirect '/stories' 17 | else 18 | "Not todaaaay" 19 | end 20 | end 21 | 22 | get '/stories' do 23 | @stories = Story.all 24 | 25 | slim :stories 26 | end 27 | 28 | get '/:id' do 29 | @story = Story.find(params[:id]) 30 | 31 | slim :story 32 | end -------------------------------------------------------------------------------- /views/components/_head.slim: -------------------------------------------------------------------------------- 1 | title HerStory 2 | meta name="viewport" content="width=device-width, initial-scale=1.0" 3 | 4 | link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous" 5 | link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous" 6 | 7 | link rel="icon" type="image/ico" href="images/favicon.ico" -------------------------------------------------------------------------------- /views/index.slim: -------------------------------------------------------------------------------- 1 | h1 HerStory 2 | p What does it mean to post? 3 | p What will happen when you post? 4 | p What to do after your share your story? 5 | 6 | form action="/submit" method="POST" 7 | .form-group 8 | label for="title" Title 9 | input.form-control type="text" name="story[title]" value="Enter title" id="title" 10 | .form-group 11 | label for="story" Your story 12 | textarea.form-control rows="5" type="text" name="story[story]" value="Enter your story" id="story" 13 | .row 14 | .col-xs-12 15 | input.btn.btn-primary.col-xs-12 type="submit" value="Share your story" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Empower Hack 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 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: 20160409212805) do 15 | 16 | # These are extensions that must be enabled in order to support this database 17 | enable_extension "plpgsql" 18 | 19 | create_table "stories", force: :cascade do |t| 20 | t.integer "user_id" 21 | t.string "title" 22 | t.text "story" 23 | t.datetime "date_created" 24 | end 25 | 26 | end 27 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | activemodel (4.2.6) 5 | activesupport (= 4.2.6) 6 | builder (~> 3.1) 7 | activerecord (4.2.6) 8 | activemodel (= 4.2.6) 9 | activesupport (= 4.2.6) 10 | arel (~> 6.0) 11 | activesupport (4.2.6) 12 | i18n (~> 0.7) 13 | json (~> 1.7, >= 1.7.7) 14 | minitest (~> 5.1) 15 | thread_safe (~> 0.3, >= 0.3.4) 16 | tzinfo (~> 1.1) 17 | arel (6.0.3) 18 | builder (3.2.2) 19 | i18n (0.7.0) 20 | json (1.8.3) 21 | minitest (5.8.4) 22 | pg (0.18.4) 23 | rack (1.6.4) 24 | rack-protection (1.5.3) 25 | rack 26 | sinatra (1.4.7) 27 | rack (~> 1.5) 28 | rack-protection (~> 1.4) 29 | tilt (>= 1.3, < 3) 30 | sinatra-activerecord (2.0.9) 31 | activerecord (>= 3.2) 32 | sinatra (~> 1.0) 33 | slim (3.0.6) 34 | temple (~> 0.7.3) 35 | tilt (>= 1.3.3, < 2.1) 36 | temple (0.7.6) 37 | thread_safe (0.3.5) 38 | tilt (2.0.2) 39 | tzinfo (1.2.2) 40 | thread_safe (~> 0.1) 41 | 42 | PLATFORMS 43 | ruby 44 | 45 | DEPENDENCIES 46 | activerecord 47 | pg 48 | sinatra 49 | sinatra-activerecord 50 | slim 51 | 52 | BUNDLED WITH 53 | 1.11.2 54 | --------------------------------------------------------------------------------