From 5532790dd6810d06dfd0c3fc914e9f6c7ead02c4 Mon Sep 17 00:00:00 2001 From: GaboCam Date: Thu, 14 Nov 2019 01:20:03 +0000 Subject: [PATCH 1/5] basic html template --- Gemfile.lock | 93 ++++++++++++++++++++++++++++++++++++++++++++ app/actions.rb | 4 ++ app/views/index.html | 53 +++++++++++++++++++++++++ test.html | 0 4 files changed, 150 insertions(+) create mode 100644 Gemfile.lock create mode 100644 test.html 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..77bbf8245 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -0,0 +1,4 @@ +get '/' do + File.read(File.join('app/views','index.html')) + +end diff --git a/app/views/index.html b/app/views/index.html index e69de29bb..cd0d32aad 100644 --- a/app/views/index.html +++ b/app/views/index.html @@ -0,0 +1,53 @@ + + + + + Finstagram + + +
+

Finstagram

+
+
+
+
+ sharky_j +

sharky_j

+

15 minutes ago

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

    + sharky_j: Out for the long weekend... too embarrassed to show + + + + + + Document + + + + + +

    +
  • +
+ + +
+ +

Finstagram

+ Finstagram + + + \ No newline at end of file diff --git a/test.html b/test.html new file mode 100644 index 000000000..e69de29bb From 23962af20b3c1843d90f01376871029f409a245a Mon Sep 17 00:00:00 2001 From: GaboCam Date: Tue, 19 Nov 2019 01:49:02 +0000 Subject: [PATCH 2/5] CSS styles --- app/views/index.html | 108 +++++++++++++++++++++++++------------ public/stylesheets/app.css | 29 ++++++++++ 2 files changed, 103 insertions(+), 34 deletions(-) diff --git a/app/views/index.html b/app/views/index.html index cd0d32aad..5ec514d99 100644 --- a/app/views/index.html +++ b/app/views/index.html @@ -3,51 +3,91 @@ Finstagram + + + + + + + + + + Finstagram

Finstagram

-
-
-
- sharky_j -

sharky_j

-

15 minutes ago

-
- - post from sharky_j - - -
0 likes - 0 comments +
+
+ + + 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 +

    +
  • +
+
-
    -
  • -

    - sharky_j: Out for the long weekend... too embarrassed to show - - - - - - Document - - - - - -

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

      + marlin_peppa: lunchtime! ;) +

      +
    +
    -
+ -

Finstagram

- Finstagram \ No newline at end of file diff --git a/public/stylesheets/app.css b/public/stylesheets/app.css index e69de29bb..bc7fc49e1 100755 --- a/public/stylesheets/app.css +++ b/public/stylesheets/app.css @@ -0,0 +1,29 @@ +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:hover{ + padding: 10px; + transition: padding 0.5s; +} \ No newline at end of file From 91375aa4f5300dc4f5f9ef85f865c4b01e92e7c4 Mon Sep 17 00:00:00 2001 From: GaboCam Date: Wed, 27 Nov 2019 04:31:44 +0000 Subject: [PATCH 3/5] W2D2 Hashes --- .theia/launch.json | 6 +++++ app/actions.rb | 51 +++++++++++++++++++++++++++++++++++++- app/views/index.erb | 18 ++++++++++++++ public/stylesheets/app.css | 7 ++++-- 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 .theia/launch.json create mode 100644 app/views/index.erb 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/app/actions.rb b/app/actions.rb index 77bbf8245..c28913545 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -1,4 +1,53 @@ + +def humanized_time_ago(time_ago_in_minutes) + if time_ago_in_minutes >= 60 + "#{time_ago_in_minutes / 60} hours ago" + else + "#{time_ago_in_minutes} minutes ago" + end +end + + + get '/' do - File.read(File.join('app/views','index.html')) + 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_post_shark, finstagram_post_whale, finstagram_post_marlin].to_s end diff --git a/app/views/index.erb b/app/views/index.erb new file mode 100644 index 000000000..1012b08bf --- /dev/null +++ b/app/views/index.erb @@ -0,0 +1,18 @@ + + + + + + Document + + + <% 3.times do %> + <%= @example_string + "
" %> + <% end %> + + <%= "

