diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 000000000..24b11a74e --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,3 @@ +vscode: + extensions: + - CraigMaslowski.erb@0.0.1:5znDha/nn0PphUrpB9a5Nw== \ No newline at end of file diff --git a/.theia/launch.json b/.theia/launch.json new file mode 100644 index 000000000..a2ea02c46 --- /dev/null +++ b/.theia/launch.json @@ -0,0 +1,6 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + "version": "0.2.0", + "configurations": [] +} diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..237081948 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,93 @@ +GEM + remote: https://rubygems.org/ + specs: + activemodel (4.2.11.1) + activesupport (= 4.2.11.1) + builder (~> 3.1) + activerecord (4.2.11.1) + activemodel (= 4.2.11.1) + activesupport (= 4.2.11.1) + arel (~> 6.0) + activesupport (4.2.11.1) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + arel (6.0.4) + backports (3.15.0) + bond (0.5.1) + builder (3.2.3) + coderay (1.1.2) + concurrent-ruby (1.1.5) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + method_source (0.9.2) + minitest (5.13.0) + multi_json (1.14.1) + mustermann (1.0.3) + nio4r (2.5.2) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + puma (4.3.0) + nio4r (~> 2.0) + rack (2.0.7) + rack-protection (2.0.7) + rack + rack-test (0.6.3) + rack (>= 1.0) + rake (13.0.0) + 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.2) + rack (>= 1.0) + sinatra (2.0.7) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.7) + tilt (~> 2.0) + sinatra-activerecord (2.0.14) + activerecord (>= 3.2) + sinatra (>= 1.0) + sinatra-contrib (2.0.7) + backports (>= 2.8.2) + multi_json + mustermann (~> 1.0) + rack-protection (= 2.0.7) + sinatra (= 2.0.7) + tilt (~> 2.0) + sqlite3 (1.3.13) + thread_safe (0.3.6) + tilt (2.0.10) + 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.5) + thread_safe (~> 0.1) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord (~> 4.2.0) + activesupport + pry + puma + rake + shotgun + sinatra + sinatra-activerecord + sinatra-contrib + sqlite3 (~> 1.3.6) + tux + +BUNDLED WITH + 2.0.2 diff --git a/app/actions.rb b/app/actions.rb index e69de29bb..291114d33 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -0,0 +1,43 @@ +get '/' do + + @finstagram_posts = FinstagramPost.order(created_at: :desc) + erb(:index) + +end + +get '/signup' do #if a user navigates to the path + + @user = User.new #setup empty @user object + erb(:signup) #render "pp/views/signup.erb" + +end + + +post '/signup' do + # "Form submitted!" + +#params.to_s + +#grab user input values +email = params[:email] +avatar_url = params[:avatar_url] +username = params[:username] +password = params[:password] + +#instntiate and save a User + +if email.present? && avatar_url.present? && username.present? && password.present? + +#instantiate and save a user + user = User.new({email: email, avatar_url:avatar_url, username: username, password: password}) + user.save + +#return readable representation of user objectc +escape_html user.inspect + +else + +#display simple error +"Validation failed" +end +end diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 000000000..6e1dad549 --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,5 @@ +class Comment < ActiveRecord::Base + + belongs_to :user + belongs_to :finstagram_post +end diff --git a/app/models/finstagram_post.rb b/app/models/finstagram_post.rb new file mode 100644 index 000000000..c89b73c8a --- /dev/null +++ b/app/models/finstagram_post.rb @@ -0,0 +1,29 @@ +class FinstagramPost < ActiveRecord::Base + + belongs_to :user + has_many :comments + has_many :likes + + validates_presence_of :user + +def humanized_time_ago + time_ago_in_seconds = Time.now - self.created_at + time_ago_in_minutes = time_ago_in_seconds / 60 + + if time_ago_in_minutes >= 60 + + "#{(time_ago_in_minutes / 60).to_i} hours ago" + else + "#{time_ago_in_minutes.to_i} minutes ago" + end +end + +def like_count + self.likes.size +end + +def comment_count + self.comments.size +end + +end \ No newline at end of file diff --git a/app/models/like.rb b/app/models/like.rb new file mode 100644 index 000000000..ffffd39f8 --- /dev/null +++ b/app/models/like.rb @@ -0,0 +1,5 @@ +class Like +

