feat(feeds): add optional sandboxed in-tab article preview
Build and publish container images / images (push) Successful in 10m41s
Release container images / release (push) Successful in 24s

This commit is contained in:
Anya Tokugawa committed 2026-11-08 13:55:22 +09:00
1 parent ea1ca432c5
commit f4869c7c8b
10 files changed
+68 -5

No files matched your search

+4 -2
View File
@@ -6,6 +6,7 @@
const t=k=>(word[k]||[k,k])[ja?1:0],el=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;return n;};
Object.assign(word,{notify_due:['Notify on due dates','期限日に通知する'],notify_planned:['Notify on planned dates','取り組む日に通知する'],reminder_time:['Default notification time','通知の既定時刻']});
Object.assign(word,{wiki_prefix:['Default Wiki parent path for mail / RSS','メール・RSS取り込みの既定Wiki親Path']});
Object.assign(word,{rss_link_mode:['Open RSS article links','RSSの記事リンクの開き方']});
const status=root.querySelector('#productivity-status'),content=root.querySelector('#productivity-content');
root.querySelectorAll('[data-word]').forEach(n=>n.textContent=t(n.dataset.word));root.querySelector('h1,h2,h3').textContent=t(root.dataset.view==='settings'?'settings':'report');
async function request(path,options={}){const timeout=AbortSignal.timeout(15000);const r=await fetch(api+path,{credentials:'same-origin',cache:'no-store',signal:signal?AbortSignal.any([signal,timeout]):timeout,...options,headers:{'Content-Type':'application/json',...options.headers}});const d=await r.json().catch(()=>({}));if(!r.ok||r.redirected)throw Error(t(d.error||'error'));return d;}
@@ -14,11 +15,12 @@
const data=await request('preferences'),p=data.preferences;const form=el('form');form.className='productivity-settings';const fields={};
const projects=await request('items?kind=project&view=all&limit=100');
if(p.project_uuid&&!projects.items.some(x=>x.uuid===p.project_uuid)){try{const current=await request('items/'+encodeURIComponent(p.project_uuid));if(current.item.kind==='project')projects.items.unshift(current.item);}catch{ /* Keep the saved reference visible without exposing inaccessible data. */ }}
for(const key of ['project_uuid','wiki_prefix','assignee_uuid','due_days','start_days','planned_days','review_days','estimate_minutes','complexity','notify_due','notify_planned','reminder_time','digest_enabled','digest_time','timezone']){
for(const key of ['project_uuid','wiki_prefix','rss_link_mode','assignee_uuid','due_days','start_days','planned_days','review_days','estimate_minutes','complexity','notify_due','notify_planned','reminder_time','digest_enabled','digest_time','timezone']){
if(key==='notify_due')form.append(el('h3',ja?'新規タスクのInbox通知':'Inbox reminders for new tasks'));
if(key==='digest_enabled')form.append(el('h3',ja?'日次メール':'Daily email'));
const label=el('label',t(key));label.className='productivity-setting';const input=el(key==='project_uuid'?'select':'input');input.name=key;
const label=el('label',t(key));label.className='productivity-setting';const input=el(['project_uuid','rss_link_mode'].includes(key)?'select':'input');input.name=key;
if(key==='project_uuid'){const empty=el('option',t('none'));empty.value='';input.append(empty);for(const item of projects.items){const option=el('option',item.title);option.value=item.uuid;input.append(option);}if(p[key]&&!projects.items.some(x=>x.uuid===p[key])){const current=el('option',p[key]);current.value=p[key];input.append(current);}}
else if(key==='rss_link_mode'){for(const [value,label]of [['tab',ja?'新しいタブ':'New tab'],['embedded',ja?'本文上のポップアップ':'Popup over article']]){const option=el('option',label);option.value=value;input.append(option);}p[key] ||= 'tab';}
else if(['digest_enabled','notify_due','notify_planned'].includes(key)){input.type='checkbox';input.checked=!!p[key];input.setAttribute('role','switch');}
else if(key.endsWith('_days')||['estimate_minutes','complexity'].includes(key)){input.type='number';input.min=key==='complexity'?1:0;input.max=key.endsWith('_days')?3650:key==='complexity'?5:10080;input.step=1;}
else input.type=['digest_time','reminder_time'].includes(key)?'time':'text';