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 0000000..209ad98 Binary files /dev/null and b/src/assets/badges/hosted_ds.gif differ diff --git a/src/assets/badges/swege.gif b/src/assets/badges/swege.gif new file mode 100644 index 0000000..1af4b10 Binary files /dev/null and b/src/assets/badges/swege.gif differ diff --git a/swege.cfg b/swege.cfg index a8b40aa..fb6317d 100644 --- a/swege.cfg +++ b/swege.cfg @@ -1,5 +1,5 @@ title:Darkn Neko source:src -destination:site +destination:dst header:src/_header.html footer:src/_footer.html