one more " + @example_string + "

" %> + + + + + \ No newline at end of file diff --git a/public/stylesheets/app.css b/public/stylesheets/app.css index bc7fc49e1..5122f2e5f 100755 --- a/public/stylesheets/app.css +++ b/public/stylesheets/app.css @@ -23,7 +23,10 @@ main { border-radius: 50%; } +a.photo{ + transition: padding 0.5s; +} + a.photo:hover{ padding: 10px; - transition: padding 0.5s; -} \ No newline at end of file +} From 589bdd6575ba341764efa826a9b23aff7e4f47de Mon Sep 17 00:00:00 2001 From: GaboCam Date: Thu, 28 Nov 2019 01:46:37 +0000 Subject: [PATCH 4/5] W3D2 dataBase --- app/actions.rb | 57 +++++------------------------------ app/models/finstagram_post.rb | 3 ++ app/models/user.rb | 3 ++ db/schema.rb | 47 +++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 49 deletions(-) create mode 100644 app/models/finstagram_post.rb create mode 100644 app/models/user.rb create mode 100644 db/schema.rb diff --git a/app/actions.rb b/app/actions.rb index c28913545..47997f0a5 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -1,53 +1,12 @@ - -def humanized_time_ago(time_ago_in_minutes) - if time_ago_in_minutes >= 60 - "#{time_ago_in_minutes / 60} hours ago" - else - "#{time_ago_in_minutes} minutes ago" - end -end - - - 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! ;)" - }] - } + x=3 + y=5 + + (x+y).to_s - [finstagram_post_shark, finstagram_post_whale, finstagram_post_marlin].to_s +(1..10).each do |i| + i.to_s end + +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..79708781a --- /dev/null +++ b/app/models/finstagram_post.rb @@ -0,0 +1,3 @@ +class FinstagramPost < ActiveRecord::Base + +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..3ef3abac2 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,3 @@ +class User < ActiveRecord::Base + +end \ 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 From abe8e2df52412bfb71e8f7a497ce4570140afd8d Mon Sep 17 00:00:00 2001 From: GaboCam Date: Thu, 5 Dec 2019 01:55:16 +0000 Subject: [PATCH 5/5] W4D2 added form POST submit --- .gitpod.yml | 3 +++ app/actions.rb | 45 +++++++++++++++++++++++++++----- app/models/comment.rb | 5 ++++ app/models/finstagram_post.rb | 26 +++++++++++++++++++ app/models/like.rb | 5 ++++ app/models/user.rb | 4 +++ app/views/index.erb | 48 ++++++++++++++++++++++------------- app/views/index.html | 10 +++++++- app/views/signup.erb | 28 ++++++++++++++++++++ app/views/type.html | 28 ++++++++++++++++++++ public/stylesheets/lib.css | 4 ++- 11 files changed, 179 insertions(+), 27 deletions(-) create mode 100644 .gitpod.yml create mode 100644 app/models/comment.rb create mode 100644 app/models/like.rb create mode 100644 app/views/signup.erb create mode 100644 app/views/type.html 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/app/actions.rb b/app/actions.rb index 47997f0a5..291114d33 100755 --- a/app/actions.rb +++ b/app/actions.rb @@ -1,12 +1,43 @@ get '/' do - x=3 - y=5 - - (x+y).to_s + @finstagram_posts = FinstagramPost.order(created_at: :desc) + erb(:index) -(1..10).each do |i| - i.to_s end -end \ No newline at end of file +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 index 79708781a..c89b73c8a 100644 --- a/app/models/finstagram_post.rb +++ b/app/models/finstagram_post.rb @@ -1,3 +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 - - - - - Document - - - <% 3.times do %> - <%= @example_string + "
" %> - <% end %> - - <%= "

one more " + @example_string + "

" %> - - - - - \ No newline at end of file +
+

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 5ec514d99..517b16227 100644 --- a/app/views/index.html +++ b/app/views/index.html @@ -88,6 +88,14 @@

3 hours ago

+ + - \ No newline at end of file + + + + + + + \ 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/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"] {