Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vscode:
extensions:
- CraigMaslowski.erb@0.0.1:5znDha/nn0PphUrpB9a5Nw==
6 changes: 6 additions & 0 deletions .theia/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": []
}
93 changes: 93 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions app/actions.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Comment < ActiveRecord::Base

belongs_to :user
belongs_to :finstagram_post
end
29 changes: 29 additions & 0 deletions app/models/finstagram_post.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions app/models/like.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Like <ActiveRecord::Base

belongs_to :user
belongs_to :finstagram_post
end
7 changes: 7 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class User < ActiveRecord::Base

has_many :finstagram_posts
has_many :comments
has_many :likes

end
30 changes: 30 additions & 0 deletions app/views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<header>
<h1>Finstagram</h1>
</header>
<main role="main">
<% @finstagram_posts.each do |finstagram_post| %>
<article class="finstagram-post">
<div class="user-info">
<img src="<%= finstagram_post.user.avatar_url %>" alt="<%= finstagram_post.user.username %>">
<h2><%= finstagram_post.user.username %></h2>
<h3><%= finstagram_post.humanized_time_ago %></h3>
</div>
<a class="photo" href="#">
<img src="<%= finstagram_post.photo_url %>" alt="finstagram post from <%= finstagram_post.user.username %>">
</a>
<div class="actions">
<%= finstagram_post.like_count %> likes
<span class="comment-count"><%= finstagram_post.comment_count %> comments</span>
</div>
<ul class="comments">
<% finstagram_post.comments.each do |comment| %>
<li>
<p>
<%= comment.user.username %>: <%= comment.text %>
</p>
</li>
<% end %>
</ul>
</article>
<% end %>
</main>
101 changes: 101 additions & 0 deletions app/views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!doctype html>

<html>
<head>
<title>Finstagram</title>

<link rel="stylesheet" href="../../../stylesheets/normalize.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300italic,700italic,700,300">
<link href="https://fonts.googleapis.com/css?family=Calistoga&display=swap" rel="stylesheet">

<link rel="stylesheet" href="../../../stylesheets/lib.css">
<link rel="stylesheet" href="../../../stylesheets/app.css">


<title>Finstagram</title>
</head>
<body>
<header>
<h1>Finstagram</h1>
</header>
<main role="main">
<article class="finstagram-post">
<div class="user-info">
<img src="http://naserca.com/images/sharky_j.jpg" alt="sharky_j">
<h2>sharky_j</h2>
<h3>15 minutes ago</h3>
</div>
<a class="photo" href="#">
<img src="http://naserca.com/images/shark.png" alt="post from sharky_j">
</a>
<div class="actions">
0 likes
<span class="comment-count">0 comments</span>
</div>
<ul class="comments">
<li>
<p>
sharky_j: Out for the long weekend... too embarrassed to show y'all the beach bod!
</p>
</li>
</ul>
</article>

<article class = "finstagram-post">
<div class = "user-info">
<img src="http://naserca.com/images/kirk_whalum.jpg" alt="kirk_whalum">
<h2>kirk_whalum</h2>
<h3>1 hour ago </h3>
</div>
<a class = "photo" href="#">
<img src="http://naserca.com/images/whale.jpg" alt="finstagram post from kirk_whalum">
</a>
<div class="actions">
0 likes
<span class="comment-count">0 comments</span>
</div>
<ul class = "comments">
<li>
<p>
kirk_whalum: #weekendvibes
</p>
</li>
</ul>
</article>

<article class="finstagram-post">
<div class="user-info">
<img src="http://naserca.com/images/marlin_peppa.jpg" alt="marlin_peppa">
<h2>marlin_peppa</h2>
<h3>3 hours ago</h3>
</div>
<a class="photo" href="#">
<img src="http://naserca.com/images/marlin.jpg" alt="finstagram post from marlin_peppa">
</a>
<div class="actions">
0 likes
<span class="comment-count">0 comments</span>
</div>
<ul class="comments">
<li>
<p>
marlin_peppa: lunchtime! ;)
</p>
</li>
</ul>
</article>


</main>



</body>




</html>



28 changes: 28 additions & 0 deletions app/views/signup.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<form method= "POST" action="/signup">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id = "email" name="email">
</div>

<div class="form-group">
<label for="avatar_url">Avatar URL</label>
<input type="text" id="avatar_url" name="avatar_url">
</div>

<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username">
</div>

<div class="form-group">

<label for="password">Password</label>
<input type="password" id="password" name="password">
</div>

<div class="form-group">
<button type="submit">Signup</button>
</div>


</form>
28 changes: 28 additions & 0 deletions app/views/type.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<form method= "POST" action="/signup">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id = "email" name="email">
</div>

<div class="form-group">
<label for="avatar_url">Avatar URL</label>
<input type="text" id="avatar_url" name="avater_url">
</div>

<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username">
</div>

<div class="form-group">

<label for="password">Password</label>
<input type="password" id="password" name="password">
</div>

<div class="form-group">
<button type="submit">Signup</button>
</div>


</form>
Loading