diff --git a/README.md b/README.md index 28c89d5..d7b05bf 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ Currently very much a work in progress, but it's baically functional. Deploy the `/tkr` directory to a web server that supports php. It will work either as the root of a (sub)domain (e.g. tky.mydomain.com) or if served from a subdirectory (e.g. mydomain.com/tkr). -If you serve it from a subdirectory, set the value of `$basePath` in `/app/Config.php` to the subdirectory name, excluding the trailing slash (e.g. `/tkr`) +If you serve it from a subdirectory, set the value of `$basePath` in `config/init.php` to the subdirectory name, excluding the trailing slash (e.g. `/tkr`) -It provides an rss feed at `/rss` relative to where it's being served (e.g. `/tkr/rss` if served from `/tkr/`). Each rss entry links to an individual post (which I call "ticks"). +It provides an rss feed at `/rss` and an atom feed at `/atom` relative to where it's being served (e.g. `/tkr/rss` if served from `/tkr/`). Each rss entry links to an individual post (which I call "ticks"). ## Serving diff --git a/public/css/tkr.css b/public/css/tkr.css index 23113ed..d1e5631 100644 --- a/public/css/tkr.css +++ b/public/css/tkr.css @@ -169,13 +169,6 @@ label { gap: 0.5em; } -.upload-container { - background: white; - border-radius: 8px; - padding: 20px; - box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); -} - .fieldset-items { margin-bottom: 14px; display: grid; @@ -293,6 +286,12 @@ label { - Once the width exceeds that (e.g. desktops), it will convert to horizontal alignment */ @media (min-width: 600px) { + label { + text-align: right; + padding-top: 10px; /* Match input padding */ + margin-bottom: 0; + } + .home-container { grid-template-columns: 1fr 2fr; grid-gap: 2em; @@ -306,12 +305,6 @@ label { align-items: start; } - label { - text-align: right; - padding-top: 10px; /* Match input padding */ - margin-bottom: 0; - } - .file-info { grid-column: 2; /* Align with input column */ } diff --git a/public/index.php b/public/index.php index 8a54d00..7eeb907 100644 --- a/public/index.php +++ b/public/index.php @@ -42,7 +42,7 @@ loadClasses(); // Everything's loaded. Now we can start ticking. Util::confirm_setup(); -$config = Config::load(); +$config = ConfigModel::load(); Session::start(); Session::generateCsrfToken(); diff --git a/src/Controller/AdminController/AdminController.php b/src/Controller/AdminController/AdminController.php index 9db62af..ad4f78b 100644 --- a/src/Controller/AdminController/AdminController.php +++ b/src/Controller/AdminController/AdminController.php @@ -3,8 +3,8 @@ class AdminController extends Controller { // GET handler // render the admin page public function index(){ - $config = Config::load(); - $user = User::load(); + $config = ConfigModel::load(); + $user = UserModel::load(); $vars = [ 'user' => $user, @@ -17,22 +17,22 @@ class AdminController extends Controller { // POST handler // save updated settings public function handleSave(){ - $config = Config::load(); + $config = ConfigModel::load(); - if (!Config::isFirstSetup()) { + if (!ConfigModel::isFirstSetup()) { if (!Session::isLoggedIn()){ header('Location: ' . $config->basePath . '/login'); exit; } } - $user = User::load(); + $user = UserModel::load(); // handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { $errors = []; - // User profile + // UserModel profile $username = trim($_POST['username'] ?? ''); $displayName = trim($_POST['display_name'] ?? ''); $about = trim($_POST['about'] ?? ''); @@ -115,11 +115,15 @@ class AdminController extends Controller { } } - if (Config::isFirstSetup()){ - Config::completeSetup(); + if (ConfigModel::isFirstSetup()){ + ConfigModel::completeSetup(); } header('Location: ' . $config->basePath . '/admin'); exit; } -} \ No newline at end of file + + private function getCustomCss(){ + + } +} diff --git a/src/Controller/AuthController/AuthController.php b/src/Controller/AuthController/AuthController.php index 0bbbfde..445676a 100644 --- a/src/Controller/AuthController/AuthController.php +++ b/src/Controller/AuthController/AuthController.php @@ -1,7 +1,7 @@ basePath); exit; } diff --git a/src/Controller/FeedController/FeedController.php b/src/Controller/FeedController/FeedController.php index eede6ab..8014ac3 100644 --- a/src/Controller/FeedController/FeedController.php +++ b/src/Controller/FeedController/FeedController.php @@ -1,12 +1,12 @@ config = Config::load(); - $this->ticks = iterator_to_array(Tick::streamTicks($this->config->itemsPerPage)); + $this->config = ConfigModel::load(); + $this->ticks = iterator_to_array(TickModel::streamTicks($this->config->itemsPerPage)); $this->vars = [ 'config' => $this->config, 'ticks' => $this->ticks, diff --git a/src/Controller/HomeController/HomeController.php b/src/Controller/HomeController/HomeController.php index d671bab..628bc44 100644 --- a/src/Controller/HomeController/HomeController.php +++ b/src/Controller/HomeController/HomeController.php @@ -4,12 +4,12 @@ class HomeController extends Controller { // renders the homepage view. public function index(){ $page = isset($_GET['page']) ? max(1, (int)$_GET['page']) : 1; - $config = Config::load(); - $user = User::load(); + $config = ConfigModel::load(); + $user = UserModel::load(); $limit = $config->itemsPerPage; $offset = ($page - 1) * $limit; - $ticks = iterator_to_array(Tick::streamTicks($limit, $offset)); + $ticks = iterator_to_array(TickModel::streamTicks($limit, $offset)); $view = new HomeView(); $tickList = $view->renderTicksSection($config->siteDescription, $ticks, $page, $limit); @@ -34,11 +34,13 @@ class HomeController extends Controller { } // save the tick - Tick::save($_POST['tick']); + if (trim($_POST['tick'])){ + TickModel::save($_POST['tick']); + } } // get the config - $config = Config::load(); + $config = ConfigModel::load(); // redirect to the index (will show the latest tick if one was sent) header('Location: ' . $config->basePath); diff --git a/src/Controller/MoodController/MoodController.php b/src/Controller/MoodController/MoodController.php index 6352b31..b48b56c 100644 --- a/src/Controller/MoodController/MoodController.php +++ b/src/Controller/MoodController/MoodController.php @@ -1,8 +1,8 @@ render_mood_picker(self::get_emojis_with_labels(), $user->mood); @@ -23,8 +23,8 @@ } // Get the data we need - $config = Config::load(); - $user = User::load(); + $config = ConfigModel::load(); + $user = UserModel::load(); $mood = $_POST['mood']; // set the mood diff --git a/src/Controller/TickController/TickController.php b/src/Controller/TickController/TickController.php index ffd165f..22ddc61 100644 --- a/src/Controller/TickController/TickController.php +++ b/src/Controller/TickController/TickController.php @@ -3,7 +3,7 @@ class TickController extends Controller{ // every tick is identified by its timestamp public function index(string $year, string $month, string $day, string $hour, string $minute, string $second){ - $model = new Tick(); + $model = new TickModel(); $tick = $model->get($year, $month, $day, $hour, $minute, $second); $this->render('tick.php', $tick); } diff --git a/src/Framework/Session/Session.php b/src/Framework/Session/Session.php index bc02995..3a975b3 100644 --- a/src/Framework/Session/Session.php +++ b/src/Framework/Session/Session.php @@ -25,7 +25,7 @@ class Session { } public static function isLoggedIn(): bool { - //echo "User ID set: ". isset($_SESSION['user_id']). "
"; + //echo "UserModel ID set: ". isset($_SESSION['user_id']). "
"; //exit; return isset($_SESSION['user_id']); } diff --git a/src/Framework/Util/Util.php b/src/Framework/Util/Util.php index 8e1d9bf..d43997c 100644 --- a/src/Framework/Util/Util.php +++ b/src/Framework/Util/Util.php @@ -89,7 +89,7 @@ class Util { // See if there's any data in the tables $user_count = (int) $db->query("SELECT COUNT(*) FROM user")->fetchColumn(); $settings_count = (int) $db->query("SELECT COUNT(*) FROM settings")->fetchColumn(); - $config = Config::load(); + $config = ConfigModel::load(); // If either table has no records and we aren't on /admin if ($user_count === 0 || $settings_count === 0){ diff --git a/src/Model/Config/Config.php b/src/Model/ConfigModel/Config.php similarity index 96% rename from src/Model/Config/Config.php rename to src/Model/ConfigModel/Config.php index 57cf594..d7c135d 100644 --- a/src/Model/Config/Config.php +++ b/src/Model/ConfigModel/Config.php @@ -1,5 +1,5 @@ prepare("UPDATE settings SET site_title=?, site_description=?, base_url=?, base_path=?, items_per_page=? WHERE id=1"); } else { $stmt = $db->prepare("INSERT INTO settings (id, site_title, site_description, base_url, base_path, items_per_page) VALUES (1, ?, ?, ?, ?, ?)"); diff --git a/src/Model/Tick/Tick.php b/src/Model/TickModel/TickModel.php similarity index 98% rename from src/Model/Tick/Tick.php rename to src/Model/TickModel/TickModel.php index dc81c0f..569611c 100644 --- a/src/Model/Tick/Tick.php +++ b/src/Model/TickModel/TickModel.php @@ -1,5 +1,5 @@ $tickTime, 'tick' => $tick, - 'config' => Config::load(), + 'config' => ConfigModel::load(), ]; } } diff --git a/src/Model/User/User.php b/src/Model/UserModel/UserModel.php similarity index 96% rename from src/Model/User/User.php rename to src/Model/UserModel/UserModel.php index e351ee0..480312a 100644 --- a/src/Model/User/User.php +++ b/src/Model/UserModel/UserModel.php @@ -1,5 +1,5 @@ prepare("UPDATE user SET username=?, display_name=?, about=?, website=?, mood=? WHERE id=1"); } else { $stmt = $db->prepare("INSERT INTO user (id, username, display_name, about, website, mood) VALUES (1, ?, ?, ?, ?, ?)"); diff --git a/templates/admin.php b/templates/admin.php index 3983b5e..d015f42 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -1,5 +1,5 @@ - - + + @@ -13,14 +13,14 @@
- User settings + UserModel settings
- + - + Site settings
- + - + - + - + - +
+
+ + +
Change password
- + - +
+
+ CSS Upload +
+ + + +
+ File Requirements:
+ • Must be a valid CSS file (.css extension)
+ • Maximum size: 2MB
+ • Will be scanned for malicious content +
+ + + + +
+
diff --git a/templates/feed/atom.php b/templates/feed/atom.php index 0f5815a..892af8b 100644 --- a/templates/feed/atom.php +++ b/templates/feed/atom.php @@ -1,4 +1,4 @@ - + siteTitle); diff --git a/templates/feed/rss.php b/templates/feed/rss.php index 81ee9db..4822a36 100644 --- a/templates/feed/rss.php +++ b/templates/feed/rss.php @@ -1,4 +1,4 @@ - + - - + + diff --git a/templates/login.php b/templates/login.php index 399a4d9..1d46ab8 100644 --- a/templates/login.php +++ b/templates/login.php @@ -1,4 +1,4 @@ - + diff --git a/templates/mood.php b/templates/mood.php index ca70ede..bc9667c 100644 --- a/templates/mood.php +++ b/templates/mood.php @@ -1,4 +1,4 @@ - + diff --git a/templates/partials/head.php b/templates/partials/head.php index 97e74d9..ad5f074 100644 --- a/templates/partials/head.php +++ b/templates/partials/head.php @@ -1,4 +1,4 @@ - + <?= $config->siteTitle ?> diff --git a/templates/partials/navbar.php b/templates/partials/navbar.php index cc7d09c..469047d 100644 --- a/templates/partials/navbar.php +++ b/templates/partials/navbar.php @@ -1,4 +1,4 @@ - +