From e2578358fb2544c6eb3cd7d784831df1218511e5 Mon Sep 17 00:00:00 2001 From: Utku Bilen Demir <84389167+UtkuBilenDemir@users.noreply.github.com> Date: Tue, 22 Sep 2026 01:02:32 +0200 Subject: [PATCH] hygiene: minimalist unification with chess tool (F tokens) + prune legacy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - plugin/manager.html: replace stark B mono (#ffffff/#0a0a0a, radius 0) with chess F Cleaned D+B tokens (#f8f8f8/#ddd, radius 8px, soft shadow, Inter + iA Writer Duo) — same :root, --bg/--panel/--line/--accent/--radius, unified tabs as underline (vs boxed), cards/tables/pills with shadow. Update inline JS styles (#0a0a0a -> var(--accent)/var(--line)) for reimport bar, infobox, status, artifacts. - plugin/bootstrap.js: remove 394 lines legacy static-dashboard code (openStaticDashboard, buildManagerHtml, conflictRows, groupedRows, tableRows, conflictTables, statusCards, countStatuses, escapeHtml, fileHref, artifactLink, importClippings, configure, pickDirectory) — now only manager pipeline + annotation writer remain (881 vs 1275 lines). - src/kindle_zotero_importer/cli.py: minimalist description, primary highlighted (others are developer utilities). - Build verified: tests pass, XPI rebuilt 23K, JS syntax ok. --- plugin/bootstrap.js | 394 ------------------------------ plugin/manager.html | 210 +++++++++------- src/kindle_zotero_importer/cli.py | 2 +- 3 files changed, 128 insertions(+), 478 deletions(-) diff --git a/plugin/bootstrap.js b/plugin/bootstrap.js index 8121a00..b8c2cb6 100644 --- a/plugin/bootstrap.js +++ b/plugin/bootstrap.js @@ -206,27 +206,6 @@ var KindleZoteroImporter = { return ok && value.value ? value.value : null; }, - async configure() { - const current = { - projectDir: this.getProjectDir(), - pythonPath: this.getPythonPath(), - zoteroDbPath: this.getZoteroDbPath(), - zoteroStorageRoot: this.getZoteroStorageRoot(), - }; - try { - const configPath = this.getConfigPath(); - await Zotero.File.putContentsAsync(configPath, JSON.stringify(current, null, 2) + "\n"); - this.alert( - "Kindle Zotero Importer Configuration", - `Configuration file written to:\n${configPath}\n\nEdit this file to change paths. The import dialog will show the active settings before running.` - ); - this.revealFile(configPath); - } catch (error) { - Zotero.logError(error); - this.alert("Kindle Zotero Importer Failed", String(error && error.stack ? error.stack : error)); - } - }, - async openManager() { if (this.managerWindow && !this.managerWindow.closed) { this.managerWindow.focus(); @@ -254,21 +233,6 @@ var KindleZoteroImporter = { }; }, - async openStaticDashboard() { - const settings = await this.getRuntimeSettings(); - const data = { - matches: await this.readJsonArtifact("matches.json"), - generatedOverrides: await this.readJsonArtifact("match-overrides.generated.json"), - positionedPlan: await this.readJsonArtifact("import-plan.positioned.json"), - finalPlan: await this.readJsonArtifact("import-plan.final.json"), - summary: await this.readJsonArtifact("plugin-summary.json"), - persistentOverrides: await this.readJsonArtifact("match-overrides.json"), - }; - const outputPath = this.artifactPath("kindle-import-manager.html"); - await Zotero.File.putContentsAsync(outputPath, this.buildManagerHtml(settings, data)); - this.openFile(outputPath); - }, - async loadOverridesFile() { const path = this.artifactPath("match-overrides.json"); try { @@ -355,337 +319,6 @@ var KindleZoteroImporter = { } }, - escapeHtml(value) { - return String(value ?? "") - .replaceAll("&", "&") - .replaceAll("<", "<") - .replaceAll(">", ">") - .replaceAll('"', """) - .replaceAll("'", "'"); - }, - - fileHref(path) { - return "file://" + encodeURI(path).replaceAll("#", "%23"); - }, - - artifactLink(label, relativePath) { - const path = this.artifactPath(relativePath); - return `${this.escapeHtml(label)}`; - }, - - countStatuses(items, key = "status") { - const counts = {}; - for (const item of items || []) { - const status = item[key] || "unknown"; - counts[status] = (counts[status] || 0) + 1; - } - return counts; - }, - - statusCards(counts) { - return Object.entries(counts || {}) - .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])) - .map(([status, count]) => `
${this.escapeHtml(row.snippet || "")}| Type | Status | Count | Kindle Title | Details / Candidate Differences | Override / Fix Snippet |
|---|
match-overrides.json for now, then rerun Import Kindle Clippings. Direct in-dashboard editing is the next step.
- ${this.escapeHtml(settings.projectDir)}${this.escapeHtml(settings.pythonPath)}${this.escapeHtml(settings.zoteroDbPath)}${this.escapeHtml(settings.zoteroStorageRoot)}${this.escapeHtml(this.getConfigPath())}kindle-import annotations.
- Rows include unresolved title matches, generated override suggestions, attachment problems, and positioning failures. Use search to filter titles, statuses, citekeys, and candidate text. Showing first 200 rows per group.
- - ${this.conflictTables(conflicts)} - -`; - }, - - async importClippings() { - let progressWindow = null; - try { - const clippingsPath = await this.pickFile("Select Kindle My Clippings.txt", "*.txt"); - if (!clippingsPath) { - return; - } - - const settings = await this.getRuntimeSettings(); - const settingsMessage = [ - "Run Kindle import pipeline with these settings?", - "", - `Clippings: ${clippingsPath}`, - `Project directory: ${settings.projectDir}`, - `Python: ${settings.pythonPath}`, - `Zotero DB: ${settings.zoteroDbPath}`, - `Zotero storage: ${settings.zoteroStorageRoot}`, - `Config file: ${this.getConfigPath()}`, - "", - "This first creates/updates review files. You can choose whether to import annotations after the summary.", - ].join("\n"); - if (!Services.prompt.confirm(this.getMainWindow(), "Kindle Zotero Importer", settingsMessage)) { - return; - } - - progressWindow = this.createProgress("Starting Kindle import..."); - if (progressWindow) { - progressWindow.changeHeadline("Kindle Zotero Importer: reading clippings"); - } - const summary = await this.runPipeline(clippingsPath, settings); - if (progressWindow && progressWindow.progress) { - progressWindow.progress.setProgress(100); - progressWindow.changeHeadline("Kindle Zotero Importer: pipeline complete"); - } - const finalPlanPath = summary.outputs.final_plan; - const finalPlan = JSON.parse(await Zotero.File.getContentsAsync(finalPlanPath)); - this.notify( - `Pipeline completed. ${summary.counts.final_annotations || 0} final annotations ready.`, - true - ); - - const decision = this.confirmImport(summary); - if (decision === "review") { - this.revealFile(summary.outputs.mismatch_review); - return; - } - if (decision !== "import") { - return; - } - - if (progressWindow) { - progressWindow.changeHeadline("Kindle Zotero Importer: writing annotations"); - } - const results = await this.writeAnnotations(finalPlan, false); - this.notify( - `Import finished. Created ${results.created}; skipped ${results.skippedExisting}; updated order ${results.updatedSortIndex}; recreated ${results.recreatedForSortIndex}; failed ${results.failed.length}.`, - results.failed.length === 0 - ); - this.alert("Kindle Zotero Importer", this.formatWriterResults(results)); - } catch (error) { - Zotero.logError(error); - this.notify("Import failed. See the error dialog for details.", false); - this.alert("Kindle Zotero Importer Failed", String(error && error.stack ? error.stack : error)); - } finally { - if (progressWindow && progressWindow.startCloseTimer) { - progressWindow.startCloseTimer(1000); - } - } - }, - async pickFile(title, filter) { try { const pickerModule = ChromeUtils.importESModule( @@ -717,33 +350,6 @@ var KindleZoteroImporter = { } }, - async pickDirectory(title) { - try { - const pickerModule = ChromeUtils.importESModule( - "chrome://zotero/content/modules/filePicker.mjs" - ); - const FilePicker = pickerModule.FilePicker; - if (typeof FilePicker !== "function") { - throw new Error(`Zotero FilePicker module did not export a constructor: ${Object.keys(pickerModule)}`); - } - const fp = new FilePicker(); - fp.init(this.getPickerWindow(), title, fp.modeGetFolder); - - const result = await fp.show(); - if (result !== fp.returnOK) { - return null; - } - return fp.file; - } catch (error) { - Zotero.logError(error); - return this.promptForPath( - "Kindle Zotero Importer", - "Folder picker failed. Enter the full project directory path:", - this.defaultProjectDir - ); - } - }, - async runPipeline(clippingsPath, settings, isFull = false) { const python = settings.pythonPath; const projectDir = settings.projectDir; diff --git a/plugin/manager.html b/plugin/manager.html index 74fc276..d0f494c 100644 --- a/plugin/manager.html +++ b/plugin/manager.html @@ -4,26 +4,54 @@