DecodeMarketing commited on
Commit
7fbdd56
·
unverified ·
1 Parent(s): 1684dc3

fix: pick the master file, keep names inside the area, Henkel terms (#8)

Browse files

JM's first test (2026-11-30): picking a folder left users without
guidance, so the user now picks the master file itself; the window
opens where the last master was.

Names could stick out of the network area (Henkel 55, DECODE 21 of 86
slides) and ran into the legend and the subline; the layout now keeps
every name inside. The Henkel legend sits where JM placed it, the
network uses the room above it, and the Henkel legend says
"psychological", taken from the reporting tool's Henkel terms.

build_network.py CHANGED
@@ -859,7 +859,7 @@ document.addEventListener('DOMContentLoaded', function() {{
859
  </div>
860
  </div>
861
 
862
- <input type="file" id="pptxMasterPick" accept=".pptx" multiple style="display:none">
863
  <div id="pptxDialog"></div>
864
  <script>
865
  __PPTX_EXPORT_JS__
 
859
  </div>
860
  </div>
861
 
862
+ <input type="file" id="pptxMasterPick" accept=".pptx" style="display:none">
863
  <div id="pptxDialog"></div>
864
  <script>
865
  __PPTX_EXPORT_JS__
pptx_export.js CHANGED
@@ -317,6 +317,7 @@
317
  }
318
  placeLabels(nodes, cx, cy);
319
  chooseSides(nodes, edges, by, A, cx, cy);
 
320
  return defects(nodes, edges, by);
321
  }
322
 
@@ -326,7 +327,7 @@
326
  function sideCost(n, nodes, edges, by, A) {
327
  var bx = bbox(n), cost = 0;
328
  var lab = [n.lx, n.ly, n.lx + n.lw, n.ly + n.lh];
329
- if (bx[0] < A.x - 0.01 || bx[2] > A.x + A.w + 0.01 || bx[1] < A.y - 0.01 || bx[3] > A.y + A.h + 0.01) cost += 5;
330
  nodes.forEach(function (o) {
331
  if (o === n) return;
332
  var bo = bbox(o);
@@ -355,6 +356,17 @@
355
  nodes.forEach(function (n) { n.fixedSide = null; });
356
  }
357
 
 
 
 
 
 
 
 
 
 
 
 
358
  /* Does the segment a-b cross the rectangle r = [x0, y0, x1, y1]? (Liang-Barsky) */
359
  function segHitsRect(ax, ay, bx, by_, r) {
360
  var t0 = 0, t1 = 1, dx = bx - ax, dy = by_ - ay;
@@ -745,9 +757,12 @@
745
  });
746
  }
747
 
748
- function legendRuns(showIdx) {
749
- return [{ text: '● ', color: COLORS.reward }, { text: 'emotional ', color: COLORS.legend },
750
- { text: '● ', color: COLORS.nonreward }, { text: 'functional ', color: COLORS.legend },
 
 
 
751
  { text: (showIdx ? 'dot size & (…) = category index' : 'dot size = category index') +
752
  ' · line thickness = strength of connection', color: COLORS.legend }];
753
  }
 
317
  }
318
  placeLabels(nodes, cx, cy);
319
  chooseSides(nodes, edges, by, A, cx, cy);
320
+ keepInside(nodes, A);
321
  return defects(nodes, edges, by);
322
  }
323
 
 
327
  function sideCost(n, nodes, edges, by, A) {
328
  var bx = bbox(n), cost = 0;
329
  var lab = [n.lx, n.ly, n.lx + n.lw, n.ly + n.lh];
330
+ if (bx[0] < A.x - 0.01 || bx[2] > A.x + A.w + 0.01 || bx[1] < A.y - 0.01 || bx[3] > A.y + A.h + 0.01) cost += 50; // a name never leaves the area
331
  nodes.forEach(function (o) {
332
  if (o === n) return;
333
  var bo = bbox(o);
 
356
  nodes.forEach(function (n) { n.fixedSide = null; });
357
  }
358
 
359
+ /* Last step: a dot whose name still sticks out of the area moves in, name
360
+ and all (JM 2026-11-30: names ran into the legend and the subline). */
361
+ function keepInside(nodes, A) {
362
+ nodes.forEach(function (n) {
363
+ var b = bbox(n), dx = 0, dy = 0;
364
+ if (b[0] < A.x) dx = A.x - b[0]; else if (b[2] > A.x + A.w) dx = A.x + A.w - b[2];
365
+ if (b[1] < A.y) dy = A.y - b[1]; else if (b[3] > A.y + A.h) dy = A.y + A.h - b[3];
366
+ n.x += dx; n.lx += dx; n.y += dy; n.ly += dy;
367
+ });
368
+ }
369
+
370
  /* Does the segment a-b cross the rectangle r = [x0, y0, x1, y1]? (Liang-Barsky) */
371
  function segHitsRect(ax, ay, bx, by_, r) {
372
  var t0 = 0, t1 = 1, dx = bx - ax, dy = by_ - ay;
 
757
  });
758
  }
