From 1e8b17bb8935b7d0ec1c4cef9d3a34d355a18629 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Fri, 30 Sep 2022 21:37:26 -0800 Subject: [PATCH 1/6] add copy button to viewer --- templates/pasta.html | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/templates/pasta.html b/templates/pasta.html index 879c948..adf52cb 100644 --- a/templates/pasta.html +++ b/templates/pasta.html @@ -16,13 +16,31 @@ {{pasta.id_as_animals()}}
-
- {% if args.highlightsyntax %} -
{{pasta.content_syntax_highlighted()}}
- {%- else %} -
{{pasta.content_not_highlighted()}}
- {%- endif %} +
+ +
+ {% if args.highlightsyntax %} +
{{pasta.content_syntax_highlighted()}}
+ {%- else %} +
{{pasta.content_not_highlighted()}}
+ {%- endif %} +
+ + + {% include "footer.html" %} From c39b77823461dba7f47debc6fba885069cc3735b Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 1 Oct 2022 20:50:05 -0800 Subject: [PATCH 2/6] properly escape content --- src/pasta.rs | 4 ++++ templates/pasta.html | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pasta.rs b/src/pasta.rs index 3a54070..a728211 100644 --- a/src/pasta.rs +++ b/src/pasta.rs @@ -80,6 +80,10 @@ impl Pasta { pub fn content_not_highlighted(&self) -> String { html_highlight(&self.content, "txt") } + + pub fn content_escaped(&self) -> String { + self.content.replace("`", "\\`").replace("$", "\\$") + } } impl fmt::Display for Pasta { diff --git a/templates/pasta.html b/templates/pasta.html index adf52cb..587619c 100644 --- a/templates/pasta.html +++ b/templates/pasta.html @@ -33,7 +33,7 @@ @@ -79,8 +81,8 @@ code-line::before { background: transparent; top: 0; right: 0; - padding: 8px; - margin: 5px; + padding: 3px; + margin: 3px; } From e031ea0e9510bb3bd281d1c3b62fce7349aab3d4 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 22 Oct 2022 10:30:16 -0800 Subject: [PATCH 4/6] use a tag instead of button --- templates/pasta.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/pasta.html b/templates/pasta.html index 1198e30..540011e 100644 --- a/templates/pasta.html +++ b/templates/pasta.html @@ -17,9 +17,9 @@

- +
{% if args.highlightsyntax %}
{{pasta.content_syntax_highlighted()}}
@@ -83,6 +83,7 @@ code-line::before { right: 0; padding: 3px; margin: 3px; + cursor: pointer; } From fd8a66bcbcc9c4d992d35d60705694e3be0dfb26 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 22 Oct 2022 10:34:39 -0800 Subject: [PATCH 5/6] use proper semantics for a tag as button --- templates/pasta.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pasta.html b/templates/pasta.html index 540011e..388c8a6 100644 --- a/templates/pasta.html +++ b/templates/pasta.html @@ -17,7 +17,7 @@

- + Copy
From b1ccb43855080bc21bfec2f96daf8f5a44973271 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 22 Oct 2022 10:37:43 -0800 Subject: [PATCH 6/6] remove hash --- templates/pasta.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pasta.html b/templates/pasta.html index 388c8a6..6e069ac 100644 --- a/templates/pasta.html +++ b/templates/pasta.html @@ -17,7 +17,7 @@