Commits

Shlomi Fish committed 961f927

Output the nav-data as JSON.

Now comes the hard part of populating the navigation menu.

  • Participants
  • Parent commits 938b983
  • Branches convert-from-jquery-treeview-to-jqtree-plugin

Comments (0)

Files changed (4)

 
 ALL_DEST_BASE = dest
 
+NAV_DATA_DEP = lib/MyNavData.pm
+NAV_DATA_AS_JSON_BIN = bin/nav-data-as-json
 
-DOCS_COMMON_DEPS = template.wml lib/MyNavData.pm
+DOCS_COMMON_DEPS = template.wml $(NAV_DATA_DEP)
 
-all: make-dirs docbook_targets fortunes-target latemp_targets css_targets sitemap_targets copy_fortunes site-source-install presentations_targets lc_pres_targets art_slogans_targets graham_func_pres_targets mojo_pres hhgg_convert lib/MathJax/README.md mathjax_dest plaintext_scripts_with_offending_extensions svg_nav_images
+all: make-dirs docbook_targets fortunes-target latemp_targets css_targets sitemap_targets copy_fortunes site-source-install presentations_targets lc_pres_targets art_slogans_targets graham_func_pres_targets mojo_pres hhgg_convert lib/MathJax/README.md mathjax_dest plaintext_scripts_with_offending_extensions svg_nav_images generate_nav_data_as_json
 
 include lib/make/gmsl/gmsl
 
 
 $(SVG_NAV_IMAGES): lib/images/navigation/section/sect-nav-arrows.pl
 	perl $<
+
+NAV_DATA_AS_JSON = $(T2_DEST)/_data/nav.json
+
+generate_nav_data_as_json: $(NAV_DATA_AS_JSON)
+
+$(NAV_DATA_AS_JSON): $(NAV_DATA_DEP) $(NAV_DATA_AS_JSON_BIN)
+	./$(NAV_DATA_AS_JSON_BIN) -o $@
+
+generate_nav_data_as_json:
+

bin/nav-data-as-json

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib './lib';
+
+use Getopt::Long qw(GetOptions);
+
+use IO::All;
+
+use MyNavData;
+
+my $output_fn;
+
+GetOptions(
+    'output|o=s' => \$output_fn,
+)
+or die "Wrong options - $!";
+
+io->file($output_fn)->println(
+    MyNavData->output_fully_expanded_as_json()
+);

common/_data/PLACEHOLDER

Empty file added.
 
 use utf8;
 
+use JSON qw(encode_json);
+
 use Shlomif::Homepage::SectionMenu;
 
 my $hosts =
     );
 }
 
+sub output_fully_expanded_as_json
+{
+    my $class = shift;
+
+    my %params =
+    $class->generic_get_params(
+        {
+            fully_expanded => 1,
+        },
+    );
+
+    return encode_json($params{tree_contents});
+}
+
 1;