Loading app.py +7 −1 Original line number Diff line number Diff line from quart import Quart, jsonify, render_template, request, Response, redirect, send_from_directory, jsonify from quart import Quart, render_template, request, Response, redirect, send_from_directory, abort import re, yaml, json, typing import lostmediafinder Loading Loading @@ -122,6 +122,12 @@ async def load_thing(): t = await youtube(3, request.args['id'], "youtube", jsn=False) return await render_template("noscript/fid.j2", resp=t) @app.route("/noscript/wtf.svg") async def wtf(): if url := request.args.get("url"): return await render_template("noscript/uglylinkhack.j2", link=url), {"Content-Type": "image/svg+xml"} abort(400) @app.route("/") async def index(): """ Loading static/test1.html 0 → 100644 +12 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html> <body> <h1>Hello, World!</h1> <div id="hi" style="position: element(heading);"> <p>Hello, world</p> </div> <div id="hi" style="position: running(heading);"> <p>Goodbye, cruel world</p> </div> </body> </html> No newline at end of file templates/noscript/fid.j2 +0 −3 Original line number Diff line number Diff line Loading @@ -45,8 +45,5 @@ span > a:visited { </li> {%endfor%} </ul> <details><summary>Raw json</summary> {{resp.json()}} </details> </body> </html> templates/noscript/fidStream.j2 0 → 100644 +61 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="/static/normalize.css" rel="stylesheet" type="text/css" /> <link href="/static/skeleton.css" rel="stylesheet" type="text/css" /> <link href="/static/styles.css" rel="stylesheet" /> <style> body { font-family: Ubuntu, Arial, sans-serif; } span > a { color: cyan; } span > a:visited { color: pink; } </style> </head> <body> <h2>Video ID: {{ resp.id }}</h1> <ul> {% for cls, clsn in promised_keys.items() %} <div id="{{cls}}"> <li>{{ clsn }} : <span id="loading-msg"> <img src="/static/loading.gif" width="25" height="25" /> Loading... </span> <span id="is-archived"></span> <br> <span id="note"></span> </li> </div> {%endfor%} </ul> </body> <style> {% for res in stream %} {{res.classname}} > #is-archived::after { background-color: black; {% if res.archived %} color: green; {% set comments = "(incl. comments)" if res.comments else "" %} {% set metaonly = "(metadata only)" if res.metaonly else "" %} content: "Archived! {{metaonly}} {{comments}}"; {% elif res.error %} color: white; content: "Error"; {% else %} {% endif %} } {% if res.note %} {{res.classname}} > #note::after { content: "{{res.note}}"; } {% endif %} {% endfor %} </style> </html> templates/noscript/uglylinkhack.j2 0 → 100644 +27 −0 Original line number Diff line number Diff line <!-- DOESN'T WORK : Links embedded in the `content` property are not clickable --> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- this is an ugly hack so we can create an <a> element from CSS --> <!-- please never ever use this in real code --> <!-- Use foreignObject if available --> <!-- If it is available, hide the fallback <a> --> <!-- why do we use both? <a> is supported better in older browsers, but for some reason Opera likes to be different and it was introduced in a later version --> <!-- Currently, for simplicity, we only add the <a>; if you do want to add more browser support, I would recommend having the <foreignObject> and add a stylesheet to it that hides the <a> --> <!-- I'm far too lazy to do that myself, but you can try it :P --> <foreignObject x="0" y="1em" width="6400" height="1400em"> <div xmlns="http://www.w3.org/1999/xhtml"> <iframe src="/">HELP</iframe> </div> </foreignObject> <!--<a href="{{link}}" xlink:href="{{link}}" id="#hacky-thing"> <text x="0" y="1em">(link)</text> </a>--> </svg> No newline at end of file Loading
app.py +7 −1 Original line number Diff line number Diff line from quart import Quart, jsonify, render_template, request, Response, redirect, send_from_directory, jsonify from quart import Quart, render_template, request, Response, redirect, send_from_directory, abort import re, yaml, json, typing import lostmediafinder Loading Loading @@ -122,6 +122,12 @@ async def load_thing(): t = await youtube(3, request.args['id'], "youtube", jsn=False) return await render_template("noscript/fid.j2", resp=t) @app.route("/noscript/wtf.svg") async def wtf(): if url := request.args.get("url"): return await render_template("noscript/uglylinkhack.j2", link=url), {"Content-Type": "image/svg+xml"} abort(400) @app.route("/") async def index(): """ Loading
static/test1.html 0 → 100644 +12 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html> <body> <h1>Hello, World!</h1> <div id="hi" style="position: element(heading);"> <p>Hello, world</p> </div> <div id="hi" style="position: running(heading);"> <p>Goodbye, cruel world</p> </div> </body> </html> No newline at end of file
templates/noscript/fid.j2 +0 −3 Original line number Diff line number Diff line Loading @@ -45,8 +45,5 @@ span > a:visited { </li> {%endfor%} </ul> <details><summary>Raw json</summary> {{resp.json()}} </details> </body> </html>
templates/noscript/fidStream.j2 0 → 100644 +61 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="/static/normalize.css" rel="stylesheet" type="text/css" /> <link href="/static/skeleton.css" rel="stylesheet" type="text/css" /> <link href="/static/styles.css" rel="stylesheet" /> <style> body { font-family: Ubuntu, Arial, sans-serif; } span > a { color: cyan; } span > a:visited { color: pink; } </style> </head> <body> <h2>Video ID: {{ resp.id }}</h1> <ul> {% for cls, clsn in promised_keys.items() %} <div id="{{cls}}"> <li>{{ clsn }} : <span id="loading-msg"> <img src="/static/loading.gif" width="25" height="25" /> Loading... </span> <span id="is-archived"></span> <br> <span id="note"></span> </li> </div> {%endfor%} </ul> </body> <style> {% for res in stream %} {{res.classname}} > #is-archived::after { background-color: black; {% if res.archived %} color: green; {% set comments = "(incl. comments)" if res.comments else "" %} {% set metaonly = "(metadata only)" if res.metaonly else "" %} content: "Archived! {{metaonly}} {{comments}}"; {% elif res.error %} color: white; content: "Error"; {% else %} {% endif %} } {% if res.note %} {{res.classname}} > #note::after { content: "{{res.note}}"; } {% endif %} {% endfor %} </style> </html>
templates/noscript/uglylinkhack.j2 0 → 100644 +27 −0 Original line number Diff line number Diff line <!-- DOESN'T WORK : Links embedded in the `content` property are not clickable --> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- this is an ugly hack so we can create an <a> element from CSS --> <!-- please never ever use this in real code --> <!-- Use foreignObject if available --> <!-- If it is available, hide the fallback <a> --> <!-- why do we use both? <a> is supported better in older browsers, but for some reason Opera likes to be different and it was introduced in a later version --> <!-- Currently, for simplicity, we only add the <a>; if you do want to add more browser support, I would recommend having the <foreignObject> and add a stylesheet to it that hides the <a> --> <!-- I'm far too lazy to do that myself, but you can try it :P --> <foreignObject x="0" y="1em" width="6400" height="1400em"> <div xmlns="http://www.w3.org/1999/xhtml"> <iframe src="/">HELP</iframe> </div> </foreignObject> <!--<a href="{{link}}" xlink:href="{{link}}" id="#hacky-thing"> <text x="0" y="1em">(link)</text> </a>--> </svg> No newline at end of file