From 2831f35593a31890a467ac08578ea2b72fb1a881 Mon Sep 17 00:00:00 2001 From: tanyacode Date: Thu, 14 Nov 2019 01:19:32 +0000 Subject: [PATCH 01/13] stage all files --- Gemfile.lock | 93 ++++++++++++++++++++++++++++++++++++++++++++ app/actions.rb | 3 ++ app/views/index.html | 35 +++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 Gemfile.lock 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..a79f85f32 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -0,0 +1,3 @@ +get '/' do + File.read(File.join('app/views', 'index.html')) +end \ No newline at end of file diff --git a/app/views/index.html b/app/views/index.html index e69de29bb..3965eb34c 100644 --- a/app/views/index.html +++ b/app/views/index.html @@ -0,0 +1,35 @@ + + + + + + + Finstagram + +
+

Finstagram

+
+<
+
+
+ sharky_j +

sharky_j

+

15 minutes ago

+
+ + 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! +

    +
  • +
+
+ + \ No newline at end of file From c5fe240c67a7cb478dcf22939132b7be714bbdc2 Mon Sep 17 00:00:00 2001 From: tanyacode Date: Wed, 20 Nov 2019 16:22:28 +0000 Subject: [PATCH 02/13] update index.html --- app/views/index.html | 98 +++++++++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 25 deletions(-) diff --git a/app/views/index.html b/app/views/index.html index 3965eb34c..74f4eb659 100644 --- a/app/views/index.html +++ b/app/views/index.html @@ -4,32 +4,80 @@ + Finstagram -
-

Finstagram

-
-<
-
-
- sharky_j -

sharky_j

-

15 minutes ago

-
- - 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

+ +
+ +
+ + + 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 From e5f86eb80274992857799ce86614df0b4cfaf1c3 Mon Sep 17 00:00:00 2001 From: tanyacode Date: Wed, 20 Nov 2019 18:06:46 +0000 Subject: [PATCH 03/13] added css styles --- app/views/index.html | 5 +++-- public/stylesheets/app.css | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/views/index.html b/app/views/index.html index 74f4eb659..689f0ac08 100644 --- a/app/views/index.html +++ b/app/views/index.html @@ -3,6 +3,7 @@ + Finstagram @@ -16,7 +17,7 @@

Finstagram

@@ -38,7 +39,7 @@

15 minutes ago