759
 
760
+ /* meta: the master's net.meta - term_emotional / term_functional are the
761
+ client's own words from the reporting tool (Henkel: psychological). */
762
+ function legendRuns(showIdx, meta) {
763
+ var emo = (meta && meta.term_emotional) || 'emotional', fun = (meta && meta.term_functional) || 'functional';
764
+ return [{ text: '● ', color: COLORS.reward }, { text: emo + ' ', color: COLORS.legend },
765
+ { text: '● ', color: COLORS.nonreward }, { text: fun + ' ', color: COLORS.legend },
766
  { text: (showIdx ? 'dot size & (…) = category index' : 'dot size = category index') +
767
  ' · line thickness = strength of connection', color: COLORS.legend }];
768
  }
pptx_export_ui.js CHANGED
@@ -1,16 +1,15 @@
1
- /* The PowerPoint button of the generated HTML: find the network masters,
2
- confirm master / sample / flag / footer, get one slide per attribute
3
- (pptx_export.js).
4
  The masters live in one fixed folder (auto report\Input\network masters).
5
- A web page cannot open a folder on its own, so the user picks it ONCE; the
6
- browser remembers it (Edge/Chrome) and only asks to allow access again.
7
- Browsers without that ability (e.g. Firefox) pick the master file each time.
8
  Uses the page's own data and rules: attrMeta, buildNetwork, getMaxL1,
9
  isReward, SHOW_CAT_IDX, MIN_CORR, MAX_CORR, PROJECT, CHART_TITLE. */
10
  (function () {
11
  'use strict';
12
  var FOLDER = 'auto report\\Input\\network masters';
13
- var masters = []; // [{file, frame, bytes, M}] - what was found
14
 
15
  function $(id) { return document.getElementById(id); }
16
  function escH(s) { return String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); }
@@ -46,129 +45,83 @@
46
  : [parts, year].filter(Boolean).join(' | ');
47
  }
48
 
49
- // ------------------------------------------------ the remembered folder
50
  function db() {
51
  return new Promise(function (ok, no) {
52
- var r = indexedDB.open('network-pptx-export', 1);
53
- r.onupgradeneeded = function () { r.result.createObjectStore('folder'); };
54
  r.onsuccess = function () { ok(r.result); };
55
  r.onerror = function () { no(r.error); };
56
  });
57
  }
58
- function remembered() {
59
  return db().then(function (d) {
60
  return new Promise(function (ok) {
61
- var q = d.transaction('folder').objectStore('folder').get('masters');
62
  q.onsuccess = function () { ok(q.result || null); };
63
  q.onerror = function () { ok(null); };
64
  });
65
  }).catch(function () { return null; });
66
  }
67
- function remember(handle) {
68
- return db().then(function (d) {
69
- var t = d.transaction('folder', 'readwrite');
70
- if (handle) t.objectStore('folder').put(handle, 'masters'); else t.objectStore('folder').delete('masters');
71
- }).catch(function () {});
72
- }
73
-
74
- function allowed(h) {
75
- if (!h) return Promise.resolve(null);
76
- return h.queryPermission({ mode: 'read' }).then(function (p) {
77
- return p === 'granted' ? p : h.requestPermission({ mode: 'read' });
78
- }).then(function (p) { return p === 'granted' ? h : null; }).catch(function () { return null; });
79
  }
80
 
81
- function pickFolder() {
82
- return window.showDirectoryPicker({ id: 'network-masters', mode: 'read' }).then(function (h) { remember(h); return h; });
83
- }
84
 
85
- function mastersIn(h) {
86
- var it = h.values(), found = [];
87
- function next() {
88
- return it.next().then(function (r) {
89
- if (r.done) return found;
90
- if (r.value.kind === 'file' && /^Network master .+\.pptx$/i.test(r.value.name)) found.push(r.value);
91
- return next();
92
- });
93
- }
94
- return next().then(function (entries) {
95
- return Promise.all(entries.map(function (e) { return e.getFile(); }));
96
  });
97
  }
