site

Website's source files.
Log | Files | Refs | Submodules | LICENSE

commit 5e906f09d1b87591bfe764c0fbe27cc741dfee03
parent 40eb4f97bf28a854f74c65b942c86f02df4d81e1
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date:   Mon, 24 Jan 2022 01:51:05 -0800

Better background colors, bkgs chosen by server

Diffstat:
Mpublic/css/terminal.css | 7++++++-
Mserver.ts | 22++++++++++++++++++++++
Mviews/index.handlebars | 1+
Mviews/layouts/main.handlebars | 1-
Mviews/post.handlebars | 1+
5 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/public/css/terminal.css b/public/css/terminal.css @@ -55,9 +55,14 @@ h4 { padding: 0; margin: auto; margin-top: auto; - background-color: rgba(200,200,200,0.2); + background-color: rgba(41,44,45,0.6); border: 0.1em solid white; text-align: center; + text-shadow: + -1px -1px 0 #000, + 1px -1px 0 #000, + -1px 1px 0 #000, + 1px 1px 0 #000; } #taskbar div { diff --git a/server.ts b/server.ts @@ -8,6 +8,27 @@ import fs from 'fs'; const app = express(); const port = process.env.PORT || 3000; +let theBkgScript = ''; +let allBkgScripts: string[] = []; + +function getBkgScripts(scriptDir: string) : string[] { + let result: string[] = []; + let files = fs.readdirSync(scriptDir); + files.forEach(file => { + if(path.extname(file) == '.js' && file != 'backs.js') { + result.push(file); + } + }); + return result; +} + +allBkgScripts = getBkgScripts('./external/site-bkgs/bin/'); +theBkgScript = allBkgScripts[Math.floor(Math.random() * allBkgScripts.length)]; + +// Get a new background script once per day. +setInterval(() => { + theBkgScript = allBkgScripts[Math.floor(Math.random() * allBkgScripts.length)]; +}, (1000 * 60 * 60 * 24)); function getMonthByNumber(i: number) : string { const months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', @@ -187,6 +208,7 @@ app.get('/', (req, res, next) => { windows: [new TerminalWindow(new Cat('public/figlet.html'), new LS('.', '.html', ['main', 'software', 'sneed']), new Cat('public/front.html'))], + bkgScript: `/site-bkgs/bin/${theBkgScript}`, }); }); diff --git a/views/index.handlebars b/views/index.handlebars @@ -1,3 +1,4 @@ {{#each windows}} {{> terminalTemplate}} {{/each}} +<script type="module" defer src={{bkgScript}}></script> diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars @@ -15,7 +15,6 @@ </head> <body> <div id="preamble" class="status"> - <script type="module" defer src="/site-bkgs/bin/archs.js"></script> <div id="task-meta" class="topl"> <h4 style="margin-left:1em; margin-top:0.5em;">Links</h4> <hr> diff --git a/views/post.handlebars b/views/post.handlebars @@ -1 +1,2 @@ Post +<script type="module" defer src="/site-bkgs/bin/{{bkgScript}}"></script>