Skip to content

Commit bc43fa6

Browse files
authored
Merge pull request #9 from tuanle03/develop
Release v16.12.2023
2 parents ba26787 + 35d30d6 commit bc43fa6

File tree

1,873 files changed

+1285
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,873 files changed

+1285
-42
lines changed
6 KB
Binary file not shown.

.gitignore

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
*.rbc
2+
capybara-*.html
3+
.rspec
4+
/db/*.sqlite3
5+
/db/*.sqlite3-journal
6+
/db/*.sqlite3-[0-9]*
7+
/public/system
8+
/coverage/
9+
/spec/tmp
10+
*.orig
11+
rerun.txt
12+
pickle-email-*.html
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*
16+
/tmp/*
17+
!/log/.keep
18+
!/tmp/.keep
19+
20+
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
21+
config/initializers/secret_token.rb
22+
config/master.key
23+
24+
# Only include if you have production secrets in this file, which is no longer a Rails default
25+
# config/secrets.yml
26+
27+
# dotenv, dotenv-rails
28+
# TODO Comment out these rules if environment variables can be committed
29+
.env
30+
.env*.local
31+
32+
## Environment normalization:
33+
/.bundle
34+
/vendor/bundle
35+
36+
# these should all be checked in to normalize the environment:
37+
# Gemfile.lock, .ruby-version, .ruby-gemset
38+
39+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
40+
.rvmrc
41+
42+
# if using bower-rails ignore default bower_components path bower.json files
43+
/vendor/assets/bower_components
44+
*.bowerrc
45+
bower.json
46+
47+
# Ignore pow environment settings
48+
.powenv
49+
50+
# Ignore Byebug command history file.
51+
.byebug_history
52+
53+
# Ignore node_modules
54+
node_modules/
55+
56+
# Ignore precompiled javascript packs
57+
/public/packs
58+
/public/packs-test
59+
/public/assets
60+
61+
# Ignore yarn files
62+
/yarn-error.log
63+
yarn-debug.log*
64+
.yarn-integrity
65+
66+
# Ignore uploaded files in development
67+
/storage/*
68+
!/storage/.keep
69+
/public/uploads

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
4242
# Reduces boot times through caching; required in config/boot.rb
4343
gem "bootsnap", require: false
4444

45+
gem "devise"
46+
47+
gem 'devise-jwt'
48+
4549
# Use Sass to process CSS
4650
# gem "sassc-rails"
4751

@@ -51,6 +55,7 @@ gem "bootsnap", require: false
5155
group :development, :test do
5256
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
5357
gem "debug", platforms: %i[ mri mingw x64_mingw ]
58+
gem 'rspec-rails'
5459
end
5560

5661
group :development do

Gemfile.lock

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ GEM
6868
tzinfo (~> 2.0)
6969
addressable (2.8.6)
7070
public_suffix (>= 2.0.2, < 6.0)
71+
bcrypt (3.1.20)
7172
bindex (0.8.1)
7273
bootsnap (1.17.0)
7374
msgpack (~> 1.2)
@@ -87,6 +88,25 @@ GEM
8788
debug (1.9.0)
8889
irb (~> 1.10)
8990
reline (>= 0.3.8)
91+
devise (4.9.3)
92+
bcrypt (~> 3.0)
93+
orm_adapter (~> 0.1)
94+
railties (>= 4.1.0)
95+
responders
96+
warden (~> 1.2.3)
97+
devise-jwt (0.11.0)
98+
devise (~> 4.0)
99+
warden-jwt_auth (~> 0.8)
100+
diff-lcs (1.5.0)
101+
dry-auto_inject (1.0.1)
102+
dry-core (~> 1.0)
103+
zeitwerk (~> 2.6)
104+
dry-configurable (1.1.0)
105+
dry-core (~> 1.0, < 2)
106+
zeitwerk (~> 2.6)
107+
dry-core (1.0.1)
108+
concurrent-ruby (~> 1.0)
109+
zeitwerk (~> 2.6)
90110
erubi (1.12.0)
91111
globalid (1.2.1)
92112
activesupport (>= 6.1)
@@ -102,6 +122,7 @@ GEM
102122
jbuilder (2.11.5)
103123
actionview (>= 5.0.0)
104124
activesupport (>= 5.0.0)
125+
jwt (2.7.1)
105126
loofah (2.20.0)
106127
crass (~> 1.0.2)
107128
nokogiri (>= 1.5.9)
@@ -130,6 +151,7 @@ GEM
130151
nokogiri (1.14.2)
131152
mini_portile2 (~> 2.8.0)
132153
racc (~> 1.4)
154+
orm_adapter (0.5.0)
133155
psych (5.1.1.1)
134156
stringio
135157
public_suffix (5.0.4)
@@ -172,7 +194,27 @@ GEM
172194
regexp_parser (2.8.3)
173195
reline (0.4.1)
174196
io-console (~> 0.5)
197+
responders (3.1.1)
198+
actionpack (>= 5.2)
199+
railties (>= 5.2)
175200
rexml (3.2.6)
201+
rspec-core (3.12.2)
202+
rspec-support (~> 3.12.0)
203+
rspec-expectations (3.12.3)
204+
diff-lcs (>= 1.2.0, < 2.0)
205+
rspec-support (~> 3.12.0)
206+
rspec-mocks (3.12.6)
207+
diff-lcs (>= 1.2.0, < 2.0)
208+
rspec-support (~> 3.12.0)
209+
rspec-rails (6.1.0)
210+
actionpack (>= 6.1)
211+
activesupport (>= 6.1)
212+
railties (>= 6.1)
213+
rspec-core (~> 3.12)
214+
rspec-expectations (~> 3.12)
215+
rspec-mocks (~> 3.12)
216+
rspec-support (~> 3.12)
217+
rspec-support (3.12.1)
176218
rubyzip (2.3.2)
177219
selenium-webdriver (4.10.0)
178220
rexml (~> 3.2, >= 3.2.5)
@@ -198,6 +240,13 @@ GEM
198240
railties (>= 6.0.0)
199241
tzinfo (2.0.6)
200242
concurrent-ruby (~> 1.0)
243+
warden (1.2.9)
244+
rack (>= 2.0.9)
245+
warden-jwt_auth (0.8.0)
246+
dry-auto_inject (>= 0.8, < 2)
247+
dry-configurable (>= 0.13, < 2)
248+
jwt (~> 2.1)
249+
warden (~> 1.2)
201250
web-console (4.2.0)
202251
actionview (>= 6.0.0)
203252
activemodel (>= 6.0.0)
@@ -222,11 +271,14 @@ DEPENDENCIES
222271
bootsnap
223272
capybara
224273
debug
274+
devise
275+
devise-jwt
225276
importmap-rails
226277
jbuilder
227278
puma (~> 5.0)
228279
rails (~> 7.0.4, >= 7.0.4.3)
229280
redis (~> 4.0)
281+
rspec-rails
230282
selenium-webdriver
231283
sprockets-rails
232284
sqlite3 (~> 1.4)

app/.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
class CommentsController < ApplicationController
2+
3+
def index
4+
@comments = Comment.all
5+
end
6+
7+
def new
8+
@comment = Comment.new
9+
end
10+
11+
def create
12+
@comment = Comment.new(comment_params)
13+
14+
if @comment.save
15+
redirect_to comments_path, notice: "Comment was successfully created."
16+
else
17+
render :new
18+
end
19+
end
20+
21+
def edit
22+
@comment = Comment.find(params[:id])
23+
end
24+
25+
def update
26+
@comment = Comment.find(params[:id])
27+
28+
if @comment.update(comment_params)
29+
redirect_to comments_path, notice: "Comment was successfully updated."
30+
else
31+
render :edit
32+
end
33+
end
34+
35+
def destroy
36+
Comment.find(params[:id]).destroy
37+
redirect_to comments_path, notice: "Comment was successfully deleted."
38+
end
39+
40+
private
41+
42+
def comment_params
43+
params.require(:comment).permit(:user_id, :linked_object_id, :linked_object_type, :content, :status)
44+
end
45+
end
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
class DiscussionsController < ApplicationController
2+
3+
def index
4+
@discussions = Discussion.all
5+
end
6+
7+
def show
8+
@discussion = Discussion.find(params[:id])
9+
end
10+
11+
def new
12+
@discussion = Discussion.new
13+
end
14+
15+
def create
16+
@discussion = Discussion.new(discussion_params)
17+
if @discussion.save
18+
redirect_to @discussion
19+
else
20+
render :new
21+
end
22+
end
23+
24+
def edit
25+
@discussion = Discussion.find(params[:id])
26+
end
27+
28+
def update
29+
@discussion = Discussion.find(params[:id])
30+
if @discussion.update(discussion_params)
31+
redirect_to @discussion
32+
else
33+
render :edit
34+
end
35+
end
36+
37+
def destroy
38+
@discussion = Discussion.find(params[:id])
39+
@discussion.destroy
40+
redirect_to discussions_path
41+
end
42+
43+
private
44+
45+
def discussion_params
46+
params.require(:discussion).permit(:user_id, :content, :status)
47+
end
48+
end
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
class FeedbacksController < ApplicationController
2+
3+
before_action :authenticate_user!, except: [:index, :show]
4+
belongs_to :user
5+
belongs_to :post
6+
7+
def index
8+
@feedbacks = Feedback.all
9+
end
10+
11+
def new
12+
@feedback = Feedback.new
13+
end
14+
15+
def show
16+
@feedback = Feedback.find(params[:id])
17+
end
18+
19+
def create
20+
@feedback = Feedback.new(feedback_params)
21+
if @feedback.save
22+
redirect_to @feedback
23+
else
24+
render :new
25+
end
26+
end
27+
28+
def update
29+
@feedback = Feedback.find(params[:id])
30+
if @feedback.update(feedback_params)
31+
redirect_to @feedback
32+
else
33+
render :edit
34+
end
35+
end
36+
37+
def destroy
38+
@feedback = Feedback.find(params[:id])
39+
@feedback.destroy
40+
redirect_to feedbacks_path
41+
end
42+
43+
private
44+
45+
def feedback_params
46+
params.require(:feedback).permit(:user_id, :post_id, :content)
47+
end
48+
end

app/controllers/follows_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class FollowsController < ApplicationController
2+
end

app/controllers/posts_controller.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,38 @@ def create
2020
render :new
2121
end
2222
end
23+
24+
def edit
25+
@post = Post.find_by_id(params[:id])
26+
27+
if @post.nil?
28+
redirect_to posts_path
29+
end
30+
end
31+
32+
def update
33+
post = Post.find_by_id(params[:id])
34+
35+
if post.update_attributes(params[:post])
36+
redirect_to posts_path
37+
else
38+
render :edit
39+
end
40+
end
41+
42+
def destroy
43+
post = Post.find_by_id(params[:id])
44+
45+
if post.destroy
46+
redirect_to posts_path, notice: "Post deleted"
47+
else
48+
redirect_to posts_path, notice: "Post could not be deleted"
49+
end
50+
end
51+
52+
private
53+
54+
def post_params
55+
params.require(:post).permit(:user_id, :title, :body, :status, :total_view)
56+
end
2357
end

0 commit comments

Comments
 (0)