mirror of
https://git.ari.lt/ari.lt/ari.lt.git
synced 2025-02-04 17:49:24 +01:00
Added be page and also add netlify api minification
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
parent
ab4aebdd82
commit
eea543fe09
6 changed files with 362 additions and 1 deletions
1
Makefile
1
Makefile
|
@ -10,5 +10,6 @@ clean:
|
|||
.github \
|
||||
|
||||
netlify: build clean
|
||||
./scripts/netlifyapis.sh
|
||||
|
||||
.PHONY: build clean netlify
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
"Additional notes": {
|
||||
"placeholder": "Additional things you have tried to do",
|
||||
"id": "additional",
|
||||
"optional": true
|
||||
"optional": true,
|
||||
"textbox": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
195
content/js/be/index.js
Normal file
195
content/js/be/index.js
Normal file
|
@ -0,0 +1,195 @@
|
|||
"use strict";
|
||||
|
||||
const FORM_CHECKERS = {
|
||||
android: (e, edata) => {
|
||||
let data = Object.fromEntries(new FormData(e.target).entries());
|
||||
|
||||
console.log(data);
|
||||
console.log(edata);
|
||||
|
||||
function no_has_gh(str) {
|
||||
return str.indexOf(data["gh-username"]) !== -1;
|
||||
}
|
||||
|
||||
if (!/^[0-9a-zA-Z]+$/.test(data["gh-username"]))
|
||||
alert("Invalid github username");
|
||||
else if (
|
||||
edata["disallowed-android-versions"].includes(
|
||||
data["and-version"].toLowerCase()
|
||||
)
|
||||
)
|
||||
alert("Disallowed android version");
|
||||
else if (data["ctree-url"])
|
||||
if (no_has_gh(data["ctree-url"]))
|
||||
alert(
|
||||
"You have not provided any (valid) url from common trees"
|
||||
);
|
||||
else if (no_has_gh(data["dev-url"])) alert("No valid device url");
|
||||
else if (data["err-url"].indexOf("pastebin.com") !== -1)
|
||||
alert("Pastebin is not allowed");
|
||||
else if (no_has_gh(data["kern-url"]))
|
||||
alert("No valid kernel tree given");
|
||||
else if (data["rom-url"].indexOf("github") === -1)
|
||||
alert("No github url provided for the rom");
|
||||
else if (no_has_gh(data["ven-url"]))
|
||||
alert("No valid vendor url specified");
|
||||
else return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
function append_children(parent, ...children) {
|
||||
for (let child of children) parent.appendChild(child);
|
||||
}
|
||||
|
||||
function submit_btn() {
|
||||
let submit = document.createElement("button");
|
||||
submit.innerText = "Submit";
|
||||
submit.id = "submit-button";
|
||||
|
||||
return submit;
|
||||
}
|
||||
|
||||
function to_clipboard(text) {
|
||||
if (window.clipboardData && window.clipboardData.setData) {
|
||||
return window.clipboardData.setData("Text", text);
|
||||
} else if (
|
||||
document.queryCommandSupported &&
|
||||
document.queryCommandSupported("copy")
|
||||
) {
|
||||
var textarea = document.createElement("textarea");
|
||||
textarea.textContent = text;
|
||||
textarea.style.position = "fixed";
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
|
||||
try {
|
||||
return document.execCommand("copy");
|
||||
} catch (ex) {
|
||||
console.warn("Copy to clipboard failed.", ex);
|
||||
return prompt("Copy to clipboard: Ctrl+C, Enter", text);
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function render_type(type, data) {
|
||||
if (type.startsWith("%") || !(type in data)) {
|
||||
document.body.innerHTML = "<h1>Not a valid type, not rendering</h1>";
|
||||
setTimeout(() => (document.location = "."), 1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
document.body.innerHTML =
|
||||
"<h1>Rendering form... (if this takes too long please see the dev console)</h1>";
|
||||
|
||||
let form = document.createElement("form");
|
||||
form.id = "form";
|
||||
|
||||
for (let [key, value] of Object.entries(data[type])) {
|
||||
let label = document.createElement("label");
|
||||
label.innerText = key;
|
||||
label.setAttribute("for", value.id);
|
||||
|
||||
let input = document.createElement(
|
||||
value.textbox ? "textarea" : "input"
|
||||
);
|
||||
input.id = input.name = value.id;
|
||||
input.placeholder = input.title = value.placeholder;
|
||||
input.required = !value.optional;
|
||||
|
||||
append_children(form, input, label, document.createElement("br"));
|
||||
}
|
||||
|
||||
form.appendChild(submit_btn());
|
||||
document.body.innerHTML = "";
|
||||
|
||||
let title = document.createElement("h1");
|
||||
title.innerText = `Error report form: ${type}`;
|
||||
|
||||
document.body.innerHTML = `${title.outerHTML}${form.outerHTML}`;
|
||||
|
||||
document.getElementById("form").addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
let is_good = true;
|
||||
|
||||
if (type in FORM_CHECKERS)
|
||||
is_good = FORM_CHECKERS[type](e, data[`%${type}`]);
|
||||
|
||||
if (is_good) {
|
||||
let text = `Error submission form: ${type}
|
||||
From: ${document.location}
|
||||
|
||||
`;
|
||||
for (let [key, value] of new FormData(e.target).entries()) {
|
||||
if (!value) continue;
|
||||
|
||||
text += `${
|
||||
document.querySelector(`label[for="${key}"]`).innerText
|
||||
}: ${value}\n`;
|
||||
}
|
||||
|
||||
document.body.innerText = text;
|
||||
document.body.onclick = () => {
|
||||
to_clipboard(document.body.innerText);
|
||||
alert("Copied to clipboard");
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function render_full(data) {
|
||||
document.body.innerHTML = "<h1>Pick a type (no `t` GET param found)</h1>";
|
||||
|
||||
let label = document.createElement("label");
|
||||
label.setAttribute("for", "types");
|
||||
label.innerText = "Pick the error report type:";
|
||||
|
||||
let select = document.createElement("select");
|
||||
select.name = "types";
|
||||
select.id = "types";
|
||||
|
||||
let submit = submit_btn();
|
||||
|
||||
submit.onclick = () => {
|
||||
let val = select.value;
|
||||
if (!val) alert("Not a valid type :(");
|
||||
|
||||
render_type(val, data);
|
||||
};
|
||||
|
||||
for (let key in data) {
|
||||
if (key.startsWith("%")) continue;
|
||||
|
||||
let option = document.createElement("option");
|
||||
option.value = key;
|
||||
option.innerText = key;
|
||||
|
||||
select.appendChild(option);
|
||||
}
|
||||
|
||||
append_children(document.body, label, select, submit);
|
||||
}
|
||||
|
||||
function main() {
|
||||
let type = new URL(document.location).searchParams.get("t");
|
||||
|
||||
fetch("/api/errtemplate.json")
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
if (type) render_type(type, data);
|
||||
else render_full(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(`Error, please report it to ${document.domain}/git: ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", main);
|
85
content/styles/be/index.css
Normal file
85
content/styles/be/index.css
Normal file
|
@ -0,0 +1,85 @@
|
|||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
background-color: #181818;
|
||||
color: whitesmoke;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
max-width: 1200px;
|
||||
margin: auto;
|
||||
padding: 4em;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
margin-bottom: 0.7em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#types {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
#types,
|
||||
label[for="types"] {
|
||||
font-weight: bold;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
#submit-button {
|
||||
display: block;
|
||||
margin: 1em;
|
||||
width: 20%;
|
||||
border: none;
|
||||
padding: 0.5em;
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
transition: background-color 0.4s ease-in-out;
|
||||
}
|
||||
|
||||
#submit-button:focus,
|
||||
#submit-button:hover {
|
||||
cursor: pointer;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
transition: background-color 0.4s ease-in-out;
|
||||
}
|
||||
|
||||
label {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
form * {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: none;
|
||||
height: 10em;
|
||||
}
|
||||
|
||||
textarea,
|
||||
input {
|
||||
padding: 0.3em;
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
form * {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
label::after {
|
||||
content: "^";
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
#submit-button {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
67
page/be/index.html
Normal file
67
page/be/index.html
Normal file
|
@ -0,0 +1,67 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Ari::web -> Be</title>
|
||||
|
||||
<meta name="description" content="Error submission forms for ABOT" />
|
||||
<meta
|
||||
name="keywords"
|
||||
content="ari, ari-web, form, page-form, android, linux, google, be, build error, building, error"
|
||||
/>
|
||||
<meta
|
||||
name="robots"
|
||||
content="follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large"
|
||||
/>
|
||||
<meta property="og:type" content="website" />
|
||||
|
||||
<meta name="color-scheme" content="dark" />
|
||||
<meta name="theme-color" content="#181818" />
|
||||
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
|
||||
<link rel="stylesheet" href="/content/styles/clean/index.css" />
|
||||
<link rel="stylesheet" href="/content/styles/be/index.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--//--><![CDATA[//><!--
|
||||
/**
|
||||
* @licstart The following is the entire license notice for the JavaScript
|
||||
* code in this page.
|
||||
*
|
||||
* Copyright (C) 2022 Ari Archer
|
||||
*
|
||||
* The JavaScript code in this page is free software: you can redistribute
|
||||
* it and/or modify it under the terms of the GNU General Public License
|
||||
* (GNU GPL) as published by the Free Software Foundation, either version 3
|
||||
* of the License, or (at your option) any later version. The code is
|
||||
* distributed WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU GPL
|
||||
* for more details.
|
||||
*
|
||||
* As additional permission under GNU GPL version 3 section 7, you may
|
||||
* distribute non-source (e.g., minimized or compacted) forms of that code
|
||||
* without the copy of the GNU GPL normally required by section 4, provided
|
||||
* you include this license notice and a URL through which recipients can
|
||||
* access the Corresponding Source.
|
||||
*
|
||||
* @licend The above is the entire license notice for the JavaScript code
|
||||
* in this page.
|
||||
*/
|
||||
|
||||
//--><!]]>
|
||||
</script>
|
||||
|
||||
<script src="/content/js/be/index.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Please stand by while I'm fetching the required data...</h1>
|
||||
<h2>
|
||||
If this takes too long please check the dev tools using CTRL + SHIFT
|
||||
+ I and opening the console
|
||||
</h2>
|
||||
</body>
|
||||
</html>
|
12
scripts/netlifyapis.sh
Executable file
12
scripts/netlifyapis.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
main() {
|
||||
for api in api/*; do
|
||||
api_cont="$(sed 's/^\s*//g; s/: /:/g' "$api" | tr -d '\n')"
|
||||
printf '%s' "$api_cont" >"$api"
|
||||
done
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Add table
Reference in a new issue