diff --git a/public/stylesheets/app.css b/public/stylesheets/app.css index e69de29bb..53151cc1d 100755 --- a/public/stylesheets/app.css +++ b/public/stylesheets/app.css @@ -0,0 +1,36 @@ +header { + background-color: #244751; + color: #E8FDFF; +} + +body { + background-color: whitesmoke; +} +main { + background-color: white; + padding: 16px; +} + + +.my-class-name finstagram-post { + margin-bottom: 48px; +} +#tanya { color: violet } + +.finstagram-post .user-info img { + border-radius: 100%; +} +body { + font-family: 'Pacifico', cursive; +} + +h3 {color: brown} +h2 {color: black} +a.photo:hover{ + padding: 10px; transition: padding 0.5s; } +a.photo{ + transition: padding 0.5s; + } + a.photo:hover{ + padding: 10px; + } \ No newline at end of file From c3c25dec8d94ddb1362d6ff5c6547ef0ce093f29 Mon Sep 17 00:00:00 2001 From: tanyacode Date: Thu, 28 Nov 2019 02:02:07 +0000 Subject: [PATCH 04/13] create fin --- .gitpod.yml | 4 +++ app/actions.rb | 57 ++++++++++++++++++++++++++++++++++++-- app/views/index.erb | 28 +++++++++++++++++++ app/views/index.html | 6 ++-- app/views/layout.erb | 12 ++++++++ public/stylesheets/app.css | 36 ++++++++++++++++++++++++ 6 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 .gitpod.yml create mode 100644 app/views/index.erb create mode 100644 app/views/layout.erb diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 000000000..befe419f2 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,4 @@ +vscode: + extensions: + - CraigMaslowski.erb@0.0.1:5znDha/nn0PphUrpB9a5Nw== + - rebornix.ruby@0.26.0:RN+gv0dPjYfMqlcEEralhg== \ No newline at end of file diff --git a/app/actions.rb b/app/actions.rb index a79f85f32..76a21bfb0 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -1,3 +1,56 @@ get '/' do - File.read(File.join('app/views', 'index.html')) -end \ No newline at end of file + def humanized_time_ago(minutes) + return minutes + # your previous finstagram post code is up here + # add the following @finstagram_posts line + + @finstagram_posts = [@finstagram_post_shark, @finstagram_post_whale, @finstagram_post_marlin] + + + end + @finstagram_post_shark = { + username: "sharky_j", + avatar_url: "http://naserca.com/images/sharky_j.jpg", + photo_url: "http://naserca.com/images/shark.jpg", + humanized_time_ago: humanized_time_ago(15), + like_count: 0, + comment_count: 1, + comments: [{ + username: "sharky_j", + text: "Out for the long weekend... too embarrassed to show y'all the beach bod!" + }] + } + + @finstagram_post_whale = { + username: "kirk_whalum", + avatar_url: "http://naserca.com/images/kirk_whalum.jpg", + photo_url: "http://naserca.com/images/whale.jpg", + humanized_time_ago: humanized_time_ago(65), + like_count: 0, + comment_count: 1, + comments: [{ + username: "kirk_whalum", + text: "#weekendvibes" + }] + } + + @finstagram_post_marlin = { + username: "marlin_peppa", + avatar_url: "http://naserca.com/images/marlin_peppa.jpg", + photo_url: "http://naserca.com/images/marlin.jpg", + humanized_time_ago: humanized_time_ago(190), + like_count: 0, + comment_count: 1, + comments: [{ + username: "marlin_peppa", + text: "lunchtime! ;)" + }] + } + + + @finstagram_posts = [@finstagram_post_shark, @finstagram_post_whale, @finstagram_post_marlin] + + + + erb(:index) +end diff --git a/app/views/index.erb b/app/views/index.erb new file mode 100644 index 000000000..7c085977a --- /dev/null +++ b/app/views/index.erb @@ -0,0 +1,28 @@ +
+

Finstagram

+
+
+ <% @finstagram_posts.each do |finstagram_post| %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/index.html b/app/views/index.html index 74f4eb659..469ec3a18 100644 --- a/app/views/index.html +++ b/app/views/index.html @@ -3,6 +3,7 @@ + Finstagram @@ -16,7 +17,7 @@

Finstagram

+<%= example string %> \ No newline at end of file diff --git a/app/views/layout.erb b/app/views/layout.erb new file mode 100644 index 000000000..6db5af6e5 --- /dev/null +++ b/app/views/layout.erb @@ -0,0 +1,12 @@ + + + + + + + Finstagram + + + <%= yield %> + + \ No newline at end of file diff --git a/public/stylesheets/app.css b/public/stylesheets/app.css index e69de29bb..53151cc1d 100755 --- a/public/stylesheets/app.css +++ b/public/stylesheets/app.css @@ -0,0 +1,36 @@ +header { + background-color: #244751; + color: #E8FDFF; +} + +body { + background-color: whitesmoke; +} +main { + background-color: white; + padding: 16px; +} + + +.my-class-name finstagram-post { + margin-bottom: 48px; +} +#tanya { color: violet } + +.finstagram-post .user-info img { + border-radius: 100%; +} +body { + font-family: 'Pacifico', cursive; +} + +h3 {color: brown} +h2 {color: black} +a.photo:hover{ + padding: 10px; transition: padding 0.5s; } +a.photo{ + transition: padding 0.5s; + } + a.photo:hover{ + padding: 10px; + } \ No newline at end of file From f11e8d86d1b4b66131134140e508311628f08ff3 Mon Sep 17 00:00:00 2001 From: tanyacode Date: Tue, 3 Dec 2019 01:22:01 +0000 Subject: [PATCH 05/13] vizualization database --- .gitignore | 3 ++- app/actions.rb | 31 ++++++++++++------------------ app/models/user.rb | 3 +++ app/views/index.erb | 12 +++++++----- db/schema.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 app/models/user.rb create mode 100644 db/schema.rb diff --git a/.gitignore b/.gitignore index 0e9472f6a..966efe1ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -db/db.sqlite3 \ No newline at end of file +db/db.sqlite3 +finstagram_post = FinstagramPost.new({ photo_url: "http://naserca.com/images/shark.jpg" }) \ No newline at end of file diff --git a/app/actions.rb b/app/actions.rb index 76a21bfb0..620f5d2df 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -1,25 +1,18 @@ get '/' do - def humanized_time_ago(minutes) - return minutes - # your previous finstagram post code is up here - # add the following @finstagram_posts line - - @finstagram_posts = [@finstagram_post_shark, @finstagram_post_whale, @finstagram_post_marlin] + - - end @finstagram_post_shark = { - username: "sharky_j", - avatar_url: "http://naserca.com/images/sharky_j.jpg", - photo_url: "http://naserca.com/images/shark.jpg", - humanized_time_ago: humanized_time_ago(15), - like_count: 0, - comment_count: 1, - comments: [{ - username: "sharky_j", - text: "Out for the long weekend... too embarrassed to show y'all the beach bod!" - }] - } + username: "sharky_j", + avatar_url: "http://naserca.com/images/sharky_j.jpg", + photo_url: "http://naserca.com/images/shark.jpg", + humanized_time_ago: humanized_time_ago(15), + like_count: 0, + comment_count: 1, + comments: [{ + username: "sharky_j", + text: "Out for the long weekend... too embarrassed to show y'all the beach bod!" + }] +} @finstagram_post_whale = { username: "kirk_whalum", diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..0a476d020 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,3 @@ +class FinstagramPost < ActiveRecord::Base + +end \ No newline at end of file diff --git a/app/views/index.erb b/app/views/index.erb index 7c085977a..d8ca7ce60 100644 --- a/app/views/index.erb +++ b/app/views/index.erb @@ -17,11 +17,13 @@ <%= finstagram_post[:comment_count] %> comment
    -
  • -

    - <%= finstagram_post[:comments][0][:username] %>: <%= finstagram_post[:comments][0][:text] %> -

    -
  • + <% finstagram_post[:comments].each do |comment| %> +
  • +

    + <%= comment[:username] %>: <%= comment[:text] %> +

    +
  • + <% end %>
<% end %> 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 From 77559e7623f594bb9d4ac99635c24d0eab79a2b2 Mon Sep 17 00:00:00 2001 From: tanyacode Date: Mon, 9 Dec 2019 22:00:44 +0000 Subject: [PATCH 06/13] add db --- .gitignore | 5 +++-- db/db.sqlite3 | Bin 0 -> 32768 bytes 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 db/db.sqlite3 diff --git a/.gitignore b/.gitignore index 966efe1ad..0a476d020 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -db/db.sqlite3 -finstagram_post = FinstagramPost.new({ photo_url: "http://naserca.com/images/shark.jpg" }) \ No newline at end of file +class FinstagramPost < ActiveRecord::Base + +end \ No newline at end of file diff --git a/db/db.sqlite3 b/db/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..4df32e394588a239a2a869628e4126a49534b374 GIT binary patch literal 32768 zcmeI)Z*S5-90%|g*viz2i4Xc{$)%4*CjZ7vlxQMqV~C7x2vPJwbHWX}(ZYJiHXkzI zf!Uk$jqHg}{IwfKST-}GdqBPy`tRE7-S2Z(k_##CcB-xtYY1!J0~ zC1^>~GD(ZH6Xs2lKH0fuo6xfP(lT9O-1W88w^Z`}+Vc11*u4xLB0&HG5P$##AOHaf zKw!=V#?K7HG)?{Fz2cwyqVMht8Lg79>UOzdvqt%4)n-I@_*S zHp}%Eduz8?x!KsN)Tq#=U2Cw~7A?(c^%1j1QUp#|%Jr4#ih#0qU0*8R4Y=nF2U5+P zZ3luY(Q&x4ScmqM>xu9_!|-4_J3X#18s^H1esUBwzdi6g;VU`W8q+~cvTr92C5|bA za80ehQBaKq!^~v#lTT4lGg@-?cyT(&+0*|j*kNy=2F@txTkMbr?H&(%@+M(zCl<}M zHN6!DB@g;E%X6eS7zw{EW)2soLYg_b>T?@?;*N4$P!;vPVRbr}qGz8^e zJA~E!9y34WiU+e2!sG4~&5%oZGze(m{~g!Zh#BVdoIcLEen%XSe3z&k+3rzIj_1afB*y_009U<00Izz00bZa0SL^WKwOWd@^>gM%>U=F za}f~)AOHafKmY;|fB*y_009U<;6fk~Pc7xofB!$#Qm1f%00bZa0SG_<0uX=z1Rwwb z2teRA1@`o$w$jqHa#_-QANyaNy`ECTQZDCndgr3ev-D<7&h>a#$lT;00bZa0SG_<0uX=z1Rwx` z|1Xf# Date: Mon, 9 Dec 2019 22:15:18 +0000 Subject: [PATCH 07/13] add signup --- app/views/signup.erb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 app/views/signup.erb diff --git a/app/views/signup.erb b/app/views/signup.erb new file mode 100644 index 000000000..bf3c87178 --- /dev/null +++ b/app/views/signup.erb @@ -0,0 +1,21 @@ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
\ No newline at end of file From a119b96cbcfee2efeb34d97231ac6724c89fab5a Mon Sep 17 00:00:00 2001 From: tanyacode Date: Mon, 16 Dec 2019 21:02:06 +0000 Subject: [PATCH 08/13] add db, actions, models --- app/actions.rb | 25 ++++++++++++++++++++++++- app/models/comment.rb | 3 +++ app/models/like.rb | 3 +++ app/views/login.erb | 13 +++++++++++++ db/db.sqlite3 | Bin 32768 -> 32768 bytes 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 app/models/comment.rb create mode 100644 app/models/like.rb create mode 100644 app/views/login.erb diff --git a/app/actions.rb b/app/actions.rb index 620f5d2df..56c771e8c 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -1,7 +1,7 @@ get '/' do - @finstagram_post_shark = { +@finstagram_post_shark = { username: "sharky_j", avatar_url: "http://naserca.com/images/sharky_j.jpg", photo_url: "http://naserca.com/images/shark.jpg", @@ -47,3 +47,26 @@ erb(:index) end + +get '/' do + @finstagram_posts = FinstagramPost.order(created_at: :desc) + erb(:index) +end + +post '/login' do + username = params[:username] + password = params[:password] + + user = User.find_by(username: username) + + if user && user.password == password + "Success!" + else + "Login failed." + end +end + +get '/signup' do # if a user navigates to the path "/signup", + @user = User.new # setup empty @user object + erb(:signup) # render "app/views/signup.erb" +end \ No newline at end of file diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 000000000..eab118afe --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,3 @@ +class Comment < ActiveRecord::Base + +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..e043b1829 --- /dev/null +++ b/app/models/like.rb @@ -0,0 +1,3 @@ +class Like < ActiveRecord::Base + +end \ No newline at end of file diff --git a/app/views/login.erb b/app/views/login.erb new file mode 100644 index 000000000..85c2aca00 --- /dev/null +++ b/app/views/login.erb @@ -0,0 +1,13 @@ +
+
+ + +
+
+ + +
+
+ +
+
\ No newline at end of file diff --git a/db/db.sqlite3 b/db/db.sqlite3 index 4df32e394588a239a2a869628e4126a49534b374..2bf8cd6851310c51461eae702fa58b7f4d7c3f51 100644 GIT binary patch delta 230 zcmZo@U}|V!njp={Hc`fzk!@qb5_>LY{`(C4-}qnh-`^}KaFJh}gPB>JGbb}UwV0cU zS(Y<7KQ}iuucUbMH-A0>Hb(x<4E&pc3Rm)ndo!{#aB}K8I+kQ)7ApWzVtHzDer~Fw zk%6J5uAz~xp_zh_ft9Jbm8qGYnYp2fg#~UIUIqpRM*brV{6~O>@8Y+yVq^mv?&yf7 S!@|nYSkKhJ!qn0bw+sLlxi+x? delta 45 zcmZo@U}|V!njp={GEv5vk!54T5_>jA{%;KY-!=;dyy4&c&7V(TF-w5JW|n|I`~XD5 B4($K{ From 16edf619e6e62cbc7979a8569c465d72e649897d Mon Sep 17 00:00:00 2001 From: tanyacode Date: Mon, 16 Dec 2019 21:23:34 +0000 Subject: [PATCH 09/13] add and update models --- app/actions.rb | 50 -------------------- app/models/comment.rb | 3 ++ app/models/finstagram_post.rb | 28 +++++++++++ app/models/like.rb | 3 ++ app/models/user.rb | 6 ++- app/views/index.erb | 16 +++---- app/views/index.html | 85 ---------------------------------- app/views/signup.erb | 10 ++-- db/db.sqlite3 | Bin 32768 -> 32768 bytes 9 files changed, 52 insertions(+), 149 deletions(-) create mode 100644 app/models/finstagram_post.rb delete mode 100644 app/views/index.html diff --git a/app/actions.rb b/app/actions.rb index 56c771e8c..e0da8ae1b 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -1,53 +1,3 @@ -get '/' do - - -@finstagram_post_shark = { - username: "sharky_j", - avatar_url: "http://naserca.com/images/sharky_j.jpg", - photo_url: "http://naserca.com/images/shark.jpg", - humanized_time_ago: humanized_time_ago(15), - like_count: 0, - comment_count: 1, - comments: [{ - username: "sharky_j", - text: "Out for the long weekend... too embarrassed to show y'all the beach bod!" - }] -} - - @finstagram_post_whale = { - username: "kirk_whalum", - avatar_url: "http://naserca.com/images/kirk_whalum.jpg", - photo_url: "http://naserca.com/images/whale.jpg", - humanized_time_ago: humanized_time_ago(65), - like_count: 0, - comment_count: 1, - comments: [{ - username: "kirk_whalum", - text: "#weekendvibes" - }] - } - - @finstagram_post_marlin = { - username: "marlin_peppa", - avatar_url: "http://naserca.com/images/marlin_peppa.jpg", - photo_url: "http://naserca.com/images/marlin.jpg", - humanized_time_ago: humanized_time_ago(190), - like_count: 0, - comment_count: 1, - comments: [{ - username: "marlin_peppa", - text: "lunchtime! ;)" - }] - } - - - @finstagram_posts = [@finstagram_post_shark, @finstagram_post_whale, @finstagram_post_marlin] - - - - erb(:index) -end - get '/' do @finstagram_posts = FinstagramPost.order(created_at: :desc) erb(:index) diff --git a/app/models/comment.rb b/app/models/comment.rb index eab118afe..4d595c836 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,3 +1,6 @@ class Comment < ActiveRecord::Base + belongs_to :user + belongs_to :finstagram_post + end \ No newline at end of file diff --git a/app/models/finstagram_post.rb b/app/models/finstagram_post.rb new file mode 100644 index 000000000..864d6308e --- /dev/null +++ b/app/models/finstagram_post.rb @@ -0,0 +1,28 @@ +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 + # New Stuff Start + def like_count + self.likes.size + end + + def comment_count + self.comments.size + end + # New Stuff End +end \ No newline at end of file diff --git a/app/models/like.rb b/app/models/like.rb index e043b1829..89a3af999 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -1,3 +1,6 @@ class Like < ActiveRecord::Base + belongs_to :user + belongs_to :finstagram_post + end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 0a476d020..3b12f1f11 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,7 @@ -class FinstagramPost < ActiveRecord::Base +class User < ActiveRecord::Base + + has_many :finstagram_posts + has_many :comments + has_many :likes end \ No newline at end of file diff --git a/app/views/index.erb b/app/views/index.erb index d8ca7ce60..9241080a6 100644 --- a/app/views/index.erb +++ b/app/views/index.erb @@ -5,22 +5,22 @@ <% @finstagram_posts.each do |finstagram_post| %>
- finstagram post from <%= finstagram_post[:username] %> + finstagram post from <%= finstagram_post.user.username %>
- <%= finstagram_post[:like_count] %> likes - <%= finstagram_post[:comment_count] %> comment + <%= finstagram_post.like_count %> likes + <%= finstagram_post.comment_count %> comments
\ No newline at end of file diff --git a/app/views/shared/likes.erb b/app/views/shared/likes.erb index 156ed6978..05a997c05 100644 --- a/app/views/shared/likes.erb +++ b/app/views/shared/likes.erb @@ -26,12 +26,4 @@ <%= finstagram_post.like_count %> likes - - - - - - - - - <% end %> \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/db/db.sqlite3 b/db/db.sqlite3 index cc632ab8f326e687e2cb0b4787f838055dfa4112..b5dfa03453f384d1fe3d2b32eef09c84d9fcf94c 100644 GIT binary patch literal 36864 zcmeI5$aybn&j9eH6T;#&&g1S;9MUhh41vlq;p6Nw`lQ>TzDN@>H z`3?Ls-t@9pUVG!EpTIkBdgHh^JMGRaWEZUxNW{;lO7TYUHCOX#a#g4}n% z=-zzxA3po}KRf*Lzx?ti|MWLtb)R+uJAs|RPGBdn6W9st1a<;{-~_(;H}Bqk{`u!` zf9K6n++P-S>_7Zu9>e zJLYTy7JT>ySO51i%Knpgpa14JZ-4jiJ{t7{TGJ2LfA)PNf0+G$%h;jl=l<*E-hA=? z5#5s_`fw-zK4$4Z{n_V-!`tAaQPbFfQQp^6HZED0WItH_lkb`IgUmncBH$3<$X|aG ze)7?I|NWnSJm&{bn?8R1^n1sDbiwH#%;7_Ef7|Bh5zW#4ha|E#D!+$jh^A@n@4)f@ zVYt3|_mg*@|MvLyn`7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