Minifying
This commit is contained in:
parent
19203148e5
commit
9c4115b9ed
14 changed files with 347 additions and 29 deletions
89
build.sh
Executable file
89
build.sh
Executable file
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
RED='\033[1;31m'
|
||||
GREEN='\033[1;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[1;34m'
|
||||
RESET='\033[0m'
|
||||
|
||||
minjs="dist/script.min.js"
|
||||
mincss="dist/style.min.css"
|
||||
minhtml="dist/index.html"
|
||||
|
||||
minjs_name="script.min.js"
|
||||
mincss_name="style.min.css"
|
||||
minhtml_name="index.html"
|
||||
|
||||
title() {
|
||||
echo
|
||||
echo -e "${BLUE}[*]${RESET} $1"
|
||||
}
|
||||
|
||||
success() {
|
||||
echo
|
||||
echo -e "${GREEN}[V]${RESET} Done"
|
||||
echo
|
||||
}
|
||||
|
||||
check_deps() {
|
||||
which "$1" >/dev/null 2>/dev/null
|
||||
if [[ $? == 1 ]]; then
|
||||
echo -e "${RED}[!]${RESET} $1 is required"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
js_minify() {
|
||||
order=('js/anim.js' 'js/script.js' 'js/init.js' 'js/menu.js' 'js/control.js' 'js/handlers.js')
|
||||
terser -o "$minjs" ${order[*]}
|
||||
}
|
||||
|
||||
html_minify () {
|
||||
html-minifier \
|
||||
--collapse-boolean-attributes \
|
||||
--collapse-inline-tag-whitespace \
|
||||
--collapse-whitespace \
|
||||
--remove-attribute-quotes \
|
||||
--remove-comments \
|
||||
--remove-optional-tags \
|
||||
--remove-script-type-attributes \
|
||||
--remove-style-link-type-attributes \
|
||||
--use-short-doctype \
|
||||
-o "$minhtml" \
|
||||
"$1"
|
||||
}
|
||||
|
||||
copy_files() {
|
||||
exclude=('\.$' '\.git' 'index.html' 'styles.less' 'js' 'dist' 'build.sh' 'html_conv' 'README.md')
|
||||
items="${exclude[@]}"
|
||||
regex="${items//[[:space:]]/|}"
|
||||
find -maxdepth 1 -exec bash -c "if [[ {} =~ $regex ]]; then :; else cp -r {} dist/; fi" \;
|
||||
}
|
||||
|
||||
title "Checking dependencies"
|
||||
check_deps terser
|
||||
check_deps lessc
|
||||
check_deps cleancss
|
||||
check_deps html-minifier
|
||||
check_deps python3
|
||||
|
||||
mkdir dist/
|
||||
|
||||
title "Minifying JS"
|
||||
js_minify
|
||||
|
||||
title "Converting LESS"
|
||||
lessc "styles.less" "$mincss"
|
||||
|
||||
title "Minifying CSS"
|
||||
cleancss -o "$mincss" "$mincss"
|
||||
|
||||
title "Minifying HTML"
|
||||
cat index.html | python3 html_conv.py "$minjs_name" "$mincss_name" >"$minhtml"
|
||||
html_minify "$minhtml"
|
||||
|
||||
title "Copying other files"
|
||||
copy_files
|
||||
|
||||
success
|
2
clean.sh
Executable file
2
clean.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
rm -rf dist/
|
165
fontawesome/LICENSE.txt
Normal file
165
fontawesome/LICENSE.txt
Normal file
|
@ -0,0 +1,165 @@
|
|||
Fonticons, Inc. (https://fontawesome.com)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Font Awesome Free License
|
||||
|
||||
Font Awesome Free is free, open source, and GPL friendly. You can use it for
|
||||
commercial projects, open source projects, or really almost whatever you want.
|
||||
Full Font Awesome Free license: https://fontawesome.com/license/free.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
|
||||
|
||||
The Font Awesome Free download is licensed under a Creative Commons
|
||||
Attribution 4.0 International License and applies to all icons packaged
|
||||
as SVG and JS file types.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
# Fonts: SIL OFL 1.1 License
|
||||
|
||||
In the Font Awesome Free download, the SIL OFL license applies to all icons
|
||||
packaged as web and desktop font files.
|
||||
|
||||
Copyright (c) 2022 Fonticons, Inc. (https://fontawesome.com)
|
||||
with Reserved Font Name: "Font Awesome".
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
SIL OPEN FONT LICENSE
|
||||
Version 1.1 - 26 February 2007
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting — in part or in whole — any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
# Code: MIT License (https://opensource.org/licenses/MIT)
|
||||
|
||||
In the Font Awesome Free download, the MIT license applies to all non-font and
|
||||
non-icon files.
|
||||
|
||||
Copyright 2022 Fonticons, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
# Attribution
|
||||
|
||||
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
|
||||
Awesome Free files already contain embedded comments with sufficient
|
||||
attribution, so you shouldn't need to do anything additional when using these
|
||||
files normally.
|
||||
|
||||
We've kept attribution comments terse, so we ask that you do not actively work
|
||||
to remove them from files, especially code. They're a great way for folks to
|
||||
learn about Font Awesome.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
# Brand Icons
|
||||
|
||||
All brand icons are trademarks of their respective owners. The use of these
|
||||
trademarks does not indicate endorsement of the trademark holder by Font
|
||||
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
|
||||
to represent the company, product, or service to which they refer.**
|
6
fontawesome/css/brands.min.css
vendored
Normal file
6
fontawesome/css/brands.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
fontawesome/css/fontawesome.min.css
vendored
Normal file
6
fontawesome/css/fontawesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
fontawesome/css/solid.min.css
vendored
Normal file
6
fontawesome/css/solid.min.css
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/*!
|
||||
* Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
|
||||
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||
* Copyright 2022 Fonticons, Inc.
|
||||
*/
|
||||
:host,:root{--fa-style-family-classic:"Font Awesome 6 Free";--fa-font-solid:normal 900 1em/1 "Font Awesome 6 Free"}@font-face{font-family:"Font Awesome 6 Free";font-style:normal;font-weight:900;font-display:block;src:url(../webfonts/fa-solid-900.woff2) format("woff2"),url(../webfonts/fa-solid-900.ttf) format("truetype")}.fa-solid,.fas{font-weight:900}
|
BIN
fontawesome/webfonts/fa-brands-400.ttf
Normal file
BIN
fontawesome/webfonts/fa-brands-400.ttf
Normal file
Binary file not shown.
BIN
fontawesome/webfonts/fa-brands-400.woff2
Normal file
BIN
fontawesome/webfonts/fa-brands-400.woff2
Normal file
Binary file not shown.
BIN
fontawesome/webfonts/fa-solid-900.ttf
Normal file
BIN
fontawesome/webfonts/fa-solid-900.ttf
Normal file
Binary file not shown.
BIN
fontawesome/webfonts/fa-solid-900.woff2
Normal file
BIN
fontawesome/webfonts/fa-solid-900.woff2
Normal file
Binary file not shown.
26
html_conv.py
Normal file
26
html_conv.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
SCRIPTS = r'((<script src="js/\w+\.js"></script>[\s\r\n]+)+)'
|
||||
MINJS = '<script src="{}"></script>'
|
||||
|
||||
LESSJS = '<script src="https://cdn.jsdelivr.net/npm/less"></script>'
|
||||
STYLES = '<link rel="stylesheet/less" type="text/css" href="styles.less" />'
|
||||
CSS = '<link rel="stylesheet" href="{}" />'
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
stdin = sys.stdin.read()
|
||||
|
||||
conv = re.sub(SCRIPTS, MINJS.format(sys.argv[1]), stdin)
|
||||
conv = conv.replace(LESSJS, '')
|
||||
conv = conv.replace(STYLES, CSS.format(sys.argv[2]))
|
||||
|
||||
sys.stdout.write(conv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
32
index.html
32
index.html
|
@ -6,8 +6,10 @@
|
|||
<title>DarkCat09's Web Site</title>
|
||||
<link rel="stylesheet/less" type="text/css" href="styles.less" />
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/shakrmedia/tuesday@v1.1.0/build/tuesday.min.css" />
|
||||
<script src="https://kit.fontawesome.com/a966b160a8.js" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/less" ></script>
|
||||
<link rel="stylesheet" href="fontawesome/css/fontawesome.min.css" />
|
||||
<link rel="stylesheet" href="fontawesome/css/solid.min.css" />
|
||||
<link rel="stylesheet" href="fontawesome/css/brands.min.css" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<!-- The Universe -->
|
||||
|
@ -109,31 +111,7 @@
|
|||
Details
|
||||
</label>
|
||||
<div class="hidden" id="details-1">
|
||||
<pre>
|
||||
System:
|
||||
Kernel: 5.19.1-3-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.1.1
|
||||
Desktop: KDE Plasma v: 5.24.6 Distro: Manjaro Linux base: Arch Linux
|
||||
CPU:
|
||||
Info: 6-core model: Intel Core i5-10400 bits: 64 type: MT MCP
|
||||
arch: Comet Lake rev: 3 cache: L1: 384 KiB L2: 1.5 MiB L3: 12 MiB
|
||||
Graphics:
|
||||
Device-1: Intel CometLake-S GT2 [UHD Graphics 630] vendor: ASUSTeK
|
||||
driver: i915 v: kernel arch: Gen-9.5 bus-ID: 00:02.0
|
||||
Display: x11 server: X.Org v: 21.1.4 driver: X: loaded: modesetting
|
||||
gpu: i915 resolution: 1920x1080~60Hz
|
||||
OpenGL: renderer: Mesa Intel UHD Graphics 630 (CML GT2) v: 4.6 Mesa
|
||||
22.1.6 direct render: Yes
|
||||
Drives:
|
||||
Local Storage: total: 1.36 TiB used: 180.51 GiB (12.9%)
|
||||
ID-1: /dev/nvme0n1 vendor: Western Digital model: WD Blue SN570 500GB
|
||||
size: 465.76 GiB temp: 37.9 C
|
||||
ID-2: /dev/sda vendor: Western Digital model: WD10EZEX-00BBHA0
|
||||
size: 931.51 GiB
|
||||
Info:
|
||||
Processes: 291 Uptime: 1h 37m Memory: 30.21 GiB used: 4.49 GiB (14.9%)
|
||||
Init: systemd Compilers: gcc: 12.1.1 clang: 14.0.6 Packages: 1479
|
||||
Shell: Zsh v: 5.9 inxi: 3.3.21
|
||||
</pre>
|
||||
<pre id="inxi"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
23
inxi.txt
Normal file
23
inxi.txt
Normal file
|
@ -0,0 +1,23 @@
|
|||
System:
|
||||
Kernel: 5.19.1-3-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.1.1
|
||||
Desktop: KDE Plasma v: 5.24.6 Distro: Manjaro Linux base: Arch Linux
|
||||
CPU:
|
||||
Info: 6-core model: Intel Core i5-10400 bits: 64 type: MT MCP
|
||||
arch: Comet Lake rev: 3 cache: L1: 384 KiB L2: 1.5 MiB L3: 12 MiB
|
||||
Graphics:
|
||||
Device-1: Intel CometLake-S GT2 [UHD Graphics 630] vendor: ASUSTeK
|
||||
driver: i915 v: kernel arch: Gen-9.5 bus-ID: 00:02.0
|
||||
Display: x11 server: X.Org v: 21.1.4 driver: X: loaded: modesetting
|
||||
gpu: i915 resolution: 1920x1080~60Hz
|
||||
OpenGL: renderer: Mesa Intel UHD Graphics 630 (CML GT2) v: 4.6 Mesa
|
||||
22.1.6 direct render: Yes
|
||||
Drives:
|
||||
Local Storage: total: 1.36 TiB used: 180.51 GiB (12.9%)
|
||||
ID-1: /dev/nvme0n1 vendor: Western Digital model: WD Blue SN570 500GB
|
||||
size: 465.76 GiB temp: 37.9 C
|
||||
ID-2: /dev/sda vendor: Western Digital model: WD10EZEX-00BBHA0
|
||||
size: 931.51 GiB
|
||||
Info:
|
||||
Processes: 291 Uptime: 1h 37m Memory: 30.21 GiB used: 4.49 GiB (14.9%)
|
||||
Init: systemd Compilers: gcc: 12.1.1 clang: 14.0.6 Packages: 1479
|
||||
Shell: Zsh v: 5.9 inxi: 3.3.21
|
21
js/init.js
21
js/init.js
|
@ -1,6 +1,7 @@
|
|||
function init() {
|
||||
initStars()
|
||||
computeAge()
|
||||
insertSystemInfo()
|
||||
}
|
||||
|
||||
function initStars() {
|
||||
|
@ -13,10 +14,10 @@ function initStars() {
|
|||
]
|
||||
const len = colors.length
|
||||
|
||||
const canvas = document.querySelector('canvas#stars')
|
||||
const canvas = document.getElementById('stars')
|
||||
const css = getComputedStyle(canvas)
|
||||
|
||||
const w = canvas.width = styleValue(css.getPropertyValue('width' ))
|
||||
const w = canvas.width = styleValue(css.getPropertyValue('width'))
|
||||
const h = canvas.height = styleValue(css.getPropertyValue('height'))
|
||||
|
||||
// if CSS hasn't been loaded yet
|
||||
|
@ -67,3 +68,19 @@ function computeAge() {
|
|||
|
||||
document.getElementById('age-js').textContent = Math.floor(age)
|
||||
}
|
||||
|
||||
function insertSystemInfo() {
|
||||
|
||||
const inxi = document.getElementById('inxi')
|
||||
|
||||
let xhr = new XMLHttpRequest()
|
||||
xhr.open('GET', '/inxi.txt')
|
||||
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState != xhr.DONE) return
|
||||
if (xhr.status != 200) return
|
||||
inxi.textContent = xhr.response
|
||||
}
|
||||
|
||||
xhr.send()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue