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
1. Clone the repository
```sh
$ git clone https://github.com/titaniumnetwork-development/Ultraviolet-Static.git
> Cloning into Ultraviolet-Static...
$ cd Ultraviolet-Static
```
2. Install dependencies
```sh
npm install
```
3. Make your changes...
4. Produce the `dist/` directory and import the Ultraviolet scripts
```sh
npm run build
```
5. Package for NPM to produce `ultraviolet-static.X.X.X.tar.gz` file
```sh
npm pack
```
@ -30,12 +37,15 @@ npm pack
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))
```sh
$ npm install https://github.com/titaniumnetwork-development/Ultraviolet-Static/releases/download/v1.0.0/ultraviolet-static-1.0.0.tgz
# OR
$ npm install ../path/to/ultraviolet-static-1.0.0.tgz
```
3. Continue instructions...
```sh
$ 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",
"main": "lib/index.js",
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "node scripts/build.js"
},
"files": [
"dist",
"lib"
],
"dependencies": {
"fs-extra": "^10.1.0",
"ultraviolet": "https://github.com/titaniumnetwork-development/Ultraviolet/releases/download/v1.0.1/ultraviolet-1.0.1.tgz"
}
"name": "ultraviolet-static",
"main": "lib/index.js",
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "node scripts/build.js"
},
"files": [
"dist",
"lib"
],
"dependencies": {
"fs-extra": "^10.1.0",
"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://unpkg.com/@fortawesome/fontawesome-free@5.15.4/css/all.min.css');
@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");
@keyframes fadeInAnimation {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
* {
font-family: Roboto;
font-family: Roboto;
}
body {
margin: 0;
background: #111;
display: flex;
flex-direction: column;
min-height: 100vh;
animation: fadeInAnimation ease-in-out 0.3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
margin: 0;
background: #111;
display: flex;
flex-direction: column;
min-height: 100vh;
animation: fadeInAnimation ease-in-out 0.3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
.fa-magnifying-glass {
color: white;
color: white;
}
.logo-wrapper {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin-top: 10%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin-top: 10%;
}
.logo {
width: 150px;
width: 150px;
}
.logo-wrapper .text {
font-size: 75px;
font-family: "Roboto";
color: #FFF;
font-size: 75px;
font-family: "Roboto";
color: #fff;
}
.logo-wrapper h1 {
color: white;
color: white;
}
footer {
margin-top: auto;
width: 93%;
align-self: center;
height: 80px;
display: flex;
justify-content: left;
align-items: center;
margin-top: auto;
width: 93%;
align-self: center;
height: 80px;
display: flex;
justify-content: left;
align-items: center;
}
footer a,
footer span {
margin: 0 15px;
text-decoration: none;
color: #FFF;
font-size: 15px;
margin: 0 15px;
text-decoration: none;
color: #fff;
font-size: 15px;
}
footer a {
cursor: pointer;
cursor: pointer;
}
footer a:hover {
text-decoration: underline;
text-decoration: underline;
}
form {
display: flex;
justify-content: center;
display: flex;
justify-content: center;
}
.desc {
display: flex;
justify-content: center;
display: flex;
justify-content: center;
}
.desc p {
width: 560px;
color: rgba(253, 253, 253, 0.514);
width: 560px;
color: rgba(253, 253, 253, 0.514);
}
form input {
background: none;
font-family: inherit;
padding: 0px 17px;
height: 48px;
border: 1px solid rgb(255, 255, 255, .2);
color: var(--text-color);
border-radius: 3px;
outline: none;
width: 350px;
margin-top: 5px;
border-radius: 50px;
color: #FFF;
background: none;
font-family: inherit;
padding: 0px 17px;
height: 48px;
border: 1px solid rgb(255, 255, 255, 0.2);
color: var(--text-color);
border-radius: 3px;
outline: none;
width: 350px;
margin-top: 5px;
border-radius: 50px;
color: #fff;
}
form input:focus {
border: 1px solid rgba(253, 253, 253, 0.514);
border-radius: 6px;
animation: fadeInAnimation ease-in-out 0.3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
border: 1px solid rgba(253, 253, 253, 0.514);
border-radius: 6px;
animation: fadeInAnimation ease-in-out 0.3s;
animation-iteration-count: 1;
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 input = document.querySelector('input');
const form = document.querySelector("form");
const input = document.querySelector("input");
form.addEventListener('submit', async event => {
event.preventDefault();
window.navigator.serviceWorker.register('./sw.js', {
scope: __uv$config.prefix
}).then(() => {
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;
form.addEventListener("submit", async (event) => {
event.preventDefault();
window.navigator.serviceWorker
.register("./sw.js", {
scope: __uv$config.prefix,
})
.then(() => {
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 = ''){
if (/^http(s?):\/\//.test(val) || val.includes('.') && val.substr(0, 1) !== ' ') return true;
return false;
};
function isUrl(val = "") {
if (
/^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.config.js');
importScripts('./uv/uv.sw.js');
importScripts("./uv/uv.bundle.js");
importScripts("./uv/uv.config.js");
importScripts("./uv/uv.sw.js");
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
self.__uv$config = {
prefix: '/service/',
bare: '/bare/',
encodeUrl: Ultraviolet.codec.xor.encode,
decodeUrl: Ultraviolet.codec.xor.decode,
handler: '/uv/uv.handler.js',
bundle: '/uv/uv.bundle.js',
config: '/uv/uv.config.js',
sw: '/uv/uv.sw.js',
prefix: "/service/",
bare: "/bare/",
encodeUrl: Ultraviolet.codec.xor.encode,
decodeUrl: Ultraviolet.codec.xor.decode,
handler: "/uv/uv.handler.js",
bundle: "/uv/uv.bundle.js",
config: "/uv/uv.config.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 { uvPath } from 'ultraviolet';
import fs from "fs-extra";
import { uvPath } from "ultraviolet";
try {
await fs.mkdir('dist');
await fs.mkdir("dist");
} catch (err) {
if (err?.code !== 'EEXIST') throw err;
if (err?.code !== "EEXIST") throw err;
}
await fs.copy(uvPath, 'dist/uv/');
await fs.copy('public', 'dist/');
await fs.copy(uvPath, "dist/uv/");
await fs.copy("src", "dist/");