From: Ben Sherratt Date: Mon, 29 Dec 2025 11:57:18 +0000 (+0000) Subject: Better configuration X-Git-Url: https://git.bts.cx/garden.git/commitdiff_plain/2812e275ef0f68ae484ec50fd954dd88225a2532 Better configuration * Added links * Added feed file targets --- diff --git a/config.php b/config.php index 9ea6b10..074f8f3 100644 --- a/config.php +++ b/config.php @@ -12,6 +12,12 @@ define('GARDEN_TEMPLATE_DIR', garden_path(__DIR__, 'templates')); // Where do you want to write the website to? define('GARDEN_OUTPUT_DIR', garden_path(__DIR__, 'public')); +// Filename for the Atom feed +define('GARDEN_ATOM_FEED_FILENAME', 'feed.atom'); + +// Filename for the JSON feed +define('GARDEN_JSON_FEED_FILENAME', 'feed.json'); + // Put anything here you want the templates to be able to see... define('GARDEN_TEMPLATE_CONSTANTS', [ 'site_name' => 'garden', @@ -24,4 +30,8 @@ define('GARDEN_TEMPLATE_CONSTANTS', [ 'itch_link' => 'https://itch.io', 'itch_handle' => '@???.itch.io', + + 'sidebar_links' => [ + [ 'text' => 'git', 'url' => 'https://git-scm.com/' ], + ], ]); diff --git a/garden.php b/garden.php index e4429e3..99cb012 100644 --- a/garden.php +++ b/garden.php @@ -520,7 +520,7 @@ function garden_generate_html($output_directory, $content_items) { // Feed /////////////////////////////////////////////////////////////////////////////// -function garden_generate_atom($output_directory, $content_items) { +function garden_generate_atom($output_directory, $output_filename, $content_items) { $recent_items = []; foreach ($content_items as $item) { if ($item->type != GardenItemType::Article) { @@ -538,10 +538,10 @@ function garden_generate_atom($output_directory, $content_items) { $variables['recent_items'] = $recent_items; $html_data = garden_template_render('atom', $variables); - garden_write_file(garden_path($output_directory, 'feed.atom'), $html_data); + garden_write_file(garden_path($output_directory, $output_filename), $html_data); } -function garden_generate_json($output_directory, $content_items) { +function garden_generate_json($output_directory, $output_filename, $content_items) { $recent_items = []; foreach ($content_items as $item) { if ($item->type != GardenItemType::Article) { @@ -559,7 +559,7 @@ function garden_generate_json($output_directory, $content_items) { $feed['version'] = 'https://jsonfeed.org/version/1.1'; $feed['title'] = GARDEN_TEMPLATE_CONSTANTS['site_name']; $feed['home_page_url'] = garden_site_url('/'); - $feed['feed_url'] = garden_site_url('/feed.json'); + $feed['feed_url'] = garden_site_url($output_filename); $feed['items'] = []; foreach ($recent_items as $item) { @@ -573,7 +573,7 @@ function garden_generate_json($output_directory, $content_items) { } $json_data = json_encode($feed); - garden_write_file(garden_path($output_directory, 'feed.json'), $json_data); + garden_write_file(garden_path($output_directory, $output_filename), $json_data); } /////////////////////////////////////////////////////////////////////////////// @@ -588,8 +588,14 @@ function garden() { garden_move_raw($process_items); $post_process_items = garden_generate_html(GARDEN_OUTPUT_DIR, $process_items); garden_make_images($post_process_items); - garden_generate_atom(GARDEN_OUTPUT_DIR, $process_items); - garden_generate_json(GARDEN_OUTPUT_DIR, $process_items); + + if (defined('GARDEN_ATOM_FEED_FILENAME')) { + garden_generate_atom(GARDEN_OUTPUT_DIR, GARDEN_ATOM_FEED_FILENAME, $process_items); + } + + if (defined('GARDEN_JSON_FEED_FILENAME')) { + garden_generate_json(GARDEN_OUTPUT_DIR, GARDEN_JSON_FEED_FILENAME, $process_items); + } } /////////////////////////////////////////////////////////////////////////////// diff --git a/templates/atom.php b/templates/atom.php index 5335752..d074dbc 100644 --- a/templates/atom.php +++ b/templates/atom.php @@ -6,7 +6,7 @@ date) ?> - + diff --git a/templates/base.php b/templates/base.php index 75cedb2..2961a4b 100644 --- a/templates/base.php +++ b/templates/base.php @@ -42,9 +42,22 @@ + + + +