docs(website): add worked guides and keep Pages publishing manual (#925)
* fix(pages): reserve publishing for the REA website * docs(website): add worked guides and agent prompt examples * ci(website): check relevant PRs and publish only on demand * docs(website): clarify IDA coverage and analysis session lifetime
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
function toCsv(notes) {
|
||||
const quote = (value) => `"${String(value).replaceAll('"', '""')}"`;
|
||||
return (
|
||||
[
|
||||
"id,title",
|
||||
...notes.map((note) => `${note.id},${quote(note.title)}`),
|
||||
].join("\n") + "\n"
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { toCsv };
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Notes — Electron analysis example</title>
|
||||
<script src="renderer.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Notes</h1>
|
||||
<button id="export" type="button">Export notes</button>
|
||||
<p id="status" role="status"></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,19 @@
|
||||
const { app, BrowserWindow, ipcMain } = require("electron");
|
||||
const { writeFileSync } = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const { toCsv } = require("./csv.js");
|
||||
|
||||
const notes = [{ id: 1, title: "First note" }];
|
||||
|
||||
ipcMain.handle("notes:export", () => {
|
||||
const destination = path.join(app.getPath("downloads"), "notes.csv");
|
||||
writeFileSync(destination, toCsv(notes), "utf8");
|
||||
return destination;
|
||||
});
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const window = new BrowserWindow({
|
||||
webPreferences: { preload: path.join(__dirname, "preload.js") },
|
||||
});
|
||||
window.loadFile("index.html");
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "rea-notes-example",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"main": "main.js"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
const { contextBridge, ipcRenderer } = require("electron");
|
||||
|
||||
contextBridge.exposeInMainWorld("notes", {
|
||||
exportCsv: () => ipcRenderer.invoke("notes:export"),
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
document.querySelector("#export").addEventListener("click", async () => {
|
||||
const destination = await window.notes.exportCsv();
|
||||
document.querySelector("#status").textContent = `Saved to ${destination}`;
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
document.querySelector("#export").addEventListener("click", async () => {
|
||||
const status = document.querySelector("#status");
|
||||
try {
|
||||
const response = await fetch("./notes.json");
|
||||
if (!response.ok)
|
||||
throw new Error(`Notes request failed: ${response.status}`);
|
||||
const { notes } = await response.json();
|
||||
const quote = (value) => `"${String(value).replaceAll('"', '""')}"`;
|
||||
const csv =
|
||||
[
|
||||
"id,title",
|
||||
...notes.map((note) => `${note.id},${quote(note.title)}`),
|
||||
].join("\n") + "\n";
|
||||
const url = URL.createObjectURL(new Blob([csv], { type: "text/csv" }));
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "notes.csv";
|
||||
link.click();
|
||||
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||||
status.textContent = `Exported ${notes.length} notes to notes.csv.`;
|
||||
} catch (error) {
|
||||
status.textContent = error.message;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Notes — REA browser example</title>
|
||||
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml" />
|
||||
<link rel="stylesheet" href="../../assets/styles.css" />
|
||||
<script src="export.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<main class="container example-app">
|
||||
<p class="breadcrumb">
|
||||
<a href="../../guides/browser/">Browser observation guide</a> / Example
|
||||
</p>
|
||||
<p class="eyebrow">A small app to inspect</p>
|
||||
<h1>Notes</h1>
|
||||
<p class="lede">
|
||||
Two notes. One CSV export. Observe what happens when you click.
|
||||
</p>
|
||||
<ul class="example-notes">
|
||||
<li>First note</li>
|
||||
<li>Follow the export</li>
|
||||
</ul>
|
||||
<button class="button" type="button" id="export">Export notes</button>
|
||||
<p class="example-status" id="status" role="status" aria-live="polite">
|
||||
Ready to export.
|
||||
</p>
|
||||
<p class="caption">
|
||||
This example loads <code>notes.json</code> and creates a CSV in your
|
||||
browser.
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"notes": [
|
||||
{ "id": 1, "title": "First note" },
|
||||
{ "id": 2, "title": "Follow the export" }
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user