Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaning up coding style and reacquainting myself with this codebase.
- Loading branch information
Showing
25 changed files
with
231 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require_once dirname(__FILE__) . '/../include/init.php'; | ||
loadlib('url'); | ||
require_once dirname(__FILE__) . "/../include/init.php"; | ||
|
||
# Post title in URI form | ||
if (2 != sizeof($argv)) { | ||
echo "Usage: {$argv[0]} <title>\n"; | ||
err("Usage: {$argv[0]} <title>\n"); | ||
exit(1); | ||
} | ||
|
||
loadlib('url'); | ||
|
||
$title = url_sanitize($argv[1]); | ||
if ('' == $title) { | ||
echo "[new] post title resulted in an empty URI\n"; | ||
if ("" == $title) { | ||
err("[new] post title resulted in an empty URI\n"); | ||
exit(1); | ||
} | ||
$posts = dirname(__FILE__) . '/../posts'; | ||
$posts = dirname(__FILE__) . "/../posts"; | ||
if (!is_dir($posts)) { mkdir($posts); } | ||
if (file_exists("$posts/$y/$m/$d/$title")) { | ||
echo "[new] there is already a post by that name today\n"; | ||
err("[new] there is already a post by that name today\n"); | ||
exit(1); | ||
} | ||
|
||
# Date directories | ||
$y = date('Y'); | ||
$m = date('m'); | ||
$d = date('d'); | ||
$y = date("Y"); | ||
$m = date("m"); | ||
$d = date("d"); | ||
if (!is_dir("$posts/$y")) { mkdir("$posts/$y", 0755); } | ||
if (!is_dir("$posts/$y/$m")) { mkdir("$posts/$y/$m", 0755); } | ||
if (!is_dir("$posts/$y/$m/$d")) { mkdir("$posts/$y/$m/$d", 0755); } | ||
file_put_contents("$posts/$y/$m/$d/$title", | ||
"{$argv[1]}\n\n[tags]\n\n<p>[body]</p>"); | ||
|
||
# Great success! | ||
echo "[new] post has been created and can be edited in:\n[new] ", | ||
realpath("$posts/$y/$m/$d/$title"), "\n"; | ||
|
||
err("[new] post has been created and can be edited in:\n[new] ", | ||
realpath("$posts/$y/$m/$d/$title"), "\n"); | ||
exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.