diff --git a/database_schema.sql b/database_schema.sql
index a31ed7c..1f06c33 100644
--- a/database_schema.sql
+++ b/database_schema.sql
@@ -3,9 +3,9 @@
-- https://www.phpmyadmin.net/
--
-- Host: localhost
--- Generation Time: Jul 20, 2024 at 02:33 PM
+-- Generation Time: Aug 21, 2024 at 11:22 PM
-- Server version: 11.4.2-MariaDB
--- PHP Version: 8.3.9
+-- PHP Version: 8.3.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
@@ -29,7 +29,7 @@ SET time_zone = "+00:00";
CREATE TABLE IF NOT EXISTS `blogposts` (
`blogpost_id` uuid NOT NULL DEFAULT uuid() COMMENT 'uuid of the blogpost',
- `readable_address` varchar(64) DEFAULT NULL COMMENT 'Human-readable addressing alternative for an article. For example, blogpost with readable_address = "example" can be accessed by article.php?address=example.',
+ `readable_address` varchar(64) NOT NULL COMMENT 'Human-readable addressing alternative for an article. For example, blogpost with readable_address = "example" can be accessed by blog/article/example.',
`title` varchar(64) DEFAULT NULL COMMENT 'title of the blogpost',
`abstract` varchar(512) DEFAULT NULL COMMENT 'short version of the blogpost to be displayed as preview, usually the first paragraph of the real article.',
`content` text DEFAULT NULL COMMENT 'html for the article',
diff --git a/docs/www/blog/writearticle.php b/docs/www/blog/writearticle.php
index 8d62996..3b09b4e 100644
--- a/docs/www/blog/writearticle.php
+++ b/docs/www/blog/writearticle.php
@@ -255,25 +255,34 @@ if(isset($_POST["submit"])) {
$abstract = $_POST["article_abstract"];
$content = $_POST["article_content"];
- // If adress is empty, set it to null
+ // If adress is empty, repopulate the prefills and show error
if(strcmp($address, "") == 0) {
- $address = null;
- }
-
- if($_POST["blogpost_id"]) {
- $blogpostId = $_POST["blogpost_id"];
- update_blogpost($conn, $blogpostId, $address, $title, $tagsStr,
- $abstract, $content);
+ // Set prefill values for the form
+ $blogId_prefill = isset($_POST["blogpost_id"]) ?
+ sanitize_input($_POST["blogpost_id"]) : "";
+ $title_prefill = $title;
+ $address_prefill = $address;
+ $abstract_prefill = $abstract;
+ $content_prefill = $content;
+ $tagStr_prefill = $tagsStr;
+ $addrErr = "Cannot be empty!";
}
+ // Otherwise update/create the blogpost
else {
- $blogpostId = publish_blogpost($conn, $address, $title, $tagsStr,
- $abstract, $content);
- }
+ if($_POST["blogpost_id"]) {
+ $blogpostId = sanitize_input($_POST["blogpost_id"]);
+ update_blogpost($conn, $blogpostId, $address, $title, $tagsStr,
+ $abstract, $content);
+ }
+ else {
+ $blogpostId = publish_blogpost($conn, $address, $title, $tagsStr,
+ $abstract, $content);
+ }
- generate_atom_feed($conn);
+ generate_atom_feed($conn);
- // Show button to generate the article
- printf("
+ // Show button to generate the article
+ printf("