add and run prettier & eslint

This commit is contained in:
David Reed 2022-09-15 18:39:00 -04:00
parent c471d03c90
commit 2143595613
14 changed files with 2711 additions and 419 deletions

1
.eslintignore Normal file
View file

@ -0,0 +1 @@
dist

7
.eslintrc.json Normal file
View file

@ -0,0 +1,7 @@
{
"root": true,
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
}
}

1
.prettierignore Normal file
View file

@ -0,0 +1 @@
dist

4
.prettierrc.json Normal file
View file

@ -0,0 +1,4 @@
{
"useTabs": false,
"singleQuote": false
}

View file

@ -7,21 +7,28 @@ Static files/assets used to spin up an Ultraviolet website.
## Packaging ## Packaging
1. Clone the repository 1. Clone the repository
```sh ```sh
$ git clone https://github.com/titaniumnetwork-development/Ultraviolet-Static.git $ git clone https://github.com/titaniumnetwork-development/Ultraviolet-Static.git
> Cloning into Ultraviolet-Static... > Cloning into Ultraviolet-Static...
$ cd Ultraviolet-Static $ cd Ultraviolet-Static
``` ```
2. Install dependencies 2. Install dependencies
```sh ```sh
npm install npm install
``` ```
3. Make your changes... 3. Make your changes...
4. Produce the `dist/` directory and import the Ultraviolet scripts 4. Produce the `dist/` directory and import the Ultraviolet scripts
```sh ```sh
npm run build npm run build
``` ```
5. Package for NPM to produce `ultraviolet-static.X.X.X.tar.gz` file 5. Package for NPM to produce `ultraviolet-static.X.X.X.tar.gz` file
```sh ```sh
npm pack npm pack
``` ```
@ -30,12 +37,15 @@ npm pack
1. Follow installation steps until you need to run `npm install` 1. Follow installation steps until you need to run `npm install`
2. Install the produced Ultraviolet-Static tgz (upload to Discord, Github, etc...) (see [Packaging](#packaging)) 2. Install the produced Ultraviolet-Static tgz (upload to Discord, Github, etc...) (see [Packaging](#packaging))
```sh ```sh
$ npm install https://github.com/titaniumnetwork-development/Ultraviolet-Static/releases/download/v1.0.0/ultraviolet-static-1.0.0.tgz $ npm install https://github.com/titaniumnetwork-development/Ultraviolet-Static/releases/download/v1.0.0/ultraviolet-static-1.0.0.tgz
# OR # OR
$ npm install ../path/to/ultraviolet-static-1.0.0.tgz $ npm install ../path/to/ultraviolet-static-1.0.0.tgz
``` ```
3. Continue instructions... 3. Continue instructions...
```sh ```sh
$ npm start $ npm start
``` ```

View file

@ -1,3 +1,3 @@
import { fileURLToPath } from 'url'; import { fileURLToPath } from "url";
export const publicPath = fileURLToPath(new URL('../dist/', import.meta.url)); export const publicPath = fileURLToPath(new URL("../dist/", import.meta.url));

2709
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,21 @@
{ {
"name": "ultraviolet-static", "name": "ultraviolet-static",
"main": "lib/index.js", "main": "lib/index.js",
"version": "1.0.0", "version": "1.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "node scripts/build.js" "build": "node scripts/build.js"
}, },
"files": [ "files": [
"dist", "dist",
"lib" "lib"
], ],
"dependencies": { "dependencies": {
"fs-extra": "^10.1.0", "fs-extra": "^10.1.0",
"ultraviolet": "https://github.com/titaniumnetwork-development/Ultraviolet/releases/download/v1.0.1/ultraviolet-1.0.1.tgz" "ultraviolet": "https://github.com/titaniumnetwork-development/Ultraviolet/releases/download/v1.0.1/ultraviolet-1.0.1.tgz"
} },
"devDependencies": {
"eslint": "^8.23.0",
"prettier": "^2.7.1"
}
} }

View file

