Compare commits
2
Commits
65c776d1a2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
682d03e60c | ||
|
|
97296843df |
@@ -1,38 +1,62 @@
|
||||
# sv
|
||||
Preview can be found here -> https://gornodox.dev
|
||||
|
||||
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
|
||||
Hello everyone that decided to visit my repo.
|
||||
Today i present to you a 'Work In Progress', state of the art (not really) portfolio website.
|
||||
|
||||
## Creating a project
|
||||
The main idea was that the "bash terminal" would serve as the main interface that the user would interact with...
|
||||
|
||||
If you're seeing this, you've probably already done this step. Congrats!
|
||||
But then I thought to myself,
|
||||
>*Wouldn't it be cool if it would actually work like a terminal?`*
|
||||
|
||||
```sh
|
||||
# create a new project in the current directory
|
||||
npx sv create
|
||||
...and that's how we got here.
|
||||
|
||||
# create a new project in my-app
|
||||
npx sv create my-app
|
||||
```
|
||||
>***Make note that not all features listed below may be implemented when you're seeing this.***
|
||||
|
||||
## Developing
|
||||
The whole environment is a simulation of a linux environment, from every data structure to the way everything behaves. Theres a file system representation that gets generated from a live folder structure by [this](https://github.com/ChaosMakerMLG/FileSystemParser) project.
|
||||
This gets parsed by my website into the object structure that the whole `Bash` algorithm can deal and interact with.
|
||||
|
||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||
There are users, permissions, ownership, links (hard and symbolic)
|
||||
File system supports file contents - they get cached into a file with a name, and the node stored on heap just has the name to the correct file cache.
|
||||
|
||||
```sh
|
||||
npm run dev
|
||||
Every command is treated like a process that can be exited
|
||||
aswell as files being executable
|
||||
|
||||
# or start the server and open the app in a new browser tab
|
||||
npm run dev -- --open
|
||||
```
|
||||
All of this is purely data-driven and modular, so if you where to take my code and just implement an IO system that would interact with my algorithm, then it would work out of the box, which is REALLYYY COOOL in my opinion.
|
||||
|
||||
## Building
|
||||
All the changes that the user makes will be stored on their browsers `localStorage` and read out on login
|
||||
|
||||
To create a production version of your app:
|
||||
The website will still serve the purpose of being a portfolio but the actuall portfolio part will just be a process that is ran at initialization of the terminal, and it will display the info about me as a TUI ^w^
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
It can of course be shutdown as mentioned above and thats how you get access to the shell ;)
|
||||
|
||||
You can preview the production build with `npm run preview`.
|
||||
## This project uses and implements:
|
||||
|
||||
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
||||
- Tree traversal
|
||||
- Binary search
|
||||
- Quick sort
|
||||
- And much mode weird stuff...
|
||||
|
||||
## Commands:
|
||||
- return
|
||||
- ls
|
||||
- echo
|
||||
- touch
|
||||
- mkdir
|
||||
- pwd
|
||||
- cd
|
||||
- exit
|
||||
- cp
|
||||
- mv
|
||||
- rm
|
||||
- cat
|
||||
- less
|
||||
- chown
|
||||
- chmod
|
||||
- reboot
|
||||
- help
|
||||
- whoami
|
||||
- sudo
|
||||
- su
|
||||
- clear
|
||||
|
||||
> More will probably added with time :)
|
||||
@@ -225,7 +225,7 @@ function result_ls(this: Bash, data: any, args: CommandArgs): HTMLElement {
|
||||
colWidths.push(Math.max(...columns[i].map((name) => name.length)));
|
||||
}
|
||||
|
||||
const calcWidth: number = colWidths.reduce((prev, curr) => prev + curr) + ((c-1) * 2);
|
||||
const calcWidth: number = colWidths.reduce((prev, curr) => prev + curr) + ((c-1) * 3);
|
||||
|
||||
if(calcWidth < maxWidth) lowBound = c + 1;
|
||||
else if(calcWidth > maxWidth) highBound = c -1
|
||||
@@ -234,7 +234,6 @@ function result_ls(this: Bash, data: any, args: CommandArgs): HTMLElement {
|
||||
const wrapper: HTMLElement = document.createElement('div');
|
||||
|
||||
wrapper.style.display = 'flex';
|
||||
wrapper.style.columnGap = `${this.getTerminalFontSize() * 2}px`;
|
||||
wrapper.style.marginBottom = `${this.getTerminalFontSize() * 2}px`;
|
||||
|
||||
let fileIndex = 0;
|
||||
@@ -323,6 +322,7 @@ function formatChildren(node: TreeNode): string {
|
||||
if (!node.children) throw new Error('children array is null on this node');
|
||||
|
||||
const c = node.children.length.toString();
|
||||
console.log(c, "TEST TEST");
|
||||
return c.length > 1 ? c : ` ${c}`;
|
||||
}
|
||||
|
||||
@@ -362,35 +362,28 @@ function formatName(node: TreeNode, flag: any, shouldShift: boolean) {
|
||||
let name: string = node.name;
|
||||
const char: string = flag.has('Q') ? '"' : "'";
|
||||
|
||||
if (/\s/.test(node.name)) {
|
||||
name = `${char}${name}${char}`
|
||||
} else {
|
||||
//Shift non quoted names 1 char right to align if any names in group have a quote
|
||||
name = `${shouldShift ? ' ' : ''}${node.name}`;
|
||||
if (/\s/.test(node.name)) name = `${char}${name}${char}`;
|
||||
|
||||
if(flag.has('p') && node.type === Type.Directory) name = `${name}/`
|
||||
|
||||
if((flag.has('l') || flag.has('g') || flag.has('o'))) {
|
||||
// Is the ls in long format
|
||||
if (!(/\s/.test(node.name))) {
|
||||
//Shift non quoted names 1 char right to align if any names in group have a quote
|
||||
name = `${shouldShift ? ' ' : ''}${name}`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(/\s/.test(node.name))) {
|
||||
name = ` ${name}`;
|
||||
}
|
||||
|
||||
name = `${name} `;
|
||||
}
|
||||
|
||||
return flag.has('p') && node.type === Type.Directory ? `${name}/` : name;
|
||||
return name
|
||||
}
|
||||
|
||||
/* function formatOutputShort(node: TreeNode, flag: any) {
|
||||
let output: string = node.name;
|
||||
const char: string = flag.has('Q') ? '"' : "'";
|
||||
|
||||
if (/\s/.test(node.name)) {
|
||||
if(flag.has('i')) {
|
||||
|
||||
}
|
||||
else {
|
||||
output = `${char}${node.name}${char}`;
|
||||
}
|
||||
|
||||
if(flag.has('i')) {
|
||||
output = `${node.inode} ${output}`
|
||||
}
|
||||
|
||||
return flag.has('p') && node.type === Type.Directory ? ` ${output}/ ` : output;
|
||||
} */
|
||||
|
||||
const checkFlags = (pFlags: string[]) => {
|
||||
const flagSet = new Set(pFlags);
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
}
|
||||
|
||||
function getFontSize() {
|
||||
const e = document.getElementById('cout');
|
||||
return 10;
|
||||
/* const e = document.getElementById('cout');
|
||||
if(!e) {
|
||||
throw new Error('cant get font size of the terminal element. its null');
|
||||
}
|
||||
@@ -34,7 +35,7 @@
|
||||
const canvas = document.createElement('canvas');
|
||||
const ctx = canvas.getContext('2d')!;
|
||||
ctx.font = `${window.getComputedStyle(e, null).getPropertyValue('font-size')} 'JetBrains Mono', monospace;`;
|
||||
return ctx.measureText('M').width;
|
||||
return ctx.measureText(' ').width; */
|
||||
}
|
||||
|
||||
function handleInput(event: KeyboardEvent) {
|
||||
|
||||
Reference in New Issue
Block a user