life-story 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +136 -0
- data/LICENSE +21 -0
- data/README.md +40 -0
- data/Rakefile +8 -0
- data/app/controllers/application_controller.rb +31 -0
- data/app/controllers/story_controller.rb +101 -0
- data/app/controllers/user_controller.rb +59 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/category.rb +4 -0
- data/app/models/concerns/slugifiable.rb +13 -0
- data/app/models/story.rb +8 -0
- data/app/models/user.rb +12 -0
- data/app/models/user_story.rb +4 -0
- data/app/views/layout.erb +42 -0
- data/app/views/stories/edit.erb +51 -0
- data/app/views/stories/new.erb +47 -0
- data/app/views/stories/show.erb +46 -0
- data/app/views/stories/show_by_category.erb +27 -0
- data/app/views/stories/show_by_date.erb +27 -0
- data/app/views/stories/show_by_users.erb +29 -0
- data/app/views/users/signup.erb +36 -0
- data/app/views/welcome.erb +51 -0
- data/config.ru +10 -0
- data/config/environment.rb +12 -0
- data/db/development.sqlite +0 -0
- data/db/migrate/20200118192302_create_users.rb +9 -0
- data/db/migrate/20200118192313_create_categories.rb +7 -0
- data/db/migrate/20200118192321_create_stories.rb +10 -0
- data/db/migrate/20200118201120_create_user_stories.rb +8 -0
- data/db/schema.rb +38 -0
- data/db/seeds.rb +39 -0
- data/development.sqlite +0 -0
- data/lib/.gitkeep +0 -0
- data/life-story.gemspec +46 -0
- data/public/favicon.ico +0 -0
- data/public/images/.gitkeep +0 -0
- data/public/images/life-story.png +0 -0
- data/public/javascripts/.gitkeep +0 -0
- data/public/stylesheets/main.css +246 -0
- metadata +204 -0
data/app/models/.gitkeep
ADDED
File without changes
|
data/app/models/story.rb
ADDED
data/app/models/user.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative './concerns/slugifiable.rb'
|
2
|
+
|
3
|
+
class User < ActiveRecord::Base
|
4
|
+
extend Slugifiable::ClassMethods
|
5
|
+
include Slugifiable::InstanceMethods
|
6
|
+
|
7
|
+
has_many :user_stories
|
8
|
+
has_many :stories, through: :user_stories
|
9
|
+
has_many :categories, through: :stories
|
10
|
+
|
11
|
+
has_secure_password
|
12
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
|
3
|
+
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
|
4
|
+
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
|
5
|
+
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
|
6
|
+
<head>
|
7
|
+
<meta charset="utf-8" />
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
|
9
|
+
|
10
|
+
<title>LifeStory</title>
|
11
|
+
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
13
|
+
|
14
|
+
<link rel="stylesheet" href="/stylesheets/main.css" />
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
<div class="wrapper">
|
18
|
+
|
19
|
+
<% flash.keys.each do |type| %>
|
20
|
+
<div data-alert class="flash <%= type %> alert-box radius">
|
21
|
+
<%= flash[type] %>
|
22
|
+
<a href="#" class="close">×</a>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<%= yield %>
|
27
|
+
|
28
|
+
<footer class="branding">
|
29
|
+
<small>© 2020 <strong>LifeStory</strong></small>
|
30
|
+
<% if logged_in? %>
|
31
|
+
<a href="/logout">Log out</a>
|
32
|
+
<% end %>
|
33
|
+
</footer>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
37
|
+
<!--[if lt IE 7]>
|
38
|
+
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"></script>
|
39
|
+
<script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})})</script>
|
40
|
+
<![endif]-->
|
41
|
+
</body>
|
42
|
+
</html>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<header><img src="/images/life-story.png" class="img-responsive main-image"></header>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
<h2>Edit your story</h2>
|
5
|
+
|
6
|
+
<div class="content">
|
7
|
+
<form action="/stories/<%= @story.id %>" method="post" id="new">
|
8
|
+
<input type="hidden" id="hidden" name="_method" value="patch">
|
9
|
+
This is a story about <select id="category" name="category" required>
|
10
|
+
<option value="<%= @story.category_id %>" selected><%= @story.category.name %></option>
|
11
|
+
<% Category.all.reject {|c| c.id == @story.category_id }.each do |category| %>
|
12
|
+
<option value="<%= category.id %>"><%= category.name %></option>
|
13
|
+
<% end %>
|
14
|
+
</select>.<br>
|
15
|
+
|
16
|
+
I <input type="text" name="summary" id="summary" value="<%= @story.summary %>" style="width:60%" required>.<br>
|
17
|
+
|
18
|
+
It happened on <input type="date" id="date" name="date" value="<%= @story.date %>" style="width:30%" required>. <br>
|
19
|
+
|
20
|
+
<textarea name="description" style="width:90%; height:400px;" required><%= @story.description %></textarea><br>
|
21
|
+
|
22
|
+
I want <select id="user" name="users[]" style="width:25%">
|
23
|
+
<option hidden disabled selected value>None</option>
|
24
|
+
<% User.all.reject {|u| u.id == current_user.id }.each do |user| %>
|
25
|
+
<option value = "<%= user.id %>"><%= user.username %></option>
|
26
|
+
<% end %>
|
27
|
+
</select> and
|
28
|
+
|
29
|
+
<select id="user" name="users[]" style="width:25%">
|
30
|
+
<option hidden disabled selected value>None</option>
|
31
|
+
<% User.all.reject {|u| u.id == current_user.id }.each do |user| %>
|
32
|
+
<option value = "<%= user.id %>"><%= user.username %></option>
|
33
|
+
<% end %>
|
34
|
+
</select> to be a part of this story.<br>
|
35
|
+
|
36
|
+
<button type="submit" value="submit" style="padding:18px 64px; margin:18px 0">Update story</button>
|
37
|
+
</form>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="sidebar">
|
41
|
+
<ul>
|
42
|
+
<li><a href="/stories/<%= @story.id %>">Back to story</a></li>
|
43
|
+
<li><a href="/new">New story</a></li>
|
44
|
+
<li><a href="/users/<%= current_user.slug %>">View my stories</a></li>
|
45
|
+
<li><a href="/">Back to homepage</a></li>
|
46
|
+
<li><a href="/logout">Log out</a></li>
|
47
|
+
</ul>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
</div>
|
51
|
+
</div>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<header><img src="/images/life-story.png" class="img-responsive main-image"></header>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
<h2>Write your story</h2>
|
5
|
+
|
6
|
+
<div class="content">
|
7
|
+
<form action="/" method="post" id="new">
|
8
|
+
This is a story about <select id="category" name="category" required>
|
9
|
+
<% Category.all.each do |category| %>
|
10
|
+
<option value = "<%= category.id %>"><%= category.name %></option>
|
11
|
+
<% end %>
|
12
|
+
</select>.<br>
|
13
|
+
|
14
|
+
I <input type="text" id="summary" name="summary" placeholder="did something" style="width:60%" required>.<br>
|
15
|
+
|
16
|
+
It happened on <input type="date" id="date" name="date" style="width:30%" required>.<br>
|
17
|
+
|
18
|
+
<textarea name="description" placeholder="I feel.." style="width:90%; height:400px;" required></textarea>.<br>
|
19
|
+
|
20
|
+
I want <select id="user" name="users[]" style="width:25%">
|
21
|
+
<option hidden disabled selected value>None</option>
|
22
|
+
<% User.all.reject {|u| u.id == current_user.id }.each do |user| %>
|
23
|
+
<option value = "<%= user.id %>"><%= user.username %></option>
|
24
|
+
<% end %>
|
25
|
+
</select> and
|
26
|
+
|
27
|
+
<select id="user" name="users[]" style="width:25%">
|
28
|
+
<option hidden disabled selected value>None</option>
|
29
|
+
<% User.all.reject {|u| u.id == current_user.id }.each do |user| %>
|
30
|
+
<option value = "<%= user.id %>"><%= user.username %></option>
|
31
|
+
<% end %>
|
32
|
+
</select> to be a part of this story.<br>
|
33
|
+
|
34
|
+
<button type="submit" value="submit" style="padding:18px 64px; margin:18px 0">Publish</button>
|
35
|
+
</form>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div class="sidebar">
|
39
|
+
<ul>
|
40
|
+
<li><a href="/new">New story</a></li>
|
41
|
+
<li><a href="/users/<%= current_user.slug %>">View my stories</a></li>
|
42
|
+
<li><a href="/">Back to homepage</a></li>
|
43
|
+
<li><a href="/logout">Log out</a></li>
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<header><img src="/images/life-story.png" class="img-responsive main-image"></header>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
<h2>Here's the story:</h2>
|
5
|
+
|
6
|
+
<div class="content">
|
7
|
+
<p style="background-color:#eee; line-height:50px;">
|
8
|
+
I <mark><%= @story.summary %></mark> on <mark><a href="/dates/<%= @story.date %>" style="font-family:sans-serif; font-size:16px; font-weight:bold; color:black"><%= @story.date %></a></mark>,
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p style="font-family:courier; font-size:14px; margin-left:50px; text-indent:50px">
|
12
|
+
"<%= @story.description %>"
|
13
|
+
</p>
|
14
|
+
|
15
|
+
<p style="text-align:center">
|
16
|
+
-- by <% @story.users.each do |user| %>
|
17
|
+
<a href="/users/<%= user.slug %>" style="font-family:sans-serif; font-size:16px; font-weight:bold; color:black"><mark><%= user.username %></a> </mark>
|
18
|
+
<% end %>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p style="text-align: right"><a href="/categories/<%= @story.category.name %>" style="font-family:sans-serif; font-size:16px; font-weight:bold; color:black">Tag: <mark><%= @story.category.name %></mark></a>
|
22
|
+
</p>
|
23
|
+
|
24
|
+
<% if @story.user_ids.include?(current_user.id) %>
|
25
|
+
<form action="/stories/<%= @story.id %>" method="post" style="margin:18px 0; float:right">
|
26
|
+
<input type="hidden" id="hidden" name="_method" value="delete">
|
27
|
+
<button type="submit" value="submit" style="padding:18px 64px;">Delete Story</button>
|
28
|
+
</form>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="sidebar">
|
34
|
+
<ul>
|
35
|
+
<% if @story.user_ids.include?(current_user.id) %>
|
36
|
+
<li><a href="/stories/<%= @story.id %>/edit">Edit story</a></li>
|
37
|
+
<% end %>
|
38
|
+
<li><a href="/new">New story</a></li>
|
39
|
+
<li><a href="/users/<%= current_user.slug %>">View my stories</a></li>
|
40
|
+
<li><a href="/">Back to homepage</a></li>
|
41
|
+
<li><a href="/logout">Log out</a></li>
|
42
|
+
</ul>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
</div>
|
46
|
+
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<header><img src="/images/life-story.png" class="img-responsive main-image"></header>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
<h2>Stories about <mark><%= @category.name %></mark></h2>
|
5
|
+
|
6
|
+
<div class="content">
|
7
|
+
<% @category.stories.all.order("date desc").each do |story| %>
|
8
|
+
<p id="stories" onclick="location.href='/stories/<%= story.id %>'">
|
9
|
+
<% story.users.each do |user| %>
|
10
|
+
<mark><%= user.username %>,</mark>
|
11
|
+
<% end %>
|
12
|
+
recorded something about their <mark><%= story.category.name %></mark> happened on <mark><%= story.date %></mark>.
|
13
|
+
</p>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="sidebar">
|
18
|
+
<ul>
|
19
|
+
<li><a href="/new">New story</a></li>
|
20
|
+
<li><a href="/users/<%= current_user.slug %>">View my stories</a></li>
|
21
|
+
<li><a href="/">Back to homepage</a></li>
|
22
|
+
<li><a href="/logout">Log out</a></li>
|
23
|
+
</ul>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
</div>
|
27
|
+
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<header><img src="/images/life-story.png" class="img-responsive main-image"></header>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
<h2>Stories happened on <mark><%= @date %></mark></h2>
|
5
|
+
|
6
|
+
<div class="content">
|
7
|
+
<% Story.all.select {|s| s.date == @date}.each do |story| %>
|
8
|
+
<p id="stories" onclick="location.href='/stories/<%= story.id %>'">
|
9
|
+
<% story.users.each do |user| %>
|
10
|
+
<mark><%= user.username %>,</mark>
|
11
|
+
<% end %>
|
12
|
+
recorded something about their <mark><%= story.category.name %></mark> happened on <mark><%= story.date %></mark>.
|
13
|
+
</p>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="sidebar">
|
18
|
+
<ul>
|
19
|
+
<li><a href="/new">New story</a></li>
|
20
|
+
<li><a href="/users/<%= current_user.slug %>">View my stories</a></li>
|
21
|
+
<li><a href="/">Back to homepage</a></li>
|
22
|
+
<li><a href="/logout">Log out</a></li>
|
23
|
+
</ul>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
</div>
|
27
|
+
</div>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<header><img src="/images/life-story.png" class="img-responsive main-image"></header>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
<h2><mark><%= @user.username %></mark>'s stories:</h2>
|
5
|
+
|
6
|
+
<div class="content">
|
7
|
+
<% @user.stories.all.order("date desc").each do |story| %>
|
8
|
+
<p id="stories" onclick="location.href='/stories/<%= story.id %>'">
|
9
|
+
<% story.users.each do |user| %>
|
10
|
+
<mark><%= user.username %>,</mark>
|
11
|
+
<% end %>
|
12
|
+
recorded something about their <mark><%= story.category.name %></mark> happened on <mark><%= story.date %></mark>.
|
13
|
+
</p>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="sidebar">
|
18
|
+
<ul>
|
19
|
+
<li><a href="/new">New story</a></li>
|
20
|
+
<li><a href="/users/<%= current_user.slug %>">View my stories</a></li>
|
21
|
+
<li><a href="/">Back to homepage</a></li>
|
22
|
+
<li><a href="/logout">Log out</a></li>
|
23
|
+
</ul>
|
24
|
+
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
</div>
|
29
|
+
</div>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<header><img src="/images/life-story.png" class="img-responsive main-image"></header>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
<h2>Create your own account:</h2>
|
5
|
+
<div class="content">
|
6
|
+
|
7
|
+
|
8
|
+
<form action="/signup" method="post">
|
9
|
+
<label for="username">Usermame:</label>
|
10
|
+
<input type="text" id="username" name="username" required>
|
11
|
+
|
12
|
+
<label for="email">Email:</label>
|
13
|
+
<input type="text" id="email" name="email" required>
|
14
|
+
|
15
|
+
<label for="password">Password:</label>
|
16
|
+
<input type="text" id="password" name="password" required>
|
17
|
+
|
18
|
+
<button type="submit" value="submit">Sign up</button>
|
19
|
+
</form>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div class="sidebar">
|
23
|
+
<h3>Already have an account?</h3><br>
|
24
|
+
<form action="/login" method="post">
|
25
|
+
<label for="username">Usermame:</label>
|
26
|
+
<input type="text" id="username" name="username" required>
|
27
|
+
|
28
|
+
<label for="password">Password:</label>
|
29
|
+
<input type="text" id="password" name="password" required>
|
30
|
+
|
31
|
+
<button type="submit" value="submit">Log in</button>
|
32
|
+
</form>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
</div>
|
36
|
+
</div>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<header><img src="/images/life-story.png" class="img-responsive main-image"></header>
|
3
|
+
<div class="col-md-8 col-md-offset-2">
|
4
|
+
<h2>[əˈloːˌha] !</h2>
|
5
|
+
|
6
|
+
<div class="content">
|
7
|
+
<p>Welcome to Life Story™, a place where important memories are kept.</p>
|
8
|
+
<p>We can all so easily lose focus. We grow anxious about work, about time, about some inconsequential people and their comments, yet in the end, they do not matter.</p>
|
9
|
+
<p>Let's keep us reminded of what really define us - those moments that we shared, we loved, we fought and made the right decision. </p>
|
10
|
+
|
11
|
+
<% if logged_in? %>
|
12
|
+
<h3>Here's what's been happening:</h3>
|
13
|
+
<% Story.all.order("date desc").each do |story| %>
|
14
|
+
<p id="stories" onclick="location.href='/stories/<%= story.id %>'">
|
15
|
+
<% story.users.each do |user| %>
|
16
|
+
<mark><%= user.username %>,</mark>
|
17
|
+
<% end %>
|
18
|
+
recorded something about their <mark><%= story.category.name %></mark> happened on <mark><%= story.date %></mark>.
|
19
|
+
</p>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="sidebar">
|
25
|
+
<% if !logged_in? %>
|
26
|
+
<h3>Sign in</h3><br>
|
27
|
+
<form action="/login" method="post">
|
28
|
+
<label for="username">Usermame:</label>
|
29
|
+
<input type="text" id="username" name="username" required>
|
30
|
+
|
31
|
+
<label for="password">Password:</label>
|
32
|
+
<input type="text" id="password" name="password" required>
|
33
|
+
|
34
|
+
<button type="submit" value="submit">Log in</button>
|
35
|
+
</form>
|
36
|
+
|
37
|
+
<p><a href="/signup">Don't have an account?</a></p>
|
38
|
+
|
39
|
+
<% else %>
|
40
|
+
|
41
|
+
<h3>Welcome back, <%= current_user.username %>!</h3>
|
42
|
+
<ul>
|
43
|
+
<li><a href="/new">New story</a></li>
|
44
|
+
<li><a href="/users/<%= current_user.slug %>">View my stories</a></li>
|
45
|
+
<li><a href="/logout">Log out</a></li>
|
46
|
+
</ul>
|
47
|
+
<% end %>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
</div>
|
data/config.ru
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require './config/environment'
|
2
|
+
|
3
|
+
if ActiveRecord::Migrator.needs_migration?
|
4
|
+
raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
|
5
|
+
end
|
6
|
+
|
7
|
+
use Rack::MethodOverride
|
8
|
+
use UserController
|
9
|
+
use StoryController
|
10
|
+
run ApplicationController
|
@@ -0,0 +1,12 @@
|
|
1
|
+
ENV['SINATRA_ENV'] ||= "development"
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
Bundler.require(:default, ENV['SINATRA_ENV'])
|
5
|
+
|
6
|
+
ActiveRecord::Base.establish_connection(
|
7
|
+
:adapter => "sqlite3",
|
8
|
+
:database => "db/#{ENV['SINATRA_ENV']}.sqlite"
|
9
|
+
)
|
10
|
+
|
11
|
+
require './app/controllers/application_controller'
|
12
|
+
require_all 'app'
|