├── .gitattributes ├── addon ├── chrome │ └── content │ │ ├── zoteroPane.css │ │ ├── icons │ │ ├── favicon.png │ │ └── favicon@0.5x.png │ │ └── preferences.xhtml ├── prefs.js ├── locale │ ├── zh-CN │ │ ├── mainWindow.ftl │ │ ├── preferences.ftl │ │ └── addon.ftl │ └── en-US │ │ ├── mainWindow.ftl │ │ ├── preferences.ftl │ │ └── addon.ftl ├── manifest.json └── bootstrap.js ├── doc ├── Pane.jpg └── README-zhCN.md ├── .prettierignore ├── .gitignore ├── .vscode ├── extensions.json ├── settings.json ├── launch.json └── toolkit.code-snippets ├── jest.config.js ├── src ├── modules │ ├── zoteroUtils.ts │ ├── category.ts │ ├── constants.ts │ ├── prefs.ts │ ├── column.ts │ ├── categorialTag.ts │ ├── message.ts │ ├── pinyin.test.ts │ ├── tagFilter.ts │ ├── tagDialogData.ts │ ├── preferenceScript.ts │ ├── manager.ts │ ├── shortcuts.ts │ └── tagDialogUI.ts ├── utils │ ├── window.ts │ ├── logger.ts │ ├── prefs.ts │ ├── ztoolkit.ts │ ├── wait.ts │ └── locale.ts ├── index.ts ├── addon.ts └── hooks.ts ├── tsconfig.json ├── .github ├── dependabot.yml ├── renovate.json └── workflows │ └── release.yml ├── typings └── global.d.ts ├── eslint.config.mjs ├── .env.example ├── zotero-plugin.config.ts ├── package.json ├── combine.mjs ├── README.md └── LICENSE /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf -------------------------------------------------------------------------------- /addon/chrome/content/zoteroPane.css: -------------------------------------------------------------------------------- 1 | .makeItRed { 2 | background-color: tomato; 3 | } 4 | -------------------------------------------------------------------------------- /doc/Pane.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panhaoyu/zotero-categorial-tags/HEAD/doc/Pane.jpg -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | build 3 | logs 4 | node_modules 5 | package-lock.json 6 | yarn.lock 7 | pnpm-lock.yaml 8 | # zotero-cmd.json 9 | -------------------------------------------------------------------------------- /addon/chrome/content/icons/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panhaoyu/zotero-categorial-tags/HEAD/addon/chrome/content/icons/favicon.png -------------------------------------------------------------------------------- /addon/prefs.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | pref("__prefsPrefix__.enable", true); 3 | pref("__prefsPrefix__.input", "This is input"); 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | logs 3 | node_modules 4 | pnpm-lock.yaml 5 | yarn.lock 6 | zotero-cmd.json 7 | .DS_Store 8 | .env 9 | /.idea 10 | /data -------------------------------------------------------------------------------- /addon/chrome/content/icons/favicon@0.5x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panhaoyu/zotero-categorial-tags/HEAD/addon/chrome/content/icons/favicon@0.5x.png -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "esbenp.prettier-vscode", 5 | "macabeus.vscode-fluent" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnType": false, 3 | "editor.formatOnSave": true, 4 | "editor.codeActionsOnSave": { 5 | "source.fixAll.eslint": "explicit" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} **/ 2 | module.exports = { 3 | testEnvironment: "node", 4 | transform: { 5 | "^.+\.tsx?$": ["ts-jest",{}], 6 | }, 7 | }; -------------------------------------------------------------------------------- /src/modules/zoteroUtils.ts: -------------------------------------------------------------------------------- 1 | export function getItemTags(item: Zotero.Item): { tag: string; type: number }[] { 2 | // See https://github.com/panhaoyu/zotero-categorial-tags/issues/44 3 | if (!item.getTags) return []; 4 | 5 | return item.getTags(); 6 | } -------------------------------------------------------------------------------- /src/utils/window.ts: -------------------------------------------------------------------------------- 1 | export { isWindowAlive }; 2 | 3 | /** 4 | * Check if the window is alive. 5 | * Useful to prevent opening duplicate windows. 6 | * @param win 7 | */ 8 | function isWindowAlive(win?: Window) { 9 | return win && !Components.utils.isDeadWrapper(win) && !win.closed; 10 | } 11 | -------------------------------------------------------------------------------- /addon/locale/zh-CN/mainWindow.ftl: -------------------------------------------------------------------------------- 1 | item-section-example1-head-text = 2 | .label = 插件模板: 条目信息 3 | item-section-example1-sidenav-tooltip = 4 | .tooltiptext = 这是插件模板面板(条目信息) 5 | item-section-example2-head-text = 6 | .label = 插件模板: 阅读器[{$status}] 7 | item-section-example2-sidenav-tooltip = 8 | .tooltiptext = 这是插件模板面板(阅读器) 9 | item-section-example2-button-tooltip = 10 | .tooltiptext = 移除此面板 11 | -------------------------------------------------------------------------------- /src/modules/category.ts: -------------------------------------------------------------------------------- 1 | import { CategorialTag } from "./categorialTag"; 2 | 3 | export class Category { 4 | readonly name: string; 5 | readonly tags: CategorialTag[]; 6 | readonly itemCount: number; 7 | 8 | constructor(name: string, tags: CategorialTag[]) { 9 | tags = tags.sort((i, j) => j.itemCount - i.itemCount); 10 | this.name = name; 11 | this.tags = tags; 12 | this.itemCount = this.tags.map(i => i.itemCount).reduce((i, j) => i + j, 0); 13 | } 14 | } -------------------------------------------------------------------------------- /src/modules/constants.ts: -------------------------------------------------------------------------------- 1 | import { config } from "../../package.json"; 2 | 3 | export const PrefDefault = { 4 | shortcut: "Ctrl+T" 5 | }; 6 | export const PrefKey = { 7 | shortcut: "shortcut" 8 | }; 9 | export const ElementID = { 10 | shortcutKeyInput: `#zotero-prefpane-${config.addonRef}-open-shortcut-key-input`, 11 | captureShortcutButton: `#zotero-prefpane-${config.addonRef}-capture-shortcut-button` 12 | }; 13 | export const CommandKey = { 14 | openTagTab: "open-tag-tab" 15 | }; -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true, 4 | "module": "commonjs", 5 | "target": "ES2016", 6 | "resolveJsonModule": true, 7 | "skipLibCheck": true, 8 | "strict": true, 9 | "allowSyntheticDefaultImports": true, 10 | "esModuleInterop": true 11 | }, 12 | "include": [ 13 | "src", 14 | "typings", 15 | "node_modules/zotero-types" 16 | ], 17 | "exclude": [ 18 | "build", 19 | "addon" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /addon/locale/en-US/mainWindow.ftl: -------------------------------------------------------------------------------- 1 | item-section-example1-head-text = 2 | .label = Plugin Template: Item Info 3 | item-section-example1-sidenav-tooltip = 4 | .tooltiptext = This is Plugin Template section (item info) 5 | item-section-example2-head-text = 6 | .label = Plugin Template: Reader [{$status}] 7 | item-section-example2-sidenav-tooltip = 8 | .tooltiptext = This is Plugin Template section (reader) 9 | item-section-example2-button-tooltip = 10 | .tooltiptext = Unregister this section 11 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /addon/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "__addonName__", 4 | "version": "__buildVersion__", 5 | "description": "__description__", 6 | "homepage_url": "__homepage__", 7 | "author": "__author__", 8 | "icons": { 9 | "48": "chrome/content/icons/favicon@0.5x.png", 10 | "96": "chrome/content/icons/favicon.png" 11 | }, 12 | "applications": { 13 | "zotero": { 14 | "id": "__addonID__", 15 | "update_url": "__updateURL__", 16 | "strict_min_version": "6.999", 17 | "strict_max_version": "8.*" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Start", 11 | "runtimeExecutable": "npm", 12 | "runtimeArgs": ["run", "start"] 13 | }, 14 | { 15 | "type": "node", 16 | "request": "launch", 17 | "name": "Build", 18 | "runtimeExecutable": "npm", 19 | "runtimeArgs": ["run", "build"] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /addon/locale/zh-CN/preferences.ftl: -------------------------------------------------------------------------------- 1 | pref-help = { $name } Build { $version } { $time } 2 | 3 | pref-dialog-open-shortcut-key-label = 对话框打开快捷键 4 | 5 | pref-dialog-open-shortcut-key-description = 为打开对话框提供键盘快捷键设置。
6 | 支持的快捷键包括:
7 | - 功能键(例如 F1、F2)
8 | - 修饰键组合(例如 Ctrl+Alt+D)

9 | 10 | 格式:修饰键+按键(例如 Ctrl+Shift+K)
11 | 修饰键:Ctrl、Alt、Shift、Meta(macOS 上为 Command)

