From 8adcc18d221c432de3470b4d28122728c5cd6ac8 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Mon, 3 Dec 2018 07:54:10 -0800 Subject: [PATCH 1/8] read external menuItem file --- menu-files/js/iiab-menu.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/menu-files/js/iiab-menu.js b/menu-files/js/iiab-menu.js index ea29ad1..80c3bd1 100644 --- a/menu-files/js/iiab-menu.js +++ b/menu-files/js/iiab-menu.js @@ -29,6 +29,7 @@ var apkBaseUrl = "/content/apk/"; var menuUrl = '/iiab-menu/menu-files/'; var configJson = '/iiab-menu/config.json'; var defUrl = menuUrl + 'menu-defs/'; +var menuItemFile = './menuitems.json'; var imageUrl = menuUrl + 'images/'; var menuServicesUrl = menuUrl + 'services/'; var iiabMeterUrl = "/iiab_meter.php" @@ -44,6 +45,7 @@ var mobilePortraitSize = baseFontSize + "px"; var mobileLscapeSize = baseFontSize / 2 + "px"; var menuHtml = ""; var menuDefs = {}; +var menuItems = {}; var zimVersions = {}; var scaffold = $.Deferred(); @@ -72,6 +74,32 @@ var getZimVersions = $.getJSON(zimVersionIdx) zimVersions = data;}) .fail(jsonErrhandler); +// Get the list of menuItems +$.ajax({ + type: 'GET', + async: false, + url: menuItemFile, + dataType: 'text' + }) +.done(function( data ) { + var html = ''; + var lines = String(data); + lines = lines.split("\n"); + cleaner = ''; + for (var i = 0, len = lines.length; i < len; i++) { + line = lines[i].trim(); + var n = line.search('//'); + if (n == 0) {continue;} + n = line.search('menuItems'); + if (n != -1) {cleaner += '[';continue;} + n = line.search(';'); + if (n != -1) {cleaner += ']';continue;} + cleaner += line; + } + //alert(cleaner); + menuItems = JSON.parse(cleaner); +}); + // This is the main processing if (dynamicHtml){ //$.when(scaffold, getZimVersions, getConfigJson).then(procMenu); From 8fcf339352e50cd8aea15e3c7d172eef67137f84 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Mon, 3 Dec 2018 08:10:17 -0800 Subject: [PATCH 2/8] put menuitems.json along with index.html in home to permit site specific menus --- cp-menus | 5 ++ samples/menuitems.json | 103 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 samples/menuitems.json diff --git a/cp-menus b/cp-menus index 94a7466..25b036c 100755 --- a/cp-menus +++ b/cp-menus @@ -49,6 +49,11 @@ if [ ! -e $WWWROOT/home/index.html ]; then cp samples/sampler.html $WWWROOT/home/index.html fi +# copy sample menuIndex file if none exists in home +if [ ! -e $WWWROOT/home/menuitems.json ]; then + cp samples/menuitem.json $WWWROOT/home/menuitem.json +fi + # restore modified files from local cp -rf $MENUDIR/local/* $MENUDIR/menu-files diff --git a/samples/menuitems.json b/samples/menuitems.json new file mode 100644 index 0000000..45cb3ea --- /dev/null +++ b/samples/menuitems.json @@ -0,0 +1,103 @@ + menuItems = [ + "en-usb", + //"ar-kaos", + //"ar-tabshoura_kg", + //"ar-wikibooks_ar_all", + //"ar-wikipedia_ar_all", + //"ar-wikipedia_ar_medicine", + //"ar-wikiquote_ar_all", + //"ar-wiktionary_ar_all", + //"en-afristory-za", + //"en-afristory", + //"en-asst_medical", + //"en-ck12", + //"en-ebooks", + //"en-edison", + //"en-elgg", + //"en-fairshake", + //"en-GCF2015", + //"en-gutenberg_en_all", + //"en-healthphone", + //"en-hesperian_health", + //"en-iicba", + //"en-infonet", + //"en-kalite-ess", + //"en-kalite-india", + "en-kalite", + "en-kalite-sample-videos", + //"en-kalite_health", + //"en-law_library", + //"en-local_content", + //"en-math_expression", + //"en-medline_plus-static", + //"en-medline_plus", + "en-moodle", + //"en-musictheory", + "en-nextcloud", + //"en-olpc", + //"en-osm", + //"en-owncloud", + //"en-oya", + "en-phet_html", + "en-ray_charles_sample", + "fr-tedxlausannechange-2013_fr_all", + //"en-practical_action", + //"en-radiolab", + //"en-rpi_guide", + //"en-saylor", + //"en-scale-of-universe", + //"en-scratch", + "en-sugarizer", + //"en-tabshoura_kg", + //"en-tedmed_en_all", + //"en-ted_en_science", + //"en-test_zim", + //"en-understanding_algebra", + //"en-wikibooks_en_all", + //"en-wikipedia_en_all", + //"en-wikipedia_en_for_schools", + //"en-wikipedia_en_medicine", + //"en-wikipedia_en_simple_all", + //"en-wikipedia_en_wp1-08", + //"en-wikipedia_kn_medicine", + //"en-wikisource_en_all", + //"en-wikispecies_en_all", + //"en-wikiversity_en_all", + //"en-wikivoyage_en_all", + //"en-wiktionary_en_all", + //"en-wiktionary_en_simple_all", + "en-worldmap_8", + "en-enjoy", + //"es-ap_didact", + //"es-bibliofilo", + //"es-biblioteca", + //"es-blockly_games", + //"es-cnbguatemala", + //"es-ebooks", + //"es-educalab", + //"es-GCF2015", + //"es-guatemala", + //"es-guias", + //"es-hesperian_health", + //"es-medline_plus", + //"es-soluciones", + //"es-vedoque", + //"es-wikibooks_es_all", + //"es-wikihow", + //"es-wikipedia_es_all", + //"es-wikisource_es_all", + //"es-wikiversity_es_all", + //"es-wikivoyage_es_all", + //"es-wiktionary_es_all", + //"fr-ebooksgratuits", + //"fr-haitifutur", + //"fr-phet-haiti", + //"fr-wikipedia_fr_all", + //"hi-healthphone", + //"kn-healthphone", + //"kn-wikipedia_kn_all", + //"kn-wikipedia_kn_medicine", + //"kn-wikisource_kn_all", + //"kn-wiktionary_kn_all", + "en-credits" + ]; From 2c17ba997cd3a17b266bd8d9f9ab3dd0e9186de7 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Tue, 4 Dec 2018 07:06:52 -0800 Subject: [PATCH 3/8] update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e168545..5379193 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ This repo contains a menuing system for Internet in a Box ## IIAB Menu -iiab-menu is a menuing system that uses json files for each menu item, which are loaded by and rendered in javascript, -based on an html file that contains an array of the menu items to load. This file will usually be named index.html, but can have -any name. +iiab-menu is a menuing system that uses json files for each menu item, which are loaded by and rendered in javascript. +A menu is defined by a folder, which contains a two files: a copy of "index.html", and a json file, which contains the list of the menu items to load. This file will usually be named index.html, but can have +any name, as long as it is accompanied in a folder by a single *.json file. -The menu files are nominally in /library/www/html/iiab-menu, but the index file can be anywhere as the path to supporting files is absolute. -Several sample files are included in the samples directory. +The menu files are nominally in /library/www/html/iiab-menu, but the index and json files can be anywhere as the path to supporting files is absolute. +Several sample *.json files are included in the samples directory. A menu item, a set of links to one piece of content such as the wikipedia, is defined by a 'menu-def' json file. There is a sample in the samples directory. There may also be an optional html file that contains free form html to be appended to the menu item entry. From 40fde3b49d983bf2825424546395fcfef3f1ec17 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Tue, 4 Dec 2018 07:15:02 -0800 Subject: [PATCH 4/8] one size now fits all--index.html --- cp-menus | 2 +- samples/index.html | 103 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 samples/index.html diff --git a/cp-menus b/cp-menus index 94a7466..a712b7f 100755 --- a/cp-menus +++ b/cp-menus @@ -46,7 +46,7 @@ fi # copy sample index file if none exists in home if [ ! -e $WWWROOT/home/index.html ]; then - cp samples/sampler.html $WWWROOT/home/index.html + cp samples/index.html $WWWROOT/home/index.html fi # restore modified files from local diff --git a/samples/index.html b/samples/index.html new file mode 100644 index 0000000..c209591 --- /dev/null +++ b/samples/index.html @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + + + + + + + From d5cf50d76c24dfeb74c76c492bc2ba6a4032ffa3 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Tue, 4 Dec 2018 07:37:35 -0800 Subject: [PATCH 5/8] cannot find javascript glob function to use *.json as menuitems.json --- README.md | 4 ++-- cp-menus | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5379193..0974103 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ This repo contains a menuing system for Internet in a Box ## IIAB Menu iiab-menu is a menuing system that uses json files for each menu item, which are loaded by and rendered in javascript. -A menu is defined by a folder, which contains a two files: a copy of "index.html", and a json file, which contains the list of the menu items to load. This file will usually be named index.html, but can have -any name, as long as it is accompanied in a folder by a single *.json file. +A menu is defined by a folder, which contains a two files: a copy of "index.html", and a "menuitems.json" file, which contains the list of the menu items to load. The html file will usually be named "index.html", but can have +any name, as long as it is accompanied in a folder by a single "menuitems.json" file. The menu files are nominally in /library/www/html/iiab-menu, but the index and json files can be anywhere as the path to supporting files is absolute. Several sample *.json files are included in the samples directory. diff --git a/cp-menus b/cp-menus index a9f28b6..5b22886 100755 --- a/cp-menus +++ b/cp-menus @@ -51,7 +51,7 @@ fi # copy sample menuIndex file if none exists in home if [ ! -e $WWWROOT/home/menuitems.json ]; then - cp samples/menuitem.json $WWWROOT/home/menuitem.json + cp samples/menuitems.json $WWWROOT/home/menuitems.json fi # restore modified files from local From 6ef37aa9331c7f6f39c94d46dc051c75c68f09ed Mon Sep 17 00:00:00 2001 From: George Hunt Date: Tue, 4 Dec 2018 08:43:48 -0800 Subject: [PATCH 6/8] remove mention of glob .json --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0974103..8f5b7a5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repo contains a menuing system for Internet in a Box iiab-menu is a menuing system that uses json files for each menu item, which are loaded by and rendered in javascript. A menu is defined by a folder, which contains a two files: a copy of "index.html", and a "menuitems.json" file, which contains the list of the menu items to load. The html file will usually be named "index.html", but can have -any name, as long as it is accompanied in a folder by a single "menuitems.json" file. +any name, as long as it is accompanied in a folder by a "menuitems.json" file. The menu files are nominally in /library/www/html/iiab-menu, but the index and json files can be anywhere as the path to supporting files is absolute. Several sample *.json files are included in the samples directory. From dd0223cb18a4b23f203503f1b5e9e520b19599f9 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Tue, 4 Dec 2018 08:45:27 -0800 Subject: [PATCH 7/8] remove tech talk --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f5b7a5..b6f86bc 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A menu is defined by a folder, which contains a two files: a copy of "index.html any name, as long as it is accompanied in a folder by a "menuitems.json" file. The menu files are nominally in /library/www/html/iiab-menu, but the index and json files can be anywhere as the path to supporting files is absolute. -Several sample *.json files are included in the samples directory. +Several sample json files are included in the samples directory. A menu item, a set of links to one piece of content such as the wikipedia, is defined by a 'menu-def' json file. There is a sample in the samples directory. There may also be an optional html file that contains free form html to be appended to the menu item entry. From 128f6e28ce07755bdcc886b5621e1490b61ab3c7 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Tue, 4 Dec 2018 20:39:04 +0000 Subject: [PATCH 8/8] extra