Изменён тип роутеров с # на /
This commit is contained in:
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,6 +1,11 @@
|
|||||||
.parcel-cache/
|
.parcel-cache/
|
||||||
.parcel-app/
|
|
||||||
ec*.exe
|
|
||||||
public/
|
|
||||||
content/
|
content/
|
||||||
app/bootstrap*
|
app/bootstrap*
|
||||||
|
|
||||||
|
# new env
|
||||||
|
dev/
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# for windows
|
||||||
|
ec*.exe
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
public/
|
|
||||||
static/
|
|
||||||
app/assets/css/bootstrap*
|
app/assets/css/bootstrap*
|
||||||
app/assets/js/bootstrap*
|
app/assets/js/bootstrap*
|
||||||
package.json
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
server/
|
server/
|
||||||
*.md
|
*.md
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
## Используемые технологии
|
## Используемые технологии
|
||||||
|
|
||||||
- **Языки:** **JavaScript** для фрота, **Crystal** для бэка и **Bash** для скриптов.
|
- **Языки:** **JavaScript** для фрота, **Crystal** для бэка и **Bash** для скриптов.
|
||||||
- **Инструменты:** Parcel, Prettier, EditorConfig
|
- **Инструменты:** Parcel, Prettier, EditorConfig, nginx
|
||||||
|
|
||||||
## Сборка
|
## Сборка
|
||||||
|
|
||||||
|
|||||||
45
app/app.js
45
app/app.js
@@ -22,7 +22,17 @@ window.onload = function () {
|
|||||||
document.getElementById('app_theme_switcher').addEventListener('click', switch_theme, false);
|
document.getElementById('app_theme_switcher').addEventListener('click', switch_theme, false);
|
||||||
|
|
||||||
// routes handler
|
// routes handler
|
||||||
window.addEventListener('hashchange', location_handler);
|
document.addEventListener('click', (e) => {
|
||||||
|
const { target } = e;
|
||||||
|
if (!target.matches('nav a')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
route();
|
||||||
|
});
|
||||||
|
|
||||||
|
window.onpopstate = location_handler;
|
||||||
|
window.route = route;
|
||||||
location_handler();
|
location_handler();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -46,11 +56,24 @@ function switch_theme() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const route = (event) => {
|
||||||
|
event = event || window.event; // get window.event if event argument not provided
|
||||||
|
event.preventDefault();
|
||||||
|
// window.history.pushState(state, unused, target link);
|
||||||
|
window.history.pushState({}, '', event.target.href);
|
||||||
|
location_handler();
|
||||||
|
};
|
||||||
|
|
||||||
const location_handler = async () => {
|
const location_handler = async () => {
|
||||||
let location = window.location.hash.replace('#', '');
|
const url = window.location.pathname;
|
||||||
if (location.length == 0) {
|
let location;
|
||||||
|
|
||||||
|
if (url == 0 || url == '/') {
|
||||||
location = '/';
|
location = '/';
|
||||||
|
} else {
|
||||||
|
location = url.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const route = routes[location] || routes['404'];
|
const route = routes[location] || routes['404'];
|
||||||
const html = await fetch(route.template).then((response) => response.text());
|
const html = await fetch(route.template).then((response) => response.text());
|
||||||
document.getElementById('content').innerHTML = html;
|
document.getElementById('content').innerHTML = html;
|
||||||
@@ -58,11 +81,19 @@ const location_handler = async () => {
|
|||||||
document.querySelector('meta[name="description"]').setAttribute('content', route.description);
|
document.querySelector('meta[name="description"]').setAttribute('content', route.description);
|
||||||
|
|
||||||
if (route.script) {
|
if (route.script) {
|
||||||
let script = document.getElementById('content').querySelector('script');
|
const route_script = document.getElementById('content').querySelector('script');
|
||||||
document.querySelector('#autorun').innerHTML = script.innerHTML;
|
let autorun_script = document.querySelector('#autorun');
|
||||||
script.remove();
|
|
||||||
|
|
||||||
eval(document.querySelector('#autorun').innerHTML);
|
// инициализирует новый блок кода
|
||||||
|
autorun_script.remove();
|
||||||
|
autorun_script = document.createElement('script');
|
||||||
|
autorun_script.setAttribute('type', 'module');
|
||||||
|
autorun_script.setAttribute('id', 'autorun');
|
||||||
|
autorun_script.innerHTML = route_script.innerHTML;
|
||||||
|
|
||||||
|
// удаляет скрипт из загруженной страницы и запускает новый
|
||||||
|
route_script.remove();
|
||||||
|
document.body.append(autorun_script);
|
||||||
} else {
|
} else {
|
||||||
document.querySelector('#autorun').innerHTML = '';
|
document.querySelector('#autorun').innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/* SITE */
|
/* SITE */
|
||||||
Last update: Sun Aug 06 04:57 AM MSK 2023
|
Last update: Sun Aug 19 02:47 AM MSK 2023
|
||||||
Language: Russian
|
Language: Russian
|
||||||
Doctype: HTML5
|
Doctype: HTML5
|
||||||
IDE: Sublime Text 4
|
IDE: Sublime Text 4
|
||||||
Tools: Parcel, Prettier, EditorConfig
|
Tools: Parcel, Prettier, EditorConfig, nginx
|
||||||
Components: Bootstrap 5.3.1
|
Components: Bootstrap 5.3.1
|
||||||
Server: 1Gb RAM 1CPU KVM by FirstVDS
|
Server: 1Gb RAM 1CPU KVM by FirstVDS
|
||||||
Server OS: ArchLinux rolling
|
Server OS: ArchLinux rolling
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
Home
|
Home
|
||||||
</a>
|
</a>
|
||||||
<a class="nav-link fw-bold py-1 px-0 icon-link" href="#about">
|
<a class="nav-link fw-bold py-1 px-0 icon-link" href="/about">
|
||||||
<svg
|
<svg
|
||||||
class="svg-icon"
|
class="svg-icon"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
|||||||
@@ -1,106 +1,135 @@
|
|||||||
<ul class="dropdown-menu d-block position-static shadow mb-3 mb-md-0">
|
<nav>
|
||||||
<li>
|
<ul class="dropdown-menu d-block position-static shadow mb-3 mb-md-0">
|
||||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#games">
|
<li>
|
||||||
<svg
|
<a class="dropdown-item d-flex gap-2 align-items-center" href="/games">
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<svg
|
||||||
width="16"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
height="16"
|
width="16"
|
||||||
viewBox="0 0 24 24"
|
height="16"
|
||||||
fill="none"
|
viewBox="0 0 24 24"
|
||||||
stroke="currentColor"
|
fill="none"
|
||||||
stroke-width="2"
|
stroke="currentColor"
|
||||||
stroke-linecap="round"
|
stroke-width="2"
|
||||||
stroke-linejoin="round"
|
stroke-linecap="round"
|
||||||
class="feather feather-activity">
|
stroke-linejoin="round"
|
||||||
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
|
class="feather feather-activity">
|
||||||
</svg>
|
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
|
||||||
Games
|
</svg>
|
||||||
</a>
|
Games
|
||||||
</li>
|
</a>
|
||||||
<li><hr class="dropdown-divider" /></li>
|
</li>
|
||||||
<li>
|
<li><hr class="dropdown-divider" /></li>
|
||||||
<a
|
<li>
|
||||||
class="dropdown-item d-flex gap-2 align-items-center"
|
<a class="dropdown-item d-flex gap-2 align-items-center" href="/old_pc">
|
||||||
href="https://ё.a2s.su/"
|
Старые компьютеры
|
||||||
target="_blank">
|
</a>
|
||||||
<svg
|
</li>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<li><hr class="dropdown-divider" /></li>
|
||||||
width="16"
|
<li>
|
||||||
height="16"
|
<a
|
||||||
viewBox="0 0 24 24"
|
class="dropdown-item d-flex gap-2 align-items-center"
|
||||||
fill="none"
|
href="https://ё.a2s.su/"
|
||||||
stroke="currentColor"
|
target="_blank">
|
||||||
stroke-width="2"
|
<svg
|
||||||
stroke-linecap="round"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
stroke-linejoin="round"
|
width="16"
|
||||||
class="feather feather-book">
|
height="16"
|
||||||
<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path>
|
viewBox="0 0 24 24"
|
||||||
<path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path>
|
fill="none"
|
||||||
</svg>
|
stroke="currentColor"
|
||||||
Буква <span class="font-monospace">ё</span>
|
stroke-width="2"
|
||||||
</a>
|
stroke-linecap="round"
|
||||||
</li>
|
stroke-linejoin="round"
|
||||||
<li><hr class="dropdown-divider" /></li>
|
class="feather feather-book">
|
||||||
<li>
|
<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path>
|
||||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#git">
|
<path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path>
|
||||||
<svg
|
</svg>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
Буква <span class="font-monospace">ё</span>
|
||||||
width="16"
|
</a>
|
||||||
height="16"
|
</li>
|
||||||
viewBox="0 0 24 24"
|
<li><hr class="dropdown-divider" /></li>
|
||||||
fill="none"
|
<li>
|
||||||
stroke="currentColor"
|
<a class="dropdown-item d-flex gap-2 align-items-center" href="/irc">
|
||||||
stroke-width="2"
|
<svg
|
||||||
stroke-linecap="round"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
stroke-linejoin="round">
|
width="16"
|
||||||
<path
|
height="16"
|
||||||
d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" />
|
viewBox="0 0 24 24"
|
||||||
<polyline points="3.27 6.96 12 12.01 20.73 6.96" />
|
fill="none"
|
||||||
<line x1="12" y1="22.08" x2="12" y2="12" />
|
stroke="currentColor"
|
||||||
</svg>
|
stroke-width="2"
|
||||||
Git инстанс
|
stroke-linecap="round"
|
||||||
</a>
|
stroke-linejoin="round">
|
||||||
</li>
|
<line x1="4" y1="9" x2="20" y2="9" />
|
||||||
<li><hr class="dropdown-divider" /></li>
|
<line x1="4" y1="15" x2="20" y2="15" />
|
||||||
<li>
|
<line x1="10" y1="3" x2="8" y2="21" />
|
||||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#personal">
|
<line x1="16" y1="3" x2="14" y2="21" />
|
||||||
<svg
|
</svg>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="16"
|
IRC сервер
|
||||||
height="16"
|
</a>
|
||||||
viewBox="0 0 24 24"
|
</li>
|
||||||
fill="none"
|
<li>
|
||||||
stroke="currentColor"
|
<a class="dropdown-item d-flex gap-2 align-items-center" href="/git">
|
||||||
stroke-width="2"
|
<svg
|
||||||
stroke-linecap="round"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
stroke-linejoin="round"
|
width="16"
|
||||||
class="feather feather-user">
|
height="16"
|
||||||
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
|
viewBox="0 0 24 24"
|
||||||
<circle cx="12" cy="7" r="4"></circle>
|
fill="none"
|
||||||
</svg>
|
stroke="currentColor"
|
||||||
Personal
|
stroke-width="2"
|
||||||
</a>
|
stroke-linecap="round"
|
||||||
</li>
|
stroke-linejoin="round">
|
||||||
<li>
|
<path
|
||||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#trash">
|
d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" />
|
||||||
<svg
|
<polyline points="3.27 6.96 12 12.01 20.73 6.96" />
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<line x1="12" y1="22.08" x2="12" y2="12" />
|
||||||
width="16"
|
</svg>
|
||||||
height="16"
|
Git инстанс
|
||||||
viewBox="0 0 24 24"
|
</a>
|
||||||
fill="none"
|
</li>
|
||||||
stroke="currentColor"
|
<li><hr class="dropdown-divider" /></li>
|
||||||
stroke-width="2"
|
<li>
|
||||||
stroke-linecap="round"
|
<a class="dropdown-item d-flex gap-2 align-items-center" href="/personal">
|
||||||
stroke-linejoin="round"
|
<svg
|
||||||
class="feather feather-trash-2">
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<polyline points="3 6 5 6 21 6"></polyline>
|
width="16"
|
||||||
<path
|
height="16"
|
||||||
d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
viewBox="0 0 24 24"
|
||||||
<line x1="10" y1="11" x2="10" y2="17"></line>
|
fill="none"
|
||||||
<line x1="14" y1="11" x2="14" y2="17"></line>
|
stroke="currentColor"
|
||||||
</svg>
|
stroke-width="2"
|
||||||
Trash
|
stroke-linecap="round"
|
||||||
</a>
|
stroke-linejoin="round"
|
||||||
</li>
|
class="feather feather-user">
|
||||||
</ul>
|
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
|
||||||
|
<circle cx="12" cy="7" r="4"></circle>
|
||||||
|
</svg>
|
||||||
|
Personal
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="dropdown-item d-flex gap-2 align-items-center" href="/trash">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
class="feather feather-trash-2">
|
||||||
|
<polyline points="3 6 5 6 21 6"></polyline>
|
||||||
|
<path
|
||||||
|
d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
||||||
|
<line x1="10" y1="11" x2="10" y2="17"></line>
|
||||||
|
<line x1="14" y1="11" x2="14" y2="17"></line>
|
||||||
|
</svg>
|
||||||
|
Trash
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|||||||
14
package.json
14
package.json
@@ -1,18 +1,16 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "a2s",
|
"name": "a2s",
|
||||||
"version": "1.0.0",
|
"version": "0.0.0",
|
||||||
"description": "ololo",
|
"description": "ololo",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "npx parcel serve --dist-dir .parcel-app app/index.html icons/*.png pages/*.html content/*/*/*",
|
"develop": "npm run clean; ln -s pages/ dev/pages/; npm run watch-app",
|
||||||
"serve-https": "npx parcel serve --https --dist-dir public app/index.html pages/*.html content/*/*/*",
|
"watch-app": "npx parcel watch --dist-dir dev/ app/index.html",
|
||||||
"build": "npm run clean; npm run build-pages; npm run build-app; npm run git-hash",
|
"build": "npm run clean; npm run build-app; npm run git-hash",
|
||||||
"build-app": "npx parcel build --no-cache --no-source-maps --no-optimize --no-content-hash --dist-dir public app/index.html",
|
"build-app": "npx parcel build --no-cache --no-source-maps --no-optimize --no-content-hash --dist-dir dist/ app/index.html",
|
||||||
"build-pages": "npx parcel build --no-cache --no-source-maps --no-optimize --no-content-hash --dist-dir public/ content/*/*/* pages/*.html",
|
|
||||||
"prettier": "npx prettier --write .",
|
"prettier": "npx prettier --write .",
|
||||||
"git-hash": "./update_commit.sh",
|
"git-hash": "./update_commit.sh",
|
||||||
"clean": "rm -rf ./public/ &> /dev/null",
|
"clean": "rm -rf ./dev/* ./dist/* &> /dev/null"
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
},
|
||||||
"author": "Alexander Popov <iiiypuk@fastmail.fm>",
|
"author": "Alexander Popov <iiiypuk@fastmail.fm>",
|
||||||
"license": "WTFPL",
|
"license": "WTFPL",
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import { update_lastfm_nowplay } from './js/lastfm-nowplay.js';
|
import { update_lastfm_nowplay } from '/pages/js/lastfm-nowplay.js';
|
||||||
|
|
||||||
function autorun() {
|
function autorun() {
|
||||||
if (!window.DEBUG) {
|
if (!window.DEBUG) {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import { update_rev2 } from './js/rev2.js';
|
import { update_rev2 } from '/pages/js/rev2.js';
|
||||||
|
|
||||||
function autorun() {
|
function autorun() {
|
||||||
if (!window.DEBUG) {
|
if (!window.DEBUG) {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -f "./public/index.html" ]; then
|
if [ -f "./dist/index.html" ]; then
|
||||||
GIT_COMMIT_HASH=$(git rev-parse --short HEAD)
|
GIT_COMMIT_HASH=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
echo -n "Update git commit hash in 'index.html' "
|
echo -n "Update git commit hash in 'index.html' "
|
||||||
sed -i -- "s/{GIT_COMMIT_HASH}/$GIT_COMMIT_HASH/g" ./public/index.html
|
sed -i -- "s/{GIT_COMMIT_HASH}/$GIT_COMMIT_HASH/g" ./dist/index.html
|
||||||
echo " Complete!"
|
echo " Complete!"
|
||||||
else
|
else
|
||||||
echo "Run 'npm run build'"
|
echo "Run 'npm run build'"
|
||||||
|
|||||||
Reference in New Issue
Block a user