aboutsummaryrefslogtreecommitdiff
path: root/pastebin/website-pastebin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-02-05 00:23:23 -0300
committerEuAndreh <eu@euandre.org>2020-02-05 00:23:23 -0300
commitd935cd37ee3566091b706702474265b3a5136f2d (patch)
tree7bb57f941d6b612402761c3e3a8b41e2bea72596 /pastebin/website-pastebin
parentAdd code metadata annotation (diff)
downloadeuandre.org-d935cd37ee3566091b706702474265b3a5136f2d.tar.gz
euandre.org-d935cd37ee3566091b706702474265b3a5136f2d.tar.xz
Delete old files
Diffstat (limited to 'pastebin/website-pastebin')
-rwxr-xr-xpastebin/website-pastebin121
1 files changed, 0 insertions, 121 deletions
diff --git a/pastebin/website-pastebin b/pastebin/website-pastebin
deleted file mode 100755
index 9aa4956..0000000
--- a/pastebin/website-pastebin
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env perl
-
-=head1 NAME
-
-website pastebin - Create new pastebins from the org-mode template.
-
-=head1 SYNOPSIS
-
-website pastebin [options]
-
- Options:
- --help Show the manpage.
- --title Title of the pastebin.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<-h, --help>
-
-Prints the manual page and exits.
-
-=item B<-t, --title>
-
-The title of the pastebin. This string will be slugified and the output is used to create the pastebin file name. Special characters are simplified or discarded.
-
-=back
-
-=head1 DESCRIPTION
-
-B<website pastebin> creates a pastebin org-mode text files, that are later processed to produce HTML to be deployed statically.
-
-=cut
-
-use strict;
-use warnings;
-use Getopt::Long qw(:config no_ignore_case bundling);
-use Pod::Usage qw(pod2usage);
-use Unicode::Normalize qw(NFKD);
-use File::Basename qw(dirname);
-use Term::ANSIColor;
-
-my $help = 0;
-my $title = '';
-my $lang = '';
-my $test = 0;
-GetOptions(
- 'help|h|?' => \$help,
- 'title|t=s' => \$title,
- 'lang|l=s' => \$lang,
- 'test|?' => \$test
-) or pod2usage(-verbose => 1, -exitval => 2);
-pod2usage(
- -verbose => 2,
- -exitval => 0
-) if $help;
-pod2usage(
- -verbose => 1,
- -exitval => 2,
- -message => colored("Missing required --title argument.", "red")
-) if !$title && !$test;
-pod2usage(
- -verbose =>1,
- -exitval => 2,
- -message => colored("Missing required --lang argument.", "red")
-) if !$lang && !$test;
-
-# Taken from:
-# https://stackoverflow.com/a/4009519
-sub slugify {
- my $input = shift;
- $input = NFKD($input); # Normalize (decompose) the Unicode string
- $input =~ tr/\000-\177//cd; # Strip non-ASCII characters (>127)
- $input =~ s/[^\w\s-]//g; # Remove all characters that are not word characters (includes _), spaces, or hyphens
- $input =~ s/^\s+|\s+$//g; # Trim whitespace from both ends
- $input = lc($input);
- $input =~ s/[-\s]+/-/g; # Replace all occurrences of spaces and hyphens with a single hyphen
- return $input;
-}
-
-if ($test) {
- eval "use Test::More tests => 4"; die $@ if $@;
- is(slugify("My Custom Title String"), "my-custom-title-string");
- is(slugify("String with áccents and sym?bol-s."), "string-with-accents-and-symbol-s");
- is(slugify("unicode-↓æđ-chars"), "unicode-aaa-chars");
- is(slugify(" spaces and line
-break"), "spaces-and-line-break");
- done_testing();
- exit;
-}
-
-our $dirname = dirname(__FILE__);
-our $in = "$dirname/skeleton.org";
-our $out;
-my $date = `date +"%Y-%m-%d"`;
-chomp $date;
-my %ENV = (title => $title, date => $date, lang => $lang);
-
-# Derived from both:
-# https://unix.stackexchange.com/a/294836
-# https://stackoverflow.com/a/47664214
-sub envsubst {
- open(IN, '<'.$in) or die $!;
- open(OUT, '>'.$out) or die $!;
- while(<IN>) {
- $_ =~ s/\$([_a-zA-Z]+)/$ENV{$1}/g;
- print OUT $_;
- }
- close(IN);
- close(OUT);
-}
-
-my $slug = slugify($title);
-$out = `realpath $dirname/../site/pastebin/$slug.org`;
-chomp $out;
-
-envsubst();
-
-`cat $out | vipe | sponge $out`;
-
-print "$out\n";