summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-26 12:16:25 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-26 12:16:25 +0100
commitbe87482f8964db882a9b61eac843b051a5654b27 (patch)
treef0f5b8914440b160403d5588e0422845332efc46
parentb4cff9b034893efbd40844de43d3563429cef8bd (diff)
Adds syntax highlighting and perl techjournal note
-rw-r--r--content/techjournal/perl_script_to_create_quicknotes_page.md89
-rw-r--r--layouts/partials/head.html1
-rw-r--r--static/css/syntax.css86
3 files changed, 176 insertions, 0 deletions
diff --git a/content/techjournal/perl_script_to_create_quicknotes_page.md b/content/techjournal/perl_script_to_create_quicknotes_page.md
new file mode 100644
index 0000000..c3424ab
--- /dev/null
+++ b/content/techjournal/perl_script_to_create_quicknotes_page.md
@@ -0,0 +1,89 @@
+---
+title: "Perl script to create this quicknotes page"
+date: 2024-05-26T11:58:04+01:00
+draft: false
+categories: ['Computing']
+tags: ['perl']
+---
+
+I use [quicknote](https://git.yulqen.org/go/quicknote/), written in Go, to add the links to an intermediate page, and then the following Perl to push it to the server.
+This is rough, rookie code at its finest.
+
+I like Perl.
+
+{{< highlight perl >}}
+#!/usr/bin/env -S perl -w
+
+use 5.010;
+use warnings;
+use strict;
+use DateTime;
+use File::Copy;
+use Cwd qw(getcwd);
+
+my $description = $ARGV[0];
+
+if (not defined $description) {
+ print "Please pass even a paltry introductory sentence in quotes. Thanks.\n";
+ exit;
+}
+
+sub get_quicknotes {
+ my $quicknote_file = "/home/lemon/Documents/Notes/quicknote.md";
+ my $bak = "/home/lemon/Documents/Notes/quicknote.md-BAK";
+ copy($quicknote_file, $bak) or die "Failed to make backup of file: $!";
+ my @quicknotes;
+ open my $fh, "<", $quicknote_file or die "Cannot open quicknote.md file";
+ while (<$fh>) {
+ if ($_ =~ /^- (.*)$/) {
+ push @quicknotes => "- $1\n";
+ }
+ }
+ truncate $quicknote_file, 0;
+ return \@quicknotes;
+}
+
+
+my $now = DateTime->now;
+my $day_name = $now->day_name;
+my $day = $now->day;
+my $month = $now->month_name;
+my $year = $now->year;
+
+my $outfile = "/home/lemon/code/html/yulqen.org/content/techjournal/quicknote_capture_${day}_${month}_$year.md";
+
+my $frontmatter = <<TEXT;
+---
+title: "Quicknote capture $day_name $day $month $year"
+date: $now
+draft: false
+categories: ["Tech"]
+tags: ['quicknotes']
+---
+
+$description
+
+TEXT
+
+my $qn_ref = get_quicknotes();
+open my $FH, ">>", $outfile or die $!;
+print $FH $frontmatter;
+foreach (@{$qn_ref}) {
+ print $FH $_;
+}
+close($FH);
+
+chdir "/home/lemon/code/html/yulqen.org";
+say getcwd();
+my @gitaddcmd = ("git add -A");
+my @gitcommitcmd = ("git commit -m 'update'");
+my @gitpushcmd = ("git push");
+my @pushcmd = ("make push");
+system(@pushcmd) or die "Cannot push the file to the remote: $?";
+system(@gitaddcmd) or die "Cannot do git add $?";
+system(@gitcommitcmd) or die "Cannot do git commit: $?";
+system(@gitpushcmd) or die "Cannot do git push: $?";
+
+say "Done!";
+{{< /highlight >}}
+
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 4c5d49c..918c1ad 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -11,6 +11,7 @@
{{ range .Site.Params.custom_css -}}
<link rel="stylesheet" href="{{ . | absURL }}" type="text/css" media="screen">
+ <link rel="stylesheet" href="{{ "css/syntax.css" | relURL }}">
{{- end}}
<title>{{ .Title }}</title>
</head>
diff --git a/static/css/syntax.css b/static/css/syntax.css
new file mode 100644
index 0000000..9018df9
--- /dev/null
+++ b/static/css/syntax.css
@@ -0,0 +1,86 @@
+/* Background */ .bg { background-color: #ffffff; }
+/* PreWrapper */ .chroma { background-color: #ffffff; }
+/* Other */ .chroma .x { }
+/* Error */ .chroma .err { color: #a61717; background-color: #e3d2d2 }
+/* CodeLine */ .chroma .cl { }
+/* LineLink */ .chroma .lnlinks { outline: none; text-decoration: none; color: inherit }
+/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
+/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
+/* LineHighlight */ .chroma .hl { background-color: #ffffcc }
+/* LineNumbersTable */ .chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
+/* LineNumbers */ .chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
+/* Line */ .chroma .line { display: flex; }
+/* Keyword */ .chroma .k { color: #000000; font-weight: bold }
+/* KeywordConstant */ .chroma .kc { color: #000000; font-weight: bold }
+/* KeywordDeclaration */ .chroma .kd { color: #000000; font-weight: bold }
+/* KeywordNamespace */ .chroma .kn { color: #000000; font-weight: bold }
+/* KeywordPseudo */ .chroma .kp { color: #000000; font-weight: bold }
+/* KeywordReserved */ .chroma .kr { color: #000000; font-weight: bold }
+/* KeywordType */ .chroma .kt { color: #445588; font-weight: bold }
+/* Name */ .chroma .n { }
+/* NameAttribute */ .chroma .na { color: #008080 }
+/* NameBuiltin */ .chroma .nb { color: #0086b3 }
+/* NameBuiltinPseudo */ .chroma .bp { color: #999999 }
+/* NameClass */ .chroma .nc { color: #445588; font-weight: bold }
+/* NameConstant */ .chroma .no { color: #008080 }
+/* NameDecorator */ .chroma .nd { color: #3c5d5d; font-weight: bold }
+/* NameEntity */ .chroma .ni { color: #800080 }
+/* NameException */ .chroma .ne { color: #990000; font-weight: bold }
+/* NameFunction */ .chroma .nf { color: #990000; font-weight: bold }
+/* NameFunctionMagic */ .chroma .fm { }
+/* NameLabel */ .chroma .nl { color: #990000; font-weight: bold }
+/* NameNamespace */ .chroma .nn { color: #555555 }
+/* NameOther */ .chroma .nx { }
+/* NameProperty */ .chroma .py { }
+/* NameTag */ .chroma .nt { color: #000080 }
+/* NameVariable */ .chroma .nv { color: #008080 }
+/* NameVariableClass */ .chroma .vc { color: #008080 }
+/* NameVariableGlobal */ .chroma .vg { color: #008080 }
+/* NameVariableInstance */ .chroma .vi { color: #008080 }
+/* NameVariableMagic */ .chroma .vm { }
+/* Literal */ .chroma .l { }
+/* LiteralDate */ .chroma .ld { }
+/* LiteralString */ .chroma .s { color: #dd1144 }
+/* LiteralStringAffix */ .chroma .sa { color: #dd1144 }
+/* LiteralStringBacktick */ .chroma .sb { color: #dd1144 }
+/* LiteralStringChar */ .chroma .sc { color: #dd1144 }
+/* LiteralStringDelimiter */ .chroma .dl { color: #dd1144 }
+/* LiteralStringDoc */ .chroma .sd { color: #dd1144 }
+/* LiteralStringDouble */ .chroma .s2 { color: #dd1144 }
+/* LiteralStringEscape */ .chroma .se { color: #dd1144 }
+/* LiteralStringHeredoc */ .chroma .sh { color: #dd1144 }
+/* LiteralStringInterpol */ .chroma .si { color: #dd1144 }
+/* LiteralStringOther */ .chroma .sx { color: #dd1144 }
+/* LiteralStringRegex */ .chroma .sr { color: #009926 }
+/* LiteralStringSingle */ .chroma .s1 { color: #dd1144 }
+/* LiteralStringSymbol */ .chroma .ss { color: #990073 }
+/* LiteralNumber */ .chroma .m { color: #009999 }
+/* LiteralNumberBin */ .chroma .mb { color: #009999 }
+/* LiteralNumberFloat */ .chroma .mf { color: #009999 }
+/* LiteralNumberHex */ .chroma .mh { color: #009999 }
+/* LiteralNumberInteger */ .chroma .mi { color: #009999 }
+/* LiteralNumberIntegerLong */ .chroma .il { color: #009999 }
+/* LiteralNumberOct */ .chroma .mo { color: #009999 }
+/* Operator */ .chroma .o { color: #000000; font-weight: bold }
+/* OperatorWord */ .chroma .ow { color: #000000; font-weight: bold }
+/* Punctuation */ .chroma .p { }
+/* Comment */ .chroma .c { color: #999988; font-style: italic }
+/* CommentHashbang */ .chroma .ch { color: #999988; font-style: italic }
+/* CommentMultiline */ .chroma .cm { color: #999988; font-style: italic }
+/* CommentSingle */ .chroma .c1 { color: #999988; font-style: italic }
+/* CommentSpecial */ .chroma .cs { color: #999999; font-weight: bold; font-style: italic }
+/* CommentPreproc */ .chroma .cp { color: #999999; font-weight: bold; font-style: italic }
+/* CommentPreprocFile */ .chroma .cpf { color: #999999; font-weight: bold; font-style: italic }
+/* Generic */ .chroma .g { }
+/* GenericDeleted */ .chroma .gd { color: #000000; background-color: #ffdddd }
+/* GenericEmph */ .chroma .ge { color: #000000; font-style: italic }
+/* GenericError */ .chroma .gr { color: #aa0000 }
+/* GenericHeading */ .chroma .gh { color: #999999 }
+/* GenericInserted */ .chroma .gi { color: #000000; background-color: #ddffdd }
+/* GenericOutput */ .chroma .go { color: #888888 }
+/* GenericPrompt */ .chroma .gp { color: #555555 }
+/* GenericStrong */ .chroma .gs { font-weight: bold }
+/* GenericSubheading */ .chroma .gu { color: #aaaaaa }
+/* GenericTraceback */ .chroma .gt { color: #aa0000 }
+/* GenericUnderline */ .chroma .gl { text-decoration: underline }
+/* TextWhitespace */ .chroma .w { color: #bbbbbb }