Show read-only server reading hours in settings
This commit is contained in:
1 parent
de8e7ed988
commit
ddd9c62c40
9 files changed
+89
-7
No files matched your search
@@ -222,6 +222,10 @@ main { max-width: 1200px; margin: 0 auto; padding: 16px; }
|
||||
.settings-title-row { display: flex; align-items: center; gap: 12px; }
|
||||
.settings-hint { margin: 5px 0 20px; }
|
||||
.settings-content .card { max-width: none; }
|
||||
.reading-hours-list { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
|
||||
.reading-hours-day { display: grid; grid-template-columns: minmax(95px, 8em) minmax(0, 1fr); gap: 12px; padding: 10px 12px; }
|
||||
.reading-hours-day + .reading-hours-day { border-top: 1px solid var(--line); }
|
||||
.reading-hours-day span { overflow-wrap: anywhere; }
|
||||
.peer-card { min-width: 0; overflow-wrap: anywhere; }
|
||||
.peer-card textarea, .peer-card input { min-width: 0; max-width: 100%; }
|
||||
.peer-card .row > .field { min-width: 0; }
|
||||
|
||||
+11
-1
@@ -3,6 +3,7 @@
|
||||
// Two navigation levels; scraper tabs stay within their section, not another menu.
|
||||
const SETTINGS_SECTIONS = [
|
||||
{ id: 'user/reading', group: 'User', title: 'Reading', hint: 'Reader modes, page spacing and zoom.' },
|
||||
{ id: 'user/reading-hours', group: 'User', title: 'Reading hours', hint: 'When this server allows chapter reading.' },
|
||||
{ id: 'user/reading-time', group: 'User', title: 'Reading time & privacy', hint: 'Your clock, Reading Story and personal data.' },
|
||||
{ id: 'user/notifications', group: 'User', title: 'Notifications', hint: 'Chapter alerts and your optional webhook.' },
|
||||
{ id: 'user/account', group: 'User', title: 'Account', hint: 'Your account and password.' },
|
||||
@@ -15,6 +16,15 @@ const SETTINGS_SECTIONS = [
|
||||
{ id: 'admin/health', group: 'Admin', title: 'Service health', hint: 'Service status, incidents and recovery.', href: 'health.html' },
|
||||
];
|
||||
const SCRAPER_TABS = ['activity', 'queue', 'updates', 'sources'];
|
||||
const READING_DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
|
||||
function readingDayText(schedule, index) {
|
||||
const previous = (index + 6) % 7;
|
||||
const carried = schedule.days[previous].filter(([start, end]) => end < start)
|
||||
.map(([, end]) => `00:00–${end} (from ${READING_DAYS[previous]})`);
|
||||
const starting = schedule.days[index].map(([start, end]) => `${start}–${end}${end < start ? ' (next day)' : ''}`);
|
||||
return [...carried, ...starting].join(' · ') || 'Closed all day';
|
||||
}
|
||||
|
||||
function settingsRoute(hash, admin) {
|
||||
const parts = String(hash || '').replace(/^#/, '').split('/');
|
||||
@@ -59,4 +69,4 @@ function settingsShell(me, active = 'user/reading') {
|
||||
return { content, titleRow, select };
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined') module.exports = { SETTINGS_SECTIONS, SCRAPER_TABS, settingsRoute };
|
||||
if (typeof module !== 'undefined') module.exports = { SETTINGS_SECTIONS, SCRAPER_TABS, settingsRoute, readingDayText };
|
||||
@@ -85,6 +85,22 @@
|
||||
h('button', { class: 'btn small', onclick: async () => { await save({ zoom: {} }); zoomText.textContent = zooms(); } }, 'Reset to fit'),
|
||||
h('div', { class: 'muted small' }, '100% = the page fits the screen. Change it in the reader with Ctrl + mouse wheel, a pinch, or the + / - keys.'))));
|
||||
|
||||
const readingHoursBody = h('div', {}, h('p', { class: 'muted' }, 'Loading server reading hours…'));
|
||||
section('user/reading-hours').append(h('section', { class: 'card' },
|
||||
h('h2', {}, 'Server reading hours'), readingHoursBody,
|
||||
h('p', { class: 'muted small' }, 'These hours are set in the server deployment and cannot be changed here. Overnight windows continue into the next day.')));
|
||||
api('api/reading-schedule').then(schedule => {
|
||||
readingHoursBody.textContent = '';
|
||||
if (!schedule.enabled) {
|
||||
readingHoursBody.append(h('p', {}, 'Reading is available at any time. No schedule is configured.'));
|
||||
return;
|
||||
}
|
||||
readingHoursBody.append(h('p', { class: 'muted' }, `Server timezone: ${schedule.timezone}`),
|
||||
h('div', { class: 'reading-hours-list' }, READING_DAYS.map((day, index) =>
|
||||
h('div', { class: 'reading-hours-day' }, h('strong', {}, day),
|
||||
h('span', {}, readingDayText(schedule, index))))));
|
||||
}).catch(error => { readingHoursBody.replaceChildren(h('p', { class: 'error', role: 'alert' }, `Could not load reading hours: ${error.message}`)); });
|
||||
|
||||
section('user/reading-time').append(h('section', { class: 'card' },
|
||||
h('h2', {}, 'Clock & Reading Story'),
|
||||
check('readingClock', 'Track and show the Active Reading Clock',
|
||||
|
||||
Reference in new issue
Block a user