diff --git a/README.md b/README.md index e168545..b6f86bc 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 "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 "menuitems.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. diff --git a/cp-menus b/cp-menus index 94a7466..5b22886 100755 --- a/cp-menus +++ b/cp-menus @@ -46,7 +46,12 @@ 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 + +# copy sample menuIndex file if none exists in home +if [ ! -e $WWWROOT/home/menuitems.json ]; then + cp samples/menuitems.json $WWWROOT/home/menuitems.json fi # restore modified files from local 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); diff --git a/samples/index.html b/samples/index.html new file mode 100644 index 0000000..c79b87b --- /dev/null +++ b/samples/index.html @@ -0,0 +1,102 @@ + + + + Internet in a Box - HOME + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + + + + + + + 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" + ];