98
 
99
- function load(files) {
100
- return Promise.all(files.map(function (f) {
101
- return f.arrayBuffer().then(function (buf) {
102
- return NetPptx.openMaster(JSZip, buf, { DOMParser: DOMParser, XMLSerializer: XMLSerializer }).then(function (M) {
103
- return { file: f.name, frame: M.meta.frame, bytes: buf, M: M };
104
- });
105
- }).catch(function () { return null; }); // not a network master: left out
106
- })).then(function (list) {
107
- return list.filter(Boolean).sort(function (a, b) {
108
- return (a.frame === 'DECODE' ? '' : a.frame).localeCompare(b.frame === 'DECODE' ? '' : b.frame);
109
  });
 
 
110
  });
111
  }
112
 
113
- function opened(list, where) {
114
- if (!list.length) {
115
- remember(null);
116
- return alert('No network master found' + (where ? ' in "' + where + '"' : '') + '.\n' +
117
- 'Please click PowerPoint again and pick the folder "' + FOLDER + '".');
118
- }
119
- masters = list;
120
- showDialog(defaultMaster());
121
- }
122
-
123
- // the client's own master if there is one (PROJECT.client), else DECODE
124
- function defaultMaster() {
125
- var c = String(PROJECT.client || '').toLowerCase(), i;
126
- for (i = 0; i < masters.length; i++) if (c && c.indexOf(masters[i].frame.toLowerCase()) >= 0) return i;
127
- for (i = 0; i < masters.length; i++) if (masters[i].frame === 'DECODE') return i;
128
- return 0;
129
- }
130
-
131
- window.startPptxExport = function (otherFolder) {
132
- if (!window.showDirectoryPicker) { // no folder access in this browser: pick the file(s)
133
  var input = $('pptxMasterPick');
134
  input.value = '';
135
  return input.click();
136
  }
137
- var where = '';
138
- (otherFolder ? Promise.resolve(null) : remembered().then(allowed)).then(function (h) {
139
- return h || pickFolder();
140
- }).then(function (h) {
141
- where = h.name;
142
- return mastersIn(h);
143
- }).then(load).then(function (list) { opened(list, where); }).catch(function (err) {
144
- if (err && err.name === 'AbortError') return; // the user closed the folder window
145
- alert('The network masters could not be read: ' + (err.message || err));
146
  });
147
  };
148
 
149
  function onPicked(ev) {
150
- var files = Array.prototype.slice.call(ev.target.files || []);
151
- if (files.length) load(files).then(function (list) { opened(list, ''); });
152
  }
153
 
154
  // ------------------------------------------------ the dialog