12 | 13 | 注意:目前仅全面测试了 Ctrl 修饰键
14 | 其他修饰键可能无法按预期工作
15 | 配置后请重启 Zotero 16 | 17 | pref-dialog-capture-shortcut-label = 捕获快捷键 18 | pref-dialog-capture-shortcut-button = 捕获 -------------------------------------------------------------------------------- /src/modules/prefs.ts: -------------------------------------------------------------------------------- 1 | import { config } from "../../package.json"; 2 | import { getString } from "../utils/locale"; 3 | 4 | class PreferencesManager { 5 | async register() { 6 | const prefOptions = { 7 | pluginID: config.addonID, 8 | src: rootURI + "chrome/content/preferences.xhtml", 9 | label: getString("prefs-title"), 10 | image: `chrome://${config.addonRef}/content/icons/favicon.png`, 11 | defaultXUL: true 12 | }; 13 | await Zotero.PreferencePanes.register(prefOptions); 14 | } 15 | } 16 | 17 | export const preferenceManager = new PreferencesManager(); -------------------------------------------------------------------------------- /src/utils/logger.ts: -------------------------------------------------------------------------------- 1 | class Logger { 2 | private readonly console: Console; 3 | 4 | constructor() { 5 | this.console = Zotero.getMainWindow()?.console; 6 | } 7 | 8 | debug(message: string) { 9 | this.console.debug(message); 10 | } 11 | 12 | info(message: string) { 13 | this.console.info(message); 14 | } 15 | 16 | warn(message: string) { 17 | this.console.warn(message); 18 | } 19 | 20 | error(message: string) { 21 | this.console.error(message); 22 | } 23 | 24 | log(message: string) { 25 | this.console.log(message); 26 | } 27 | } 28 | 29 | export const logger = new Logger(); -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended", 5 | ":semanticPrefixChore", 6 | ":prHourlyLimitNone", 7 | ":prConcurrentLimitNone", 8 | ":enableVulnerabilityAlerts", 9 | ":dependencyDashboard", 10 | "group:allNonMajor", 11 | "schedule:weekly" 12 | ], 13 | "labels": ["dependencies"], 14 | "packageRules": [ 15 | { 16 | "matchPackageNames": [ 17 | "zotero-plugin-toolkit", 18 | "zotero-types", 19 | "zotero-plugin-scaffold" 20 | ], 21 | "schedule": ["at any time"], 22 | "automerge": true 23 | } 24 | ], 25 | "git-submodules": { 26 | "enabled": true 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/modules/column.ts: -------------------------------------------------------------------------------- 1 | import { tagManager } from "./manager"; 2 | import { config } from "../../package.json"; 3 | import { getString } from "../utils/locale"; 4 | 5 | export class ColumnManager { 6 | 7 | 8 | async register() { 9 | // Initialize the Manager by updating its cache 10 | Zotero.ItemTreeManager.registerColumns({ 11 | pluginID: config.addonID, 12 | dataKey: "categorial-tags", 13 | label: getString("categorial-tags-column-name"), 14 | dataProvider: (item: Zotero.Item, dataKey: string) => { 15 | return tagManager 16 | .getTagsOfItem(item) 17 | .map(i => i.tagName) 18 | .join(" "); 19 | } 20 | }); 21 | } 22 | } 23 | 24 | export const columnManager = new ColumnManager(); -------------------------------------------------------------------------------- /typings/global.d.ts: -------------------------------------------------------------------------------- 1 | import { ZoteroToolkit } from "zotero-plugin-toolkit"; 2 | import AddonClass from "../src/addon"; 3 | 4 | declare global { 5 | const _globalThis: { 6 | [key: string]: any; 7 | Zotero: _ZoteroTypes.Zotero; 8 | ZoteroPane: _ZoteroTypes.ZoteroPane; 9 | Zotero_Tabs: typeof Zotero_Tabs; 10 | window: Window; 11 | document: Document; 12 | ztoolkit: CustomZoteroToolkit; 13 | addon: AddonClass; 14 | }; 15 | 16 | const addon: AddonClass; 17 | 18 | class CustomZoteroToolkit extends ZoteroToolkit { 19 | log(...message: any[]); 20 | } 21 | 22 | const ztoolkit: CustomZoteroToolkit; 23 | 24 | const rootURI: string; 25 | 26 | const addon: Addon; 27 | 28 | const __env__: "production" | "development"; 29 | 30 | class Localization { 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /addon/locale/zh-CN/addon.ftl: -------------------------------------------------------------------------------- 1 | startup-begin = 插件加载中 2 | startup-finish = 插件已就绪 3 | menuitem-label = 插件模板: 帮助工具样例 4 | menupopup-label = 插件模板: 弹出菜单 5 | menuitem-submenulabel = 插件模板:子菜单 6 | menuitem-filemenulabel = 插件模板: 文件菜单 7 | prefs-title = 分类标签 8 | prefs-table-title = 标题 9 | prefs-table-detail = 详情 10 | tabpanel-lib-tab-label = 库标签 11 | tabpanel-reader-tab-label = 阅读器标签 12 | categorial-tags-column-name = 分类标签 13 | categorial-tags-selection-titles = 14 | { $length -> 15 | [1] 选中的 1 个条目 16 | *[other] 选中的 { $length } 个条目 17 | } 18 | categorial-tags-dialog-title = 调整条目标签:{ $selectionTitles } 19 | categorial-tags-no-selection-hint = 未选择条目。请选择至少一个条目以修改标签。 20 | categorial-tags-dialog-title-info = 来自于分类标签的信息 21 | categorial-tags-dialog-title-warning = 来自于分类标签的提醒 22 | categorial-tags-dialog-title-error = 来自于分类标签的报错 23 | -------------------------------------------------------------------------------- /addon/locale/en-US/preferences.ftl: -------------------------------------------------------------------------------- 1 | pref-help = { $name } Build { $version } { $time } 2 | 3 | pref-dialog-open-shortcut-key-label = Dialog Open Shortcut Key 4 | 5 | pref-dialog-open-shortcut-key-description = Provides a keyboard shortcut to open the dialog.
6 | Supported shortcuts include:
7 | - Function keys (e.g. F1, F2)
8 | - Modifier key combinations (e.g. Ctrl+Alt+D)

9 | 10 | Format: Modifier+Key (e.g. Ctrl+Shift+K).
11 | Modifiers: Ctrl, Alt, Shift, Meta (Command on macOS).

