feat(feeds): add templated capture paths and inline modal
Build and publish container images / images (push) Successful in 11m2s

This commit is contained in:
Anya Tokugawa committed 2026-11-08 13:44:20 +09:00
1 parent 78da33d549
commit a5f90f933d
12 files changed
+138 -11

No files matched your search

+15 -6
View File
@@ -175,20 +175,29 @@
form.onsubmit=async event=>{event.preventDefault();save.disabled=true;try{await post('sources',{uuid:sourceID,version:source?.version||0,provider:provider.value,title:title.value,folder:folder.value,url:url.value,interval_seconds:Number(interval.value)*60,enabled:enabled.checked,write_enabled:provider.value==='freshrss'&&write.checked,username:user.value,password:password.value});password.value='';await reload();status.textContent=t('Saved','保存しました');}catch(e){report(e);}finally{save.disabled=false;}};title.focus();
}
function captureForm(item){
editing=true;detailSeq++;reader.replaceChildren();const form=el('form');reader.append(form);form.append(el('h1',t('Attributed Wiki note / task','出典付きWikiメモ・タスク')));
editing=true;detailSeq++;clearTimeout(actionTimer);const dialog=el('dialog',undefined,'feed-capture'),form=el('form');dialog.ariaLabel=t('Capture Wiki / task','Wiki・タスク追加');reader.append(dialog);dialog.append(form);
const close=()=>{if(!busy)dialog.close();},heading=el('div',undefined,'feed-capture-heading');heading.append(el('h2',t('Capture Wiki / task','Wiki・タスク追加')),button('×',t('Close','閉じる'),close));form.append(heading);
dialog.addEventListener('close',()=>{clearTimeout(previewTimer);generation++;dialog.remove();editing=false;pollAction(item);});dialog.addEventListener('cancel',e=>{if(busy)e.preventDefault();});dialog.addEventListener('keydown',e=>e.stopPropagation());
const title=field(form,t('Title','件名'),item.title.slice(0,250));title.required=true;title.maxLength=300;
const task=field(form,t('Also create a task','タスクを作成する'),'','checkbox');task.disabled=root.dataset.tasks!=='true';
const prefix=field(form,t('Wiki parent Path (empty = task only)','Wikiの親Path(空ならタスクのみ)'),root.dataset.wikiPrefix||'');prefix.placeholder='/notes/feeds';prefix.required=true;prefix.maxLength=500;
if(root.dataset.tasks==='true'){const settings=el('a','⚙');settings.href='/-/sys/config?panel=organizer';settings.target='_blank';settings.rel='noopener';settings.title=settings.ariaLabel=t('Configure default Wiki parent path in personal settings','個人設定で既定のWiki親Pathを設定');prefix.parentElement.append(settings);}
const tokens=el('div',undefined,'feed-capture-tokens');for(const token of ['{YYYY}','{MM}','{DD}','{Subject}'])tokens.append(button(token,t('Insert ','挿入: ')+token,()=>{prefix.setRangeText(token,prefix.selectionStart??prefix.value.length,prefix.selectionEnd??prefix.value.length,'end');prefix.dispatchEvent(new Event('input',{bubbles:true}));prefix.focus();}));form.append(tokens);
const destination=el('output',undefined,'feed-capture-destination');destination.ariaLabel=t('Destination','保存先');form.append(destination);
const notes=field(form,t('Your note','メモ'));const copy=field(form,t('Include cached text (explicit copy)','取得済み本文も保存する(明示コピー)'),'','checkbox');
const confirm=field(form,t('I checked the destination publication policy and the material to copy.','保存先の公開範囲と、コピーする内容を確認しました。'),'','checkbox');confirm.required=true;
const validate=()=>{prefix.required=!task.checked;confirm.required=!!prefix.value.trim()||!task.checked;};task.onchange=prefix.oninput=validate;
const save=el('button',t('Create','作成'));save.type='submit';form.append(save,button(t('Cancel','取消'),'',()=>{editing=false;renderItem(item);}));let pending=null;
form.onsubmit=async event=>{event.preventDefault();const body='Source: '+item.url+'\nFeed: '+item.feed+'\n\n'+notes.value+(copy.checked?'\n\n'+item.body:'');const spec={title:title.value,notes:notes.value,prefix:prefix.value.trim(),body,task:task.checked};const fingerprint=JSON.stringify(spec);if(!pending||pending.fingerprint!==fingerprint)pending={fingerprint,request_id:crypto.randomUUID()};save.disabled=true;
for(const [name,input]of Object.entries({title,task,prefix,notes,copy,confirm})){input.name=name;if(input.type==='checkbox')input.parentElement.classList.add('feed-capture-check');else input.parentElement.classList.add('feed-capture-field');}
const notice=el('p',undefined,'feed-warning');notice.role='status';const actions=el('div',undefined,'feed-capture-actions'),save=el('button',t('Create','作成'));save.type='submit';actions.append(button(t('Cancel','取消'),'',close),save);form.append(notice,actions);
let pending=null,generation=0,previewTimer,resolved=null,busy=false;const requestID=crypto.randomUUID();
const preview=()=>{clearTimeout(previewTimer);const n=++generation;resolved=null;confirm.checked=false;prefix.required=!task.checked;confirm.required=!!prefix.value.trim()||!task.checked;save.disabled=true;notice.textContent='';destination.textContent='';
if(!prefix.value.trim()){resolved='';destination.textContent=task.checked?t('Task only','タスクのみ'):'';save.disabled=!task.checked;return;}
previewTimer=setTimeout(async()=>{try{const data=await post('capture-preview',{prefix:prefix.value.trim(),title:title.value});if(n!==generation||!dialog.isConnected)return;resolved=data.prefix;destination.textContent=resolved.replace(/\/$/,'')+'/'+(task.checked?'mail-':'rss-')+requestID;save.disabled=false;}catch(e){if(n===generation&&dialog.isConnected){notice.textContent=t('Check the parent Path and placeholders.','親Pathとプレースホルダを確認してください。');}}},180);
};task.onchange=prefix.oninput=title.oninput=preview;copy.onchange=()=>{confirm.checked=false;};dialog.showModal();preview();title.focus();
form.onsubmit=async event=>{event.preventDefault();if(busy||resolved===null||!form.reportValidity())return;const body='Source: '+item.url+'\nFeed: '+item.feed+'\n\n'+notes.value+(copy.checked?'\n\n'+item.body:'');const spec={title:title.value,notes:notes.value,prefix:resolved,body,task:task.checked};const fingerprint=JSON.stringify(spec);if(!pending||pending.fingerprint!==fingerprint)pending={fingerprint,request_id:requestID};busy=true;save.disabled=true;
try{let data;if(task.checked){const input={request_id:pending.request_id,title:title.value,notes:(notes.value+'\nSource: '+item.url).trim()};if(spec.prefix){input.wiki_prefix=spec.prefix;input.wiki_body=body;}const res=await fetch('/_/api/v1/extension/organizer.tasks/capture',{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json'},body:JSON.stringify(input)});data=await res.json().catch(()=>({}));if(!res.ok||res.redirected)throw Error(t('Capture failed: ','作成に失敗: ')+(data.error||res.status));}
else data=await post('note',{request_id:pending.request_id,source:item.source,id:item.id,path:spec.prefix.replace(/\/$/,'')+'/rss-'+pending.request_id,title:title.value,body,confirm_publication:confirm.checked});
reader.replaceChildren(el('p',t('Created.','作成しました。')));if(data.item){const a=el('a',t('Open task','タスクを開く'));a.href='/v/plan/task/'+encodeURIComponent(data.item.uuid);reader.append(a);}const page=data.page_uuid||data.item?.page_uuid;if(page){const a=el('a',t('Open Wiki','Wikiを開く'));a.href='/v/uuid:'+encodeURIComponent(page);reader.append(el('p'),a);}editing=false;
}catch(e){report(e);}finally{save.disabled=false;}
dialog.replaceChildren(el('h2',t('Created','作成しました')));if(data.item){const a=el('a',t('Open task','タスクを開く'));a.href='/v/plan/task/'+encodeURIComponent(data.item.uuid);dialog.append(a);}const page=data.page_uuid||data.item?.page_uuid;if(page){const a=el('a',t('Open Wiki','Wikiを開く'));a.href='/v/uuid:'+encodeURIComponent(page);dialog.append(el('p'),a);}const done=button(t('Close','閉じる'),'',close);dialog.append(el('p'),done);done.focus();
}catch(e){notice.textContent=e.message;}finally{busy=false;save.disabled=resolved===null;}
};
}
document.addEventListener('keydown',event=>{if(event.defaultPrevented||event.isComposing||event.ctrlKey||event.altKey||event.metaKey)return;if(event.key==='Escape'&&!help.hidden){hideHelp();event.preventDefault();return;}const input=event.target.closest?.('input,textarea,select,[contenteditable=true]');if(input){if(event.key==='Escape'){event.target.blur();event.preventDefault();}return;}if(event.key==='?'&&!help.hidden){hideHelp();event.preventDefault();return;}if(event.key==='Enter'&&event.target.closest?.('button,a'))return;if(editing){if(event.key==='Escape'){closeReader();event.preventDefault();}return;}
+1 -1
View File
@@ -26,7 +26,7 @@
if(key==='project_uuid')for(const option of input.options)option.defaultSelected=option.selected=option.value===(p.project_uuid||'');
else if(input.type==='checkbox')input.defaultChecked=input.checked;
else input.defaultValue=input.value;
if(key==='wiki_prefix'){input.placeholder='/notes';input.maxLength=500;const help=el('p',ja?'メール本文・RSSのWiki取り込みに使う親Pathです。RSSでは入力欄の初期値になり、空にすればタスクのみ作成できます。設定が空欄の場合、メールはプロジェクトのWiki配下を使い、RSSは未入力になります。保存内容はそのPathの公開範囲・閲覧権限に従います。':'Parent path for mail / RSS Wiki captures. RSS pre-fills this value; clearing it allows task-only capture. If unset, mail uses the project Wiki subtree and RSS leaves the field blank. Saved content inherits the destination visibility and read permissions.');help.className='productivity-note';form.append(help);}
if(key==='wiki_prefix'){input.placeholder='/notes/{YYYY}/{MM}/{Subject}';input.maxLength=500;const help=el('p',ja?'メール・RSS取り込みの保存先。{YYYY}・{MM}・{DD}は作成日(ドメインのタイムゾーン)、{Subject}は件名です。RSSでは入力欄を空にすればタスクのみ作成できます。設定が空欄の場合、メールはプロジェクトのWiki配下を使い、RSSは未入力になります。保存内容はそのPathの公開範囲・閲覧権限に従います。':'Mail / RSS capture destination. {YYYY}, {MM}, {DD} use the creation date in the Domain timezone; {Subject} uses the title. Clear the RSS field for task-only capture. If unset, mail uses the project Wiki subtree and RSS leaves the field blank. Content inherits destination visibility and permissions.');help.className='productivity-note';form.append(help);}
if(key==='reminder_time'){const help=el('p',ja?'新規タスクの対応する日付が設定されている場合だけ通知します。既存タスクは変更しません。通知時刻は保存時のドメインのタイムゾーン('+data.timezone+')を使用します。':'Reminders apply only to new tasks with the corresponding date. Existing tasks are unchanged. Times use the Domain timezone on save ('+data.timezone+').');help.className='productivity-note';form.append(help);}
}
const note=el('p',ja?'日数は作成日からの暦日です。空欄は未設定、0は当日。担当者の指定では閲覧権限は付与されません。メールは今日の計画・期限到来分を最大100件送ります。SMTPは管理者設定を使用し、配信時刻にはキュー待ちの遅延があります。':'Offsets are calendar days from creation; blank means unset, 0 means today. Assignment does not grant access. Email includes up to 100 tasks planned or due today, using administrator SMTP settings. Queue delays may apply.');note.className='productivity-note';form.append(note);