155
- function showDialog(mi, keep) {
156
- var m = masters[mi], M = m.M;
157
  var attrs = listedAttributes(), maxL1 = getMaxL1();
158
  var flagOpts = '<option value="">- no flag -</option>' + M.flags.slice().sort(function (a, b) { return a.name.localeCompare(b.name); })
159
  .map(function (f) { return '<option value="' + f.code + '">' + escH(f.name) + ' (' + f.code + ')</option>'; }).join('');
160
  var fontOk = !document.fonts || document.fonts.check('12pt "' + M.meta.font + '"');
161
- var masterOpts = masters.map(function (x, i) {
162
- return '<option value="' + i + '"' + (i === mi ? ' selected' : '') + '>' + escH(label(x.frame)) + '</option>';
163
- }).join('');
164
  var box = $('pptxDialog');
165
  box.innerHTML =
166
  '<div class="xp">' +
167
- '<h2>PowerPoint</h2>' +
168
- '<p class="sub">' + escH(m.file) + (window.showDirectoryPicker ? ' &middot; <a href="#" id="xpFolder">other folder</a>' : '') + '</p>' +
169
- '<div class="row"><b>' + attrs.length + ' attributes</b> as listed on the left; the network shows ' +
170
  '<b>' + maxL1 + ' connections</b> each (the Connections setting).</div>' +
171
- '<label>Master</label><select id="xpMaster">' + masterOpts + '</select>' +
172
  '<label>Sample</label><input id="xpSample" value="Total">' +
173
  '<label>Country flag</label><select id="xpFlag">' + flagOpts + '</select>' +
174
  '<label>Footer</label><input id="xpFooter" value="' + escH(footerDefault(M.meta.frame)) + '">' +
@@ -179,11 +132,6 @@
179
  '</div>';
180
  box.style.display = 'flex';
181
  $('xpFlag').value = NetPptx.suggestFlag(M, PROJECT.country);
182
- if (keep) { $('xpSample').value = keep.sample; $('xpFlag').value = keep.flag; } // switching the master keeps these
183
- $('xpMaster').onchange = function () {
184
- showDialog(+this.value, { sample: $('xpSample').value, flag: $('xpFlag').value });
185
- };
186
- if ($('xpFolder')) $('xpFolder').onclick = function (ev) { ev.preventDefault(); closeDialog(); window.startPptxExport(true); };
187
  $('xpCancel').onclick = closeDialog;
188
  $('xpGo').onclick = function () { run(m, attrs, maxL1); };
189
  if (!attrs.length) { $('xpGo').disabled = true; $('xpStatus').textContent = 'No attribute is listed on the left (check the filter).'; }
@@ -194,8 +142,8 @@
194
  function run(m, attrs, maxL1) {
195
  var M = m.M;
196
  var settings = { sample: $('xpSample').value.trim() || 'Total', flag: $('xpFlag').value,
197
- footer: $('xpFooter').value.trim(), legendRuns: NetPptx.legendRuns(SHOW_CAT_IDX) };
198
- $('xpGo').disabled = true; $('xpCancel').disabled = true; $('xpMaster').disabled = true;
199
  var status = $('xpStatus'), measure = measurer(M.meta.font), sizes = NetPptx.sizesOf(M);
200
  var nets = [], small = [], k = 0;
201
  function step() {
 
1
+ /* The PowerPoint button of the generated HTML: the user picks a network
2
+ master file, confirms sample / flag / footer and gets one slide per
3
+ attribute (pptx_export.js).
4
  The masters live in one fixed folder (auto report\Input\network masters).
5
+ The user picks the master FILE (JM, 2026-11-30: picking a document is
6
+ clearer than picking a folder); Edge/Chrome open the file window in the
7
+ folder of the last master picked.
8
  Uses the page's own data and rules: attrMeta, buildNetwork, getMaxL1,
9
  isReward, SHOW_CAT_IDX, MIN_CORR, MAX_CORR, PROJECT, CHART_TITLE. */
10
  (function () {
11
  'use strict';
12
  var FOLDER = 'auto report\\Input\\network masters';
 
13
 
14
  function $(id) { return document.getElementById(id); }
15
  function escH(s) { return String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); }
 
45
  : [parts, year].filter(Boolean).join(' | ');
46
  }
47
 
48
+ // ------------------------------------------------ the last master picked (its folder opens next time)
49
  function db() {
50
  return new Promise(function (ok, no) {
51
+ var r = indexedDB.open('network-pptx-export', 2);
52
+ r.onupgradeneeded = function () { if (!r.result.objectStoreNames.contains('last')) r.result.createObjectStore('last'); };
53
  r.onsuccess = function () { ok(r.result); };
54
  r.onerror = function () { no(r.error); };
55
  });
56
  }
57
+ function lastPicked() {
58
  return db().then(function (d) {
59
  return new Promise(function (ok) {
60
+ var q = d.transaction('last').objectStore('last').get('master');
61
  q.onsuccess = function () { ok(q.result || null); };
62
  q.onerror = function () { ok(null); };
63
  });
64
  }).catch(function () { return null; });
65
  }
66
+ function rememberPicked(handle) {
67
+ return db().then(function (d) { d.transaction('last', 'readwrite').objectStore('last').put(handle, 'master'); }).catch(function () {});
 
 
 
 
 
 
 
 
 
 
68
  }
69
 
70
+ var PPTX = { description: 'Network master', accept: { 'application/vnd.openxmlformats-officedocument.presentationml.presentation': ['.pptx'] } };
 
 
71
 
72
+ function pickFile(start) {
73
+ var o = { id: 'network-masters', types: [PPTX], multiple: false };
74
+ if (start) o.startIn = start;
75
+ return window.showOpenFilePicker(o).catch(function (err) {
76
+ if (start && err && err.name !== 'AbortError') return pickFile(null); // the remembered file is gone: plain window
77
+ throw err;
 
 
 
 
 
78
  });
79
  }
80
 
81
+ function open(file) {
82
+ return file.arrayBuffer().then(function (buf) {
83
+ return NetPptx.openMaster(JSZip, buf, { DOMParser: DOMParser, XMLSerializer: XMLSerializer }).then(function (M) {
84
+ showDialog({ file: file.name, frame: M.meta.frame, bytes: buf, M: M });
 
 
 
 
 
 
85
  });
86
+ }).catch(function (err) {
87
+ alert((err.message || String(err)) + '\n\nThe network masters are in "' + FOLDER + '".');
88
  });
89
  }
90
 
91
+ window.startPptxExport = function () {
92
+ if (!window.showOpenFilePicker) { // other browsers: the plain file window
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  var input = $('pptxMasterPick');
94
  input.value = '';
95
  return input.click();
96
  }
97
+ lastPicked().then(pickFile).then(function (handles) {
98
+ rememberPicked(handles[0]);
99
+ return handles[0].getFile();
100
+ }).then(open).catch(function (err) {
101
+ if (err && err.name === 'AbortError') return; // the user closed the file window
102
+ alert('The master could not be read: ' + (err.message || err));
 
 
 
103
  });
104
  };
105
 
106
  function onPicked(ev) {
107
+ var file = ev.target.files && ev.target.files[0];
108
+ if (file) open(file);
109
  }
110
 
111
  // ------------------------------------------------ the dialog
112
+ function showDialog(m) {
113
+ var M = m.M;
114
  var attrs = listedAttributes(), maxL1 = getMaxL1();
115
  var flagOpts = '<option value="">- no flag -</option>' + M.flags.slice().sort(function (a, b) { return a.name.localeCompare(b.name); })
116
  .map(function (f) { return '<option value="' + f.code + '">' + escH(f.name) + ' (' + f.code + ')</option>'; }).join('');
117
  var fontOk = !document.fonts || document.fonts.check('12pt "' + M.meta.font + '"');
 
 
 
118
  var box = $('pptxDialog');
119
  box.innerHTML =
120
  '<div class="xp">' +
121
+ '<h2>PowerPoint - ' + escH(label(m.frame)) + ' master</h2>' +
122
+ '<p class="sub">' + escH(m.file) + '</p>' +
123
+ '<div class="row"><b>' + attrs.length + ' slides</b>, one per attribute as listed on the left, ' +
124
  '<b>' + maxL1 + ' connections</b> each (the Connections setting).</div>' +
 
125
  '<label>Sample</label><input id="xpSample" value="Total">' +
126
  '<label>Country flag</label><select id="xpFlag">' + flagOpts + '</select>' +
127
  '<label>Footer</label><input id="xpFooter" value="' + escH(footerDefault(M.meta.frame)) + '">' +
 
132
  '</div>';
133
  box.style.display = 'flex';
134
  $('xpFlag').value = NetPptx.suggestFlag(M, PROJECT.country);
 
 
 
 
 
135
  $('xpCancel').onclick = closeDialog;
136
  $('xpGo').onclick = function () { run(m, attrs, maxL1); };
137
  if (!attrs.length) { $('xpGo').disabled = true; $('xpStatus').textContent = 'No attribute is listed on the left (check the filter).'; }
 
142
  function run(m, attrs, maxL1) {
143
  var M = m.M;
144
  var settings = { sample: $('xpSample').value.trim() || 'Total', flag: $('xpFlag').value,
145
+ footer: $('xpFooter').value.trim(), legendRuns: NetPptx.legendRuns(SHOW_CAT_IDX, M.meta) };
146
+ $('xpGo').disabled = true; $('xpCancel').disabled = true;
147
  var status = $('xpStatus'), measure = measurer(M.meta.font), sizes = NetPptx.sizesOf(M);
148
  var nets = [], small = [], k = 0;
149
  function step() {
scripts/make_network_masters.py CHANGED
@@ -27,6 +27,7 @@ and writes Input/network masters/Network master DECODE.pptx
27
  Input/network masters/Network master REWE.pptx
28
  """
29
  import io
 
30
  import re
31
  import sys
32
  from pathlib import Path
@@ -59,8 +60,13 @@ FRAMES = {
59
  "card": None, # Henkel: no card (JM, 2026-10-15)
60
  "area": "viz.card", # the network takes the card's region
61
  "legend": "viz.legend",
 
 
62
  "legend_pt": 7,
63
  "footnote": True, # the base goes in update_sample: "Base: ..."
 
 
 
64
  },
65
  "REWE": {
66
  "source": Path("clients/REWE/frame.pptx"),
@@ -138,6 +144,17 @@ def flags_from(deck_path):
138
  return sorted(out)
139
 
140
 
 
 
 
 
 
 
 
 
 
 
 
141
  def build(root, client, cfg, flags):
142
  prs = Presentation(root / cfg["source"])
143
  if len(prs.slides) != 1:
@@ -148,11 +165,15 @@ def build(root, client, cfg, flags):
148
  # regions read off the frame before anything is removed
149
  if cfg.get("area"):
150
  area = rect_of(by_name[cfg["area"]])
 
 
151
  else:
152
  x, y, w, h = cfg["card"]
153
  ix, iy = cfg["area_inset"]
154
  area = (x + ix, y + iy, w - 2 * ix, h - 2 * iy)
155
  legend = rect_of(by_name[cfg["legend"]]) if isinstance(cfg["legend"], str) else cfg["legend"]
 
 
156
  if cfg.get("legend_span"):
157
  sx, _, sw, _ = rect_of(by_name[cfg["legend_span"]])
158
  legend = (sx, legend[1], sw, legend[3])
@@ -202,6 +223,7 @@ def build(root, client, cfg, flags):
202
  "network-master": VERSION, "frame": client, "font": font,
203
  "legend_pt": cfg["legend_pt"], "footnote": "1" if cfg["footnote"] else "0",
204
  "slide_w": round(prs.slide_width / 12700, 2), "slide_h": round(prs.slide_height / 12700, 2),
 
205
  }
206
  invisible_box(slide, "net.meta", (0, prs.slide_height / 12700 + 20, 300, 60),
207
  "\n".join(f"{k}={v}" for k, v in meta.items()))
 
27
  Input/network masters/Network master REWE.pptx
28
  """
29
  import io
30
+ import json
31
  import re
32
  import sys
33
  from pathlib import Path
 
60
  "card": None, # Henkel: no card (JM, 2026-10-15)
61
  "area": "viz.card", # the network takes the card's region
62
  "legend": "viz.legend",
63
+ "legend_y": 352.2, # JM 2026-11-30: lower than the tool's, clear of the network
64
+ "area_bottom": 347.0, # the network may use the room down to just above that legend
65
  "legend_pt": 7,
66
  "footnote": True, # the base goes in update_sample: "Base: ..."
67
+ # legend words = the tool's Henkel terms ("Psychological Goals" -> "psychological";
68
+ # JM 2026-11-30: Henkel says psychological, never emotional)
69
+ "terms_from": Path("clients/Henkel/profile.json"),
70
  },
71
  "REWE": {
72
  "source": Path("clients/REWE/frame.pptx"),
 
144
  return sorted(out)
145
 
146
 
147
+ def legend_terms(root, cfg):
148
+ """The client's words for the two kinds of dot, from the reporting tool's
149
+ profile: first word of the English term, lower case ("Psychological
150
+ Goals" -> "psychological"). Without "terms_from" the export says
151
+ emotional / functional."""
152
+ if not cfg.get("terms_from"):
153
+ return {}
154
+ terms = json.loads((root / cfg["terms_from"]).read_text(encoding="utf-8"))["terms"]["EN"]
155
+ return {f"term_{k}": terms[k].split()[0].lower() for k in ("emotional", "functional")}
156
+
157
+
158
  def build(root, client, cfg, flags):
159
  prs = Presentation(root / cfg["source"])
160
  if len(prs.slides) != 1:
 
165
  # regions read off the frame before anything is removed
166
  if cfg.get("area"):
167
  area = rect_of(by_name[cfg["area"]])
168
+ if cfg.get("area_bottom"):
169
+ area = (area[0], area[1], area[2], cfg["area_bottom"] - area[1])
170
  else:
171
  x, y, w, h = cfg["card"]
172
  ix, iy = cfg["area_inset"]
173
  area = (x + ix, y + iy, w - 2 * ix, h - 2 * iy)
174
  legend = rect_of(by_name[cfg["legend"]]) if isinstance(cfg["legend"], str) else cfg["legend"]
175
+ if cfg.get("legend_y"):
176
+ legend = (legend[0], cfg["legend_y"], legend[2], legend[3])
177
  if cfg.get("legend_span"):
178
  sx, _, sw, _ = rect_of(by_name[cfg["legend_span"]])
179
  legend = (sx, legend[1], sw, legend[3])
 
223
  "network-master": VERSION, "frame": client, "font": font,
224
  "legend_pt": cfg["legend_pt"], "footnote": "1" if cfg["footnote"] else "0",
225
  "slide_w": round(prs.slide_width / 12700, 2), "slide_h": round(prs.slide_height / 12700, 2),
226
+ **legend_terms(root, cfg),
227
  }
228
  invisible_box(slide, "net.meta", (0, prs.slide_height / 12700 + 20, 300, 60),
229
  "\n".join(f"{k}={v}" for k, v in meta.items()))