karton/templates/pasta.html

123 lines
3.3 KiB
HTML
Raw Normal View History

2022-04-10 22:21:45 +00:00
{% include "header.html" %}
<div style="float: left">
{% if pasta.content != "No Text Content" %}
<button id="copy-text-button" class="copy-text-button" style="margin-right: 0.5rem">
Copy Text
</button>
<a style="margin-right: 1rem" href="{{ args.public_path }}/raw/{{pasta.id_as_animals()}}">Raw Text
Content</a>
{%- endif %}
{% if args.qr && args.public_path.to_string() != "" %}
<a style="margin-right: 1rem" href="{{ args.public_path }}/qr/{{pasta.id_as_animals()}}">QR</a>
{%- endif %}
{% if pasta.editable %}
<a style="margin-right: 1rem" href="{{ args.public_path }}/edit/{{pasta.id_as_animals()}}">Edit</a>
{%- endif %}
<a style="margin-right: 1rem" href="{{ args.public_path }}/remove/{{pasta.id_as_animals()}}">Remove</a>
</div>
<div style="float: right">
<a style="margin-right: 0.5rem"
href="{{ args.public_path }}/pasta/{{pasta.id_as_animals()}}"><i>{{pasta.id_as_animals()}}</i></a>
{% if args.public_path.to_string() != "" %}
<button id="copy-url-button" class="copy-url-button" style="margin-right: 0">
Copy URL
</button>
{%- endif %}
</div>
{% if pasta.file.is_some() %}
<br>
<br>
<a href="{{ args.public_path }}/file/{{pasta.id_as_animals()}}/{{pasta.file.as_ref().unwrap().name()}}" download>
Download attached file: '{{pasta.file.as_ref().unwrap().name()}}' [{{pasta.file.as_ref().unwrap().size}}]
</a>
{%- endif %}
<br>
<br>
{% if pasta.content != "No Text Content" %}
2022-10-01 05:37:26 +00:00
<div class="code-container">
<div style="clear: both;">
{% if args.highlightsyntax %}
<pre><code id="code">{{pasta.content_syntax_highlighted()}}</code></pre>
{%- else %}
<pre><code id="code">{{pasta.content_not_highlighted()}}</code></pre>
{%- endif %}
</div>
</div>
{%- endif %}
<div>
<p style="font-size: small">Read {{pasta.read_count}} times, last {{pasta.last_read_time_ago_as_string()}}</p>
</div>
<br>
2022-10-01 05:37:26 +00:00
<script>
const copyURLBtn = document.getElementById("copy-url-button")
const copyTextBtn = document.getElementById("copy-text-button")
2022-10-02 04:50:05 +00:00
const content = `{{ pasta.content_escaped() }}`
const url = `{{ args.public_path }}/pasta/{{pasta.id_as_animals()}}`
copyURLBtn.addEventListener("click", () => {
navigator.clipboard.writeText(url)
copyURLBtn.innerHTML = "Copied"
setTimeout(() => {
copyURLBtn.innerHTML = "Copy URL"
}, 1000)
})
2022-10-01 05:37:26 +00:00
copyTextBtn.addEventListener("click", () => {
2022-10-01 05:37:26 +00:00
navigator.clipboard.writeText(content)
copyTextBtn.innerHTML = "Copied"
2022-10-22 18:12:15 +00:00
setTimeout(() => {
copyTextBtn.innerHTML = "Copy Text"
2022-10-22 18:12:15 +00:00
}, 1000)
2022-10-01 05:37:26 +00:00
})
</script>
<style>
code-line {
counter-increment: listing;
text-align: right;
float: left;
clear: left;
}
code-line::before {
content: counter(listing);
display: inline-block;
float: left;
padding-left: auto;
margin-left: auto;
text-align: left;
width: 1.6rem;
border-right: 1px solid lightgrey;
color: grey;
margin-right: 0.4rem;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#code {
min-height: 2rem;
}
2022-10-01 05:37:26 +00:00
.code-container {
position: relative;
}
2022-10-02 04:50:05 +00:00
.hidden {
display: none;
}
2022-10-01 05:37:26 +00:00
.copy-text-button,
.copy-url-button {
font-size: small;
padding: 4px;
width: 6rem;
}
</style>
{% include "footer.html" %}