From 468c11ae2062dc0d3b17871c69ee2141e425c453 Mon Sep 17 00:00:00 2001 From: Darkn Neko Date: Tue, 25 Jul 2023 15:49:06 +0600 Subject: [PATCH] Make minor changes --- Makefile | 4 +-- scripts/mincss | 42 +++++++++++++++++++++++++++ scripts/newpost | 50 ++++++++++++++++++++++++++++++++ src/_footer.html | 11 +++---- src/assets/badges/hosted_ds.gif | Bin 0 -> 1623 bytes src/assets/badges/swege.gif | Bin 0 -> 592 bytes swege.cfg | 2 +- 7 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 scripts/mincss create mode 100644 scripts/newpost create mode 100644 src/assets/badges/hosted_ds.gif create mode 100644 src/assets/badges/swege.gif diff --git a/Makefile b/Makefile index 069a472..135175d 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,9 @@ DESTINATION = dst PYHTON = python3 PORT = 8000 BIND = 127.0.0.1 -RS_USER = root +RS_USER = neko RS_HOST = darkn.space -RS_PATH = /var/www/html +RS_PATH = /home/neko/cyancat_net CSSDIR = ${SOURCE}/assets/styles SCRIPTS_DIR = ./scripts diff --git a/scripts/mincss b/scripts/mincss new file mode 100644 index 0000000..b6c0e78 --- /dev/null +++ b/scripts/mincss @@ -0,0 +1,42 @@ +#!/usr/bin/env perl +# Minifies CSS files, that is removes all whitespace characters. +# Usage: `ls /path/to/css/files | /path/to/this/script` + +use v5.14; +use CSS::Packer; +use warnings; +use strict; + +# It leaves the copyright in place if it encounters the word 'copyright', this +# adds 'license' word as a trigger. +# +# I have already sent a pull request for that: https://github.com/leejo/css-packer-perl/pull/12. +$CSS::Packer::COPYRIGHT_COMMENT = '\/\*((?>[^*]|\*[^/])*(?:license|copyright)(?>[^*]|\*[^/])*)\*\/'; + +# There is no matching cleanup function to call afterwards. +my $packer = CSS::Packer->init(); + +my $fh; +my $mincss_path; +my $content; +my $min; + +while (my $css_path = <>) { + chomp $css_path; + $mincss_path = $css_path =~ s/.css$/.min.css/r; + + # Read CSS file. + open($fh, '<', $css_path) or die "Cannot open $css_path: $!"; + $content = do { local $/; <$fh> }; + close $fh; + + # Minify CSS. + $min = $packer->minify(\$content, {compress => 'minify'}); + + # Write minified CSS down. + open($fh, '>', $mincss_path) or die "Cannot open $mincss_path: $!"; + print $fh $min; + close $fh; + + say "$css_path -> $mincss_path"; +} diff --git a/scripts/newpost b/scripts/newpost new file mode 100644 index 0000000..eb4beb0 --- /dev/null +++ b/scripts/newpost @@ -0,0 +1,50 @@ +#!/usr/bin/env perl + +# Creates a new website post, appends its link to the index. + +use v5.14; +use autodie; +use warnings; +use strict; + +use Tie::File; +use Time::Piece; + +# '/' is both prepended, and appended. +my $post_url_dir = 'posts'; +my $posts_dir = "./src/$post_url_dir"; +my $index_file = './src/index.md'; + +my $post_title; +my $post_filename; + +print "Post title: "; +$post_title = <>; + +print "Post file name, without extension: "; +$post_filename = <>; + +chomp $post_title; +chomp $post_filename; + +die "File already exists" if -e "$posts_dir/$post_filename.md"; + +# Create a post file and insert the title. +open (my $fh, '>', "$posts_dir/$post_filename.md"); +say $fh "# $post_title"; +close $fh; + +# Append a post URL to the index. +tie my @index_lines, 'Tie::File', $index_file; +my $posts_found = 0; +for (@index_lines) { + if ($posts_found) { + $_ .= "\n* [$post_title](/$post_url_dir/$post_filename.html)"; + last; + } + $posts_found = 1 if ($_ =~ /and such:/i); +} +untie @index_lines; + +my @cmd = ($ENV{EDITOR}, "$posts_dir/$post_filename.md"); +system @cmd; diff --git a/src/_footer.html b/src/_footer.html index 6d79687..1d7fd89 100644 --- a/src/_footer.html +++ b/src/_footer.html @@ -1,9 +1,6 @@ -
-

