Skip to content

Commit 32f843b

Browse files
NguyenThanhHaNguyenThanhHa
authored andcommitted
chapter_3_4_5
1 parent 12182eb commit 32f843b

File tree

25 files changed

+335
-47
lines changed

25 files changed

+335
-47
lines changed

.gitignore

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,69 @@
1-
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2-
#
3-
# If you find yourself ignoring temporary files generated by your text editor
4-
# or operating system, you probably want to add a global ignore instead:
5-
# git config --global core.excludesfile '~/.gitignore_global'
6-
7-
# Ignore bundler config.
8-
/.bundle
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
913

1014
# Ignore all logfiles and tempfiles.
1115
/log/*
1216
/tmp/*
1317
!/log/.keep
1418
!/tmp/.keep
1519

16-
# Ignore pidfiles, but keep the directory.
17-
/tmp/pids/*
18-
!/tmp/pids/
19-
!/tmp/pids/.keep
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
2023

21-
# Ignore uploaded files in development.
22-
/storage/*
23-
!/storage/.keep
24-
/tmp/storage/*
25-
!/tmp/storage/
26-
!/tmp/storage/.keep
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
2738

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
2859
/public/assets
2960

30-
# Ignore master key for decrypting credentials and more.
31-
/config/master.key
32-
/config/database.yml
33-
/test/*
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,6 @@ group :test do
7373
gem "selenium-webdriver"
7474
gem "webdrivers"
7575
end
76+
77+
gem 'sassc-rails'
78+

Gemfile.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ GEM
9090
irb (>= 1.5.0)
9191
reline (>= 0.3.1)
9292
erubi (1.12.0)
93+
ffi (1.17.1-x86_64-linux-gnu)
9394
globalid (1.1.0)
9495
activesupport (>= 5.0)
9596
i18n (1.14.1)
@@ -199,6 +200,14 @@ GEM
199200
rubocop (>= 1.7.0, < 2.0)
200201
ruby-progressbar (1.13.0)
201202
rubyzip (2.3.2)
203+
sassc (2.4.0)
204+
ffi (~> 1.9)
205+
sassc-rails (2.1.2)
206+
railties (>= 4.0.0)
207+
sassc (>= 2.0)
208+
sprockets (> 3.0)
209+
sprockets-rails
210+
tilt
202211
selenium-webdriver (4.10.0)
203212
rexml (~> 3.2, >= 3.2.5)
204213
rubyzip (>= 1.2.2, < 3.0)
@@ -213,6 +222,7 @@ GEM
213222
stimulus-rails (1.2.2)
214223
railties (>= 6.0.0)
215224
thor (1.2.2)
225+
tilt (2.6.0)
216226
timeout (0.4.0)
217227
turbo-rails (1.4.0)
218228
actionpack (>= 6.0.0)
@@ -253,6 +263,7 @@ DEPENDENCIES
253263
rubocop (~> 1.26)
254264
rubocop-checkstyle_formatter
255265
rubocop-rails (~> 2.14.0)
266+
sassc-rails
256267
selenium-webdriver
257268
sprockets-rails
258269
stimulus-rails

app/assets/stylesheets/application.css

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@import "bootstrap/scss/bootstrap";
2+
3+
.navbar-brand {
4+
text-transform: uppercase;
5+
letter-spacing: 0.1em;
6+
font-weight: bold;
7+
}
8+
9+
/* Tăng kích cỡ chữ cho h1 */
10+
h1 {
11+
font-size: 2.5rem;
12+
}
13+
14+
@import "custom";

app/assets/stylesheets/custom.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// app/assets/stylesheets/custom.scss
2+
body {
3+
background-color: #f8f9fa;
4+
}
5+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class PagesController < ApplicationController
2+
def home
3+
end
4+
5+
def help
6+
end
7+
8+
def contact
9+
end
10+
end

app/helpers/pages_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module PagesHelper
2+
end

app/javascript/application.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
2-
import "@hotwired/turbo-rails"
3-
import "controllers"
1+
2+
import "bootstrap";
3+
import "bootstrap/dist/css/bootstrap.min.css";
4+
import "popper.js";
5+
Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>RailsTutorial</title>
5-
<meta name="viewport" content="width=device-width,initial-scale=1">
4+
<title><%= yield(:title) || "Sample App" %></title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<%= csrf_meta_tags %>
77
<%= csp_meta_tag %>
88

9+
<!-- Gọi file CSS (đã bundle) -->
910
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
10-
<%= javascript_importmap_tags %>
11+
<!-- Gọi file JS (đã bundle) -->
12+
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
13+
14+
<!-- Bootstrap CDN -->
15+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
16+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
1117
</head>
1218

1319
<body>
14-
<%= yield %>
20+
<!-- Navbar Bootstrap 5 -->
21+
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
22+
<div class="container-fluid">
23+
<%= link_to "SAMPLE APP", root_path, class: "navbar-brand" %>
24+
25+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent">
26+
<span class="navbar-toggler-icon"></span>
27+
</button>
28+
29+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
30+
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
31+
<li class="nav-item">
32+
<%= link_to "Home", root_path, class: "nav-link" %>
33+
</li>
34+
<li class="nav-item">
35+
<%= link_to "Help", pages_help_path, class: "nav-link" %>
36+
</li>
37+
<li class="nav-item">
38+
<%= link_to "Log in", "#", class: "nav-link" %>
39+
</li>
40+
</ul>
41+
</div>
42+
</div>
43+
</nav>
44+
45+
<!-- Phần nội dung của từng trang con -->
46+
<div class="container mt-4">
47+
<%= yield %>
48+
</div>
1549
</body>
1650
</html>

0 commit comments

Comments
 (0)