Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
d26a88628b | |||
d499e013f5 | |||
b64ccd6975 | |||
c994698e2d | |||
fd1675f57a | |||
3865a79dbc | |||
f228d86e0b |
@ -10,8 +10,9 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"sass": "^1.85.1",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript": "^5.8.2",
|
||||
"vite": "^6.2.0",
|
||||
"vite-plugin-html": "^3.2.2"
|
||||
"vite-plugin-html": "^3.2.2",
|
||||
"vite-plugin-ejs": "^1.7.0"
|
||||
}
|
||||
}
|
11
src/html/footer.html
Normal file
11
src/html/footer.html
Normal file
@ -0,0 +1,11 @@
|
||||
<p class="raw-text" id="time">00:00:00</p>
|
||||
<section>
|
||||
<p class="raw-text" id="column-line">0, 0</p>
|
||||
<button id="toggle-monospace">Monospace</button>
|
||||
<button id="toggle-term-mode">UNIX</button>
|
||||
</section>
|
||||
<noscript>
|
||||
<style>
|
||||
#toggle-monospace, .raw-text { display: none }
|
||||
</style>
|
||||
</noscript>
|
14
src/html/header.html
Normal file
14
src/html/header.html
Normal file
@ -0,0 +1,14 @@
|
||||
<button class="header-left">
|
||||
<a href="https://rhpidfyre.io/" class="header-button">[rhpidfyre.io]</a>
|
||||
</button>
|
||||
<section class="header-right">
|
||||
<button>
|
||||
<a href="https://git.rhpidfyre.io/" class="header-button">GIT</a>
|
||||
</button>
|
||||
<button>
|
||||
<a href="https://files.rhpidfyre.io/" class="header-button">CLOUD</a>
|
||||
</button>
|
||||
<button>
|
||||
<a href="https://gsm.rhpidfyre.io/" class="header-button">GSM</a>
|
||||
</button>
|
||||
</section>
|
17
src/html/motd.html
Normal file
17
src/html/motd.html
Normal file
@ -0,0 +1,17 @@
|
||||
<p>Welcome to rhpidfyre.io!</p>
|
||||
<div class="return"></div>
|
||||
<p>This is a personal website by rhpidfyre / Brandon.</p>
|
||||
<p>You can find my services here or learn about me.</p>
|
||||
<div class="return"></div>
|
||||
<p>You can also contribute or view the source code of my website via the links:</p>
|
||||
<p><<a href="https://git.rhpidfyre.io/rhpidfyre/rhpidfyre.io" target="_blank">https://git.rhpidfyre.io/rhpidfyre/rhpidfyre.io</a>>.</p>
|
||||
<p><<a href="https://github.com/unixtensor/rhpidfyre.io" target="_blank">https://github.com/unixtensor/rhpidfyre.io</a>>.</p>
|
||||
<div class="return"></div>
|
||||
<p>You can get started with the command: <span class="bold">help</span></p>
|
||||
<div class="return"></div>
|
||||
<noscript>
|
||||
<p><span class="red">=================================================</span></p>
|
||||
<p><span class="red">JavaScript is disabled, functionality will be limited. :(</span></p>
|
||||
<p><span class="red">But, you will not be limited at exploring my services which you can find by navigating towards the top-right.</span></p>
|
||||
<p><span class="red">=================================================</span></p>
|
||||
</noscript>
|
22
src/index.ejs
Normal file
22
src/index.ejs
Normal file
@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width"/>
|
||||
<link rel="icon" type="image/png" href="/logo.png"/>
|
||||
<link rel="stylesheet" href="./scss/global.scss"/>
|
||||
<title>rhpidfyre.io</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<%- inlineHtml("header") %>
|
||||
</header>
|
||||
<main>
|
||||
<%- inlineHtml("motd") %>
|
||||
</main>
|
||||
<footer>
|
||||
<%- inlineHtml("footer") %>
|
||||
</footer>
|
||||
<script type="module" src="./rt/emulator/terminal.ts"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,61 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width"/>
|
||||
<link rel="icon" type="image/png" href="/logo.png"/>
|
||||
<link rel="stylesheet" href="./scss/global.scss"/>
|
||||
<title>rhpidfyre.io</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<button class="header-left">
|
||||
<a href="https://rhpidfyre.io/" class="header-button">[rhpidfyre.io]</a>
|
||||
</button>
|
||||
<section class="header-right">
|
||||
<button>
|
||||
<a href="https://git.rhpidfyre.io/" class="header-button">GIT</a>
|
||||
</button>
|
||||
<button>
|
||||
<a href="https://files.rhpidfyre.io/" class="header-button">CLOUD</a>
|
||||
</button>
|
||||
<button>
|
||||
<a href="https://gsm.rhpidfyre.io/" class="header-button">GSM</a>
|
||||
</button>
|
||||
</section>
|
||||
</header>
|
||||
<main>
|
||||
<p>Welcome to rhpidfyre.io!</p>
|
||||
<div class="return"></div>
|
||||
<p>This is a personal website by rhpidfyre / Brandon.</p>
|
||||
<p>You can find my services here or learn about me.</p>
|
||||
<div class="return"></div>
|
||||
<p>You can also contribute or view the source code of my website via the links:</p>
|
||||
<p><<a href="https://git.rhpidfyre.io/rhpidfyre/rhpidfyre.io" target="_blank">https://git.rhpidfyre.io/rhpidfyre/rhpidfyre.io</a>>.</p>
|
||||
<p><<a href="https://github.com/unixtensor/rhpidfyre.io" target="_blank">https://github.com/unixtensor/rhpidfyre.io</a>>.</p>
|
||||
<div class="return"></div>
|
||||
<p>You can get started with the command: <span class="bold">help</span></p>
|
||||
<div class="return"></div>
|
||||
<noscript>
|
||||
<p><span class="red">=================================================</span></p>
|
||||
<p><span class="red">JavaScript is disabled, functionality will be limited. :(</span></p>
|
||||
<p><span class="red">But, you will not be limited at exploring my services which you can find by navigating towards the top-right.</span></p>
|
||||
<p><span class="red">=================================================</span></p>
|
||||
</noscript>
|
||||
</main>
|
||||
<footer>
|
||||
<p class="raw-text" id="time">00:00:00</p>
|
||||
<section>
|
||||
<p class="raw-text" id="column-line">0, 0</p>
|
||||
<button id="toggle-monospace">Monospace</button>
|
||||
<button id="toggle-term-mode">UNIX</button>
|
||||
</section>
|
||||
<noscript>
|
||||
<style>
|
||||
#toggle-monospace, .raw-text { display: none }
|
||||
</style>
|
||||
</noscript>
|
||||
</footer>
|
||||
<script type="module" src="./rt/emulator/terminal.ts"></script>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 5.7 KiB |
46
src/rt/rfwfs/collection.ts
Normal file
46
src/rt/rfwfs/collection.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { type Entry } from "./main"
|
||||
|
||||
import entry_search from "./index"
|
||||
|
||||
type Files<T> = Entry<T>[]
|
||||
|
||||
interface EntryCollectionManipulate {
|
||||
pop: <T extends Entry<T>>(file_name: string) => Entry<T> | undefined,
|
||||
get: <T extends Entry<T>>(file_name: string) => Entry<T> | undefined
|
||||
push: <T extends Entry<T>>(entry: Entry<T>) => boolean,
|
||||
sort: () => void,
|
||||
}
|
||||
interface EntryCollection<T> extends EntryCollectionManipulate {
|
||||
readonly inner: Files<T>
|
||||
}
|
||||
|
||||
function entry_trait<T extends Entry<T>>() {
|
||||
const trait = {} as EntryCollection<T>
|
||||
trait.sort = function() {
|
||||
this.inner.sort((a,z) => a.name.localeCompare(z.name))
|
||||
}
|
||||
trait.push = function(entry) {
|
||||
const no_duplicates = entry_search(this.inner, entry.name)
|
||||
if (!no_duplicates) {
|
||||
this.push(entry)
|
||||
this.sort()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
trait.pop = function(file_name) {
|
||||
const file_search = entry_search(this.inner, file_name)
|
||||
if (file_search) {
|
||||
this.inner.splice(file_search.index, 1)
|
||||
return file_search.result
|
||||
}
|
||||
return
|
||||
}
|
||||
return trait
|
||||
}
|
||||
|
||||
export {
|
||||
entry_trait,
|
||||
type EntryCollection,
|
||||
type Files,
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
const enum EntryType {
|
||||
Directory,
|
||||
File
|
||||
}
|
||||
const enum Permissions {
|
||||
r,
|
||||
w,
|
||||
rw
|
||||
}
|
||||
|
||||
type FsList = FsEntry[]
|
||||
type FsEntry = Entry<{}>
|
||||
type FsDirectory = Entry<FsList>
|
||||
|
||||
type File = string
|
||||
interface Entry<T = File> {
|
||||
readonly inner?: T,
|
||||
readonly name: string,
|
||||
readonly type: EntryType,
|
||||
readonly permissions: Permissions
|
||||
}
|
||||
function Entry<T = File>(name: string, inner: T, permissions: Permissions): Entry<T> {
|
||||
return {
|
||||
type: typeof inner == "object" ? EntryType.Directory : EntryType.File,
|
||||
inner: inner,
|
||||
name: name,
|
||||
permissions: permissions
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
type FsDirectory,
|
||||
type FsEntry,
|
||||
type FsList,
|
||||
EntryType,
|
||||
Permissions,
|
||||
Entry
|
||||
}
|
@ -1,78 +1,28 @@
|
||||
import { type FsList, type FsEntry } from "./core"
|
||||
import { type Entry } from "./main"
|
||||
import { type Files } from "./collection"
|
||||
|
||||
interface SearchResult<T> {
|
||||
item: T,
|
||||
binary_index: number
|
||||
readonly result: T,
|
||||
readonly index: number
|
||||
}
|
||||
interface Search {
|
||||
binary_fs: (cloned_list: FsList, file_name: string) => SearchResult<FsEntry> | undefined,
|
||||
binary_nsort: <T>(list: T[], find: T, start: number, end: number) => SearchResult<T> | undefined,
|
||||
binary: <T>(list: T[], find: T) => SearchResult<T> | undefined,
|
||||
linear: <T>(list: T[], find: T) => SearchResult<T> | undefined,
|
||||
function wrap_result<T>(result: T, index: number): SearchResult<T> {
|
||||
return { result: result, index: index }
|
||||
}
|
||||
|
||||
function wrap_result<T>(item: T, binary_index: number): SearchResult<T> {
|
||||
return { item: item, binary_index: binary_index }
|
||||
}
|
||||
|
||||
const search = {} as Search
|
||||
|
||||
search.binary = function(list, find) {
|
||||
list.sort()
|
||||
export default function entry_search<T>(cloned_file_collection: Files<T>, file_name: string): SearchResult<Entry<T>> | undefined {
|
||||
let start = 0
|
||||
let end = list.length-1
|
||||
let end = cloned_file_collection.length-1
|
||||
while (start<=end) {
|
||||
const median = (start+end)>>1
|
||||
if (list[median] === find) {
|
||||
return wrap_result(list[median], median)
|
||||
} else if (list[median]<find) {
|
||||
start = median+1
|
||||
} else {
|
||||
end = median-1
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
const median_name = cloned_file_collection[median].name
|
||||
|
||||
search.binary_nsort = function(list, find, start = 0, end = list.length-1) {
|
||||
if (start>end) { return }
|
||||
const median = (start+end)>>1
|
||||
if (list[median] === find) {
|
||||
return wrap_result(list[median], median)
|
||||
}
|
||||
if (list[median]>find) {
|
||||
return this.binary_nsort(list, find, start, median-1)
|
||||
} else {
|
||||
return this.binary_nsort(list, find, median+1, end)
|
||||
}
|
||||
}
|
||||
|
||||
search.binary_fs = function(cloned_list, file_name) {
|
||||
cloned_list.sort((a,z) => a.name.localeCompare(z.name))
|
||||
let start = 0
|
||||
let end = cloned_list.length-1
|
||||
while (start<=end) {
|
||||
const median = (start+end)>>1
|
||||
const median_name = cloned_list[median].name
|
||||
|
||||
if (median_name === file_name) {
|
||||
return wrap_result(cloned_list[median], median)
|
||||
if (median_name == file_name) { //left == right && (T == U) is not necessary
|
||||
return wrap_result(cloned_file_collection[median], median)
|
||||
} else if (median_name<file_name) {
|
||||
start = median+1
|
||||
} else {
|
||||
end = median-1
|
||||
}
|
||||
}
|
||||
return
|
||||
return undefined
|
||||
}
|
||||
|
||||
search.linear = function(list, find) {
|
||||
for (let ind = 0; ind<list.length; ind++) {
|
||||
if (list[ind] === find) {
|
||||
return wrap_result(list[ind], ind)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
export default search
|
@ -1,85 +0,0 @@
|
||||
import { type FsDirectory, type FsEntry } from "./core"
|
||||
|
||||
import fstree from "./tree"
|
||||
import index from "./index"
|
||||
|
||||
let cached_dir = fstree[0] //start at root
|
||||
let working_path = ["/", "home", "user"]
|
||||
|
||||
const clone_working_path = () => [...working_path]
|
||||
|
||||
function get_working_dir_name() {
|
||||
return working_path[working_path.length-1]
|
||||
}
|
||||
|
||||
function get_working_dir_name_full(): string {
|
||||
const w_dir_clone = clone_working_path()
|
||||
const root = w_dir_clone.shift()
|
||||
if (root) {
|
||||
return root+w_dir_clone.join("/")
|
||||
}
|
||||
return "shift-error"
|
||||
}
|
||||
|
||||
const enum SetDirStatus {
|
||||
Valid,
|
||||
NotFound,
|
||||
NotADirectory,
|
||||
Invalid
|
||||
}
|
||||
interface FsIterEntry {
|
||||
readonly entry: FsDirectory | null,
|
||||
readonly status: SetDirStatus
|
||||
}
|
||||
function find_fs_dir(working_dir_path_clone: string[], find_dir_name: string): FsIterEntry {
|
||||
let cached_dir_clone = cached_dir.inner
|
||||
|
||||
for (let path_i = 0; path_i<working_dir_path_clone.length; path_i++) {
|
||||
if (cached_dir_clone) {
|
||||
let cached_dir_file_names: string[] = []
|
||||
cached_dir_clone.forEach((file, file_i) => cached_dir_file_names.push(file.name))
|
||||
|
||||
const search_result = index.binary(cached_dir_clone, fstree[0])
|
||||
|
||||
if (working_dir_path_clone[path_i] === find_dir_name) {
|
||||
cached_dir_clone = cached_dir_clone
|
||||
if (path_i === working_dir_path_clone.length) {
|
||||
const search_result = index.binary(cached_dir_file_names, find_dir_name)
|
||||
if (search_result) {
|
||||
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return { entry: null, status: SetDirStatus.Invalid }
|
||||
}
|
||||
return { entry: null, status: SetDirStatus.NotFound }
|
||||
}
|
||||
|
||||
function set_working_dir(name: string): SetDirStatus {
|
||||
if (name === ".") { return SetDirStatus.Valid }
|
||||
|
||||
const w_dir_clone = clone_working_path()
|
||||
if (name === "..") {
|
||||
w_dir_clone.pop()
|
||||
|
||||
} else {
|
||||
w_dir_clone.push(name)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function get_working_dir_entries(): FsEntry[] {
|
||||
|
||||
}
|
||||
|
||||
export {
|
||||
get_working_dir_name,
|
||||
get_working_dir_name_full,
|
||||
get_working_dir_entries,
|
||||
set_working_dir,
|
||||
SetDirStatus
|
||||
}
|
47
src/rt/rfwfs/main.ts
Normal file
47
src/rt/rfwfs/main.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { type EntryCollection } from "./collection"
|
||||
|
||||
const enum EntryType {
|
||||
Directory,
|
||||
File
|
||||
}
|
||||
const enum Permissions {
|
||||
r,
|
||||
w,
|
||||
rw,
|
||||
none
|
||||
}
|
||||
|
||||
interface Entry<T> {
|
||||
readonly name: string,
|
||||
readonly type: EntryType,
|
||||
readonly inner: T,
|
||||
readonly timestamp: number,
|
||||
readonly collection?: EntryCollection<T>,
|
||||
readonly permissions: Permissions,
|
||||
}
|
||||
interface Rfwfs {
|
||||
new_entry: <T extends Entry<T>>(name: string, permissions: Permissions, timestamp: number, inner: T) => Entry<T>,
|
||||
entry_trait: <T extends Entry<T>>(inner: T) => EntryCollection<T>
|
||||
new_entry_tree: <T>(files: T) => T,
|
||||
}
|
||||
|
||||
const rfwfs = {} as Rfwfs
|
||||
|
||||
rfwfs.new_entry = function(name, permissions, timestamp, inner) {
|
||||
const file_type = typeof inner == "object" ? EntryType.Directory : EntryType.File
|
||||
return {
|
||||
name: name,
|
||||
type: file_type,
|
||||
inner: inner,
|
||||
timestamp: timestamp ? timestamp : Math.floor(Date.now()/1000),
|
||||
collection: file_type === EntryType.Directory ? this.entry_trait(inner) : undefined,
|
||||
permissions: permissions,
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
EntryType,
|
||||
Permissions,
|
||||
type EntryCollection,
|
||||
type Entry,
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
import { Entry, Permissions } from "./core"
|
||||
|
||||
const user = [
|
||||
Entry("about_me.txt", "about me inside", Permissions.rw),
|
||||
Entry("services.txt", "services inside", Permissions.rw),
|
||||
Entry("hi", [], Permissions.rw)
|
||||
]
|
||||
const home = [
|
||||
Entry("user", user, Permissions.rw)
|
||||
]
|
||||
const root = [
|
||||
Entry("home", home, Permissions.r),
|
||||
Entry("bin", {}, Permissions.r),
|
||||
]
|
||||
const fstree = [
|
||||
Entry("/", root, Permissions.r)
|
||||
]
|
||||
|
||||
export default fstree
|
@ -1,9 +1,27 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { createHtmlPlugin } from 'vite-plugin-html'
|
||||
import { ViteEjsPlugin } from 'vite-plugin-ejs'
|
||||
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
|
||||
const html_dir = path.join(__dirname, "src", "html")
|
||||
|
||||
function inlineHtml(html_file_name) {
|
||||
try {
|
||||
const html_path = path.resolve(path.join(html_dir, html_file_name+".html"))
|
||||
return fs.readFileSync(html_path, "utf-8")
|
||||
} catch(read_err) {
|
||||
return "[INLINE-ERROR], "+read_err
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
createHtmlPlugin({minify: true}),
|
||||
ViteEjsPlugin({
|
||||
inlineHtml: inlineHtml
|
||||
})
|
||||
],
|
||||
root: "src",
|
||||
build: {
|
||||
|
Reference in New Issue
Block a user