Skip to content

Commit d2692f9

Browse files
authored
Merge pull request #38 from tuanle03/clr-79-create-cms-post
[CLR-79] Create CMS Post
2 parents f5866ea + 59a2aaf commit d2692f9

22 files changed

+159
-143
lines changed

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ gem 'rack-cors'
6464

6565
gem 'friendly_id'
6666

67+
gem 'haml-rails'
68+
69+
gem 'html2haml'
70+
71+
gem 'jquery-rails'
72+
6773
# Use Sass to process CSS
6874
# gem "sassc-rails"
6975

Gemfile.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ GEM
128128
dry-logic (~> 1.4)
129129
zeitwerk (~> 2.6)
130130
erubi (1.12.0)
131+
erubis (2.7.0)
131132
factory_bot (6.4.2)
132133
activesupport (>= 5.0.0)
133134
factory_bot_rails (6.4.2)
@@ -152,6 +153,20 @@ GEM
152153
grape_logging (1.8.4)
153154
grape
154155
rack
156+
haml (6.3.0)
157+
temple (>= 0.8.2)
158+
thor
159+
tilt
160+
haml-rails (2.1.0)
161+
actionpack (>= 5.1)
162+
activesupport (>= 5.1)
163+
haml (>= 4.0.6)
164+
railties (>= 5.1)
165+
html2haml (2.3.0)
166+
erubis (~> 2.7.0)
167+
haml (>= 4.0)
168+
nokogiri (>= 1.6.0)
169+
ruby_parser (~> 3.5)
155170
i18n (1.14.1)
156171
concurrent-ruby (~> 1.0)
157172
importmap-rails (1.1.5)
@@ -164,6 +179,10 @@ GEM
164179
jbuilder (2.11.5)
165180
actionview (>= 5.0.0)
166181
activesupport (>= 5.0.0)
182+
jquery-rails (4.6.0)
183+
rails-dom-testing (>= 1, < 3)
184+
railties (>= 4.2.0)
185+
thor (>= 0.14, < 2.0)
167186
jwt (2.7.1)
168187
loofah (2.20.0)
169188
crass (~> 1.0.2)
@@ -267,12 +286,15 @@ GEM
267286
rspec-support (~> 3.12)
268287
rspec-support (3.12.1)
269288
ruby2_keywords (0.0.5)
289+
ruby_parser (3.20.3)
290+
sexp_processor (~> 4.16)
270291
rubyzip (2.3.2)
271292
safely_block (0.4.0)
272293
selenium-webdriver (4.10.0)
273294
rexml (~> 3.2, >= 3.2.5)
274295
rubyzip (>= 1.2.2, < 3.0)
275296
websocket (~> 1.0)
297+
sexp_processor (4.17.0)
276298
sprockets (4.2.1)
277299
concurrent-ruby (~> 1.0)
278300
rack (>= 2.2.4, < 4)
@@ -285,7 +307,9 @@ GEM
285307
stimulus-rails (1.2.1)
286308
railties (>= 6.0.0)
287309
stringio (3.1.0)
310+
temple (0.10.3)
288311
thor (1.3.0)
312+
tilt (2.3.0)
289313
timeout (0.4.1)
290314
turbo-rails (1.4.0)
291315
actionpack (>= 6.0.0)
@@ -335,8 +359,11 @@ DEPENDENCIES
335359
grape
336360
grape-swagger
337361
grape_logging
362+
haml-rails
363+
html2haml
338364
importmap-rails
339365
jbuilder
366+
jquery-rails
340367
pg
341368
puma (~> 5.0)
342369
rack-cors

app/controllers/posts_controller.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ class PostsController < ApplicationController
22
before_action :set_post, only: %i[show edit update destroy]
33

44
def index
5-
@posts = Post.all
5+
@posts = filter_posts
6+
respond_to do |format|
7+
format.html
8+
format.js
9+
end
610
end
711

812
def show
@@ -49,4 +53,12 @@ def set_post
4953
def post_params
5054
params.require(:post).permit(:title, :body, :user_id, :status)
5155
end
56+
57+
def filter_posts
58+
if params[:status].present?
59+
Post.where(status: params[:status])
60+
else
61+
Post.all
62+
end
63+
end
5264
end

app/javascript/application.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
22
import "@hotwired/turbo-rails"
33
import "controllers"
4+
//= require jquery3
5+
//= require popper
6+
//= require bootstrap
7+
//= require jquery_ujs
8+
//= require turbolinks
9+
//= require_tree .
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
<!DOCTYPE html>
2-
<html>
3-
4-
<head>
5-
<title>Docs</title>
6-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/swagger-ui.css">
7-
</head>
8-
9-
<body>
10-
<div id="ui-wrapper-new" data-spec="/api/web/doc.json">
1+
!!!
2+
%html
3+
%head
4+
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
5+
%title Docs
6+
%link{:href => "https://cdn.jsdelivr.net/npm/[email protected]/swagger-ui.css", :rel => "stylesheet"}/
7+
%body
8+
#ui-wrapper-new{"data-spec" => "/api/web/doc.json"}
119
Loading....
12-
</div>
13-
</body>
14-
<script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js"></script>
15-
<script>
10+
%script{:src => "https://unpkg.com/[email protected]/swagger-ui-bundle.js"}
11+
:javascript
1612
var swaggerUIOptions = {
1713
url: '/api/web/doc.json',
1814
dom_id: '#ui-wrapper-new',
@@ -36,6 +32,3 @@
3632
var ui = SwaggerUIBundle(swaggerUIOptions)
3733
3834
window.ui = ui
39-
</script>
40-
41-
</html>

app/views/layouts/application.html.erb

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
!!!
2+
%html
3+
%head
4+
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
5+
%title CodeLearnApi
6+
%meta{:content => "width=device-width,initial-scale=1", :name => "viewport"}/
7+
%link{:crossorigin => "anonymous", :href => "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css", :integrity => "sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN", :rel => "stylesheet"}/
8+
= csrf_meta_tags
9+
= csp_meta_tag
10+
= stylesheet_link_tag "application", "data-turbo-track": "reload"
11+
= javascript_importmap_tags
12+
= javascript_include_tag 'https://code.jquery.com/jquery-3.6.0.min.js'
13+
%body
14+
= yield
15+
%script{:crossorigin => "anonymous", :integrity => "sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL", :src => "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"}

app/views/layouts/mailer.html.erb

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/views/layouts/mailer.html.haml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
!!!
2+
%html
3+
%head
4+
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}/
5+
:css
6+
/* Email styles need to be inline */
7+
%body
8+
= yield

app/views/layouts/mailer.text.erb

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)