Compare commits
4
Commits
No files matched your search
+2
-20
@@ -6,12 +6,8 @@
|
|||||||
<title>Queue Reader</title>
|
<title>Queue Reader</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{% if current_link %}
|
{% from 'macros.html' import magic_link %} {% if current_link %}
|
||||||
<p>
|
<p>{{ magic_link(current_link, current_link, "a") }}</p>
|
||||||
<a href="/r" target="_blank" rel="noopener noreferrer" id="a"
|
|
||||||
>{{ current_link }}</a
|
|
||||||
>
|
|
||||||
</p>
|
|
||||||
<button id="b">skip/fw</button>
|
<button id="b">skip/fw</button>
|
||||||
<script>
|
<script>
|
||||||
document.getElementById("b").addEventListener("click", async () => {
|
document.getElementById("b").addEventListener("click", async () => {
|
||||||
@@ -20,20 +16,6 @@
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/**@type {HTMLAnchorElement}*/
|
|
||||||
const a = document.getElementById("a");
|
|
||||||
a.addEventListener("click", function (e) {
|
|
||||||
// all ts so safari works ://
|
|
||||||
e.preventDefault();
|
|
||||||
window.open(
|
|
||||||
this.href,
|
|
||||||
this.target,
|
|
||||||
Array.from(this.relList).join(", ")
|
|
||||||
);
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>no</p>
|
<p>no</p>
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
{% macro magic_link(url, text, unique_id='magic_link') %}
|
||||||
|
<a
|
||||||
|
href="{{ url }}"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
id="{{ unique_id }}"
|
||||||
|
>
|
||||||
|
{{ text }}
|
||||||
|
</a>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
const a = document.getElementById("{{ unique_id }}");
|
||||||
|
a.addEventListener("click", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
window.open(
|
||||||
|
this.href,
|
||||||
|
this.target,
|
||||||
|
Array.from(this.relList).join(", ")
|
||||||
|
);
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{% endmacro %} {% macro qrcode_queue(queue_items) %} {% if queue_items %}
|
||||||
|
<ol>
|
||||||
|
{% for item in queue_items %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ item }}" target="_blank" rel="noreferrer noopener">
|
||||||
|
{{ item }}
|
||||||
|
<div class="qrcode"></div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
<style>
|
||||||
|
/* it works ig */
|
||||||
|
& {
|
||||||
|
li:has(.qrcode) {
|
||||||
|
width: min-content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</ol>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/[email protected]/qrcode.js"></script>
|
||||||
|
<script>
|
||||||
|
window.addEventListener("load", (_) => {
|
||||||
|
document.querySelectorAll(".qrcode").forEach((e) => {
|
||||||
|
const a = e.parentElement.textContent.trim();
|
||||||
|
new QRCode(e, {
|
||||||
|
text: a,
|
||||||
|
correctLevel: QRCode.CorrectLevel.L,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endif %} {% endmacro %}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Queue dump type shit</title>
|
||||||
|
<style>
|
||||||
|
li {
|
||||||
|
width: min-content;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- style="display: flex; justify-content: space-between" -->
|
||||||
|
<form id="c">
|
||||||
|
<label for="n"
|
||||||
|
>how many:
|
||||||
|
<input
|
||||||
|
name="n"
|
||||||
|
id="n"
|
||||||
|
step="1"
|
||||||
|
min="0"
|
||||||
|
type="number"
|
||||||
|
placeholder="how many"
|
||||||
|
value="1"
|
||||||
|
/></label>
|
||||||
|
<div>
|
||||||
|
<button id="s" type="button">send it</button>
|
||||||
|
<button id="all" type="button">send all</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div id="gonk"></div>
|
||||||
|
<script>
|
||||||
|
/** @type {HTMLDivElement} */
|
||||||
|
const bij = document.getElementById("gonk");
|
||||||
|
let arrlen = 0;
|
||||||
|
/** @type {HTMLInputElement} */
|
||||||
|
const n = document.getElementById("n");
|
||||||
|
const changeHandler = async () => {
|
||||||
|
const number = parseInt(n.value);
|
||||||
|
if (isNaN(number)) {
|
||||||
|
bij.textContent = "number?";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const f = new URL("/api/queue", window.location.href);
|
||||||
|
f.searchParams.append("n", number);
|
||||||
|
console.log("fetching", f);
|
||||||
|
const c = await fetch(f)
|
||||||
|
.then((r) => r.json())
|
||||||
|
.then((n) => {
|
||||||
|
console.log(n);
|
||||||
|
arrlen = n.length;
|
||||||
|
if (n) {
|
||||||
|
const ol = document.createElement("ol");
|
||||||
|
for (const i of n) {
|
||||||
|
const li = document.createElement("li");
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.href = i;
|
||||||
|
a.textContent = i;
|
||||||
|
a.target = "_blank";
|
||||||
|
a.rel = "noopener noreferrer";
|
||||||
|
li.appendChild(a);
|
||||||
|
ol.appendChild(li);
|
||||||
|
}
|
||||||
|
bij.textContent = `next ${
|
||||||
|
n.length != 1
|
||||||
|
? `${n.length} entries are`
|
||||||
|
: "entry is"
|
||||||
|
} SO gone`;
|
||||||
|
bij.appendChild(ol);
|
||||||
|
} else {
|
||||||
|
bij.textContent = "wym empty";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
arrlen = 0;
|
||||||
|
bij.textContent = `shit. cant fetch`;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
n.addEventListener("change", changeHandler);
|
||||||
|
/** @type {HTMLFormElement} */
|
||||||
|
const c = document.getElementById("c");
|
||||||
|
c.addEventListener("submit", async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
await changeHandler();
|
||||||
|
});
|
||||||
|
changeHandler();
|
||||||
|
const s = document.getElementById("s");
|
||||||
|
s.addEventListener("click", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
console.log("ts runs");
|
||||||
|
changeHandler();
|
||||||
|
for (const _ of Array(arrlen)) {
|
||||||
|
const w = window.open(
|
||||||
|
"/r",
|
||||||
|
"_blank",
|
||||||
|
"noopener, noreferrer"
|
||||||
|
);
|
||||||
|
console.log(w);
|
||||||
|
}
|
||||||
|
arrlen = 0;
|
||||||
|
bij.textContent = "something idk";
|
||||||
|
});
|
||||||
|
/** @type {HTMLButtonElement} */
|
||||||
|
const all = document.getElementById("all");
|
||||||
|
all.addEventListener(
|
||||||
|
"click",
|
||||||
|
async () =>
|
||||||
|
await fetch("/api/queue/len")
|
||||||
|
.then((d) => d.json())
|
||||||
|
.then((len) => {
|
||||||
|
console.log("ts runs", len);
|
||||||
|
for (const _ of Array(len)) {
|
||||||
|
const w = window.open(
|
||||||
|
"/r",
|
||||||
|
"_blank",
|
||||||
|
"noopener, noreferrer"
|
||||||
|
);
|
||||||
|
console.log(w);
|
||||||
|
}
|
||||||
|
arrlen = 0;
|
||||||
|
bij.textContent = "everything idk";
|
||||||
|
})
|
||||||
|
.catch((e) => console.error(e))
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>QRCode queue</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% from "macros.html" import qrcode_queue %}
|
||||||
|
{% if queue_items %}
|
||||||
|
<p>total: {{ queue_items|length }}</p>
|
||||||
|
{{ qrcode_queue(queue_items) }}
|
||||||
|
{% else %}
|
||||||
|
<p>empty</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+16
-24
@@ -7,40 +7,32 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<form method="POST" action="/queuein">
|
<form method="POST" action="/queuein">
|
||||||
<label for="l">in:</label>
|
<label for="lines">in:</label>
|
||||||
<textarea
|
<textarea
|
||||||
id="l"
|
id="l"
|
||||||
rows="20"
|
rows="20"
|
||||||
cols="100"
|
cols="100"
|
||||||
style="min-width: 20%; min-height: 20dvh"
|
style="min-width: 20%; min-height: 20dvh"
|
||||||
name="l"
|
name="lines"
|
||||||
></textarea>
|
></textarea>
|
||||||
<input type="submit" value="ahh" />
|
<input type="submit" value="ahh" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% if queue_items %}
|
|
||||||
<ol>
|
|
||||||
{% for item in queue_items %}
|
|
||||||
<li>
|
|
||||||
<a href="{{ item }}" target="_blank" rel="noreferrer noopener">
|
|
||||||
{{ item }}
|
|
||||||
<div class="qrcode"></div>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/qrcode.js"></script>
|
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener("load", (_) => {
|
/**@type {HTMLTextAreaElement} */
|
||||||
document.querySelectorAll(".qrcode").forEach((e) => {
|
(
|
||||||
const a = e.parentElement.textContent.trim();
|
// lifted from google search ai
|
||||||
new QRCode(e, {
|
document.getElementById("l")
|
||||||
text: a,
|
).addEventListener("keydown", function (e) {
|
||||||
correctLevel: QRCode.CorrectLevel.L,
|
// Check for Ctrl+Enter (Windows/Linux) or Command+Enter (Mac)
|
||||||
});
|
if ((e.ctrlKey || e.metaKey) && e.key === "Enter") {
|
||||||
});
|
e.preventDefault(); // Prevent the default newline character
|
||||||
|
// Submit the form associated with this textarea
|
||||||
|
this.form.submit();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% from "macros.html" import qrcode_queue %} {% if queue_items %}
|
||||||
|
<p>total: {{ queue_items|length }}</p>
|
||||||
|
{% endif %} {{ qrcode_queue(queue_items) }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
"gemini converted"
|
|
||||||
|
|
||||||
from collections import deque
|
|
||||||
|
|
||||||
import uvicorn
|
|
||||||
from fastapi import FastAPI, Form, Request
|
|
||||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
|
||||||
from fastapi.templating import Jinja2Templates
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
templates = Jinja2Templates(directory="templates")
|
|
||||||
queue: deque[str] = deque()
|
|
||||||
|
|
||||||
|
|
||||||
def link_extract_from_onetab(line):
|
|
||||||
"link | title"
|
|
||||||
link = line.split("|", 1)[0].strip()
|
|
||||||
return link
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/", response_class=HTMLResponse)
|
|
||||||
async def no(request: Request):
|
|
||||||
current_link = queue[0] if queue else None
|
|
||||||
return templates.TemplateResponse(
|
|
||||||
"index.html", {"request": request, "current_link": current_link}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/r")
|
|
||||||
async def redir(request: Request):
|
|
||||||
if queue:
|
|
||||||
q = queue.popleft()
|
|
||||||
return RedirectResponse(url=q)
|
|
||||||
return templates.TemplateResponse(
|
|
||||||
"index.html", {"request": request, "current_link": None}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/queuein", response_class=HTMLResponse)
|
|
||||||
async def cuh_get(request: Request):
|
|
||||||
return templates.TemplateResponse(
|
|
||||||
"queue.html", {"request": request, "queue_items": list(queue)}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/queuein")
|
|
||||||
async def cuh_post(l: str = Form("")):
|
|
||||||
for line in l.splitlines():
|
|
||||||
if line.strip():
|
|
||||||
queue.append(link_extract_from_onetab(line))
|
|
||||||
return RedirectResponse(url="/queuein", status_code=303)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
uvicorn.run(app, host="0.0.0.0", port=2222)
|
|
||||||
# uvicorn --host "0.0.0.0" --port 2222 uhhhh_fastapi:app
|
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
"gemini converted"
|
||||||
|
|
||||||
|
from collections import deque
|
||||||
|
from itertools import islice
|
||||||
|
|
||||||
|
import uvicorn
|
||||||
|
from fastapi import FastAPI, Form, Request
|
||||||
|
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||||
|
from fastapi.templating import Jinja2Templates
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
queue: deque[str] = deque() # lifo ahh
|
||||||
|
|
||||||
|
|
||||||
|
def link_extract_from_onetab(line):
|
||||||
|
"link | title"
|
||||||
|
link = line.split("|", 1)[0].strip()
|
||||||
|
return link
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/", response_class=HTMLResponse)
|
||||||
|
async def no(request: Request):
|
||||||
|
current_link = queue[0] if queue else None
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
request, "index.html", {"current_link": current_link}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/r")
|
||||||
|
async def redir(request: Request):
|
||||||
|
if queue:
|
||||||
|
q = queue.popleft()
|
||||||
|
return RedirectResponse(url=q)
|
||||||
|
return templates.TemplateResponse(request, "index.html", {"current_link": None})
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/m", response_class=HTMLResponse)
|
||||||
|
async def mlti(request: Request):
|
||||||
|
"request first new style"
|
||||||
|
return templates.TemplateResponse(request, "multi.html")
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/api/queue")
|
||||||
|
async def queueview(n: int | None = None, s: int | None = None):
|
||||||
|
return list(islice(queue, s, n))
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/api/queue/len")
|
||||||
|
async def queuelen():
|
||||||
|
return len(queue)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/qrcode_queue", response_class=HTMLResponse)
|
||||||
|
async def qrcodequeue(request: Request):
|
||||||
|
return templates.TemplateResponse(request, "qq.html", {"queue_items": list(queue)})
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/queuein", response_class=HTMLResponse)
|
||||||
|
async def cuh_get(request: Request):
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
request, "queue.html", {"queue_items": list(queue)}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/queuein")
|
||||||
|
async def cuh_post(lines: str = Form("")):
|
||||||
|
"""var name == form ele name (name="lines")"""
|
||||||
|
queue.extend(
|
||||||
|
link_extract_from_onetab(line) for line in lines.splitlines() if line.strip()
|
||||||
|
)
|
||||||
|
return RedirectResponse(url="/queuein", status_code=303)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
uvicorn.run("uhhhhup:app", host="0.0.0.0", port=2222, reload=True)
|
||||||
|
# uvicorn --host "0.0.0.0" --port 2222 --reload uhhhhup:app
|
||||||
Reference in new issue
Block a user