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
......@@ -37,8 +37,9 @@ def validate(document, version):
click.echo("Document is valid!")
def get_template_context(document):
def get_template_context(document, **kwargs):
context = {"doc": document, "version": document["version"]}
context.update(**kwargs)
context["sorted_means"] = [
models.Mean(**mean_data)
for mean_data in sorted(
......@@ -56,16 +57,17 @@ def get_template_context(document):
@cli.command()
@click.argument("document", type=click.File("r"))
@click.option("--template", "-t", type=click.File("r"))
def html(document, template):
@click.option(
"--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()
document = json.loads(content)
context = get_template_context(document)
if not template:
default_template = os.path.join(PROJECT_DIR, "templates", "profile.jinja2")
with open(default_template, "r") as f:
template_content = f.read()
else:
context = get_template_context(document, stylesheets=stylesheets)
template_content = template.read()
t = jinja2.Template(
......
......@@ -8,6 +8,9 @@
{%- if "summary" in doc %}
<meta name="description" content="{{ doc['summary'] }}" />
{% endif %}
{% for url in stylesheets %}
<link rel="stylesheet" href="{{ url }}">
{% endfor %}
</head>
<body>
<header>
......@@ -17,27 +20,6 @@
{% endif %}
</header>
<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 %}
<section>
<h2>Support me!</h2>
......@@ -59,6 +41,27 @@
{% endfor %}
</section>
{%- 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>
<script type="application/retribute+json">
{{ 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 @@
<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!" />
<link rel="stylesheet" href="./retribute_me/templates/style.css">
</head>
<body>
<header>
......@@ -15,64 +18,64 @@
</header>
<main>
<section class="identity">
<h2>My other identities</h2>
<section>
<h2>Support me!</h2>
<article>
<article class="mean">
<h3>
<a href="https://alice.me" rel="retribute me noopener">
My personal website
<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>
<article class="mean">
<h3>
<a href="https://musicbrainz.org/artist/176216c5-d6e7-4df1-83cf-85251328eb90" rel="retribute me noopener">
176216c5-d6e7-4df1-83cf-85251328eb90 on musicbrainz
</a>
Cash
</h3>
<p>I live here, you can send me money directly</p>
</article>
<article>
<article class="mean">
<h3>
<a href="https://mastodon.instance/alice" rel="retribute me noopener">
alice@mastodon.instance on fediverse
<a href="https://flattr.com/@Alice" rel="retribute me noopener">
Alice on flattr
</a>
</h3>
</article>
</section>
<section>
<h2>Support me!</h2>
<section class="identity">
<h2>My other identities</h2>
<article class="mean">
<article>
<h3>
<a href="https://freetips.com/@Alice" rel="retribute me noopener">
Tip me on freetips
<a href="https://alice.me" rel="retribute me noopener">
My personal website
</a>
</h3>
<p>This is the best place to tip me</p>
</article>
<article class="mean">
<article>
<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>
<p>I live here, you can send me money directly</p>
</article>
<article class="mean">
<article>
<h3>
<a href="https://flattr.com/@Alice" rel="retribute me noopener">
Alice on flattr
<a href="https://mastodon.instance/alice" rel="retribute me noopener">
alice@mastodon.instance on fediverse
</a>
</h3>
</article>
</section>
</main>
<script type="application/json+retribute">
<script type="application/retribute+json">
{
"id": "https://retribute.me/@Alice.json",
"identities": [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment