Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap #1322

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e19ecb5
Set up complete
Beckyrose200 Nov 22, 2021
84b6fff
Test for likes
Beckyrose200 Nov 24, 2021
a569b20
devise login
NenehB Nov 24, 2021
e068843
added signout function and change database
NenehB Nov 24, 2021
df4c849
Merge pull request #1 from NenehB/user_sign_in
Beckyrose200 Nov 24, 2021
86801ef
sign function added
NenehB Nov 24, 2021
c1a1857
24.11.21 changes made by Marc
mbrosch3-ford Nov 24, 2021
9d937c8
login details set as home root
NenehB Nov 24, 2021
eb4341a
Trying to get button to work
Beckyrose200 Nov 25, 2021
c34d8a9
Like Button Working
Beckyrose200 Nov 25, 2021
ef8a5f5
Merge branch 'master' into creating_likes
RJ21BL Nov 25, 2021
76c953a
Merge pull request #2 from NenehB/creating_likes
RJ21BL Nov 25, 2021
2420020
User login complete
NenehB Nov 25, 2021
81eeb39
Merge branch 'master' into users
RJ21BL Nov 26, 2021
ee65c38
Merge pull request #3 from NenehB/users
RJ21BL Nov 26, 2021
f67dc0a
Posts in descending order
mbrosch3-ford Nov 26, 2021
31f2cfe
User can like a post - Test implemented
mbrosch3-ford Nov 26, 2021
4cbc9b6
Solved testing for post to be in desc order
mbrosch3-ford Nov 26, 2021
b055066
Changed db migration to remove a duplicate column
Beckyrose200 Nov 26, 2021
141070a
New table for comments
Beckyrose200 Nov 26, 2021
645f68b
User log in feature test
RJ21BL Nov 26, 2021
213f580
Adding styling
Beckyrose200 Nov 26, 2021
eb0a6c5
WIP comments featrue
mbrosch3-ford Nov 29, 2021
bb71beb
wip user can submit a comment
mbrosch3-ford Nov 29, 2021
34b6a88
Added comments onto main timeline
Beckyrose200 Nov 29, 2021
87147eb
Comments working
Beckyrose200 Nov 29, 2021
7e3cbca
Added some CSS for the comments
Beckyrose200 Nov 29, 2021
a186061
Merge pull request #4 from NenehB/user_feature_test
RJ21BL Nov 30, 2021
3a78772
personal details incomplete
NenehB Nov 30, 2021
09d5de0
removed p
Beckyrose200 Nov 30, 2021
f2e69f1
Posts/comments tests passing
mbrosch3-ford Nov 30, 2021
1ffb740
Post/comments test passing
mbrosch3-ford Nov 30, 2021
a0c308f
Merge branch 'master' into adding_comments
Beckyrose200 Nov 30, 2021
9f2b5f9
Merge pull request #5 from NenehB/adding_comments
Beckyrose200 Nov 30, 2021
1deb20a
Dates displaying
Beckyrose200 Nov 30, 2021
509bcf2
Merge branch 'master' into personal_details
NenehB Nov 30, 2021
e65ac58
Merge pull request #6 from NenehB/personal_details
NenehB Nov 30, 2021
fc3fbe7
name of user who made comment
NenehB Nov 30, 2021
5ec52f2
Removed P
Beckyrose200 Nov 30, 2021
968a894
Search function working
Beckyrose200 Nov 30, 2021
27e8587
Comments show the proper username
mbrosch3-ford Dec 1, 2021
13f2c0e
Styling added for more then 1 user
Beckyrose200 Dec 1, 2021
6251bc7
Sorted out case sensitivity for the search results
Beckyrose200 Dec 1, 2021
bee634a
Added styling to the search bar and removed redundant search bar
Beckyrose200 Dec 1, 2021
fdd2190
All bugs fixed
Beckyrose200 Dec 1, 2021
f156994
All features working
Beckyrose200 Dec 1, 2021
9c303d2
All tests passing for search function
Beckyrose200 Dec 1, 2021
f9df0ce
Merge pull request #7 from NenehB/search_bar
mbrosch3-ford Dec 1, 2021
e0bbbb9
Bootstrap
NenehB Dec 1, 2021
d0d2781
Merge branch 'master' into bootstrap
Beckyrose200 Dec 1, 2021
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
Binary file added .DS_Store
Binary file not shown.
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end


gem 'orderly'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.0'
# Use postgresql as the database for Active Record
Expand All @@ -24,7 +24,8 @@ gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bcrypt', '~> 3.1.7'
gem 'devise'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
Expand All @@ -46,3 +47,5 @@ end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'
32 changes: 31 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: https://github.com/mimemagicrb/mimemagic.git
revision: 01f92d86d15d85cfd0f20dabd025dcbd36a8a60f
ref: 01f92d86d15d85cfd0f20dabd025dcbd36a8a60f
specs:
mimemagic (0.3.5)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -58,6 +65,7 @@ GEM
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
bcrypt (3.1.16)
bindex (0.8.1)
builder (3.2.4)
byebug (11.1.3)
Expand All @@ -71,6 +79,12 @@ GEM
childprocess (3.0.0)
concurrent-ruby (1.1.9)
crass (1.0.6)
devise (4.8.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.4.4)
erubi (1.10.0)
execjs (2.7.0)
Expand All @@ -93,14 +107,17 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.5.3)
minitest (5.14.4)
nio4r (2.5.5)
nokogiri (1.11.7)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
orderly (0.1.1)
capybara (>= 1.1)
rspec (>= 2.14)
orm_adapter (0.5.0)
pg (1.2.3)
public_suffix (4.0.6)
puma (3.12.6)
Expand Down Expand Up @@ -138,6 +155,13 @@ GEM
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
Expand Down Expand Up @@ -184,6 +208,8 @@ GEM
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.1.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -200,10 +226,14 @@ PLATFORMS
ruby

DEPENDENCIES
bcrypt (~> 3.1.7)
byebug
capybara (~> 2.13)
devise
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
mimemagic!
orderly
pg
puma (~> 3.12.6)
rails (~> 6.0.0)
Expand Down
Binary file added app/.DS_Store
Binary file not shown.
Binary file added app/assets/.DS_Store
Binary file not shown.
Binary file added app/assets/images/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
*= require_tree .
*= require_self
*/

3 changes: 3 additions & 0 deletions app/assets/stylesheets/comments.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the comments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
Empty file.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/sessions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/user_sign_in.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the UserSignIn controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
Binary file added app/channels/.DS_Store
Binary file not shown.
11 changes: 11 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user

def authorize
redirect_to login_url, alert: "Not authorized" if current_user.nil?
end

end
3 changes: 3 additions & 0 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class articleController < ApplicationController
before_filter :authorize, only: [:edit, :update]
end
31 changes: 31 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class CommentsController < ApplicationController

def new
@comment = Comment.new
end

def create
@comment = Comment.create(comment: comments_params["comment"], post_id: id_params, user_id: user_params)
redirect_to posts_url
end

def index
@comment = Comment.new
end

private

def comments_params
params.require(:comment).permit(:comment)
end

def id_params
params.require(:post_id)
end

def user_params
params.require(:current_user_id)
end


end
21 changes: 20 additions & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class PostsController < ApplicationController


def new
@post = Post.new
end
Expand All @@ -9,12 +11,29 @@ def create
end

def index
@posts = Post.all
@post = Post.new
@comment = Comment.new
@posts = Post.all.order(created_at: :desc)
@posts_comments = Comment.all.order(created_at: :desc)
@users = User.all
end

def update
post = Post.find_by(id: id_params)
post.increment(:likes)
post.save
redirect_to posts_url
end


private

def post_params
params.require(:post).permit(:message)
end

def id_params
params.require(:id)
end
end

26 changes: 26 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class SessionsController < ApplicationController
def new
end

def create
@user = User.find_by(email: params[:email])
if @user && @user.authenticate(params[:password])
session[:user_id] = @user.id
redirect_to '/posts#index', notice: "Logged in!"
else
flash.now.alert = "Email or password is invalid"
render "new"
end
end

# def index
# p '+++++'
# @user = User.find_by(first_name: params[:first_name])
# p '+++++'
# end
def destroy
session[:user_id] = nil
redirect_to root_url, notice: "Logged out!"
end

end
29 changes: 29 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class UsersController < ApplicationController

def new
@user = User.new
end

def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
redirect_to '/posts#index', notice: "Thank you for signing up!"
else
render "new"
end
end

def index
if params[:search_by_user] != ""
@user_searched = User.where("lower(first_name) = ?", params[:search_by_user].downcase)
end
end

private

def user_params
params.require(:user).permit(:first_name, :surname, :email, :password, :password_confirmation, :gender, :dob)
end

end
2 changes: 2 additions & 0 deletions app/helpers/comments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CommentsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SessionsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/user_sign_in_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module UserSignInHelper
end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module UsersHelper
end
2 changes: 2 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Comment < ApplicationRecord
end
1 change: 1 addition & 0 deletions app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Post < ApplicationRecord
end

6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class User < ApplicationRecord

has_secure_password

validates_uniqueness_of :email
end
8 changes: 8 additions & 0 deletions app/models/user_sign_in.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# class UserSignIn < ApplicationRecord
# # Include default devise modules. Others available are:
# # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
# devise :database_authenticatable, :registerable,
# :recoverable, :rememberable, :validatable
# end

#file not in use
1 change: 1 addition & 0 deletions app/views/comments/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

27 changes: 27 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<%= favicon_link_tag asset_path('favicon.ico') %>

<title>Acebook</title>
<%= csrf_meta_tags %>

Expand All @@ -9,6 +16,26 @@
</head>

<body>

<% if notice %>
<p class="alert alert-success"><%= notice %></p>
<% end %>
<% if alert %>
<p class="alert alert-danger"><%= alert %></p>
<% end %>

<% if current_user %>
<h3>
Logged in as <%= current_user.first_name %>.
<%= link_to "Log Out", logout_path %>
</h3>
<% else %>
<%= link_to "Log In", login_path %>
<% end %>


<%= yield %>


</body>
</html>
Empty file added app/views/posts/hello.html.erb
Empty file.
Loading