Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOES NOT WORK] Vain attempts at getting noscript streaming to work #77

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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

Expand Down Expand Up @@ -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():
"""
Expand Down
12 changes: 12 additions & 0 deletions static/test1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!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>
3 changes: 0 additions & 3 deletions templates/noscript/fid.j2
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,5 @@ span > a:visited {
</li>
{%endfor%}
</ul>
<details><summary>Raw json</summary>
{{resp.json()}}
</details>
</body>
</html>
61 changes: 61 additions & 0 deletions templates/noscript/fidStream.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!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>
27 changes: 27 additions & 0 deletions templates/noscript/uglylinkhack.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- 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>