12 | 13 | Note: Currently only Ctrl modifier has been thoroughly tested.
14 | Other modifiers may not work as expected.
15 | Please restart Zotero after configuration. 16 | 17 | pref-dialog-capture-shortcut-label = Capture Shortcut 18 | pref-dialog-capture-shortcut-button = Capture 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/utils/prefs.ts: -------------------------------------------------------------------------------- 1 | import { config } from "../../package.json"; 2 | 3 | /** 4 | * Get preference value. 5 | * Wrapper of `Zotero.Prefs.get`. 6 | * @param key 7 | */ 8 | export function getPref(key: string) { 9 | return Zotero.Prefs.get(`${config.prefsPrefix}.${key}`, true) as T; 10 | } 11 | 12 | /** 13 | * Set preference value. 14 | * Wrapper of `Zotero.Prefs.set`. 15 | * @param key 16 | * @param value 17 | */ 18 | export function setPref(key: string, value: string | number | boolean) { 19 | return Zotero.Prefs.set(`${config.prefsPrefix}.${key}`, value, true); 20 | } 21 | 22 | /** 23 | * Clear preference value. 24 | * Wrapper of `Zotero.Prefs.clear`. 25 | * @param key 26 | */ 27 | export function clearPref(key: string) { 28 | return Zotero.Prefs.clear(`${config.prefsPrefix}.${key}`, true); 29 | } 30 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { BasicTool } from "zotero-plugin-toolkit"; 2 | import Addon from "./addon"; 3 | import { config } from "../package.json"; 4 | 5 | const basicTool = new BasicTool(); 6 | 7 | if (!basicTool.getGlobal("Zotero")[config.addonInstance]) { 8 | defineGlobal("window"); 9 | defineGlobal("document"); 10 | defineGlobal("ZoteroPane"); 11 | defineGlobal("Zotero_Tabs"); 12 | _globalThis.addon = new Addon(); 13 | defineGlobal("ztoolkit", () => { 14 | return _globalThis.addon.data.ztoolkit; 15 | }); 16 | Zotero[config.addonInstance] = addon; 17 | } 18 | 19 | function defineGlobal(name: Parameters[0]): void; 20 | function defineGlobal(name: string, getter: () => any): void; 21 | function defineGlobal(name: string, getter?: () => any) { 22 | Object.defineProperty(_globalThis, name, { 23 | get() { 24 | return getter ? getter() : basicTool.getGlobal(name); 25 | } 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /src/addon.ts: -------------------------------------------------------------------------------- 1 | import { DialogHelper } from "zotero-plugin-toolkit"; 2 | import hooks from "./hooks"; 3 | import { createZToolkit } from "./utils/ztoolkit"; 4 | 5 | type Environment = "development" | "production"; 6 | 7 | interface Locale { 8 | current: Localization; 9 | } 10 | 11 | interface Prefs { 12 | window?: Window; 13 | } 14 | 15 | interface Data { 16 | alive: boolean; 17 | env: Environment; 18 | ztoolkit: CustomZoteroToolkit; 19 | locale?: Locale; 20 | prefs: Prefs; 21 | dialog?: DialogHelper; 22 | } 23 | 24 | export default class Addon { 25 | public data: Data; 26 | public hooks: typeof hooks; 27 | public api: Record; 28 | 29 | constructor() { 30 | this.data = this.initializeData(); 31 | this.hooks = hooks; 32 | this.api = {}; 33 | } 34 | 35 | private initializeData(): Data { 36 | return { 37 | alive: true, 38 | env: __env__, 39 | ztoolkit: createZToolkit(), 40 | prefs: {} 41 | }; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check Let TS check this config file 2 | 3 | import eslint from "@eslint/js"; 4 | import tseslint from "typescript-eslint"; 5 | 6 | export default tseslint.config( 7 | { 8 | ignores: ["build/**", "dist/**", "node_modules/**", "scripts/"], 9 | }, 10 | { 11 | extends: [eslint.configs.recommended, ...tseslint.configs.recommended], 12 | rules: { 13 | "@typescript-eslint/ban-ts-comment": [ 14 | "warn", 15 | { 16 | "ts-expect-error": "allow-with-description", 17 | "ts-ignore": "allow-with-description", 18 | "ts-nocheck": "allow-with-description", 19 | "ts-check": "allow-with-description", 20 | }, 21 | ], 22 | "@typescript-eslint/no-unused-vars": "off", 23 | "@typescript-eslint/no-explicit-any": [ 24 | "off", 25 | { 26 | ignoreRestArgs: true, 27 | }, 28 | ], 29 | "@typescript-eslint/no-non-null-assertion": "off", 30 | }, 31 | }, 32 | ); 33 | -------------------------------------------------------------------------------- /addon/locale/en-US/addon.ftl: -------------------------------------------------------------------------------- 1 | startup-begin = Addon is loading 2 | startup-finish = Addon is ready 3 | menuitem-label = Addon Template: Helper Examples 4 | menupopup-label = Addon Template: Menupopup 5 | menuitem-submenulabel = Addon Template 6 | menuitem-filemenulabel = Addon Template: File Menuitem 7 | prefs-title = Categorial Tags 8 | prefs-table-title = Title 9 | prefs-table-detail = Detail 10 | tabpanel-lib-tab-label = Lib Tab 11 | tabpanel-reader-tab-label = Reader Tab 12 | categorial-tags-column-name = Categorial Tags 13 | categorial-tags-selection-titles = 14 | { $length -> 15 | [1] Selected one item 16 | *[other] Selected { $length } items 17 | } 18 | categorial-tags-dialog-title = Change item tags: { $selectionTitles } 19 | categorial-tags-no-selection-hint = No items selected. Please select at least one item to modify tags. 20 | categorial-tags-dialog-title-info = Categorial Tags Information 21 | categorial-tags-dialog-title-warning = Categorial Tags Warning 22 | categorial-tags-dialog-title-error = Categorial Tags Error 23 | -------------------------------------------------------------------------------- /addon/chrome/content/preferences.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /src/modules/categorialTag.ts: -------------------------------------------------------------------------------- 1 | type TagJson = _ZoteroTypes.Tags.TagJson; 2 | 3 | export class CategorialTag { 4 | readonly categoryName: string; 5 | readonly fullName: string; 6 | readonly tagName: string; 7 | readonly tagJson: TagJson; 8 | readonly itemCount: number; 9 | readonly items: Zotero.Item[]; 10 | readonly uniqueElementId: string; 11 | readonly tagId: number; 12 | 13 | constructor(tagId: number, tagJson: TagJson, items: Zotero.Item[]) { 14 | this.tagId = tagId; 15 | this.fullName = tagJson.tag; 16 | this.uniqueElementId = `categorial-tag-${tagId}`; 17 | this.tagJson = tagJson; 18 | this.items = items; 19 | this.itemCount = items.length; 20 | 21 | // Validate that the tag name starts with "#" 22 | const tagName = tagJson.tag; 23 | if (tagName[0] !== "#") { 24 | throw new Error("Tag name must start with '#'"); 25 | } 26 | 27 | // Process tagName to extract categoryName and tagNamePart 28 | const removePrefix = tagName.slice(1); 29 | const [categoryName, tagNamePart] = removePrefix.split("/", 2); 30 | 31 | this.categoryName = categoryName; 32 | this.tagName = tagNamePart; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # Usage: 2 | # Copy this file as `.env` and fill in the variables below as instructed. 3 | 4 | # If you are developing more than one plugin, you can store the bin path and 5 | # profile path in the system environment variables, which can be omitted here. 6 | 7 | # The path of the Zotero binary file. 8 | # The path delimiter should be escaped as `\\` for win32. 9 | # The path is `*/Zotero.app/Contents/MacOS/zotero` for MacOS. 10 | ZOTERO_PLUGIN_ZOTERO_BIN_PATH = /path/to/zotero.exe 11 | 12 | # The path of the profile used for development. 13 | # Start the profile manager by `/path/to/zotero.exe -p` to create a profile for development. 14 | # @see https://www.zotero.org/support/kb/profile_directory 15 | ZOTERO_PLUGIN_PROFILE_PATH = /path/to/profile 16 | 17 | # The directory where the database is located. 18 | # If this field is kept empty, Zotero will start with the default data. 19 | # @see https://www.zotero.org/support/zotero_data 20 | ZOTERO_PLUGIN_DATA_DIR = 21 | 22 | # Custom commands to kill Zotero processes. 23 | # Commands for different platforms are already built into zotero-plugin, 24 | # if the built-in commands are not suitable for your needs, please modify this variable. 25 | # ZOTERO_PLUGIN_KILL_COMMAND = 26 | 27 | # GitHub Token 28 | # For release-it auto create release and upload assets 29 | # GITHUB_TOKEN = -------------------------------------------------------------------------------- /src/utils/ztoolkit.ts: -------------------------------------------------------------------------------- 1 | import { config } from "../../package.json"; 2 | import { BasicTool, ZoteroToolkit } from "zotero-plugin-toolkit"; 3 | 4 | BasicTool.prototype.log = (...message: any[]) => { 5 | }; 6 | 7 | export { createZToolkit }; 8 | 9 | function createZToolkit(): CustomZoteroToolkit { 10 | const _ztoolkit = new ZoteroToolkit() as CustomZoteroToolkit; 11 | /** 12 | * Alternatively, import toolkit modules you use to minify the plugin size. 13 | * You can add the modules under the `MyToolkit` class below and uncomment the following line. 14 | */ 15 | // const _ztoolkit = new MyToolkit(); 16 | initZToolkit(_ztoolkit); 17 | return _ztoolkit; 18 | } 19 | 20 | function initZToolkit(_ztoolkit: ReturnType) { 21 | const env = __env__; 22 | _ztoolkit.basicOptions.log.prefix = `[${config.addonName}]`; 23 | _ztoolkit.basicOptions.log.disableConsole = env === "production"; 24 | _ztoolkit.UI.basicOptions.ui.enableElementJSONLog = __env__ === "development"; 25 | _ztoolkit.UI.basicOptions.ui.enableElementDOMLog = __env__ === "development"; 26 | _ztoolkit.basicOptions.debug.disableDebugBridgePassword = 27 | __env__ === "development"; 28 | _ztoolkit.basicOptions.api.pluginID = config.addonID; 29 | _ztoolkit.ProgressWindow.setIconURI( 30 | "default", 31 | `chrome://${config.addonRef}/content/icons/favicon.png` 32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /src/utils/wait.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Wait until the condition is `true` or timeout. 3 | * The callback is triggered if condition returns `true`. 4 | * @param condition 5 | * @param callback 6 | * @param interval 7 | * @param timeout 8 | */ 9 | export function waitUntil( 10 | condition: () => boolean, 11 | callback: () => void, 12 | interval = 100, 13 | timeout = 10000 14 | ) { 15 | const start = Date.now(); 16 | const intervalId = ztoolkit.getGlobal("setInterval")(() => { 17 | if (condition()) { 18 | ztoolkit.getGlobal("clearInterval")(intervalId); 19 | callback(); 20 | } else if (Date.now() - start > timeout) { 21 | ztoolkit.getGlobal("clearInterval")(intervalId); 22 | } 23 | }, interval); 24 | } 25 | 26 | /** 27 | * Wait async until the condition is `true` or timeout. 28 | * @param condition 29 | * @param interval 30 | * @param timeout 31 | */ 32 | export function waitUtilAsync( 33 | condition: () => boolean, 34 | interval = 100, 35 | timeout = 10000 36 | ) { 37 | return new Promise((resolve, reject) => { 38 | const start = Date.now(); 39 | const intervalId = ztoolkit.getGlobal("setInterval")(() => { 40 | if (condition()) { 41 | ztoolkit.getGlobal("clearInterval")(intervalId); 42 | resolve(); 43 | } else if (Date.now() - start > timeout) { 44 | ztoolkit.getGlobal("clearInterval")(intervalId); 45 | reject(); 46 | } 47 | }, interval); 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - v** 7 | 8 | permissions: 9 | contents: write 10 | issues: write 11 | pull-requests: write 12 | 13 | jobs: 14 | release: 15 | runs-on: ubuntu-latest 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GitHub_TOKEN }} 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v4 21 | with: 22 | fetch-depth: 0 23 | 24 | - name: Setup Node.js 25 | uses: actions/setup-node@v4 26 | with: 27 | node-version: 20 28 | 29 | - name: Install deps 30 | run: npm install -f 31 | 32 | - name: Build 33 | run: | 34 | npm run build 35 | 36 | - name: Release to GitHub 37 | run: | 38 | npm run release 39 | # cp build/update.json update.json 40 | # cp build/update-beta.json update-beta.json 41 | # git add update.json 42 | # git add update-beta.json 43 | # git commit -m 'chore(publish): synchronizing `update.json`' 44 | # git push 45 | sleep 1s 46 | 47 | - name: Notify release 48 | uses: apexskier/github-release-commenter@v1 49 | continue-on-error: true 50 | with: 51 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 52 | comment-template: | 53 | :rocket: _This ticket has been resolved in {release_tag}. See {release_link} for release notes._ 54 | -------------------------------------------------------------------------------- /.vscode/toolkit.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "appendElement - full": { 3 | "scope": "javascript,typescript", 4 | "prefix": "appendElement", 5 | "body": [ 6 | "appendElement({", 7 | "\ttag: '${1:div}',", 8 | "\tid: '${2:id}',", 9 | "\tnamespace: '${3:html}',", 10 | "\tclassList: ['${4:class}'],", 11 | "\tstyles: {${5:style}: '$6'},", 12 | "\tproperties: {},", 13 | "\tattributes: {},", 14 | "\t[{ '${7:onload}', (e: Event) => $8, ${9:false} }],", 15 | "\tcheckExistanceParent: ${10:HTMLElement},", 16 | "\tignoreIfExists: ${11:true},", 17 | "\tskipIfExists: ${12:true},", 18 | "\tremoveIfExists: ${13:true},", 19 | "\tcustomCheck: (doc: Document, options: ElementOptions) => ${14:true},", 20 | "\tchildren: [$15]", 21 | "}, ${16:container});" 22 | ] 23 | }, 24 | "appendElement - minimum": { 25 | "scope": "javascript,typescript", 26 | "prefix": "appendElement", 27 | "body": "appendElement({ tag: '$1' }, $2);" 28 | }, 29 | "register Notifier": { 30 | "scope": "javascript,typescript", 31 | "prefix": "registerObserver", 32 | "body": [ 33 | "registerObserver({", 34 | "\t notify: (", 35 | "\t\tevent: _ZoteroTypes.Notifier.Event,", 36 | "\t\ttype: _ZoteroTypes.Notifier.Type,", 37 | "\t\tids: string[],", 38 | "\t\textraData: _ZoteroTypes.anyObj", 39 | "\t) => {", 40 | "\t\t$0", 41 | "\t}", 42 | "});" 43 | ] 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/modules/message.ts: -------------------------------------------------------------------------------- 1 | import { getString } from "../utils/locale"; 2 | 3 | enum MessageType { 4 | Info = "info", 5 | Warning = "warning", 6 | Error = "error" 7 | } 8 | 9 | export default class Message { 10 | static info(message: string) { 11 | this.showMessage(message, MessageType.Info); 12 | } 13 | 14 | static warning(message: string) { 15 | this.showMessage(message, MessageType.Warning); 16 | } 17 | 18 | static error(message: string) { 19 | this.showMessage(message, MessageType.Error); 20 | } 21 | 22 | private static showMessage(message: string, type: MessageType) { 23 | switch (type) { 24 | case MessageType.Error: 25 | message = `${message}
Please open an issue on GitHub.`; 26 | break; 27 | default: 28 | break; 29 | } 30 | 31 | const dialog = new ztoolkit.Dialog(1, 1); 32 | dialog.addCell(0, 0, { 33 | tag: "span", 34 | properties: { 35 | innerHTML: message 36 | } 37 | }); 38 | 39 | let titleKey: string; 40 | switch (type) { 41 | case MessageType.Warning: 42 | titleKey = "categorial-tags-dialog-title-warning"; 43 | break; 44 | case MessageType.Error: 45 | titleKey = "categorial-tags-dialog-title-error"; 46 | break; 47 | default: 48 | titleKey = "categorial-tags-dialog-title-info"; 49 | break; 50 | } 51 | 52 | const title = getString(titleKey); 53 | dialog.open(title); 54 | dialog.addButton("OK"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/modules/pinyin.test.ts: -------------------------------------------------------------------------------- 1 | import { TagFilter } from "./tagFilter"; 2 | 3 | describe("TagFilter", () => { 4 | const testTags = [ 5 | "重庆", "长城", "乐清", "朝阳区", "银行", "中兴区", 6 | "长兴县", "厦门", "西藏", "朝阳", "乐山", "重庆市" 7 | ]; 8 | const tagFilter = new TagFilter(testTags); 9 | 10 | test("应匹配基础拼音", () => { 11 | expect(tagFilter.filterTags("chongqing").sort()).toEqual(["重庆", "重庆市"].sort()); 12 | expect(tagFilter.filterTags("zhangcheng").sort()).toEqual(["长城"].sort()); 13 | }); 14 | 15 | test("应支持多音字不同组合", () => { 16 | expect(tagFilter.filterTags("zhongqing")).toEqual(["重庆", "重庆市"]); 17 | expect(tagFilter.filterTags("chaoyangqu")).toEqual(["朝阳区"]); 18 | }); 19 | 20 | test("应匹配原始标签名", () => { 21 | expect(tagFilter.filterTags("朝阳区")).toEqual(["朝阳区"]); 22 | }); 23 | 24 | test("应支持模糊搜索", () => { 25 | expect(tagFilter.filterTags("chq").sort()).toEqual(["重庆", "重庆市", "朝阳区"].sort()); 26 | expect(tagFilter.filterTags("cyq")).toEqual(["朝阳区"]); 27 | }); 28 | 29 | test("应处理多音字组合匹配", () => { 30 | expect([...tagFilter.filterTags("leqing"), ...tagFilter.filterTags("yueqing")]).toContain("乐清"); 31 | }); 32 | 33 | test("应返回空数组当输入为空", () => { 34 | expect(tagFilter.filterTags("")).toEqual([]); 35 | }); 36 | 37 | test("应返回空数组当无匹配项", () => { 38 | expect(tagFilter.filterTags("nonexistent")).toEqual([]); 39 | }); 40 | 41 | test("应支持大小写不敏感", () => { 42 | expect(tagFilter.filterTags("CHONGQING").sort()).toEqual(["重庆", "重庆市"].sort()); 43 | expect(tagFilter.filterTags("zhangCHENG").sort()).toEqual(["长城"].sort()); 44 | }); 45 | 46 | test("应支持多音字交叉匹配", () => { 47 | expect(tagFilter.filterTags("zhaoyang")).toEqual(["朝阳区", "朝阳"]); 48 | expect(tagFilter.filterTags("qing").sort()).toEqual(["重庆", "乐清", "重庆市"].sort()); 49 | }); 50 | }); -------------------------------------------------------------------------------- /src/modules/tagFilter.ts: -------------------------------------------------------------------------------- 1 | import pinyin from "pinyin"; 2 | import FuzzySearch from "fuzzy-search"; 3 | 4 | interface TagWithPinyin { 5 | tag: string; 6 | pinyin: string; 7 | } 8 | 9 | export class TagFilter { 10 | private readonly tagsWithPinyin: TagWithPinyin[]; 11 | private readonly searcher: FuzzySearch; 12 | 13 | constructor(tags: string[]) { 14 | this.tagsWithPinyin = tags.flatMap(tag => { 15 | const pinyinArrays = pinyin(tag, { 16 | style: pinyin.STYLE_NORMAL, 17 | heteronym: true 18 | }); 19 | return this.generateCombinations(pinyinArrays).map(p => ({ 20 | tag, 21 | pinyin: `${p.full} ${p.initials}` 22 | })); 23 | }); 24 | this.searcher = new FuzzySearch(this.tagsWithPinyin, ["pinyin", "tag"], { 25 | caseSensitive: false, 26 | sort: true 27 | }); 28 | } 29 | 30 | private generateCombinations(pinyinArrays: string[][]): Array<{ full: string, initials: string }> { 31 | let combinations = [{ full: "", initials: "" }]; 32 | for (const chars of pinyinArrays) { 33 | const newCombinations = []; 34 | for (const combo of combinations) { 35 | for (const char of chars) { 36 | newCombinations.push({ 37 | full: combo.full + char, 38 | initials: combo.initials + char[0] 39 | }); 40 | } 41 | } 42 | combinations = newCombinations; 43 | } 44 | return combinations; 45 | } 46 | 47 | public filterTags(input: string): string[] { 48 | if (!input) return []; 49 | const seen = new Set(); 50 | const results = this.searcher.search(input); 51 | return results.reduce((acc, { tag }) => { 52 | if (!seen.has(tag)) { 53 | seen.add(tag); 54 | acc.push(tag); 55 | } 56 | return acc; 57 | }, []); 58 | } 59 | } -------------------------------------------------------------------------------- /zotero-plugin.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "zotero-plugin-scaffold"; 2 | import pkg from "./package.json"; 3 | import { copyFileSync } from "fs"; 4 | 5 | export default defineConfig({ 6 | source: ["src", "addon"], 7 | dist: "build", 8 | name: pkg.config.addonName, 9 | id: pkg.config.addonID, 10 | namespace: pkg.config.addonRef, 11 | updateURL: `https://github.com/{{owner}}/{{repo}}/releases/download/release/${ 12 | pkg.version.includes("-") ? "update-beta.json" : "update.json" 13 | }`, 14 | xpiDownloadLink: 15 | "https://github.com/{{owner}}/{{repo}}/releases/download/v{{version}}/{{xpiName}}.xpi", 16 | 17 | server: { 18 | asProxy: true, 19 | }, 20 | 21 | build: { 22 | assets: ["addon/**/*.*"], 23 | define: { 24 | ...pkg.config, 25 | author: pkg.author, 26 | description: pkg.description, 27 | homepage: pkg.homepage, 28 | buildVersion: pkg.version, 29 | buildTime: "{{buildTime}}", 30 | }, 31 | esbuildOptions: [ 32 | { 33 | entryPoints: ["src/index.ts"], 34 | define: { 35 | __env__: `"${process.env.NODE_ENV}"`, 36 | }, 37 | bundle: true, 38 | target: "firefox115", 39 | outfile: `build/addon/chrome/content/scripts/${pkg.config.addonRef}.js`, 40 | }, 41 | ], 42 | // If you want to checkout update.json into the repository, uncomment the following lines: 43 | // makeUpdateJson: { 44 | // hash: false, 45 | // }, 46 | // hooks: { 47 | // "build:makeUpdateJSON": (ctx) => { 48 | // copyFileSync("build/update.json", "update.json"); 49 | // copyFileSync("build/update-beta.json", "update-beta.json"); 50 | // }, 51 | // }, 52 | }, 53 | // release: { 54 | // bumpp: { 55 | // execute: "npm run build", 56 | // }, 57 | // }, 58 | 59 | // If you need to see a more detailed build log, uncomment the following line: 60 | // logLevel: "trace", 61 | }); 62 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zotero-cateogrial-tags", 3 | "version": "0.3.0", 4 | "description": "Manage tags better by categorizing the tags.", 5 | "config": { 6 | "addonName": "Zotero Categorial Tags", 7 | "addonID": "categorialtags@panhaoyu.com", 8 | "addonRef": "categorialtags", 9 | "addonInstance": "CategorialTags", 10 | "prefsPrefix": "extensions.zotero.categorialtags" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/panhaoyu/zotero-categorial-tags.git" 15 | }, 16 | "author": "panhaoyu", 17 | "bugs": { 18 | "url": "https://github.com/panhaoyu/zotero-categorial-tags/issues" 19 | }, 20 | "homepage": "https://github.com/panhaoyu/zotero-categorial-tags#readme", 21 | "license": "AGPL-3.0-or-later", 22 | "scripts": { 23 | "start": "zotero-plugin serve", 24 | "build": "zotero-plugin build", 25 | "lint": "prettier --write . && eslint . --fix", 26 | "release": "zotero-plugin release", 27 | "test": "jest", 28 | "update-deps": "npm update --save" 29 | }, 30 | "dependencies": { 31 | "clipboardy": "^4.0.0", 32 | "fuzzy-search": "^3.2.1", 33 | "glob": "^11.0.0", 34 | "pinyin": "^4.0.0-alpha.2", 35 | "segmentit": "^2.0.3", 36 | "zotero-plugin-toolkit": "^4.1.2" 37 | }, 38 | "devDependencies": { 39 | "@eslint/js": "^9.7.0", 40 | "@types/fuzzy-search": "^2.1.5", 41 | "@types/jest": "^29.5.14", 42 | "@types/node": "^20.14.10", 43 | "@types/pinyin": "^2.10.2", 44 | "eslint": "^9.3.0", 45 | "jest": "^29.7.0", 46 | "prettier": "^3.2.5", 47 | "ts-jest": "^29.2.6", 48 | "typescript": "^5.4.5", 49 | "typescript-eslint": "^8.0.0-alpha.41", 50 | "zotero-plugin-scaffold": "^0.0.26", 51 | "zotero-types": "^3.1.0" 52 | }, 53 | "prettier": { 54 | "printWidth": 80, 55 | "tabWidth": 2, 56 | "endOfLine": "lf", 57 | "overrides": [ 58 | { 59 | "files": [ 60 | "*.xhtml" 61 | ], 62 | "options": { 63 | "htmlWhitespaceSensitivity": "css" 64 | } 65 | } 66 | ] 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /combine.mjs: -------------------------------------------------------------------------------- 1 | // 这个脚本的意义和用法: 2 | // 该脚本的目的是将指定目录中所有相关的 TypeScript (.ts)、CSS (.css)、以及 XHTML (.xhtml) 文件内容进行合并,并将合并后的内容复制到剪贴板中。 3 | // 这样可以方便地将所有实现插件功能的代码片段合并为一个文件,以便于大语言模型的输入或者其他分析用途。 4 | // 用法: 5 | // 1. 确保你已经安装了必要的依赖项,可以通过运行 `yarn add glob clipboardy` 安装。 6 | // 2. 修改 `projectRoot` 为你的项目根目录路径。 7 | // 3. 运行该脚本,所有匹配到的文件内容将被合并,并复制到剪贴板中,供你随时粘贴使用。 8 | 9 | // 安装必要的依赖项: 10 | // yarn add glob clipboardy 11 | 12 | import fs from "fs"; 13 | import path from "path"; 14 | import { sync as globSync } from "glob"; 15 | import clipboardy from "clipboardy"; 16 | 17 | // 项目的根目录 18 | const projectRoot = "F:/projects/zotero-categorial-tags"; 19 | 20 | // 要包含的文件模式 21 | const patterns = [ 22 | "**/*.ts", 23 | "**/*.css", 24 | "**/*.xhtml", 25 | "**/*.ftl" 26 | ]; 27 | 28 | // 要排除的目录 29 | const excludeDirs = [ 30 | "node_modules", 31 | "build", 32 | "data", 33 | "doc", 34 | ".github" 35 | ]; 36 | 37 | // 根据模式获取所有相关文件 38 | function getAllFiles() { 39 | let files = []; 40 | patterns.forEach((pattern) => { 41 | const options = { 42 | cwd: projectRoot, 43 | absolute: true, 44 | ignore: excludeDirs.map((dir) => `${dir}/**`) 45 | }; 46 | files = files.concat(globSync(pattern, options)); 47 | }); 48 | return files; 49 | } 50 | 51 | // 读取所有文件内容并合并 52 | function readAndMergeFiles(files) { 53 | let mergedContent = ""; 54 | files.forEach((file) => { 55 | try { 56 | const content = fs.readFileSync(file, "utf-8"); 57 | mergedContent += `\n\n/* --- File: ${path.relative(projectRoot, file)} --- */\n`; 58 | mergedContent += content; 59 | } catch (err) { 60 | console.error(`Error reading file: ${file}`, err); 61 | } 62 | }); 63 | return mergedContent; 64 | } 65 | 66 | // 主函数 67 | async function main() { 68 | const files = getAllFiles(); 69 | if (files.length === 0) { 70 | console.log("No files found matching the specified patterns."); 71 | return; 72 | } 73 | 74 | const mergedContent = readAndMergeFiles(files); 75 | 76 | // 复制到剪贴板 77 | await clipboardy.write(mergedContent); 78 | console.log("Merged content has been copied to clipboard."); 79 | } 80 | 81 | main(); -------------------------------------------------------------------------------- /doc/README-zhCN.md: -------------------------------------------------------------------------------- 1 | # Zotero Categorial Tags 插件 2 | 3 | [![Using Zotero Plugin Template](https://img.shields.io/badge/Using-Zotero%20Plugin%20Template-blue?style=flat-square&logo=github)](https://github.com/windingwind/zotero-plugin-template) 4 | 5 | ![](Pane.jpg) 6 | 7 | ## 简介 8 | 9 | **Zotero Categorial Tags** 是一款为 Zotero 用户设计的插件,旨在提升标签管理效率。通过 **分类标签** 10 | ,用户可以更有条理地组织、检索和管理文献资料,优化研究和学习过程。 11 | 12 | ## 功能特性 13 | 14 | - **分类标签列**:在条目列表中添加分类标签列,直观显示每个文献的标签信息。 15 | - **分类标签支持**:使用 `#类别/标签名` 格式将标签划分为不同类别,便于管理和查找。 16 | - **快捷键操作**:按 `Ctrl + T`(可自定义)快速打开标签管理对话框。 17 | - **标签管理对话框**:提供用户友好的界面,支持对现有标签的添加和移除。 18 | - **模糊搜索与拼音搜索**:支持模糊匹配和拼音搜索,快速定位标签。 19 | 20 | ## 安装方法 21 | 22 | ### 方法一:插件商店安装 23 | 24 | - 前往 [Zotero 插件商店](https://github.com/syt2/zotero-addons) 查找并安装 **Zotero Categorial Tags**。 25 | 26 | ### 方法二:手动安装 27 | 28 | 1. 从 [GitHub 仓库](https://github.com/panhaoyu/zotero-categorial-tags) 下载最新的 `.xpi` 文件。 29 | 2. 打开 Zotero,点击 `工具` -> `附加组件` -> 齿轮图标 -> `从文件安装附加组件...`,选择 `.xpi` 文件完成安装。 30 | 3. 重启 Zotero 激活插件。 31 | 32 | ## 使用指南 33 | 34 | ### 创建分类标签 35 | 36 | **注意**:插件不支持创建新标签,只能将文献绑定到已有标签上。请在 Zotero 中手动创建符合格式的标签后使用插件管理。 37 | 38 | 1. **格式要求**:标签需以 `#` 开头,包含 `/` 作为类别与标签名的分隔符。 39 | 40 | 2. **示例**: 41 | - `#学科/数学` 42 | - `#主题/机器学习` 43 | - `#阅读状态/已读` 44 | 45 | ### 标签绑定流程 46 | 47 | 1. **选择文献项**:在 Zotero 主界面中,选中一个或多个文献项。 48 | 2. **打开标签管理对话框**:按自定义快捷键(默认 `Ctrl + T`)打开标签管理窗口。 49 | 3. **搜索并管理标签**:使用搜索栏查找标签,支持拼音和模糊搜索,点击标签选中或取消选中。 50 | 4. **完成绑定**:按 `回车` 键保存更改。 51 | 52 | ### 查看分类标签 53 | 54 | 1. 在 Zotero 主界面右键点击条目列表的列标题。 55 | 2. 勾选 `分类标签`(或 `Categorial Tags`),即可显示每个文献的分类标签。 56 | 57 | ## 贡献与支持 58 | 59 | - **问题反馈**:使用过程中遇到问题,请在 [GitHub 问题页面](https://github.com/panhaoyu/zotero-categorial-tags/issues) 提交 60 | Issue。 61 | - **功能建议**:欢迎提出改进建议。 62 | - **贡献代码**:欢迎提交 Pull Request,帮助完善插件。 63 | 64 | ## 待解决的问题 65 | 66 | - **Mac 系统支持**:目前尚未在 macOS 上进行测试,因为缺少测试设备。欢迎 Mac 用户进行测试并反馈。 67 | - **标签创建功能**:插件不支持创建标签,需手动创建。目前尚未决定如何实现该功能,如果用户有想法,欢迎在 Issue 中交流。 68 | - **更多个性化设置**:未来版本将加入更多自定义选项。 69 | - **界面美化**:当前界面未进行美化,视觉效果较为简单。欢迎有设计经验的用户提供建议或提交 PR。 70 | 71 | 欢迎对上述问题的改进提交 Pull Request。 72 | 73 | ## 更新日志 74 | 75 | - **v0.1.9**: 增加自定义快捷键功能。 76 | - **v0.1.0**: 初始发布,支持分类标签管理、模糊和拼音搜索、快捷键操作。 77 | 78 | ## 许可证 79 | 80 | - 本项目采用 [MIT 许可证](https://github.com/panhaoyu/zotero-categorial-tags/blob/main/LICENSE) 开源。 81 | 82 | ## 鸣谢 83 | 84 | - **zotero-plugin-template**: 感谢提供的初始模板,提高了开发效率。 85 | - **zotero-style**: 感谢关于 `#Tags` 功能的探索,为插件开发提供了重要启发。 86 | -------------------------------------------------------------------------------- /addon/bootstrap.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | 3 | /** 4 | * Most of this code is from Zotero team's official Make It Red example[1] 5 | * or the Zotero 7 documentation[2]. 6 | * [1] https://github.com/zotero/make-it-red 7 | * [2] https://www.zotero.org/support/dev/zotero_7_for_developers 8 | */ 9 | 10 | var chromeHandle; 11 | 12 | function install(data, reason) {} 13 | 14 | async function startup({ id, version, resourceURI, rootURI }, reason) { 15 | await Zotero.initializationPromise; 16 | 17 | // String 'rootURI' introduced in Zotero 7 18 | if (!rootURI) { 19 | rootURI = resourceURI.spec; 20 | } 21 | 22 | var aomStartup = Components.classes[ 23 | "@mozilla.org/addons/addon-manager-startup;1" 24 | ].getService(Components.interfaces.amIAddonManagerStartup); 25 | var manifestURI = Services.io.newURI(rootURI + "manifest.json"); 26 | chromeHandle = aomStartup.registerChrome(manifestURI, [ 27 | ["content", "__addonRef__", rootURI + "chrome/content/"], 28 | ]); 29 | 30 | /** 31 | * Global variables for plugin code. 32 | * The `_globalThis` is the global root variable of the plugin sandbox environment 33 | * and all child variables assigned to it is globally accessible. 34 | * See `src/index.ts` for details. 35 | */ 36 | const ctx = { 37 | rootURI, 38 | }; 39 | ctx._globalThis = ctx; 40 | 41 | Services.scriptloader.loadSubScript( 42 | `${rootURI}/chrome/content/scripts/__addonRef__.js`, 43 | ctx, 44 | ); 45 | Zotero.__addonInstance__.hooks.onStartup(); 46 | } 47 | 48 | async function onMainWindowLoad({ window }, reason) { 49 | Zotero.__addonInstance__?.hooks.onMainWindowLoad(window); 50 | } 51 | 52 | async function onMainWindowUnload({ window }, reason) { 53 | Zotero.__addonInstance__?.hooks.onMainWindowUnload(window); 54 | } 55 | 56 | function shutdown({ id, version, resourceURI, rootURI }, reason) { 57 | if (reason === APP_SHUTDOWN) { 58 | return; 59 | } 60 | 61 | if (typeof Zotero === "undefined") { 62 | Zotero = Components.classes["@zotero.org/Zotero;1"].getService( 63 | Components.interfaces.nsISupports, 64 | ).wrappedJSObject; 65 | } 66 | Zotero.__addonInstance__?.hooks.onShutdown(); 67 | 68 | Cc["@mozilla.org/intl/stringbundle;1"] 69 | .getService(Components.interfaces.nsIStringBundleService) 70 | .flushBundles(); 71 | 72 | Cu.unload(`${rootURI}/chrome/content/scripts/__addonRef__.js`); 73 | 74 | if (chromeHandle) { 75 | chromeHandle.destruct(); 76 | chromeHandle = null; 77 | } 78 | } 79 | 80 | function uninstall(data, reason) {} 81 | -------------------------------------------------------------------------------- /src/utils/locale.ts: -------------------------------------------------------------------------------- 1 | import { config } from "../../package.json"; 2 | 3 | export { initLocale, getString, getLocaleID }; 4 | 5 | /** 6 | * Initialize locale data 7 | */ 8 | function initLocale() { 9 | const l10n = new ( 10 | typeof Localization === "undefined" 11 | ? ztoolkit.getGlobal("Localization") 12 | : Localization 13 | )([`${config.addonRef}-addon.ftl`], true); 14 | addon.data.locale = { 15 | current: l10n, 16 | }; 17 | } 18 | 19 | /** 20 | * Get locale string, see https://firefox-source-docs.mozilla.org/l10n/fluent/tutorial.html#fluent-translation-list-ftl 21 | * @param localString ftl key 22 | * @param options.branch branch name 23 | * @param options.args args 24 | * @example 25 | * ```ftl 26 | * # addon.ftl 27 | * addon-static-example = This is default branch! 28 | * .branch-example = This is a branch under addon-static-example! 29 | * addon-dynamic-example = 30 | { $count -> 31 | [one] I have { $count } apple 32 | *[other] I have { $count } apples 33 | } 34 | * ``` 35 | * ```js 36 | * getString("addon-static-example"); // This is default branch! 37 | * getString("addon-static-example", { branch: "branch-example" }); // This is a branch under addon-static-example! 38 | * getString("addon-dynamic-example", { args: { count: 1 } }); // I have 1 apple 39 | * getString("addon-dynamic-example", { args: { count: 2 } }); // I have 2 apples 40 | * ``` 41 | */ 42 | function getString(localString: string): string; 43 | function getString(localString: string, branch: string): string; 44 | function getString( 45 | localeString: string, 46 | options: { branch?: string | undefined; args?: Record }, 47 | ): string; 48 | function getString(...inputs: any[]) { 49 | if (inputs.length === 1) { 50 | return _getString(inputs[0]); 51 | } else if (inputs.length === 2) { 52 | if (typeof inputs[1] === "string") { 53 | return _getString(inputs[0], { branch: inputs[1] }); 54 | } else { 55 | return _getString(inputs[0], inputs[1]); 56 | } 57 | } else { 58 | throw new Error("Invalid arguments"); 59 | } 60 | } 61 | 62 | function _getString( 63 | localeString: string, 64 | options: { branch?: string | undefined; args?: Record } = {}, 65 | ): string { 66 | const localStringWithPrefix = `${config.addonRef}-${localeString}`; 67 | const { branch, args } = options; 68 | const pattern = addon.data.locale?.current.formatMessagesSync([ 69 | { id: localStringWithPrefix, args }, 70 | ])[0]; 71 | if (!pattern) { 72 | return localStringWithPrefix; 73 | } 74 | if (branch && pattern.attributes) { 75 | for (const attr of pattern.attributes) { 76 | if (attr.name === branch) { 77 | return attr.value; 78 | } 79 | } 80 | return pattern.attributes[branch] || localStringWithPrefix; 81 | } else { 82 | return pattern.value || localStringWithPrefix; 83 | } 84 | } 85 | 86 | function getLocaleID(id: string) { 87 | return `${config.addonRef}-${id}`; 88 | } 89 | -------------------------------------------------------------------------------- /src/hooks.ts: -------------------------------------------------------------------------------- 1 | import { config } from "../package.json"; 2 | import { initLocale } from "./utils/locale"; 3 | import { registerPrefsScripts } from "./modules/preferenceScript"; 4 | import { createZToolkit } from "./utils/ztoolkit"; 5 | import { columnManager } from "./modules/column"; 6 | import { shortcutsManager } from "./modules/shortcuts"; 7 | import { preferenceManager } from "./modules/prefs"; 8 | import { tagManager } from "./modules/manager"; 9 | import { CommandKey } from "./modules/constants"; 10 | import { logger } from "./utils/logger"; 11 | 12 | 13 | async function onStartup() { 14 | logger.info("onStartup started"); 15 | await Promise.all([ 16 | Zotero.initializationPromise, 17 | Zotero.unlockPromise, 18 | Zotero.uiReadyPromise 19 | ]); 20 | logger.info("Zotero initialization completed"); 21 | initLocale(); 22 | logger.info("Initializing managers"); 23 | await tagManager.register(); 24 | await columnManager.register(); 25 | await preferenceManager.register(); 26 | await shortcutsManager.register(); 27 | logger.info("Managers initialized"); 28 | } 29 | 30 | async function onMainWindowLoad(win: Window): Promise { 31 | addon.data.ztoolkit = createZToolkit(); 32 | logger.info("onMainWindowLoad executed"); 33 | window.MozXULElement.insertFTLIfNeeded(`${config.addonRef}-mainWindow.ftl`); 34 | } 35 | 36 | async function onMainWindowUnload(win: Window): Promise { 37 | 38 | logger.info("onMainWindowUnload executed"); 39 | ztoolkit.unregisterAll(); 40 | addon.data.dialog?.window?.close(); 41 | } 42 | 43 | function onShutdown(): void { 44 | ztoolkit.unregisterAll(); 45 | addon.data.dialog?.window?.close(); 46 | // Remove addon object 47 | addon.data.alive = false; 48 | delete Zotero[config.addonInstance]; 49 | } 50 | 51 | /** 52 | * This function is just an example of dispatcher for Preference UI events. 53 | * Any operations should be placed in a function to keep this function clear. 54 | * @param type event type 55 | * @param data event data 56 | */ 57 | async function onPrefsEvent(type: string, data: { [key: string]: any }) { 58 | logger.info(`onPrefsEvent triggered with type: ${type}`); 59 | switch (type) { 60 | case "load": 61 | registerPrefsScripts(data.window).then(); 62 | break; 63 | default: 64 | return; 65 | } 66 | } 67 | 68 | const lastTriggeredTimes: Record = {}; 69 | 70 | function onShortcuts(type: string) { 71 | const now = Date.now(); 72 | if (lastTriggeredTimes[type] && now - lastTriggeredTimes[type] < 100) { 73 | return; 74 | } 75 | lastTriggeredTimes[type] = now; 76 | 77 | logger.info(`onShortcuts triggered with type: ${type}`); 78 | switch (type) { 79 | case CommandKey.openTagTab: 80 | shortcutsManager.openTagsTabCallback().then(); 81 | break; 82 | default: 83 | break; 84 | } 85 | } 86 | 87 | export default { 88 | onStartup, 89 | onShutdown, 90 | onMainWindowLoad, 91 | onMainWindowUnload, 92 | onPrefsEvent, 93 | onShortcuts 94 | }; -------------------------------------------------------------------------------- /src/modules/tagDialogData.ts: -------------------------------------------------------------------------------- 1 | import { tagManager } from "./manager"; 2 | import { getString } from "../utils/locale"; 3 | import { TagFilter } from "./tagFilter"; 4 | import { getItemTags } from "./zoteroUtils"; 5 | 6 | interface TagState { 7 | changed: boolean; 8 | active: boolean; 9 | isFiltered: boolean; 10 | } 11 | 12 | export class TagDialogData { 13 | public itemTags: { [key: number]: TagState }; 14 | public dialogTitle: string; 15 | public tagFilter: TagFilter; 16 | private selections: Zotero.Item[]; 17 | public filterValue: string; 18 | 19 | constructor(selections: Zotero.Item[]) { 20 | this.selections = selections; 21 | this.itemTags = {}; 22 | this.dialogTitle = ""; 23 | this.filterValue = ""; 24 | 25 | const allTags = tagManager.getAllTags().map(tagData => tagData.tagName); 26 | this.tagFilter = new TagFilter(allTags); 27 | 28 | this.initialize(); 29 | } 30 | 31 | private initialize() { 32 | if (this.selections.length === 0) { 33 | throw new Error("No selections provided"); 34 | } 35 | 36 | const initialTags = getItemTags(this.selections[0]).map(tagObj => tagObj.tag); 37 | 38 | const commonTags = this.selections.slice(1).reduce((acc, selection) => { 39 | const selectionTags = getItemTags(selection).map(tagObj => tagObj.tag); 40 | return acc.filter(tag => selectionTags.includes(tag)); 41 | }, initialTags); 42 | 43 | const selectionItemsTitle = 44 | this.selections.length === 1 45 | ? this.selections[0].getDisplayTitle() 46 | : getString(`categorial-tags-selection-titles`, { args: { length: this.selections.length } }); 47 | this.dialogTitle = getString("categorial-tags-dialog-title", { args: { selectionTitles: selectionItemsTitle } }); 48 | 49 | this.itemTags = Object.fromEntries( 50 | tagManager.getAllTags().map(i => [ 51 | i.tagId, 52 | { 53 | changed: false, 54 | active: commonTags.includes(i.fullName), 55 | isFiltered: true 56 | } 57 | ]) 58 | ); 59 | } 60 | 61 | public filterTags(filterValue: string) { 62 | const filterResults = this.tagFilter.filterTags(filterValue); 63 | this.filterValue = filterValue; 64 | tagManager.getAllTags().forEach((tagData, index) => { 65 | const tagState = this.itemTags[tagData.tagId]; 66 | if (tagState) { 67 | tagState.isFiltered = filterResults.includes(tagData.tagName); 68 | } 69 | }); 70 | } 71 | 72 | 73 | public toggleTag(tagId: number) { 74 | const tagState = this.itemTags[tagId]; 75 | if (tagState) { 76 | tagState.active = !tagState.active; 77 | tagState.changed = true; 78 | } 79 | } 80 | 81 | public async saveChanges() { 82 | await Zotero.DB.executeTransaction(async () => { 83 | for (const [tagId, activeData] of Object.entries(this.itemTags)) { 84 | if (!activeData.changed) continue; 85 | const tag = tagManager.getTag(Number(tagId)); 86 | if (tag === undefined) continue; 87 | for (const selection of this.selections) { 88 | if (activeData.active) { 89 | selection.addTag(tag.fullName); 90 | } else { 91 | selection.removeTag(tag.fullName); 92 | } 93 | await selection.save(); 94 | } 95 | } 96 | }); 97 | } 98 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zotero Categorial Tags Plugin 2 | 3 | [![Using Zotero Plugin Template](https://img.shields.io/badge/Using-Zotero%20Plugin%20Template-blue?style=flat-square&logo=github)](https://github.com/windingwind/zotero-plugin-template) 4 | 5 | ![](doc/Pane.jpg) 6 | 7 | Documentation | [中文文档](doc/README-zhCN.md) 8 | 9 | ## Introduction 10 | 11 | **Zotero Categorial Tags** is a plugin designed for Zotero users to enhance tag management efficiency. By using * 12 | *categorial tags**, users can systematically organize, retrieve, and manage references, optimizing their research and 13 | study processes. 14 | 15 | ## Features 16 | 17 | - **Categorial Tags Column**: Adds a categorial tags column in the item list, clearly showing each reference's tag 18 | information. 19 | - **Categorial Tag Support**: Supports the `#Category/TagName` format to classify tags for easier management and 20 | retrieval. 21 | - **Shortcut Key**: Press `Ctrl + T` (customizable) to quickly open the tag management dialog. 22 | - **Tag Management Dialog**: Provides a user-friendly interface to add and remove existing tags. 23 | - **Fuzzy and Pinyin Search**: Supports fuzzy matching and pinyin search to quickly locate tags. 24 | 25 | ## Installation 26 | 27 | ### Method 1: Install from Add-on Store 28 | 29 | - Go to the [Zotero Add-ons Store](https://github.com/syt2/zotero-addons) and find **Zotero Categorial Tags** to 30 | install. 31 | 32 | ### Method 2: Manual Installation 33 | 34 | 1. Download the latest `.xpi` file from the [GitHub repository](https://github.com/panhaoyu/zotero-categorial-tags). 35 | 2. Open Zotero, click `Tools` -> `Add-ons` -> Gear icon -> `Install Add-on From File...`, and select the `.xpi` file to 36 | complete the installation. 37 | 3. Restart Zotero to activate the plugin. 38 | 39 | ## Usage Guide 40 | 41 | ### Creating Categorial Tags 42 | 43 | **Note**: The plugin does not support creating new tags. It can only bind items to existing tags. Please manually create 44 | appropriate tags in Zotero before managing them with the plugin. 45 | 46 | 1. **Format Requirements**: Tags must start with `#` and use `/` to separate the category and tag name. 47 | 48 | 2. **Examples**: 49 | 50 | - `#Subject/Mathematics` 51 | - `#Topic/Machine Learning` 52 | - `#ReadingStatus/Read` 53 | 54 | ### Tag Binding Process 55 | 56 | 1. **Select Items**: In Zotero's main interface, select one or more items. 57 | 2. **Open the Tag Management Dialog**: Press the custom shortcut key (default `Ctrl + T`) to open the tag management 58 | window. 59 | 3. **Search and Manage Tags**: Use the search bar to find tags quickly, supporting pinyin and fuzzy search. Click on 60 | tags to select or deselect them. 61 | 4. **Complete Binding**: Press `Enter` to save the changes. 62 | 63 | ### Viewing Categorial Tags 64 | 65 | 1. In Zotero's main interface, right-click on the column headers in the item list. 66 | 2. Check `Categorial Tags` to display categorial tags for each reference. 67 | 68 | ## Contribution and Support 69 | 70 | - **Bug Reports**: If you encounter issues, submit an Issue on 71 | the [GitHub Issues page](https://github.com/panhaoyu/zotero-categorial-tags/issues). 72 | - **Feature Suggestions**: Suggestions for improvement are welcome. 73 | - **Contributing Code**: Pull Requests are welcome to help improve the plugin. 74 | 75 | ## Known Issues 76 | 77 | - **macOS Support**: There has been no testing on macOS due to the lack of test devices. macOS users are welcome to test 78 | and provide feedback. 79 | - **Tag Creation**: The plugin does not support creating tags; they must be created manually. The implementation of this 80 | feature is undecided, and users are encouraged to share ideas on the Issues page. 81 | - **Customization Options**: Future versions will include more customization options. 82 | - **Interface Design**: The current interface has not been aesthetically enhanced. Users with design experience are 83 | encouraged to provide suggestions or submit PRs. 84 | 85 | Contributions to address the above issues are welcome via Pull Requests. 86 | 87 | ## Changelog 88 | 89 | - **v0.1.9**: Added customizable shortcut keys. 90 | - **v0.1.0**: Initial release with support for categorial tag management, fuzzy and pinyin search, and keyboard 91 | shortcuts. 92 | 93 | ## License 94 | 95 | - This project is open source under 96 | the [MIT License](https://github.com/panhaoyu/zotero-categorial-tags/blob/main/LICENSE). 97 | 98 | ## Acknowledgements 99 | 100 | - **zotero-plugin-template**: Thanks for providing the initial template, which greatly improved development efficiency. 101 | - **zotero-style**: Thanks for exploring the `#Tags` feature, which provided valuable inspiration for this plugin's 102 | development. 103 | -------------------------------------------------------------------------------- /src/modules/preferenceScript.ts: -------------------------------------------------------------------------------- 1 | import { getPref, setPref } from "../utils/prefs"; 2 | import { ElementID, PrefDefault, PrefKey } from "./constants"; 3 | import { logger } from "../utils/logger"; 4 | import { DialogHelper } from "zotero-plugin-toolkit"; 5 | 6 | export async function registerPrefsScripts(_window: Window) { 7 | logger.debug("Registering preferences scripts"); 8 | addon.data.prefs.window = _window; 9 | updatePrefsUI().then(); 10 | bindPrefEvents(); 11 | } 12 | 13 | function getElement(elementId: string): T { 14 | const window = addon.data.prefs.window; 15 | if (window === undefined) throw "Window not found"; 16 | const result = window.document.querySelector(elementId); 17 | if (!result) throw `Element not found: ${elementId}`; 18 | return result as T; 19 | } 20 | 21 | async function updatePrefsUI() { 22 | const shortcut = getPref(PrefKey.shortcut) ?? PrefDefault.shortcut; 23 | logger.debug(`Updating UI with shortcut: ${shortcut}`); 24 | getElement(ElementID.shortcutKeyInput).value = shortcut; 25 | } 26 | 27 | function bindPrefEvents() { 28 | logger.debug("Binding preference UI events"); 29 | 30 | getElement(ElementID.shortcutKeyInput).addEventListener("change", e => { 31 | const element = e.target as HTMLInputElement; 32 | const newShortcut = element.value; 33 | setPref(PrefKey.shortcut, newShortcut); 34 | logger.info(`Shortcut key updated to: ${newShortcut}`); 35 | }); 36 | 37 | getElement(ElementID.captureShortcutButton).addEventListener("click", () => { 38 | logger.debug("Shortcut capture button clicked"); 39 | void showShortcutCaptureDialog(); 40 | }); 41 | } 42 | 43 | async function showShortcutCaptureDialog() { 44 | logger.info("Showing shortcut capture dialog"); 45 | 46 | const dialog = new DialogHelper(1, 1); 47 | const inputId = "shortcut-capture-input"; 48 | 49 | dialog.addCell(0, 0, { 50 | tag: "div", 51 | styles: { padding: "10px" }, 52 | children: [ 53 | { 54 | tag: "label", 55 | properties: { value: "Press any key combination:" } 56 | }, 57 | { 58 | tag: "input", 59 | id: inputId, 60 | properties: { type: "text", readonly: true }, 61 | styles: { margin: "10px 0", fontSize: "14px" } 62 | }, 63 | { 64 | tag: "description", 65 | properties: { textContent: "Press any key combination (e.g. Ctrl+Shift+K). The combination will appear above." }, 66 | styles: { maxWidth: "300px" } 67 | } 68 | ] 69 | }); 70 | 71 | dialog.addButton("Accept", "accept-button", { 72 | noClose: false, 73 | callback: () => { 74 | const inputElement = dialog.window.document.getElementById(inputId) as HTMLInputElement; 75 | if (inputElement && inputElement.value) { 76 | setPref(PrefKey.shortcut, inputElement.value); 77 | logger.info(`Dialog accepted new shortcut: ${inputElement.value}`); 78 | updatePrefsUI(); 79 | } 80 | } 81 | }); 82 | 83 | dialog.addButton("Cancel", "cancel-button", { 84 | noClose: false, 85 | callback: () => { 86 | logger.info("Shortcut capture canceled by user"); 87 | } 88 | }); 89 | 90 | // Set dialog data with load callback 91 | dialog.setDialogData({ 92 | loadCallback: () => { 93 | const inputElement = dialog.window.document.getElementById(inputId) as HTMLInputElement; 94 | if (!inputElement) { 95 | logger.error("Input element not found in dialog"); 96 | return; 97 | } 98 | inputElement.focus(); 99 | 100 | dialog.window.addEventListener("keydown", (e: KeyboardEvent) => { 101 | e.preventDefault(); 102 | e.stopPropagation(); 103 | 104 | if (e.key === "Escape") { 105 | logger.info("Escape pressed, closing dialog"); 106 | dialog.window.close(); 107 | return; 108 | } 109 | 110 | // Skip Tab and Enter keys 111 | if (e.key === "Tab" || e.key === "Enter") return; 112 | 113 | const keys = []; 114 | if (e.ctrlKey) keys.push("Ctrl"); 115 | if (e.altKey) keys.push("Alt"); 116 | if (e.shiftKey) keys.push("Shift"); 117 | if (e.metaKey) keys.push("Meta"); 118 | 119 | // Exclude modifier keys when pressed alone 120 | if (!["Control", "Alt", "Shift", "Meta"].includes(e.key)) { 121 | keys.push(e.key); 122 | } 123 | 124 | if (keys.length > 0) { 125 | const newShortcut = keys.join("+"); 126 | inputElement.value = newShortcut; 127 | logger.debug(`Key combination captured: ${newShortcut}`); 128 | } 129 | }); 130 | } 131 | }); 132 | 133 | dialog.open("Capture Shortcut", { 134 | centerscreen: true, 135 | resizable: false, 136 | width: 400, 137 | height: 200 138 | }); 139 | } -------------------------------------------------------------------------------- /src/modules/manager.ts: -------------------------------------------------------------------------------- 1 | import { Category } from "./category"; 2 | import { CategorialTag } from "./categorialTag"; 3 | import { getItemTags } from "./zoteroUtils"; 4 | import TagJson = _ZoteroTypes.Tags.TagJson; 5 | 6 | class Manager { 7 | private categories: Category[] = []; 8 | private tagQueryMapping: { [key: string]: CategorialTag } = {}; 9 | 10 | async register() { 11 | const self: Manager = this; 12 | await self.updateCache(); 13 | 14 | async function hook() { 15 | await self.onTagChanged(); 16 | } 17 | 18 | async function hookLater() { 19 | await new Promise(resolve => setTimeout(resolve, 500)); 20 | await hook.call(self); 21 | } 22 | 23 | // 添加 hooks,在变动的时候,触发 onTagChanged 24 | const originalCreate = Zotero.Tags.create; 25 | Zotero.Tags.create = async (...args) => { 26 | const result = await originalCreate.apply(Zotero.Tags, args); 27 | await hook.call(self); 28 | return result; 29 | }; 30 | 31 | const originalRemoveFromLibrary = Zotero.Tags.removeFromLibrary; 32 | Zotero.Tags.removeFromLibrary = async (...args) => { 33 | const result = await originalRemoveFromLibrary.apply(Zotero.Tags, args); 34 | await hook.call(self); 35 | return result; 36 | }; 37 | 38 | const originalRename = Zotero.Tags.rename; 39 | Zotero.Tags.rename = async (...args) => { 40 | const result = await originalRename.apply(Zotero.Tags, args); 41 | await hook.call(self); 42 | return result; 43 | }; 44 | 45 | 46 | const originalAddTag = Zotero.Item.prototype.addTag; 47 | Zotero.Item.prototype.addTag = function(...args: any) { 48 | const result = originalAddTag.apply(this, args); 49 | hookLater.call(self).then(); 50 | return result; 51 | }; 52 | 53 | const originalRemoveTag = Zotero.Item.prototype.removeTag; 54 | Zotero.Item.prototype.removeTag = function(...args: any) { 55 | const result = originalRemoveTag.apply(this, args); 56 | hookLater.call(self).then(); 57 | return result; 58 | }; 59 | 60 | const originalReplaceTag = Zotero.Item.prototype.replaceTag; 61 | Zotero.Item.prototype.replaceTag = function(...args: any) { 62 | const result = originalReplaceTag.apply(this, args); 63 | hookLater.call(self).then(); 64 | return result; 65 | }; 66 | 67 | const originalRemoveAllTags = Zotero.Item.prototype.removeAllTags; 68 | Zotero.Item.prototype.removeAllTags = function(...args: any) { 69 | originalRemoveAllTags.apply(this, args); 70 | hookLater.call(self).then(); 71 | }; 72 | 73 | const originalSetTags = Zotero.Item.prototype.setTags; 74 | Zotero.Item.prototype.setTags = function(...args: any) { 75 | originalSetTags.apply(this, args); 76 | hookLater.call(self).then(); 77 | }; 78 | } 79 | 80 | async onTagChanged() { 81 | await this.updateCache(); 82 | } 83 | 84 | // Update and cache all CategorialTag instances and categories 85 | async updateCache(): Promise { 86 | let libraryId = ZoteroPane.getSelectedLibraryID(); 87 | while (libraryId === undefined) { 88 | await new Promise(resolve => setTimeout(resolve, 100)); // wait 0.1 seconds 89 | libraryId = ZoteroPane.getSelectedLibraryID(); 90 | } 91 | 92 | const tags = await Zotero.Tags.getAll(libraryId) as TagJson[]; 93 | const categorialTags = await Promise.all( 94 | tags 95 | .filter(tagJson => { 96 | const tagName = tagJson.tag; 97 | return tagName.startsWith("#") && tagName.includes("/"); 98 | }) 99 | .map(async tagJson => { 100 | const tagId = Zotero.Tags.getID(tagJson.tag); 101 | if (tagId === false) { 102 | throw `Tag id not found: ${tagJson.tag}`; 103 | } 104 | const itemsIds = await Zotero.Tags.getTagItems(libraryId, tagId); 105 | const items = itemsIds.map(i => Zotero.Items.get(i)); 106 | return new CategorialTag(tagId, tagJson, items); 107 | }) 108 | ); 109 | 110 | const categoryMap = new Map(); 111 | this.tagQueryMapping = {}; 112 | 113 | categorialTags.forEach(tag => { 114 | this.tagQueryMapping[tag.fullName] = tag; 115 | this.tagQueryMapping[tag.tagId] = tag; 116 | if (!categoryMap.get(tag.categoryName)) { 117 | categoryMap.set(tag.categoryName, []); 118 | } 119 | categoryMap.get(tag.categoryName)!.push(tag); 120 | }); 121 | 122 | this.categories = Array.from(categoryMap.entries()).map( 123 | ([name, tags]) => new Category(name, tags) 124 | ).sort((i, j) => j.itemCount - i.itemCount); 125 | } 126 | 127 | getTag(idOrName: string | number): CategorialTag | undefined { 128 | return this.tagQueryMapping[idOrName]; 129 | } 130 | 131 | getTagsOfItem(item: Zotero.Item): CategorialTag[] { 132 | return getItemTags(item) 133 | .map(tag => this.getTag(tag.tag)) 134 | .filter(i => i !== undefined) 135 | .map(i => i as CategorialTag) 136 | .sort((i, j) => j.itemCount - i.itemCount); 137 | } 138 | 139 | getAllTags(): CategorialTag[] { 140 | return Object.values(this.tagQueryMapping); 141 | } 142 | 143 | getAllCategories(): Category[] { 144 | return this.categories; 145 | } 146 | } 147 | 148 | export const tagManager = new Manager(); -------------------------------------------------------------------------------- /src/modules/shortcuts.ts: -------------------------------------------------------------------------------- 1 | import { CommandKey, PrefDefault, PrefKey } from "./constants"; 2 | import Message from "./message"; 3 | import { getString } from "../utils/locale"; 4 | import { TagDialogUI } from "./tagDialogUI"; 5 | import { getPref } from "../utils/prefs"; 6 | import Item = Zotero.Item; 7 | import ReaderTab = _ZoteroTypes.ReaderTab; 8 | import { logger } from "../utils/logger"; 9 | 10 | // Interface defining keyboard shortcut options 11 | interface KeyOptions { 12 | ctrl: boolean; 13 | shift: boolean; 14 | alt: boolean; 15 | meta: boolean; 16 | key: string | null; 17 | } 18 | 19 | class ShortcutManager { 20 | constructor() { 21 | // Initialize properties or events here if needed 22 | } 23 | 24 | /** 25 | * Parses a shortcut string and returns the corresponding key options. 26 | * @param shortcut - The shortcut string, e.g., "Ctrl+Shift+T". 27 | * @returns The parsed keyboard options. 28 | */ 29 | private parseShortcut(shortcut: string): KeyOptions { 30 | const keys = shortcut.toLowerCase().split("+").map(k => k.trim()); 31 | 32 | // Initialize modifier keys and main key 33 | const keyOptions: KeyOptions = { 34 | ctrl: false, 35 | shift: false, 36 | alt: false, 37 | meta: false, 38 | key: null 39 | }; 40 | 41 | // Map modifier keys and main key 42 | keys.forEach(k => { 43 | switch (k) { 44 | case "ctrl": 45 | case "control": 46 | keyOptions.ctrl = true; 47 | break; 48 | case "shift": 49 | keyOptions.shift = true; 50 | break; 51 | case "alt": 52 | keyOptions.alt = true; 53 | break; 54 | case "meta": 55 | case "command": 56 | case "cmd": 57 | keyOptions.meta = true; 58 | break; 59 | default: 60 | keyOptions.key = k; 61 | } 62 | }); 63 | 64 | return keyOptions; 65 | } 66 | 67 | /** 68 | * Registers the keyboard shortcut event listener. 69 | */ 70 | public async register(): Promise { 71 | const shortcut = getPref(PrefKey.shortcut) ?? PrefDefault.shortcut; 72 | const keyOptions = this.parseShortcut(shortcut); 73 | logger.info(`Registering shortcut: ${shortcut}, parsed: ${JSON.stringify(keyOptions)}`); 74 | 75 | // Register keyboard event listener 76 | ztoolkit.Keyboard.register((ev) => { 77 | if ( 78 | ev.type === "keydown" && 79 | ev.ctrlKey === keyOptions.ctrl && 80 | ev.shiftKey === keyOptions.shift && 81 | ev.altKey === keyOptions.alt && 82 | ev.metaKey === keyOptions.meta && 83 | ev.key?.toLowerCase() === keyOptions.key 84 | ) { 85 | logger.info("Shortcut triggered: opening tags tab"); 86 | addon.hooks.onShortcuts(CommandKey.openTagTab); 87 | 88 | } 89 | }); 90 | } 91 | 92 | /** 93 | * Callback function triggered by the shortcut to open the tags dialog. 94 | */ 95 | public async openTagsTabCallback(): Promise { 96 | logger.info("Opening tags tab callback started"); 97 | const currentPane = Zotero.getActiveZoteroPane(); 98 | const tabs = currentPane.getState().tabs; 99 | const currentTab = tabs.find(tab => tab.selected); 100 | 101 | if (!currentTab) { 102 | logger.info("No active tab found"); 103 | Message.error("Cannot find the currently selected tab to apply categorical tags."); 104 | return; 105 | } 106 | 107 | let selections: Item[] = []; 108 | logger.info(`Current tab type: ${currentTab.type}`); 109 | 110 | switch (currentTab.type) { 111 | case "reader": 112 | const readerData = currentTab.data as ReaderTab; 113 | const selectedItemId = readerData.itemID; 114 | logger.info(`Reader tab itemID: ${selectedItemId}`); 115 | 116 | if (!selectedItemId) { 117 | logger.info("No item ID in reader tab"); 118 | Message.error("Cannot identify the current item ID to apply categorical tags."); 119 | return; 120 | } 121 | 122 | const selectedItem = Zotero.Items.get(selectedItemId); 123 | if (selectedItem) { 124 | selections.push(selectedItem); 125 | } 126 | break; 127 | 128 | case "library": 129 | selections = currentPane.getSelectedItems(); 130 | logger.info(`Library tab selections: ${selections.length} items`); 131 | break; 132 | 133 | default: 134 | logger.info(`Unsupported tab type: ${currentTab.type}`); 135 | Message.error(`Unsupported tab type: "${currentTab.type}".`); 136 | return; 137 | } 138 | 139 | // Retrieve the top-level parent for each selected item, ignoring notes or PDF files 140 | selections = selections.map(item => { 141 | let parent = item; 142 | while (parent.parentItem) { 143 | parent = parent.parentItem; 144 | } 145 | return parent; 146 | }); 147 | 148 | logger.info(`Processed selections: ${selections.length} items`); 149 | if (selections.length === 0) { 150 | logger.info("No valid selections after processing"); 151 | const hint = getString("categorial-tags-no-selection-hint"); 152 | Message.info(hint); 153 | return; 154 | } 155 | 156 | logger.info("Opening tag dialog"); 157 | const tagDialog = new TagDialogUI(selections); 158 | await tagDialog.open(); 159 | } 160 | } 161 | 162 | // Instantiate and export the shortcut manager 163 | export const shortcutsManager = new ShortcutManager(); 164 | -------------------------------------------------------------------------------- /src/modules/tagDialogUI.ts: -------------------------------------------------------------------------------- 1 | import { DialogHelper } from "zotero-plugin-toolkit"; 2 | import { TagDialogData } from "./tagDialogData"; 3 | import { CategorialTag } from "./categorialTag"; 4 | import { tagManager } from "./manager"; 5 | 6 | interface Colors { 7 | foreground: string; 8 | background: string; 9 | initialBackground: string; 10 | } 11 | 12 | const ACTIVE_ITEM_BG = "#efd2ff"; 13 | const FILTERED_ITEM_BG = "#b5f1c4"; 14 | 15 | function getColors({ tag, isActive, isFiltered }: { 16 | tag: CategorialTag, 17 | isActive: boolean, 18 | isFiltered: boolean 19 | }): Colors { 20 | let foreground = "inherit"; 21 | let background = "transparent"; 22 | let initialBackground = "transparent"; 23 | 24 | if (isActive) { 25 | background = ACTIVE_ITEM_BG; 26 | initialBackground = ACTIVE_ITEM_BG; 27 | } else if (isFiltered) { 28 | background = FILTERED_ITEM_BG; 29 | } 30 | 31 | return { foreground, background, initialBackground }; 32 | } 33 | 34 | export class TagDialogUI { 35 | private dialog?: DialogHelper; 36 | private logic: TagDialogData; 37 | 38 | private readonly filterInputElementId: string = "zotero-categorial-tags-filter-input"; 39 | 40 | constructor(selections: Zotero.Item[]) { 41 | this.logic = new TagDialogData(selections); 42 | } 43 | 44 | public async open() { 45 | if (this.dialog !== undefined) return; 46 | 47 | this.dialog = new DialogHelper(3, 1); 48 | 49 | this.dialog.setDialogData({ itemTags: { ...this.logic.itemTags } }); 50 | 51 | this.dialog.addCell(0, 0, { 52 | tag: "input", 53 | id: this.filterInputElementId, 54 | properties: { 55 | type: "text", 56 | placeholder: "Filter tags...", 57 | oninput: (e: Event) => { 58 | const filterValue = (e.target as HTMLInputElement).value; 59 | this.logic.filterTags(filterValue); 60 | this.updateTagStyles(); 61 | } 62 | }, 63 | styles: { 64 | marginBottom: "10px" 65 | } 66 | }); 67 | 68 | this.dialog.addCell(1, 0, { 69 | tag: "div", 70 | styles: { 71 | userSelect: "none", 72 | overflowY: "auto" 73 | }, 74 | children: [ 75 | { 76 | tag: "table", 77 | children: [ 78 | { 79 | tag: "tbody", 80 | children: tagManager.getAllCategories().map(category => ({ 81 | tag: "tr", 82 | styles: { 83 | marginBottom: "6px" 84 | }, 85 | children: [ 86 | { 87 | tag: "th", 88 | properties: { innerText: category.name }, 89 | styles: { 90 | whiteSpace: "nowrap" // Ensure text does not wrap 91 | } 92 | }, 93 | { 94 | tag: "td", 95 | children: category.tags.map((tag: CategorialTag) => { 96 | const isFiltered = this.logic.itemTags[tag.tagId].isFiltered; 97 | const isActive = this.logic.itemTags[tag.tagId].active; 98 | const colors = getColors({ 99 | tag: tag, isActive, isFiltered 100 | }); 101 | return { 102 | tag: "span", 103 | id: tag.uniqueElementId, 104 | properties: { innerText: tag.tagName }, 105 | styles: { 106 | marginLeft: "4px", 107 | background: colors.initialBackground, 108 | whiteSpace: "nowrap", 109 | cursor: "pointer", 110 | padding: "2px", 111 | borderRadius: "4px", 112 | display: "inline-block", 113 | color: colors.foreground 114 | }, 115 | listeners: [ 116 | { 117 | type: "click", 118 | listener: () => { 119 | this.logic.toggleTag(tag.tagId); 120 | this.updateTagStyles(); 121 | } 122 | } 123 | ] 124 | }; 125 | }) 126 | } 127 | ] 128 | })) 129 | } 130 | ] 131 | } 132 | ] 133 | }); 134 | 135 | this.dialog.addButton("Save and close", "save-button", { 136 | noClose: false, 137 | callback: async () => await this.handleSaveShortcut() 138 | }); 139 | 140 | this.dialog.addButton("Cancel", "close-button", { 141 | noClose: false, 142 | callback: () => this.close() 143 | }); 144 | 145 | const mainWindow = Zotero.getMainWindow(); 146 | const screenWidth = mainWindow.screen.width; 147 | const screenHeight = mainWindow.screen.height; 148 | 149 | const title = this.logic.dialogTitle; 150 | const height = Math.min(screenHeight * 0.8, 600); // Limit height to 600px or 80% of screen height 151 | const width = Math.min(screenWidth * 0.8, 800); // Limit width to 800px or 80% of screen width 152 | 153 | this.dialog.open(title, { 154 | centerscreen: true, 155 | resizable: true, 156 | height: height, 157 | width: width 158 | }); 159 | 160 | await new Promise(resolve => setTimeout(resolve, 300)); 161 | 162 | const inputElement = this.document.getElementById(this.filterInputElementId) as HTMLInputElement | null; 163 | if (inputElement) { 164 | inputElement.focus(); 165 | } 166 | 167 | this.addGlobalKeyListeners(); 168 | } 169 | 170 | private addGlobalKeyListeners() { 171 | this.document.addEventListener("keydown", async event => { 172 | const key = event.key.toLowerCase(); 173 | if (key === "escape") { 174 | this.handleCloseShortcut(); 175 | } else if (key === "enter") { 176 | await this.handleSaveShortcut(); 177 | } 178 | }); 179 | } 180 | 181 | private handleCloseShortcut() { 182 | this.close(); 183 | } 184 | 185 | private async handleSaveShortcut() { 186 | this.close(); 187 | await this.logic.saveChanges(); 188 | } 189 | 190 | get document(): Document { 191 | return this.dialog?.window.document!; 192 | } 193 | 194 | public close() { 195 | if (this.dialog === undefined) return; 196 | this.dialog.window.close(); 197 | this.dialog = undefined; 198 | } 199 | 200 | private updateTagStyles() { 201 | const useInitial = this.logic.filterValue.length == 0; 202 | tagManager.getAllTags().forEach(tag => { 203 | const element = this.document.getElementById(tag.uniqueElementId) as HTMLSpanElement; 204 | const tagState = this.logic.itemTags[tag.tagId]; 205 | if (element && tagState) { 206 | const colors = getColors({ tag: tag, isFiltered: tagState.isFiltered, isActive: tagState.active }); 207 | element.style.color = colors.foreground; 208 | element.style.background = useInitial ? colors.initialBackground : colors.background; 209 | } 210 | }); 211 | } 212 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------