Changeset 11b3ba5 in Klonkt


Ignore:
Timestamp:
06/21/2026 03:54:13 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
1664f31
Parents:
5e61b17
Message:

fix(editor): schedule publication behind an on/off toggle (no accidental date)

The "Publish on" date field was always open → an accidentally chosen date silently
set the post to 'scheduled' (not live, no obvious reason). Now a "Schedule
publication" toggle, off by default = publish immediately; the date field appears
and counts only when the toggle is on (input disabled when off). Server honours
publish_at only with schedule_enabled (bulletproof, create + update). NL/EN/DE.

Co-Authored-By: Claude <noreply@…>

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    r5e61b17 r11b3ba5  
    186186  let publishAt = null;
    187187  const pa = Date.parse(req.body.publish_at || '');
    188   if (finalStatus === 'published' && Number.isFinite(pa) && pa > Date.now()) {
     188  if (req.body.schedule_enabled && finalStatus === 'published' && Number.isFinite(pa) && pa > Date.now()) {
    189189    finalStatus = 'scheduled';
    190190    publishAt = new Date(pa).toISOString();
     
    297297  let publishAt = null;
    298298  const pa = Date.parse(req.body.publish_at || '');
    299   if (finalStatus === 'published' && Number.isFinite(pa) && pa > Date.now()) {
     299  if (req.body.schedule_enabled && finalStatus === 'published' && Number.isFinite(pa) && pa > Date.now()) {
    300300    finalStatus = 'scheduled';
    301301    publishAt = new Date(pa).toISOString();
  • src/services/i18n.js

    r5e61b17 r11b3ba5  
    725725    'pedit.noindex_label': 'noindex (verberg voor zoekmachines)',
    726726    'pedit.fan_only_label': 'Alleen voor ingelogde fans',
    727     'pedit.publish_at_label': 'Publiceren op (laat leeg = direct)',
     727    'pedit.schedule_label': 'Publicatie inplannen',
     728    'pedit.schedule_hint': 'Staat dit uit, dan gaat je post meteen live. Aan = kies hieronder wanneer \'ie verschijnt.',
     729    'pedit.publish_at_label': 'Datum & tijd',
    728730    'pedit.scheduled_for': 'Ingepland voor {d}',
    729731    'pedit.cancel': 'Annuleren',
     
    16761678    'pedit.noindex_label': 'noindex (hide from search engines)',
    16771679    'pedit.fan_only_label': 'Logged-in fans only',
    1678     'pedit.publish_at_label': 'Publish at (leave empty = immediately)',
     1680    'pedit.schedule_label': 'Schedule publication',
     1681    'pedit.schedule_hint': 'When off, your post goes live immediately. On = pick below when it appears.',
     1682    'pedit.publish_at_label': 'Date & time',
    16791683    'pedit.scheduled_for': 'Scheduled for {d}',
    16801684    'pedit.cancel': 'Cancel',
     
    26272631    'pedit.noindex_label': 'noindex (vor Suchmaschinen verbergen)',
    26282632    'pedit.fan_only_label': 'Nur für angemeldete Fans',
    2629     'pedit.publish_at_label': 'Veröffentlichen am (leer lassen = sofort)',
     2633    'pedit.schedule_label': 'Veröffentlichung planen',
     2634    'pedit.schedule_hint': 'Wenn aus, geht dein Beitrag sofort live. An = wähle unten, wann er erscheint.',
     2635    'pedit.publish_at_label': 'Datum & Uhrzeit',
    26302636    'pedit.scheduled_for': 'Geplant für {d}',
    26312637    'pedit.cancel': 'Abbrechen',
  • src/views/pages/post-edit.ejs

    r5e61b17 r11b3ba5  
    208208            <span>🔒 <%= t('pedit.fan_only_label') %></span>
    209209          </label>
    210           <div style="margin-top:8px">
    211             <label style="display:block;font-size:12.5px;opacity:.8;margin-bottom:4px">📅 <%= t('pedit.publish_at_label') %></label>
    212             <input type="datetime-local" name="publish_at" value="<%= post.publish_at ? String(post.publish_at).replace(' ','T').slice(0,16) : '' %>" style="padding:8px 10px;border-radius:8px;border:1px solid var(--rule,rgba(128,128,128,.4));background:transparent;color:inherit">
     210          <% var _scheduled = !!(post.publish_at && (post.status === 'scheduled' || Date.parse(String(post.publish_at).replace(' ', 'T')) > Date.now())); %>
     211          <label class="pe-checkbox" style="margin-top:8px">
     212            <input type="checkbox" name="schedule_enabled" value="1" id="pe-sched-toggle" <%= _scheduled ? 'checked' : '' %>>
     213            <span>📅 <%= t('pedit.schedule_label') %></span>
     214          </label>
     215          <div id="pe-sched-fields" style="margin-top:6px;<%= _scheduled ? '' : 'display:none' %>">
     216            <label style="display:block;font-size:12.5px;opacity:.8;margin-bottom:4px"><%= t('pedit.publish_at_label') %></label>
     217            <input type="datetime-local" name="publish_at" <%= _scheduled ? '' : 'disabled' %> value="<%= post.publish_at ? String(post.publish_at).replace(' ','T').slice(0,16) : '' %>" style="padding:8px 10px;border-radius:8px;border:1px solid var(--rule,rgba(128,128,128,.4));background:transparent;color:inherit">
    213218            <% if (post.status === 'scheduled' && post.publish_at) { %><div style="font-size:12px;opacity:.7;margin-top:4px">⏳ <%= t('pedit.scheduled_for', { d: post.publish_at }) %></div><% } %>
     219            <div style="font-size:11.5px;opacity:.65;margin-top:4px"><%= t('pedit.schedule_hint') %></div>
    214220          </div>
     221          <script>
     222            (function () {
     223              var cb = document.getElementById('pe-sched-toggle');
     224              var box = document.getElementById('pe-sched-fields');
     225              if (!cb || !box) return;
     226              var inp = box.querySelector('input[name="publish_at"]');
     227              function sync() { box.style.display = cb.checked ? '' : 'none'; if (inp) inp.disabled = !cb.checked; }
     228              cb.addEventListener('change', sync); sync();
     229            })();
     230          </script>
    215231        <% } %>
    216232      </div>
Note: See TracChangeset for help on using the changeset viewer.