Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acfca90836 | ||
|
|
7291ff48f7 | ||
|
|
826c471ed7 | ||
|
|
817fb743de |
+95
-4
@@ -3508,14 +3508,50 @@ function shareChoice() {
|
||||
};
|
||||
}
|
||||
|
||||
function shareBase() {
|
||||
/* This Mac on the church network. The operator page lives here and NOWHERE
|
||||
else: it returns 404 to anything arriving through a proxy, by design. */
|
||||
function lanBase() {
|
||||
const c = shareChoice();
|
||||
if (!c || c.none) return '';
|
||||
return 'http://' + c.addr.address + ':' + state.local.port;
|
||||
}
|
||||
|
||||
/*
|
||||
* WHAT THE CONGREGATION OPENS.
|
||||
*
|
||||
* A church that has put this on a domain has said so in the operator page's
|
||||
* Public address, and from that moment the LAN address is the wrong thing to
|
||||
* print: it is not what is on the poster, not what the QR should encode, and
|
||||
* not what someone off the building's wifi can reach. The app window went on
|
||||
* showing the IP anyway, because this half of it never read that setting --
|
||||
* the operator page honoured it and the main window did not, so the two
|
||||
* disagreed about the one fact they both exist to display.
|
||||
*/
|
||||
function publicBaseConfigured() {
|
||||
const u = opConfig && typeof opConfig.publicUrl === 'string' ? opConfig.publicUrl.trim() : '';
|
||||
return u ? u.replace(/\/+$/, '') : '';
|
||||
}
|
||||
|
||||
function shareBase() {
|
||||
return publicBaseConfigured() || lanBase();
|
||||
}
|
||||
|
||||
function renderQrWarning() {
|
||||
const el = $('qrWarn');
|
||||
/*
|
||||
* On a domain the warnings below are about an address nobody is being
|
||||
* given any more. Saying "Wi-Fi is down, phones cannot reach the code"
|
||||
* while the code points at a proxy would send the desk after the wrong
|
||||
* thing entirely.
|
||||
*/
|
||||
const pub = publicBaseConfigured();
|
||||
if (pub) {
|
||||
el.hidden = false;
|
||||
el.textContent = 'The code points at ' + pub + ', set as the public address. ' +
|
||||
'This Mac still has to be reachable from there; its own address is ' +
|
||||
(lanBase() || 'unavailable') + '.';
|
||||
return;
|
||||
}
|
||||
const c = shareChoice();
|
||||
if (!c) { el.hidden = true; return; }
|
||||
|
||||
@@ -3566,6 +3602,26 @@ function renderShare() {
|
||||
const list = state.local.addresses || [];
|
||||
const box = $('addrList');
|
||||
box.textContent = '';
|
||||
/*
|
||||
* WHICH INTERFACE THE QR USES IS A QUESTION ONLY A LAN SETUP HAS.
|
||||
*
|
||||
* These rows let the operator pick the address the code points at. Once a
|
||||
* public address is configured the code points at the domain whatever they
|
||||
* pick, so the list is a row of numbers that do nothing — and the one
|
||||
* marked IN USE is not the address anyone is being given. Hide it.
|
||||
*/
|
||||
const addrBox = $('addrList');
|
||||
addrBox.hidden = !!publicBaseConfigured();
|
||||
if (addrBox.hidden) {
|
||||
/* Still draw the code itself — it is the only thing left in this panel. */
|
||||
const only = shareBase();
|
||||
$('qr').src = only
|
||||
? 'http://127.0.0.1:' + state.local.port + '/qr.svg?url=' + encodeURIComponent(only + '/')
|
||||
: '';
|
||||
renderQrWarning();
|
||||
renderOperatorUrl();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Mark the row the QR is actually using, not the row that was saved — when
|
||||
a lease moves those are two different things and the saved one is gone. */
|
||||
@@ -3607,8 +3663,40 @@ $('copyAddr').addEventListener('click', () => {
|
||||
.catch((err) => log('could not copy: ' + err.message, 'err'));
|
||||
});
|
||||
|
||||
$('openPoster').addEventListener('click', () => {
|
||||
window.open('http://127.0.0.1:' + state.local.port + '/poster', '_blank');
|
||||
/*
|
||||
* The QR itself, saved as a file, because the poster people actually print
|
||||
* is made in their own design tool. The built-in poster page is still there
|
||||
* at /poster for anyone who wants it; it is just not what this button does.
|
||||
*/
|
||||
$('saveQr').addEventListener('click', async () => {
|
||||
const base = shareBase();
|
||||
if (!base) { log('no address to encode yet', 'err'); return; }
|
||||
/*
|
||||
* Fetch the code and hand the browser a BLOB rather than linking straight at
|
||||
* the server. This window is served from the asset port and the QR comes off
|
||||
* the congregation port, so a plain <a download> is CROSS-ORIGIN — the
|
||||
* download attribute is ignored and the window navigates to the image
|
||||
* instead. With no back button, no reload item and no address bar, that
|
||||
* strands the operator on a full-screen QR with no way out; build 123 did
|
||||
* exactly that to a booth Mac. A blob: URL is same-origin, so it downloads.
|
||||
*/
|
||||
const url = 'http://127.0.0.1:' + state.local.port + '/qr.svg?url=' +
|
||||
encodeURIComponent(base + '/');
|
||||
try {
|
||||
const r = await fetch(url, { cache: 'no-store' });
|
||||
if (!r.ok) throw new Error('the server answered ' + r.status);
|
||||
const href = URL.createObjectURL(await r.blob());
|
||||
const a = document.createElement('a');
|
||||
a.href = href;
|
||||
a.download = 'church-translate-qr.svg';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
setTimeout(() => URL.revokeObjectURL(href), 10000);
|
||||
log('saved the QR for ' + base + '/ to Downloads', 'ok');
|
||||
} catch (err) {
|
||||
log('could not save the QR: ' + err.message, 'err');
|
||||
}
|
||||
});
|
||||
$('openOperator').addEventListener('click', () => {
|
||||
window.open('http://127.0.0.1:' + state.local.port + '/operator', '_blank');
|
||||
@@ -3665,7 +3753,8 @@ function renderBuildTag() {
|
||||
}
|
||||
|
||||
function renderOperatorUrl() {
|
||||
const base = shareBase();
|
||||
/* Deliberately lanBase, not shareBase: over a proxy /operator is a 404. */
|
||||
const base = lanBase();
|
||||
$('opPageUrl').textContent = base ? base + '/operator' : 'no network';
|
||||
}
|
||||
|
||||
@@ -3968,6 +4057,7 @@ async function loadOperator() {
|
||||
try {
|
||||
const j = await opApi('/api/config');
|
||||
opConfig = j.config;
|
||||
renderShare(); /* publicUrl may have just arrived */
|
||||
clearTimeout(opLoadTimer); opLoadTimer = null; // it answered; stop retrying
|
||||
opRetryMs = 0;
|
||||
renderOpLanguages();
|
||||
@@ -4022,6 +4112,7 @@ async function opSave(patch, okMsg) {
|
||||
try {
|
||||
const j = await opApi('/api/config', { method: 'POST', body: JSON.stringify(patch) });
|
||||
opConfig = j.config;
|
||||
renderShare(); /* publicUrl may have just arrived */
|
||||
if (okMsg) log(okMsg, 'ok');
|
||||
return j;
|
||||
} catch (e) { log('could not save: ' + e.message, 'err'); throw e; }
|
||||
|
||||
+1
-1
@@ -433,7 +433,7 @@
|
||||
<div id="addrList" class="addrlist"></div>
|
||||
<div class="railbtns">
|
||||
<button class="btn btn-primary" id="copyAddr">Copy address</button>
|
||||
<button class="btn" id="openPoster">Printable poster</button>
|
||||
<button class="btn" id="saveQr">Save QR image</button>
|
||||
</div>
|
||||
|
||||
<h3 class="subhead">Operator page</h3>
|
||||
|
||||
+21
@@ -662,6 +662,27 @@ function createWindow() {
|
||||
: '/index.html';
|
||||
win.loadURL(assetOrigin + page);
|
||||
|
||||
/*
|
||||
* NOTHING replaces the app in this window. There is no back button, no
|
||||
* reload item and no address bar, so a window that leaves the app page is a
|
||||
* window the operator cannot get back from — which is precisely how build
|
||||
* 123 stranded a booth Mac on a full-screen QR image. Our own pages still
|
||||
* open as their OWN windows through setWindowOpenHandler below; this only
|
||||
* refuses to replace the app itself, and sends anything external to the
|
||||
* browser where it belongs.
|
||||
*/
|
||||
win.webContents.on('will-navigate', (e, url) => {
|
||||
if (url === assetOrigin + page) return; /* reloading ourselves is fine */
|
||||
e.preventDefault();
|
||||
console.error('[main] refused to navigate the app window to ' + url);
|
||||
let local = false;
|
||||
try {
|
||||
const u = new URL(url);
|
||||
local = (u.hostname === '127.0.0.1' || u.hostname === 'localhost');
|
||||
} catch (_) { local = false; }
|
||||
if (!local) shell.openExternal(url).catch(() => {});
|
||||
});
|
||||
|
||||
win.webContents.on('did-finish-load', () => console.log('[main] page loaded'));
|
||||
win.webContents.on('did-fail-load', (_e, code, desc, url) =>
|
||||
console.error('[main] page FAILED to load: ' + code + ' ' + desc + ' ' + url));
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
"name": "church-translate-engine",
|
||||
"productName": "Church Translate",
|
||||
"version": "3.23.2",
|
||||
"buildNumber": 121,
|
||||
"buildNumber": 125,
|
||||
"private": true,
|
||||
"description": "Live sermon translation — self-contained: captures audio, transcribes, translates, and serves the congregation page itself",
|
||||
"main": "main.js",
|
||||
@@ -106,7 +106,7 @@
|
||||
]
|
||||
},
|
||||
"asar": false,
|
||||
"buildVersion": "121",
|
||||
"buildVersion": "125",
|
||||
"win": {
|
||||
"target": [
|
||||
{
|
||||
|
||||
@@ -163,10 +163,21 @@
|
||||
function renderFeatured() {
|
||||
var wrap = $('featured');
|
||||
wrap.textContent = '';
|
||||
/*
|
||||
* THE OPERATOR'S LIST IS THE LIST. This used to unshift the source
|
||||
* language in unconditionally, on the reasoning that plenty of people want
|
||||
* the English captions for accessibility rather than translation — which
|
||||
* is true, and still available, but it is not this code's call to make.
|
||||
* The operator has a switch for every language including English, and for
|
||||
* the source language alone that switch did nothing: English was put back
|
||||
* on every render, so a desk that had deliberately turned it off still
|
||||
* offered it as the first button on the page. A control that silently
|
||||
* refuses is worse than no control.
|
||||
*
|
||||
* Wanting English captions is now one click in Settings, in the same list
|
||||
* as every other language, and it stays where it is put.
|
||||
*/
|
||||
var list = (app.cfg.featured || []).slice();
|
||||
/* The source language belongs in the list too — plenty of people want the
|
||||
English captions for accessibility, not translation. */
|
||||
if (list.indexOf(app.cfg.sourceLanguage) === -1) list.unshift(app.cfg.sourceLanguage);
|
||||
list.forEach(function (code) {
|
||||
var b = langButton(code);
|
||||
if (b) wrap.appendChild(b);
|
||||
|
||||
Reference in New Issue
Block a user