Let users download shared notes as Markdown
The shared notes had no way out: everything lived in the SQLite row and the
only reader was the panel itself. Add two export endpoints and buttons for
them at the bottom of the note panel.
GET /api/notes/{page_id}/export returns one page as .md, and
GET /api/notes/export returns every page as a zip laid out as
<section>/<NN>_<title>.md. Pages are not concatenated into a single file on
purpose - the headings inside a page would collide with whatever heading
level we used as a page separator, so each page stays a verbatim file and the
numeric prefix carries the tab order instead.
Titles reach the filesystem here, so strip the Windows-forbidden characters
and control characters, cap the length, and send Content-Disposition with an
RFC 5987 filename* so Japanese titles survive. The front end deliberately
omits the anchor's download attribute to let that name win.
notes store: flush() now returns a promise so the download can wait for
pending edits to be saved before asking the server for the file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+22
@@ -187,6 +187,28 @@ SSE でストリーミング応答を返す。
|
||||
|
||||
---
|
||||
|
||||
### GET /api/notes/export
|
||||
全ページを ZIP でダウンロードさせる(`Content-Disposition: attachment`)。
|
||||
1 ページ 1 ファイルの Markdown で、本文はそのまま。エントリ名は `<セクション>/<通し番号>_<タイトル>.md`
|
||||
(セクション無しのページは ZIP 直下)。通し番号は `position` 順なのでタブの並びが残る。
|
||||
ファイル名は `notes_YYYYMMDD.zip`。
|
||||
|
||||
---
|
||||
|
||||
### GET /api/notes/{page_id}/export
|
||||
1 ページを Markdown ファイルとしてダウンロードさせる。本文はそのままで、ファイル名がタイトルになる。
|
||||
ページが存在しない場合は `404`。
|
||||
|
||||
日本語タイトルを扱うため `Content-Disposition` には RFC 5987 形式を併記する:
|
||||
|
||||
```
|
||||
attachment; filename="______.md"; filename*=UTF-8''%E8%B2%B7%E3%81%84%E7%89%A9%E3%83%AA%E3%82%B9%E3%83%88.md
|
||||
```
|
||||
|
||||
ファイル名に使えない文字(`\ / : * ? " < > |` と制御文字)は `_` に置き換え、80 文字で切る。
|
||||
|
||||
---
|
||||
|
||||
## ログ
|
||||
|
||||
### GET /logs
|
||||
|
||||
@@ -109,6 +109,9 @@ Discord 連携は [discord-bot.md](discord-bot.md)、ノートの操作方法は
|
||||
- AI 側はタイトル一覧だけを常に見ており、`read_note` で本文を読み、`write_note` で追記/全置換/新規作成する。
|
||||
AI が書き換えると SSE の `notes_updated` が飛び、開いているノートパネルが自動で最新化される。
|
||||
- 自分が編集中(未保存)のページは AI の更新で上書きされない。
|
||||
- **ダウンロード**: パネル下部の ⬇ ボタンで、開いているページを `.md` として、または全ページを
|
||||
ZIP(1 ページ 1 Markdown、セクションはフォルダ、ファイル名の通し番号でタブ順を保持)として
|
||||
手元に保存できる。未保存の編集は書き出す前に保存される。
|
||||
|
||||
## 8-9. 自動タグ付けとワードプール
|
||||
|
||||
|
||||
@@ -18,10 +18,28 @@ API 仕様は `docs/api.md` の「共有ノート」節を参照。
|
||||
| タイトルを変更 | タブを**ダブルクリック**すると入力欄になるので書き換えて Enter(または欄外をクリック) |
|
||||
| ページを削除 | タブ内の **×** をクリック(確認ダイアログあり) |
|
||||
| 本文を編集 | ページを開いた状態で下の編集エリアに直接入力 |
|
||||
| ページを1つ保存 | パネル下部の **⬇ このページ (.md)** をクリック |
|
||||
| 全ページを保存 | パネル下部の **⬇ すべて (.zip)** をクリック |
|
||||
|
||||
本文は入力を止めてから少し待つと自動保存される。保存待ちの間はタブに **●**(未保存マーク)が付く。
|
||||
ページが1つも無い場合は「+ 最初のページを作成」から始められる。
|
||||
|
||||
## 手元にダウンロードする
|
||||
|
||||
パネル下部の ⬇ ボタンでノートをファイルとして保存できる。未保存の編集があっても、
|
||||
保存してから書き出すので取りこぼしはない。
|
||||
|
||||
| ボタン | 出てくるもの |
|
||||
|---|---|
|
||||
| **⬇ このページ (.md)** | 開いているページの本文そのままの Markdown ファイル。ファイル名はページのタイトル |
|
||||
| **⬇ すべて (.zip)** | 全ページをまとめた ZIP。1 ページ 1 Markdown で、セクションはフォルダになる |
|
||||
|
||||
ZIP の中のファイル名には `01_`, `02_` … と通し番号が付く。タブの並び順を残すためで、
|
||||
展開したときも画面と同じ順番で並ぶ。ファイル名に使えない文字(`/` や `:` など)は `_` に置き換わる。
|
||||
|
||||
複数ページを 1 つのファイルに連結せず ZIP にしているのは、ページ内の見出し(`#`)が
|
||||
ページ間の見出しと混ざって階層が壊れるのを避けるため。
|
||||
|
||||
## セクションでまとめる
|
||||
|
||||
複数のページを1つのグループとしてタブ上にまとめられる。
|
||||
|
||||
Reference in New Issue
Block a user