Skip to content

Commit 53ac2ee

Browse files
committed
feat: add pug support
1 parent f2aa028 commit 53ac2ee

Some content is hidden

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

48 files changed

+433
-296
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## v2.1.0
2+
3+
- **Feat: Add pug support**
4+
- Update: @coreui/coreui-icons to 0.3.0
5+
- Update: @coreui/coreui to 2.0.3
6+
- Update: perfect-scrollbar to 1.4.0

build/pug.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
'use strict'
44

5-
// const args = process.argv.slice(2)
5+
const args = process.argv.slice(2)
66

77
const fs = require('fs')
88
const path = require('path')
99
const mkdirp = require('mkdirp')
1010
const pug = require('pug')
11-
// const src = './pug/'
11+
const src = './pug/'
1212
const dest = './src/'
13-
// const views = src + 'views/'
14-
// const pages = src + 'pages/'
1513
const pkg = require(path.resolve(__dirname, '../package.json'))
1614
const beautify = require('js-beautify').html
1715
const jsbOptions = {
@@ -21,6 +19,7 @@ const jsbOptions = {
2119
content_unformatted: ['textarea'],
2220
extra_liners: ['']
2321
}
22+
const version = args[0];
2423

2524
const basename = path.basename
2625
const dirname = path.dirname
@@ -47,14 +46,13 @@ const compile = (filename, basedir) => {
4746
const levels = filename.replace('pug/views/', '').replace('pug/pages/', '').split('/').length
4847
const base = (levels) => {
4948
let path = './'
50-
5149
while (levels > 1) {
5250
levels = levels - 1;
5351
path = path + '../'
5452
}
5553
return path
5654
}
57-
// console.log()
55+
5856
const fn = pug.compileFile(filename, {
5957
basedir: basedir,
6058
pretty: true,
@@ -65,46 +63,58 @@ const compile = (filename, basedir) => {
6563
return html
6664
}
6765

68-
// Build base version
69-
const buildBaseVersion = () => {
66+
// Build html files
67+
const compileHtml = () => {
68+
// Build index
69+
if (version === 'ajax') {
70+
const html = compile('./pug/layout/index.pug', './pug/layout/')
71+
fs.writeFile(resolve(dest, 'index.html'), beautify(html, jsbOptions), function(err) {
72+
if(err) {
73+
return console.log(err);
74+
}
75+
console.log('index.html file was saved!');
76+
})
77+
}
7078

7179
// Build views
7280
const views = walkSync('./pug/views/')
7381
views.forEach((view) => {
7482
if (isPug(view)) {
7583
const html = compile(view, './pug/layout/')
76-
const file = view.replace('pug/views/', '').replace('.pug', '.html')
77-
84+
let file
85+
if (version === 'ajax') {
86+
file = view.replace('pug/', '').replace('.pug', '.html')
87+
} else {
88+
file = view.replace('pug/views/', '').replace('.pug', '.html')
89+
}
7890
// Create tree
7991
mkdirp.sync(resolve(dest, dirname(file)))
8092
// Create HTML file
8193
fs.writeFile(resolve(dest, file), beautify(html, jsbOptions), function(err) {
8294
if(err) {
8395
return console.log(err)
8496
}
85-
console.log(file + " file was saved!")
97+
console.log(file + ' file was saved!')
8698
})
8799
}
88100
})
89-
90101
// Build pages
91102
const pages = walkSync('./pug/pages')
92103
pages.forEach((page) => {
93104
if (isPug(page)) {
94105
const html = compile(page, './pug/layout/')
95106
const file = page.replace('pug/pages/', '').replace('.pug', '.html')
96-
97107
// Create tree
98108
mkdirp.sync(resolve(dest, dirname(file)))
99109
// Create HTML file
100110
fs.writeFile(resolve(dest, file), beautify(html, jsbOptions), function(err) {
101111
if(err) {
102112
return console.log(err)
103113
}
104-
console.log(file + " file was saved!")
114+
console.log(file + ' file was saved!')
105115
})
106116
}
107117
})
108118
}
109119

110-
buildBaseVersion()
120+
compileHtml()

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@
6060
"serve": "npm-run-all --parallel localhost watch-css watch-js",
6161
"watch-css": "nodemon --ignore dist/ -e scss -x \"npm run css\"",
6262
"watch-js": "nodemon --watch src/js/src/ -x \"npm run js\"",
63-
"watch-pug": "nodemon --watch pug/ -x \"npm run pug\""
63+
"watch-pug": "nodemon -e pug -x \"npm run pug\""
6464
},
6565
"dependencies": {
66-
"@coreui/coreui": "2.0.0",
66+
"@coreui/coreui": "2.0.3",
6767
"@coreui/coreui-plugin-chartjs-custom-tooltips": "1.2.0",
68-
"@coreui/icons": "^0.1.1",
68+
"@coreui/icons": "0.3.0",
6969
"bootstrap": "4.1.1",
7070
"chart.js": "^2.7.2",
7171
"flag-icon-css": "3.0.0",
7272
"font-awesome": "4.7.0",
7373
"jquery": "3.3.1",
7474
"pace-progress": "1.0.2",
75-
"perfect-scrollbar": "^1.3.0",
75+
"perfect-scrollbar": "1.4.0",
7676
"popper.js": "1.14.3",
7777
"simple-line-icons": "2.4.1"
7878
},

pug/partials/scripts.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Bootstrap and necessary plugins
1+
// CoreUI and necessary plugins
22
script(src='node_modules/jquery/dist/jquery.min.js')
33
script(src='node_modules/popper.js/dist/umd/popper.min.js')
44
script(src='node_modules/bootstrap/dist/js/bootstrap.min.js')

pug/views/icons/coreui-icons.pug

Lines changed: 6 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
extends /default.pug
22

33
block view
4+
- var icons = ['account-logout','action-redo','action-undo','align-center','align-left','align-right','arrow-bottom','arrow-left','arrow-right','arrow-top','ban','basket-loaded','bell','bold','bookmark','briefcase','british-pound','brush','calculator','calendar','cart','chart','check','chevron-bottom','chevron-left','chevron-right','chevron-top','circle-check','circle-x','cloud','cloud-download','cloud-upload','code','cog','comment-square','credit-card','cursor','dashboard','delete','dollar','drop','envelope-closed','envelope-letter','envelope-open','euro','file','globe','graph','home','inbox','info','italic','justify-center','justify-left','justify-right','laptop','layers','lightbulb','list','location-pin','lock-locked','lock-unlocked','magnifying-glass','map','monitor','moon','note','options','paperclip','pencil','people','phone','pie-chart','print','puzzle','rss','screen-desktop','screen-smartphone','settings','share','shield','sort-ascending','sort-descending','speech','speedometer','star','sun','tablet','tags','task','thumb-down','thumb-up','trash','underline','user','user-female','user-follow','user-unfollow','wrench','yen'];
5+
46
.animated.fadeIn
57
.card.card-default
68
.card-header
@@ -10,121 +12,8 @@ block view
1012
a.card-header-action(href='https://github.com/coreui/coreui-icons', target='_blank') Github
1113
.card-body
1214
.row.text-center
13-
.col-6.col-sm-4.col-md-3
14-
i.cui-basket-loaded.icons.font-2xl.d-block.mt-4
15-
div basket-loaded
16-
.col-6.col-sm-4.col-md-3
17-
i.cui-bell.icons.font-2xl.d-block.mt-4
18-
div bell
19-
.col-6.col-sm-4.col-md-3
20-
i.cui-calculator.icons.font-2xl.d-block.mt-4
21-
div calculator
22-
.col-6.col-sm-4.col-md-3
23-
i.cui-calendar.icons.font-2xl.d-block.mt-4
24-
div calendar
25-
.col-6.col-sm-4.col-md-3
26-
i.cui-camera.icons.font-2xl.d-block.mt-4
27-
div camera
28-
.col-6.col-sm-4.col-md-3
29-
i.cui-chart.icons.font-2xl.d-block.mt-4
30-
div chart
31-
.col-6.col-sm-4.col-md-3
32-
i.cui-cloud-download.icons.font-2xl.d-block.mt-4
33-
div cloud-download
34-
.col-6.col-sm-4.col-md-3
35-
i.cui-cursor.icons.font-2xl.d-block.mt-4
36-
div cursor
37-
.col-6.col-sm-4.col-md-3
38-
i.cui-cursor-move.icons.font-2xl.d-block.mt-4
39-
div cursor-move
40-
.col-6.col-sm-4.col-md-3
41-
i.cui-drop.icons.font-2xl.d-block.mt-4
42-
div drop
43-
.col-6.col-sm-4.col-md-3
44-
i.cui-energy.icons.font-2xl.d-block.mt-4
45-
div energy
46-
.col-6.col-sm-4.col-md-3
47-
i.cui-envelope-letter.icons.font-2xl.d-block.mt-4
48-
div envelope-letter
49-
.col-6.col-sm-4.col-md-3
50-
i.cui-equalizer.icons.font-2xl.d-block.mt-4
51-
div equalizer
52-
.col-6.col-sm-4.col-md-3
53-
i.cui-globe.icons.font-2xl.d-block.mt-4
54-
div globe
55-
.col-6.col-sm-4.col-md-3
56-
i.cui-graph.icons.font-2xl.d-block.mt-4
57-
div graph
58-
.col-6.col-sm-4.col-md-3
59-
i.cui-home.icons.font-2xl.d-block.mt-4
60-
div home
61-
.col-6.col-sm-4.col-md-3
62-
i.cui-layers.icons.font-2xl.d-block.mt-4
63-
div layers
64-
.col-6.col-sm-4.col-md-3
65-
i.cui-list.icons.font-2xl.d-block.mt-4
66-
div list
67-
.col-6.col-sm-4.col-md-3
68-
i.cui-location-pin.icons.font-2xl.d-block.mt-4
69-
div location-pin
70-
.col-6.col-sm-4.col-md-3
71-
i.cui-map.icons.font-2xl.d-block.mt-4
72-
div map
73-
.col-6.col-sm-4.col-md-3
74-
i.cui-note.icons.font-2xl.d-block.mt-4
75-
div note
76-
.col-6.col-sm-4.col-md-3
77-
i.cui-options.icons.font-2xl.d-block.mt-4
78-
div options
79-
.col-6.col-sm-4.col-md-3
80-
i.cui-pencil.icons.font-2xl.d-block.mt-4
81-
div pencil
82-
.col-6.col-sm-4.col-md-3
83-
i.cui-people.icons.font-2xl.d-block.mt-4
84-
div people
85-
.col-6.col-sm-4.col-md-3
86-
i.cui-pie-chart.icons.font-2xl.d-block.mt-4
87-
div pie-chart
88-
.col-6.col-sm-4.col-md-3
89-
i.cui-puzzle.icons.font-2xl.d-block.mt-4
90-
div puzzle
91-
.col-6.col-sm-4.col-md-3
92-
i.cui-screen-desktop.icons.font-2xl.d-block.mt-4
93-
div screen-desktop
94-
.col-6.col-sm-4.col-md-3
95-
i.cui-screen-smartphone.icons.font-2xl.d-block.mt-4
96-
div screen-smartphone
97-
.col-6.col-sm-4.col-md-3
98-
i.cui-settings.icons.font-2xl.d-block.mt-4
99-
div settings
100-
.col-6.col-sm-4.col-md-3
101-
i.cui-social-facebook.icons.font-2xl.d-block.mt-4
102-
div social-facebook
103-
.col-6.col-sm-4.col-md-3
104-
i.cui-social-skype.icons.font-2xl.d-block.mt-4
105-
div social-skype
106-
.col-6.col-sm-4.col-md-3
107-
i.cui-social-twitter.icons.font-2xl.d-block.mt-4
108-
div social-twitter
109-
.col-6.col-sm-4.col-md-3
110-
i.cui-speech.icons.font-2xl.d-block.mt-4
111-
div speech
112-
.col-6.col-sm-4.col-md-3
113-
i.cui-speedometer.icons.font-2xl.d-block.mt-4
114-
div speedometer
115-
.col-6.col-sm-4.col-md-3
116-
i.cui-star.icons.font-2xl.d-block.mt-4
117-
div star
118-
.col-6.col-sm-4.col-md-3
119-
i.cui-user.icons.font-2xl.d-block.mt-4
120-
div user
121-
.col-6.col-sm-4.col-md-3
122-
i.cui-user-female.icons.font-2xl.d-block.mt-4
123-
div user-female
124-
.col-6.col-sm-4.col-md-3
125-
i.cui-user-follow.icons.font-2xl.d-block.mt-4
126-
div user-follow
127-
.col-6.col-sm-4.col-md-3
128-
i.cui-user-unfollow.icons.font-2xl.d-block.mt-4
129-
div user-unfollow
15+
each icon in icons
16+
.col-6.col-sm-4.col-md-2
17+
i(class='icons font-2xl d-block mt-5 cui-' + icon)
18+
div=icon
13019
// /.row

pug/views/typography.pug

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,37 @@ block view
1717
tr
1818
td
1919
p
20-
code.highlighter-rouge <h1></h1>
20+
code.highlighter-rouge= '<h1></h1>'
2121
td
2222
span.h1 h1. Bootstrap heading
2323
tr
2424
td
2525
p
26-
code.highlighter-rouge <h2></h2>
26+
code.highlighter-rouge= '<h2></h2>'
2727
td
2828
span.h2 h2. Bootstrap heading
2929
tr
3030
td
3131
p
32-
code.highlighter-rouge <h3></h3>
32+
code.highlighter-rouge= '<h3></h3>'
3333
td
3434
span.h3 h3. Bootstrap heading
3535
tr
3636
td
3737
p
38-
code.highlighter-rouge <h4></h4>
38+
code.highlighter-rouge= '<h4></h4>'
3939
td
4040
span.h4 h4. Bootstrap heading
4141
tr
4242
td
4343
p
44-
code.highlighter-rouge <h5></h5>
44+
code.highlighter-rouge= '<h5></h5>'
4545
td
4646
span.h5 h5. Bootstrap heading
4747
tr
4848
td
4949
p
50-
code.highlighter-rouge <h6></h6>
50+
code.highlighter-rouge= '<h6></h6>'
5151
td
5252
span.h6 h6. Bootstrap heading
5353
.card

src/404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h4 class="pt-3">Oops! You're lost.</h4>
4949
</div>
5050
</div>
5151
</div>
52-
<!-- Bootstrap and necessary plugins-->
52+
<!-- CoreUI and necessary plugins-->
5353
<script src="node_modules/jquery/dist/jquery.min.js"></script>
5454
<script src="node_modules/popper.js/dist/umd/popper.min.js"></script>
5555
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>

src/500.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h4 class="pt-3">Houston, we have a problem!</h4>
4949
</div>
5050
</div>
5151
</div>
52-
<!-- Bootstrap and necessary plugins-->
52+
<!-- CoreUI and necessary plugins-->
5353
<script src="node_modules/jquery/dist/jquery.min.js"></script>
5454
<script src="node_modules/popper.js/dist/umd/popper.min.js"></script>
5555
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>

src/base/breadcrumb.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ <h6>System Utilization</h6>
691691
<a href="https://coreui.io">CoreUI</a>
692692
</div>
693693
</footer>
694-
<!-- Bootstrap and necessary plugins-->
694+
<!-- CoreUI and necessary plugins-->
695695
<script src="node_modules/jquery/dist/jquery.min.js"></script>
696696
<script src="node_modules/popper.js/dist/umd/popper.min.js"></script>
697697
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>

0 commit comments

Comments
 (0)