]> git.bts.cx Git - garden.git/blobdiff - garden.php
Better configuration
[garden.git] / garden.php
index e4429e3f65248ca82f2dbb82f3ac166a696f41b7..99cb0123ac8f07091403252717e70e4058d05b80 100644 (file)
@@ -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);
+       }
 }
 
 ///////////////////////////////////////////////////////////////////////////////