-© 2022 -Darkn Neko — -CC-BY 4.0 License
-Built with swege and some catgirls
-

+
+Created with swege +Hosted by Darkn.Space +
diff --git a/src/assets/badges/hosted_ds.gif b/src/assets/badges/hosted_ds.gif new file mode 100644 index 0000000000000000000000000000000000000000..209ad9851fb7cd9af17ec5f861b2fa43ba2a7468 GIT binary patch literal 1623 zcmeH`{Xf$Q0LQ<3z{X;RJZv%~$5A-1l&2$f=!v51I|eLde>%6F5A-R{?WwJ`VAFhi=DKMOg2b)4W@c392LW49{z*Yg77Ao36@)5AQYAB5z)Iv-oULSB#Qtktt}zf)R=`?%-g5d6Vg4cEql8g4z@LicXayoXOVKqR4O&^T6qDhps=W< z^taNo8}w3EIiupU=s6&r1Tx4RRyL23eX~4|!zkb|uY*hqmzB@0C;;ijY(^2MqKLyN zVKWOsdMTShV^%xRx4&GYvZn|_uLF)4A8c;&iHkoKIvz=c0tWdI3Uo}h#vw7)M#4~ZqV zin?7@?(V5}n!4Cj&{L@j$kXF_(u3g(g-MZ3>GRMLy4z_M^;gK+$86)*76Poz&PE!t z`s>Xb9bN;ZW5Wgm}49p zc0!qBazPw`@mleTio}n`nMZwE4j4I>eJNKJk4qy!G<*?@9eU>P2^0A{)Hh|4`4DQ{`#3AV_k%D*RX0~ghJ;wnk%mmFV(U=pF zjQ7kCrb-EM0_`mq7Sz=1*l~3AIJ;_(@Bm5V*~RXp*U?{RYmHEzB*!)Fr~~~GGK<#$CoQCyN!b!h6GrauKlUVcQ4Xd3Ba5s z(3r8;n0|S!XpbXt%3G0;L4xp$tlUC|0x+JyVpp;`6qIOi6Z1G#ZRgY)AwJSapu4#`*p>(wyIlLXj ztm^wAO)2uMO$Sf9^kBy?qn3sClgcJP4;!HEe(b?$f4FpdM0~OXHq|^ zpLi$1WBrTAlQpoJjYyYgQ99;1W@&Y<`3?P>2Say{rLS+0TG>*3Wy%bgDsV$MTj@G+ d{)1(@*-;#NM9oNlwK~lvZ+$<*g`v@a$G=+WeQW># literal 0 HcmV?d00001 diff --git a/src/assets/badges/swege.gif b/src/assets/badges/swege.gif new file mode 100644 index 0000000000000000000000000000000000000000..1af4b1058cc0ea726158ff26270c8a1eca233825 GIT binary patch literal 592 zcmZ?wbh9u|j9`#wXkljf|Np<2m)G9Cd(WLaw|DK@mg3^~UQYk#82(>sS)J^3Y;U#Y zoTXkt$x%_shK80)=PXqekOEg6qRO?wqSB(f8T;BF&0d`jI-9wYMC21v7)YSTkX=m2{p?srZTT-nZ1^`s4dTm z>CD-4=Pz8mbopX*0Q2;mTgO=2a@Mh)ihcZK>Y9i5j~{sz{D76|$;ZH{&9_*Ntmk|E zaP6Z{|I8peZlV_S`e(Jd;@@nEr3%0FHuZ$Y@X@2mV#dF#u%X4z_$9udLx$fr4 zxm*&t=Bv|v`#NlA-K`7@?Kjtv^PN>1!@OVP(Fr_Imyo0d%aw_)`Ro#$tgq`&|5 zS^n|PoMqpcq?~F}JKtMA_Q|@h auWxM5zJG4-?^uR=hr8wd|5b4?SOWlND