@ -1,115 +1,115 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;1,300;1,400&display=swap'); @import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;1,300;1,400&display=swap");
@import url('https://unpkg.com/@fortawesome/fontawesome-free@5.15.4/css/all.min.css'); @import url("https://unpkg.com/@fortawesome/fontawesome-free@5.15.4/css/all.min.css");
@keyframes fadeInAnimation { @keyframes fadeInAnimation {
0% { 0% {
opacity: 0; opacity: 0;
} }
100% { 100% {
opacity: 1; opacity: 1;
} }
} }
* { * {
font-family: Roboto; font-family: Roboto;
} }
body { body {
margin: 0; margin: 0;
background: #111; background: #111;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 100vh; min-height: 100vh;
animation: fadeInAnimation ease-in-out 0.3s; animation: fadeInAnimation ease-in-out 0.3s;
animation-iteration-count: 1; animation-iteration-count: 1;
animation-fill-mode: forwards; animation-fill-mode: forwards;
} }
.fa-magnifying-glass { .fa-magnifying-glass {
color: white; color: white;
} }
.logo-wrapper { .logo-wrapper {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-direction: column; flex-direction: column;
margin-top: 10%; margin-top: 10%;
} }
.logo { .logo {
width: 150px; width: 150px;
} }
.logo-wrapper .text { .logo-wrapper .text {
font-size: 75px; font-size: 75px;
font-family: "Roboto"; font-family: "Roboto";
color: #FFF; color: #fff;
} }
.logo-wrapper h1 { .logo-wrapper h1 {
color: white; color: white;
} }
footer { footer {
margin-top: auto; margin-top: auto;
width: 93%; width: 93%;
align-self: center; align-self: center;
height: 80px; height: 80px;
display: flex; display: flex;
justify-content: left; justify-content: left;
align-items: center; align-items: center;
} }
footer a, footer a,
footer span { footer span {
margin: 0 15px; margin: 0 15px;
text-decoration: none; text-decoration: none;
color: #FFF; color: #fff;
font-size: 15px; font-size: 15px;
} }
footer a { footer a {
cursor: pointer; cursor: pointer;
} }
footer a:hover { footer a:hover {
text-decoration: underline; text-decoration: underline;
} }
form { form {
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.desc { .desc {
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.desc p { .desc p {
width: 560px; width: 560px;
color: rgba(253, 253, 253, 0.514); color: rgba(253, 253, 253, 0.514);
} }
form input { form input {
background: none; background: none;
font-family: inherit; font-family: inherit;
padding: 0px 17px; padding: 0px 17px;
height: 48px; height: 48px;
border: 1px solid rgb(255, 255, 255, .2); border: 1px solid rgb(255, 255, 255, 0.2);
color: var(--text-color); color: var(--text-color);
border-radius: 3px; border-radius: 3px;
outline: none; outline: none;
width: 350px; width: 350px;
margin-top: 5px; margin-top: 5px;
border-radius: 50px; border-radius: 50px;
color: #FFF; color: #fff;
} }
form input:focus { form input:focus {
border: 1px solid rgba(253, 253, 253, 0.514); border: 1px solid rgba(253, 253, 253, 0.514);
border-radius: 6px; border-radius: 6px;
animation: fadeInAnimation ease-in-out 0.3s; animation: fadeInAnimation ease-in-out 0.3s;
animation-iteration-count: 1; animation-iteration-count: 1;
animation-fill-mode: forwards; animation-fill-mode: forwards;
} }

File diff suppressed because one or more lines are too long

View file

@ -1,21 +1,27 @@
const form = document.querySelector('form'); const form = document.querySelector("form");
const input = document.querySelector('input'); const input = document.querySelector("input");
form.addEventListener('submit', async event => { form.addEventListener("submit", async (event) => {
event.preventDefault(); event.preventDefault();
window.navigator.serviceWorker.register('./sw.js', { window.navigator.serviceWorker
scope: __uv$config.prefix .register("./sw.js", {
}).then(() => { scope: __uv$config.prefix,
let url = input.value.trim(); })
if (!isUrl(url)) url = 'https://www.google.com/search?q=' + url; .then(() => {
else if (!(url.startsWith('https://') || url.startsWith('http://'))) url = 'http://' + url; let url = input.value.trim();
if (!isUrl(url)) url = "https://www.google.com/search?q=" + url;
else if (!(url.startsWith("https://") || url.startsWith("http://")))
url = "http://" + url;
window.location.href = __uv$config.prefix + __uv$config.encodeUrl(url);
window.location.href = __uv$config.prefix + __uv$config.encodeUrl(url);
}); });
}); });
function isUrl(val = ''){ function isUrl(val = "") {
if (/^http(s?):\/\//.test(val) || val.includes('.') && val.substr(0, 1) !== ' ') return true; if (
return false; /^http(s?):\/\//.test(val) ||
}; (val.includes(".") && val.substr(0, 1) !== " ")
)
return true;
return false;
}

View file

@ -1,7 +1,7 @@
importScripts('./uv/uv.bundle.js'); importScripts("./uv/uv.bundle.js");
importScripts('./uv/uv.config.js'); importScripts("./uv/uv.config.js");
importScripts('./uv/uv.sw.js'); importScripts("./uv/uv.sw.js");
const sw = new UVServiceWorker(); const sw = new UVServiceWorker();
self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event))); self.addEventListener("fetch", (event) => event.respondWith(sw.fetch(event)));

View file

@ -1,12 +1,12 @@
// This file overwrites the stock UV config.js // This file overwrites the stock UV config.js
self.__uv$config = { self.__uv$config = {
prefix: '/service/', prefix: "/service/",
bare: '/bare/', bare: "/bare/",
encodeUrl: Ultraviolet.codec.xor.encode, encodeUrl: Ultraviolet.codec.xor.encode,
decodeUrl: Ultraviolet.codec.xor.decode, decodeUrl: Ultraviolet.codec.xor.decode,
handler: '/uv/uv.handler.js', handler: "/uv/uv.handler.js",
bundle: '/uv/uv.bundle.js', bundle: "/uv/uv.bundle.js",
config: '/uv/uv.config.js', config: "/uv/uv.config.js",
sw: '/uv/uv.sw.js', sw: "/uv/uv.sw.js",
}; };

View file

@ -1,15 +1,15 @@
/** /**
* Copies public & ultraviolet into the dist directory. * Copies src & ultraviolet into the dist directory.
*/ */
import fs from 'fs-extra'; import fs from "fs-extra";
import { uvPath } from 'ultraviolet'; import { uvPath } from "ultraviolet";
try { try {
await fs.mkdir('dist'); await fs.mkdir("dist");
} catch (err) { } catch (err) {
if (err?.code !== 'EEXIST') throw err; if (err?.code !== "EEXIST") throw err;
} }
await fs.copy(uvPath, 'dist/uv/'); await fs.copy(uvPath, "dist/uv/");
await fs.copy('public', 'dist/'); await fs.copy("src", "dist/");