From dd04ad281d9123296be1a904cf647f8e7a232d3f Mon Sep 17 00:00:00 2001 From: 53hornet Date: Thu, 16 Dec 2021 22:08:00 -0500 Subject: feat: rescue post, colors, centered titles --- scripts/new.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 scripts/new.php (limited to 'scripts/new.php') diff --git a/scripts/new.php b/scripts/new.php new file mode 100755 index 0000000..f272a8a --- /dev/null +++ b/scripts/new.php @@ -0,0 +1,45 @@ +#!/usr/bin/env php + in_array($word, exceptions) ? lcfirst($word) : ucfirst($word), + $title_words +); +$title_words[0] = ucfirst($title_words[0]); +end($title_words); +$key = key($title_words); +$title_words[$key] = ucfirst($title_words[$key]); + +// Generate HTML title. +$title = implode(' ', $title_words); +$title = "

$title

\n\n"; + +// Generate post filename/URL. +$filename = strtolower(implode('-', $title_words)); +$date = date('Y-m-d'); +$filename = "$date-$filename.php"; + +if (!$handle = fopen("./drafts/$filename", 'a')) { + fwrite(STDERR, "Cannot append to file: $filename\n"); + exit; +} + +if (fwrite($handle, $title) === false) { + fwrite(STDERR, "Cannot write contents to file: $filename\n"); + exit; +} + +printf("Created post %s\n", $filename); -- cgit v1.2.3