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

Really basic stylesheet handling

parent 8e0ef7be
No related branches found
No related tags found
No related merge requests found
Pipeline #4532 passed with stage
in 36 seconds
...@@ -37,8 +37,9 @@ def validate(document, version): ...@@ -37,8 +37,9 @@ def validate(document, version):
click.echo("Document is valid!") click.echo("Document is valid!")
def get_template_context(document): def get_template_context(document, **kwargs):
context = {"doc": document, "version": document["version"]} context = {"doc": document, "version": document["version"]}
context.update(**kwargs)
context["sorted_means"] = [ context["sorted_means"] = [
models.Mean(**mean_data) models.Mean(**mean_data)
for mean_data in sorted( for mean_data in sorted(
...@@ -56,17 +57,18 @@ def get_template_context(document): ...@@ -56,17 +57,18 @@ def get_template_context(document):
@cli.command() @cli.command()
@click.argument("document", type=click.File("r")) @click.argument("document", type=click.File("r"))
@click.option("--template", "-t", type=click.File("r")) @click.option(
def html(document, template): "--template",
"-t",
type=click.File("r"),
default=os.path.join(PROJECT_DIR, "templates", "profile.jinja2"),
)
@click.option("--stylesheets", "-s", multiple=True)
def html(document, template, stylesheets):
content = document.read() content = document.read()
document = json.loads(content) document = json.loads(content)
context = get_template_context(document) context = get_template_context(document, stylesheets=stylesheets)
if not template: template_content = template.read()
default_template = os.path.join(PROJECT_DIR, "templates", "profile.jinja2")
with open(default_template, "r") as f:
template_content = f.read()
else:
template_content = template.read()
t = jinja2.Template( t = jinja2.Template(
"{% autoescape true %}" + template_content + "{% endautoescape %}", "{% autoescape true %}" + template_content + "{% endautoescape %}",
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
{%- if "summary" in doc %} {%- if "summary" in doc %}
<meta name="description" content="{{ doc['summary'] }}" /> <meta name="description" content="{{ doc['summary'] }}" />
{% endif %} {% endif %}
{% for url in stylesheets %}
<link rel="stylesheet" href="{{ url }}">
{% endfor %}
</head> </head>
<body> <body>
<header> <header>
...@@ -17,27 +20,6 @@ ...@@ -17,27 +20,6 @@
{% endif %} {% endif %}
</header> </header>
<main> <main>
{%- if sorted_identities|length > 0 %}
<section class="identity">
<h2>My other identities</h2>
{% for identity in sorted_identities %}
<article>
<h3>
{%- if identity.url %}
<a href="{{ identity.url }}" rel="retribute me noopener">
{{ identity.get_full_name() }}
</a>
{%- else %}
{{ identity.get_full_name() }}
{%- endif %}
</h3>
{%- if identity.summary %}
<p>{{ identity.summary }}</p>
{%- endif %}
</article>
{% endfor %}
</section>
{%- endif %}
{%- if sorted_means|length > 0 %} {%- if sorted_means|length > 0 %}
<section> <section>
<h2>Support me!</h2> <h2>Support me!</h2>
...@@ -59,6 +41,27 @@ ...@@ -59,6 +41,27 @@
{% endfor %} {% endfor %}
</section> </section>
{%- endif %} {%- endif %}
{%- if sorted_identities|length > 0 %}
<section class="identity">
<h2>My other identities</h2>
{% for identity in sorted_identities %}
<article>
<h3>
{%- if identity.url %}
<a href="{{ identity.url }}" rel="retribute me noopener">
{{ identity.get_full_name() }}
</a>
{%- else %}
{{ identity.get_full_name() }}
{%- endif %}
</h3>
{%- if identity.summary %}
<p>{{ identity.summary }}</p>
{%- endif %}
</article>
{% endfor %}
</section>
{%- endif %}
</main> </main>
<script type="application/retribute+json"> <script type="application/retribute+json">
{{ doc|tojson(indent=2) }} {{ doc|tojson(indent=2) }}
......
body {
color: #010101;
font-family: sans-serif;
background: #EFEFEF;
line-height: 1.5;
}
main, body > header {
max-width: 768px;
margin: 1em auto;
}
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
<title>Caring is loving</title> <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!" /> <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!" />
<link rel="stylesheet" href="./retribute_me/templates/style.css">
</head> </head>
<body> <body>
<header> <header>
...@@ -15,64 +18,64 @@ ...@@ -15,64 +18,64 @@
</header> </header>
<main> <main>
<section class="identity"> <section>
<h2>My other identities</h2> <h2>Support me!</h2>
<article> <article class="mean">
<h3> <h3>
<a href="https://alice.me" rel="retribute me noopener"> <a href="https://freetips.com/@Alice" rel="retribute me noopener">
My personal website Tip me on freetips
</a> </a>
</h3> </h3>
<p>This is the best place to tip me</p>
</article> </article>
<article> <article class="mean">
<h3> <h3>
<a href="https://musicbrainz.org/artist/176216c5-d6e7-4df1-83cf-85251328eb90" rel="retribute me noopener"> Cash
176216c5-d6e7-4df1-83cf-85251328eb90 on musicbrainz
</a>
</h3> </h3>
<p>I live here, you can send me money directly</p>
</article> </article>
<article> <article class="mean">
<h3> <h3>
<a href="https://mastodon.instance/alice" rel="retribute me noopener"> <a href="https://flattr.com/@Alice" rel="retribute me noopener">
alice@mastodon.instance on fediverse Alice on flattr
</a> </a>
</h3> </h3>
</article> </article>
</section> </section>
<section> <section class="identity">
<h2>Support me!</h2> <h2>My other identities</h2>
<article class="mean"> <article>
<h3> <h3>
<a href="https://freetips.com/@Alice" rel="retribute me noopener"> <a href="https://alice.me" rel="retribute me noopener">
Tip me on freetips My personal website
</a> </a>
</h3> </h3>
<p>This is the best place to tip me</p>
</article> </article>
<article class="mean"> <article>
<h3> <h3>
Cash <a href="https://musicbrainz.org/artist/176216c5-d6e7-4df1-83cf-85251328eb90" rel="retribute me noopener">
176216c5-d6e7-4df1-83cf-85251328eb90 on musicbrainz
</a>
</h3> </h3>
<p>I live here, you can send me money directly</p>
</article> </article>
<article class="mean"> <article>
<h3> <h3>
<a href="https://flattr.com/@Alice" rel="retribute me noopener"> <a href="https://mastodon.instance/alice" rel="retribute me noopener">
Alice on flattr alice@mastodon.instance on fediverse
</a> </a>
</h3> </h3>
</article> </article>
</section> </section>
</main> </main>
<script type="application/json+retribute"> <script type="application/retribute+json">
{ {
"id": "https://retribute.me/@Alice.json", "id": "https://retribute.me/@Alice.json",
"identities": [ "identities": [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment