From c9c2b91f7f28190a0655e3e3cdc72b9c246ece08 Mon Sep 17 00:00:00 2001 From: Max Goldman Date: Fri, 11 Sep 2020 15:01:56 -0400 Subject: [PATCH] Can mark handouts as un-indexed --- server/structure.php | 4 ++-- web/handout/handout-page.js | 4 ++++ web/handout/handout-render.js | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/structure.php b/server/structure.php index 6edcb64..99be46f 100644 --- a/server/structure.php +++ b/server/structure.php @@ -16,7 +16,7 @@ function parse($json) { function incl($config) { global $HANDOUT_TOC_KINDS; - return in_array($config->kind, $HANDOUT_TOC_KINDS); + return in_array($config->kind, $HANDOUT_TOC_KINDS) && ! property_exists($config, 'noindex'); } function entry($config) { @@ -29,5 +29,5 @@ function entry($config) { header('Content-Type: application/json'); $configs = array_map(function($name) { return substr($name, 0, -5); }, glob('data/*.json')); natsort($configs); -print json_encode(array_map(entry, array_filter(array_map(parse, array_values($configs)), incl))); +print json_encode(array_map(entry, array_values(array_filter(array_map(parse, array_values($configs)), incl)))); ?> diff --git a/web/handout/handout-page.js b/web/handout/handout-page.js index eb1c81f..6484ef8 100644 --- a/web/handout/handout-page.js +++ b/web/handout/handout-page.js @@ -55,8 +55,12 @@ HANDOUT_SCRIPTDIR = document.querySelector('script[src*=handout-page]').getAttri // when all scripts are loaded, render and run if ( ! scripts) { renderPage(); + var data = document.querySelector('script[src*=handout-page]').dataset; $('script[src*=handout-page], script[src*=render]').remove(); require('./handout-run.js').done(function(event) { + Object.entries(data).forEach(function(kv) { + event.target.dataset[kv[0]] = kv[1]; + }); event.target.setAttribute('data-handx-url', HANDOUT_HANDX); }); return; diff --git a/web/handout/handout-render.js b/web/handout/handout-render.js index ff4f546..fd8e982 100644 --- a/web/handout/handout-render.js +++ b/web/handout/handout-render.js @@ -489,6 +489,7 @@ function handoutDeliveryCallback() { part: part || null, structure: window.handoutStructure, exercises: window.handoutExercises, + noindex: document.querySelector('script[data-handx-noindex]') ? true : undefined, }); $('.exercise-panel').attr('data-ex-remote', HANDOUT_HANDX + 'submit.php')