diff --git a/data/data.db b/data/data.db index cb03fa3..71817c1 100644 Binary files a/data/data.db and b/data/data.db differ diff --git a/public/js/common/main.js b/public/js/common/main.js deleted file mode 100644 index d1425d9..0000000 --- a/public/js/common/main.js +++ /dev/null @@ -1,67 +0,0 @@ -document.addEventListener("DOMContentLoaded", () => { - // Get all "navbar-burger" elements - const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"), 0) - - // Add a click event on each of them - $navbarBurgers.forEach(el => { - el.addEventListener("click", () => { - // Get the target from the "data-target" attribute - const target = el.dataset.target - const $target = document.getElementById(target) - - // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu" - el.classList.toggle("is-active") - $target.classList.toggle("is-active") - }) - }) -}) - -document.addEventListener("DOMContentLoaded", () => { - // Functions to open and close a modal - function openModal($el) { - $el.classList.add("is-active") - } - - function closeModal($el) { - $el.classList.remove("is-active") - } - - function closeAllModals() { - ;(document.querySelectorAll(".modal") || []).forEach($modal => { - closeModal($modal) - }) - } - - // Add a click event on buttons to open a specific modal - ;(document.querySelectorAll(".js-modal-trigger") || []).forEach($trigger => { - const modal = $trigger.dataset.target - const $target = document.getElementById(modal) - - $trigger.addEventListener("click", () => { - openModal($target) - }) - }) - - // Add a click event on various child elements to close the parent modal - ;( - document.querySelectorAll( - ".modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button", - ) || [] - ).forEach($close => { - const $target = $close.closest(".modal") - - $close.addEventListener("click", () => { - closeModal($target) - }) - }) - - // Add a keyboard event to close all modals - document.addEventListener("keydown", event => { - const e = event || window.event - - if (e.keyCode === 27) { - // Escape key - closeAllModals() - } - }) -}) diff --git a/public/js/page/index.js b/public/js/page/index.js index 050ef83..993df4b 100644 --- a/public/js/page/index.js +++ b/public/js/page/index.js @@ -1 +1,46 @@ -console.log(2222) \ No newline at end of file +// Functions to open and close a modal +function openModal($el) { + $el.classList.add("is-active") +} + +function closeModal($el) { + $el.classList.remove("is-active") +} + +function closeAllModals() { + ;(document.querySelectorAll(".modal") || []).forEach($modal => { + closeModal($modal) + }) +} + +// Add a click event on buttons to open a specific modal +;(document.querySelectorAll(".js-modal-trigger") || []).forEach($trigger => { + const modal = $trigger.dataset.target + const $target = document.getElementById(modal) + + $trigger.addEventListener("click", () => { + openModal($target) + }) +}) + +// Add a click event on various child elements to close the parent modal +;( + document.querySelectorAll(".modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button") || + [] +).forEach($close => { + const $target = $close.closest(".modal") + + $close.addEventListener("click", () => { + closeModal($target) + }) +}) + +// Add a keyboard event to close all modals +document.addEventListener("keydown", event => { + const e = event || window.event + + if (e.keyCode === 27) { + // Escape key + closeAllModals() + } +}) diff --git a/public/upload/7ZKwRVLAZjvE4Q1TiaFKyNyl.jpg b/public/upload/7ZKwRVLAZjvE4Q1TiaFKyNyl.jpg new file mode 100644 index 0000000..02e8877 Binary files /dev/null and b/public/upload/7ZKwRVLAZjvE4Q1TiaFKyNyl.jpg differ diff --git a/public/upload/DfSnBa86Z1esxB5TZ4YWVi-i.jpg b/public/upload/DfSnBa86Z1esxB5TZ4YWVi-i.jpg new file mode 100644 index 0000000..02e8877 Binary files /dev/null and b/public/upload/DfSnBa86Z1esxB5TZ4YWVi-i.jpg differ diff --git a/public/upload/LbD5KJJ1nIdAJjrCSCpigySZ.jpg b/public/upload/LbD5KJJ1nIdAJjrCSCpigySZ.jpg new file mode 100644 index 0000000..02e8877 Binary files /dev/null and b/public/upload/LbD5KJJ1nIdAJjrCSCpigySZ.jpg differ diff --git a/public/upload/WHS-v_iuvglYsGar7Pysc5cG.jpg b/public/upload/WHS-v_iuvglYsGar7Pysc5cG.jpg new file mode 100644 index 0000000..02e8877 Binary files /dev/null and b/public/upload/WHS-v_iuvglYsGar7Pysc5cG.jpg differ diff --git a/public/upload/qF_hiQxR_hrv30spi7L-jM_4.jpg b/public/upload/qF_hiQxR_hrv30spi7L-jM_4.jpg new file mode 100644 index 0000000..02e8877 Binary files /dev/null and b/public/upload/qF_hiQxR_hrv30spi7L-jM_4.jpg differ diff --git a/source/route/func/index.ts b/source/route/func/index.ts new file mode 100644 index 0000000..055be33 --- /dev/null +++ b/source/route/func/index.ts @@ -0,0 +1,46 @@ +import { auth } from "@noderun/hapi-router" +import { Req, Res, ReturnValue } from "#/global" +import { exec } from "child_process" + +export default class Index { + @auth(false) + async index(request: Req, h: Res): ReturnValue { + exec("git pull", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`) + return + } + if (stderr) { + console.log(`stderr: ${stderr}`) + return + } + console.log(`stdout: ${stdout}`) + + exec('pkill -f "node"', (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`) + return + } + if (stderr) { + console.log(`stderr: ${stderr}`) + return + } + console.log(`stdout: ${stdout}`) + + exec("pnpm start", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`) + return + } + if (stderr) { + console.log(`stderr: ${stderr}`) + return + } + console.log(`stdout: ${stdout}`) + }) + }) + }) + + return h.response().code(200) + } +} diff --git a/template/helper/flush.pug b/template/helper/flush.pug index 0bab670..cbd01ea 100644 --- a/template/helper/flush.pug +++ b/template/helper/flush.pug @@ -1,5 +1,4 @@ //- 服务器反馈UI -include @/helper/helper.pug if flash - index = 0 if flash.error diff --git a/template/helper/helper.pug b/template/helper/helper.pug index 61718b4..b6ffbab 100644 --- a/template/helper/helper.pug +++ b/template/helper/helper.pug @@ -1,7 +1,11 @@ mixin css(href) link(rel="stylesheet", href="/public/"+href) + mixin script(src) script(src="/public/"+src) mixin security - include ./form_security.pug \ No newline at end of file + include ./form_security.pug + +mixin flush + include ./flush.pug \ No newline at end of file diff --git a/template/htmx/path/color.pug b/template/htmx/path/color.pug index 74282a9..2dba066 100644 --- a/template/htmx/path/color.pug +++ b/template/htmx/path/color.pug @@ -1,13 +1,11 @@ -include @/helper/flush.pug include @/helper/helper.pug ++flush() block var -title="颜色" // 网页标题 title 颜色 div(class="container page") - style - :public style/views/color.css if isLogin form(action="/color" method="post" style="margin: 0 auto; width: 500px;margin-top: 50px") h1 提交新颜色 @@ -32,47 +30,5 @@ div(class="container page") //- div(class=".wrapper_input"): input(type="text" tabindex="1" value="sadsa" name="a") //- div(class=".wrapper_input"): input(type="text" tabindex="3" value="sadsa" name="b") //- button(type="submit" tabindex="2") 提交 - h1 颜色表 #{temp.a} - div(class="color_list") - //- - - //- var list=[ - //- { color:"#00ffff",title: "青色",describe:""}, - //- { color:"#222222",title: "辅助色",describe:""}, - //- { color:"#8f8f8f",title: "辅助色",describe:""}, - //- { color:"#00d1b2",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- { color:"#999999",title: "辅助色",describe:""}, - //- ] - if list.length === 0 - div 空 - each item in list - div(class="color_item") - div(class="color_item_bg" style=`background: ${item.value}`) - div(class="color_toggle_list") - div(class="color_toggle_item") hex - div(class="color_toggle_item") rgba - div(class="color_item_name") #{item.color} - div(class="color_item_content") - div(class="color_item_title") #{item.name} - div(class="color_item_desc" title=item.desctibe) #{item.desctibe || "暂无描述"} - if isLogin - form(action="/color/del" method="post") - +security - input(type="text" value=item.id name="id" hidden) - button(type="submit" style="background: transparent;border:0;color:red;cursor: pointer;float: right;") 删除 - //- div(class="color_item") - //- img(src="/public/image/add.png", alt="添加" title="添加" class="color_add") \ No newline at end of file + .color-content + include @/htmx/ui/color-list.pug \ No newline at end of file diff --git a/template/htmx/path/index.pug b/template/htmx/path/index.pug index a17c247..3f50fd2 100644 --- a/template/htmx/path/index.pug +++ b/template/htmx/path/index.pug @@ -1,5 +1,5 @@ -include @/helper/flush.pug include @/helper/helper.pug ++flush() title 首页 block var @@ -9,8 +9,6 @@ block page div style :public style/views/index.css - script - :public js/page/index.js .content!= md button.js-modal-trigger(data-target='modal-js-example'). Open JS example modal @@ -26,31 +24,6 @@ block page button.button.is-success Save changes button.button Cancel button.modal-close.is-large(aria-label='close') - //- if isLogin - //- button(hx-target="#single-page" hx-get="/about?htmx" hx-push-url="/about" hx-trigger="click" hx-swap="innerHTML") Click Me! - - //- .tree#tree - //- details(open="true" style="direction: ltr;") - //- summary - //- span.tree-item sad - //- a.op(href="") 新建 - //- details(open="true") - //- summary - //- span.tree-item sad - //- a.op(href="") 新建 - //- details - //- summary - //- span.tree-item.tree-md-file - //- div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda - //- a.op(href="") 新建 - //- details - //- summary - //- span.tree-item.tree-md-file - //- div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda - //- a.op(href="") 新建 - //- details - //- summary - //- span.tree-item.tree-md-file.active - //- div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda - //- a.op(href="") 新建 - + script + :public js/page/index.js + include @/ui/tree.pug \ No newline at end of file diff --git a/template/htmx/ui/color-list.pug b/template/htmx/ui/color-list.pug new file mode 100644 index 0000000..f653494 --- /dev/null +++ b/template/htmx/ui/color-list.pug @@ -0,0 +1,48 @@ + +style + :public style/views/color.css + +h1 颜色表 #{temp.a} +div(class="color_list") + //- - + //- var list=[ + //- { color:"#00ffff",title: "青色",describe:""}, + //- { color:"#222222",title: "辅助色",describe:""}, + //- { color:"#8f8f8f",title: "辅助色",describe:""}, + //- { color:"#00d1b2",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- { color:"#999999",title: "辅助色",describe:""}, + //- ] + if list.length === 0 + div 空 + each item in list + div(class="color_item") + div(class="color_item_bg" style=`background: ${item.value}`) + div(class="color_toggle_list") + div(class="color_toggle_item") hex + div(class="color_toggle_item") rgba + div(class="color_item_name") #{item.color} + div(class="color_item_content") + div(class="color_item_title") #{item.name} + div(class="color_item_desc" title=item.desctibe) #{item.desctibe || "暂无描述"} + if isLogin + form(action="/color/del" method="post") + +security + input(type="text" value=item.id name="id" hidden) + button(type="submit" style="background: transparent;border:0;color:red;cursor: pointer;float: right;") 删除 + //- div(class="color_item") + //- img(src="/public/image/add.png", alt="添加" title="添加" class="color_add") \ No newline at end of file diff --git a/template/layout/layout.pug b/template/layout/layout.pug index b095f31..5af3d15 100644 --- a/template/layout/layout.pug +++ b/template/layout/layout.pug @@ -1,6 +1,5 @@ doctype html include @/helper/helper.pug -include @/helper/flush.pug block var html(lang="zh-cn" class=hideHeader?"":"has-navbar-fixed-top") @@ -23,5 +22,4 @@ html(lang="zh-cn" class=hideHeader?"":"has-navbar-fixed-top") block content //- script(src="https://unpkg.com/htmx.org@1.8.4" integrity="sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" crossorigin="anonymous") +script("js/common/htmx.min.js") - +script("js/common/main.js") block script diff --git a/template/layout/single-page.pug b/template/layout/single-page.pug index 26608e5..8edf306 100644 --- a/template/layout/single-page.pug +++ b/template/layout/single-page.pug @@ -1,6 +1,6 @@ extends @/layout/layout block content - section.section + main .container(id="single-page") block page diff --git a/template/ui/header.pug b/template/ui/header.pug index f831a3b..8bae2d9 100644 --- a/template/ui/header.pug +++ b/template/ui/header.pug @@ -49,3 +49,20 @@ nav.is-fixed-top.navbar(role='navigation', aria-label='main navigation', style=" +security a.navbar-item button(type="submit") 删除 + +script. + // Get all "navbar-burger" elements + const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"), 0) + + // Add a click event on each of them + $navbarBurgers.forEach(el => { + el.addEventListener("click", () => { + // Get the target from the "data-target" attribute + const target = el.dataset.target + const $target = document.getElementById(target) + + // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu" + el.classList.toggle("is-active") + $target.classList.toggle("is-active") + }) + }) \ No newline at end of file diff --git a/template/ui/tree.pug b/template/ui/tree.pug new file mode 100644 index 0000000..b38d2e4 --- /dev/null +++ b/template/ui/tree.pug @@ -0,0 +1,26 @@ + +.tree#tree + details(open="true" style="direction: ltr;") + summary + span.tree-item sad + a.op(href="") 新建 + details(open="true") + summary + span.tree-item sad + a.op(href="") 新建 + details + summary + span.tree-item.tree-md-file + div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda + a.op(href="") 新建 + details + summary + span.tree-item.tree-md-file + div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda + a.op(href="") 新建 + details + summary + span.tree-item.tree-md-file.active + div(style="flex: 1;width: 0;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;") asda + a.op(href="") 新建 +