Finstagram

+ +
+ <% @finstagram_posts.each do |finstagram_post| %> +
+ + + finstagram post from <%= finstagram_post.user.username %> + +
+ <%= finstagram_post.like_count %> likes + <%= finstagram_post.comment_count %> comments +
+
    + <% finstagram_post.comments.each do |comment| %> +
  • +

    + <%= comment.user.username %>: <%= comment.text %> +

    +
  • + <% end %> +
+
+ <% end %> +
\ No newline at end of file diff --git a/app/views/index.html b/app/views/index.html index e69de29bb..517b16227 100644 --- a/app/views/index.html +++ b/app/views/index.html @@ -0,0 +1,101 @@ + + + + + Finstagram + + + + + + + + + + Finstagram + + +
+

Finstagram

+
+
+
+ + + post from sharky_j + +
+ 0 likes + 0 comments +
+
    +
  • +

    + sharky_j: Out for the long weekend... too embarrassed to show y'all the beach bod! +

    +
  • +
+
+ +
+ + + finstagram post from kirk_whalum + +
+0 likes +0 comments +
+
    +
  • +

    + kirk_whalum: #weekendvibes +

    +
  • +
+
+ +
+ + + finstagram post from marlin_peppa + +
+ 0 likes + 0 comments +
+
    +
  • +

    + marlin_peppa: lunchtime! ;) +

    +
  • +
+
+ + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/app/views/signup.erb b/app/views/signup.erb new file mode 100644 index 000000000..4a918b654 --- /dev/null +++ b/app/views/signup.erb @@ -0,0 +1,28 @@ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ +
+ + +
\ No newline at end of file diff --git a/app/views/type.html b/app/views/type.html new file mode 100644 index 000000000..b0c719b32 --- /dev/null +++ b/app/views/type.html @@ -0,0 +1,28 @@ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ +
+ + +
\ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 000000000..c2f2d7cd9 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,47 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 0) do + + create_table "comments", force: :cascade do |t| + t.integer "user_id" + t.integer "finstagram_post_id" + t.text "text" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "finstagram_posts", force: :cascade do |t| + t.integer "user_id" + t.string "photo_url" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "likes", force: :cascade do |t| + t.integer "user_id" + t.integer "finstagram_post_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "users", force: :cascade do |t| + t.string "username" + t.string "avatar_url" + t.string "email" + t.string "password" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/public/stylesheets/app.css b/public/stylesheets/app.css index e69de29bb..5122f2e5f 100755 --- a/public/stylesheets/app.css +++ b/public/stylesheets/app.css @@ -0,0 +1,32 @@ +header{ + background-color: #244751; + color: #E8FDFF; +} + +body{ + background-color: whitesmoke; +font-family: 'Calistoga', cursive; + +} + +main { + background-color: white; + padding: 16px; +} + +.finstagram-post{ + margin-bottom: 48px; +} + + +.finstagram-post .user-info img { + border-radius: 50%; +} + +a.photo{ + transition: padding 0.5s; +} + +a.photo:hover{ + padding: 10px; +} diff --git a/public/stylesheets/lib.css b/public/stylesheets/lib.css index 6eef9fd0b..5d8e705cb 100644 --- a/public/stylesheets/lib.css +++ b/public/stylesheets/lib.css @@ -113,7 +113,9 @@ main { } .form-group { - margin-bottom: 1em; + +font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif + margin-bottom: 5px; } .new-comment input[type="text"] { diff --git a/test.html b/test.html new file mode 100644 index 000000000..e69de29bb