Skip to content
Snippets Groups Projects
Verified Commit 8e0ef7be authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Include the source doc in generated HTML

parent cdaba669
No related branches found
No related tags found
No related merge requests found
...@@ -56,9 +56,8 @@ def get_template_context(document): ...@@ -56,9 +56,8 @@ def get_template_context(document):
@cli.command() @cli.command()
@click.argument("document", type=click.File("r")) @click.argument("document", type=click.File("r"))
@click.argument("output", type=click.File("w"))
@click.option("--template", "-t", type=click.File("r")) @click.option("--template", "-t", type=click.File("r"))
def html(document, output, template): def html(document, template):
content = document.read() content = document.read()
document = json.loads(content) document = json.loads(content)
context = get_template_context(document) context = get_template_context(document)
...@@ -73,7 +72,8 @@ def html(document, output, template): ...@@ -73,7 +72,8 @@ def html(document, output, template):
"{% autoescape true %}" + template_content + "{% endautoescape %}", "{% autoescape true %}" + template_content + "{% endautoescape %}",
undefined=jinja2.StrictUndefined, undefined=jinja2.StrictUndefined,
) )
click.echo(t.render(**context)) output = t.render(**context)
click.echo(output)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<article> <article>
<h3> <h3>
{%- if identity.url %} {%- if identity.url %}
<a href="{{ identity.url }}" rel="me noopener"> <a href="{{ identity.url }}" rel="retribute me noopener">
{{ identity.get_full_name() }} {{ identity.get_full_name() }}
</a> </a>
{%- else %} {%- else %}
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<article class="mean"> <article class="mean">
<h3> <h3>
{%- if mean.url %} {%- if mean.url %}
<a href="{{ mean.url }}" rel="me noopener"> <a href="{{ mean.url }}" rel="retribute me noopener">
{{ mean.get_full_name() }} {{ mean.get_full_name() }}
</a> </a>
{%- else %} {%- else %}
...@@ -60,5 +60,8 @@ ...@@ -60,5 +60,8 @@
</section> </section>
{%- endif %} {%- endif %}
</main> </main>
<script type="application/retribute+json">
{{ doc|tojson(indent=2) }}
</script>
</body> </body>
</html> </html>
test.html 0 → 100644
<!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>Caring is loving</title>
<meta name="description" content="My name is Alice, I produce Creative Commons electro music. I need your support to continue working on my audio pieces!" />
</head>
<body>
<header>
<h1>Caring is loving</h1>
<p>My name is Alice, I produce Creative Commons electro music. I need your support to continue working on my audio pieces!</p>
</header>
<main>
<section class="identity">
<h2>My other identities</h2>
<article>
<h3>
<a href="https://alice.me" rel="retribute me noopener">
My personal website
</a>
</h3>
</article>
<article>
<h3>
<a href="https://musicbrainz.org/artist/176216c5-d6e7-4df1-83cf-85251328eb90" rel="retribute me noopener">
176216c5-d6e7-4df1-83cf-85251328eb90 on musicbrainz
</a>
</h3>
</article>
<article>
<h3>
<a href="https://mastodon.instance/alice" rel="retribute me noopener">
alice@mastodon.instance on fediverse
</a>
</h3>
</article>
</section>
<section>
<h2>Support me!</h2>
<article class="mean">
<h3>
<a href="https://freetips.com/@Alice" rel="retribute me noopener">
Tip me on freetips
</a>
</h3>
<p>This is the best place to tip me</p>
</article>
<article class="mean">
<h3>
Cash
</h3>
<p>I live here, you can send me money directly</p>
</article>
<article class="mean">
<h3>
<a href="https://flattr.com/@Alice" rel="retribute me noopener">
Alice on flattr
</a>
</h3>
</article>
</section>
</main>
<script type="application/json+retribute">
{
"id": "https://retribute.me/@Alice.json",
"identities": [
{
"id": "alice@mastodon.instance",
"provider": "fediverse",
"url": "https://mastodon.instance/alice",
"weight": 1
},
{
"id": "176216c5-d6e7-4df1-83cf-85251328eb90",
"provider": "musicbrainz",
"url": "https://musicbrainz.org/artist/176216c5-d6e7-4df1-83cf-85251328eb90",
"weight": 2
},
{
"id": "personal-website",
"name": "My personal website",
"provider": "custom",
"url": "https://alice.me",
"weight": 3
}
],
"means": [
{
"id": "Alice",
"provider": "flattr",
"url": "https://flattr.com/@Alice",
"weight": 0
},
{
"id": "sendmecash",
"name": "Cash",
"provider": "custom",
"summary": "I live here, you can send me money directly",
"weight": 1
},
{
"id": "freetips",
"name": "Tip me on freetips",
"provider": "unknown",
"summary": "This is the best place to tip me",
"url": "https://freetips.com/@Alice",
"weight": 2
}
],
"summary": "My name is Alice, I produce Creative Commons electro music. I need your support to continue working on my audio pieces!",
"title": "Caring is loving",
"updated": "2019-05-24T18:56:12.269457",
"url": "https://retribute.me/@Alice.html",
"version": "0.1"
}
</script>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment