Skip to content

Commit

Permalink
Run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic-DallOsto committed Aug 27, 2024
1 parent 1e92ce5 commit c0ee6f8
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 108 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ The plugin consists of four separate basic modules:
This module adds citation metadata support to Zotero.
It provides an additional Citations tab where the user can:

- add, edit or remove individual citations;
- run item-wide and citation specific actions, such as syncing citations with WikiData, parsing citations from attachments (not yet supported), etc;
- edit source item's UUIDs, such as DOI, WikiData's QID, and [OpenCitations Corpus](https://opencitations.net/corpus) ID.
- add, edit or remove individual citations;
- run item-wide and citation specific actions, such as syncing citations with WikiData, parsing citations from attachments (not yet supported), etc;
- edit source item's UUIDs, such as DOI, WikiData's QID, and [OpenCitations Corpus](https://opencitations.net/corpus) ID.

Citations metadata are currently saved as a note attachment.

Expand Down Expand Up @@ -62,7 +62,7 @@ Cita is collaboratively translated at translatewiki.net. Would you like to help
3. Add a line in `.env` pointing to the Zotero profile you will be using: `ZOTERO_PLUGIN_PROFILE_PATH = <path-to-your-zotero-profile-folder>` (ideally, create a new Zotero profile for debugging). For me the folder is called `3vvlvf75.debug`. Instructions on how to find this folder can be found [here](https://www.zotero.org/support/kb/profile_directory)
5. Run `npm install`
6. This plugin is built using esbuild. Run `npm run start` to launch Zotero and rebuild the plugin automatically each time the source code is changed (thanks to [zotero-plugin-scaffold](https://github.com/northword/zotero-plugin-scaffold)). For some changes like CSS the hot reloading doesn't work and you will need to restart Zotero. Built files will be saved to `build/addon/chrome/content`.
1. The firefox debug tools should automatically pop up, allowing you to see console output, debug code, and edit CSS. Most code should be visible under `file://` in the debugger
1. The firefox debug tools should automatically pop up, allowing you to see console output, debug code, and edit CSS. Most code should be visible under `file://` in the debugger
7. For distribution, run `npm run build`, then you can find the extension at `build/zotero-cita.xpi`.

## Publishing
Expand All @@ -71,33 +71,33 @@ Cita is collaboratively translated at translatewiki.net. Would you like to help
1. Decide new version number vX.Y.Z using [Semantic Versioning](https://semver.org/).
2. Update version number in:
- `/package.json`
- `/static/install.rdf`
- **Note:** Choose the correct update script in `em:updateURL` depending on beta/full release
- `/package.json`
- `/static/install.rdf`
- **Note:** Choose the correct update script in `em:updateURL` depending on beta/full release
3. Update `version` and `updateLink`s in `/update.rdf` or `./update-beta.rdf` (for the beta release).
4. Run `git clean -xdf` to remove untracked files, including `/build` and `/node_modules`.
5. Run `npm install`. This will also update `/package-lock.json` with the new version.
6. Run `npm run build` to build the plugin.
7. Zip the contents of `/build` into a zip file named `zotero-cita-vX.Y.Z.xpi`. E. g. `cd build && zip -r ../zotero-cita-v0.0.1.xpi *`
8. Until integration tests have been implemented (#30), install the new version
on a fresh Zotero profile and run some manual tests.
1. Run `git commit -m "Bump vX.Y.Z"` and `git push`.
2. Run `git tag vX.Y.Z` and `git push --tags`.
3. On GitHub, create a new release:
1. Choose tag vX.Y.Z.
2. Set release title "vX.Y.Z".
3. In the description, list changes since last release.
4. Attach the xpi file created above.
5. Click "Publish release" and hope everything is alright.
on a fresh Zotero profile and run some manual tests.
9. Run `git commit -m "Bump vX.Y.Z"` and `git push`.
10. Run `git tag vX.Y.Z` and `git push --tags`.
11. On GitHub, create a new release:
1. Choose tag vX.Y.Z.
2. Set release title "vX.Y.Z".
3. In the description, list changes since last release.
4. Attach the xpi file created above.
5. Click "Publish release" and hope everything is alright.

## Acknowledgements

Cita depends on:

- maxlath's [wikibase-edit](https://github.com/maxlath/wikibase-edit) & [wikibase-sdk](https://github.com/maxlath/wikibase-sdk)
- Philipp Zumstein's [QuickStatements translator for Zotero](https://github.com/UB-Mannheim/zotkat)
- Tim Wölfle's [Local Citation Network](https://timwoelfle.github.io/Local-Citation-Network/)
- [React](https://reactjs.org/)
- maxlath's [wikibase-edit](https://github.com/maxlath/wikibase-edit) & [wikibase-sdk](https://github.com/maxlath/wikibase-sdk)
- Philipp Zumstein's [QuickStatements translator for Zotero](https://github.com/UB-Mannheim/zotkat)
- Tim Wölfle's [Local Citation Network](https://timwoelfle.github.io/Local-Citation-Network/)
- [React](https://reactjs.org/)

Support for importing/exporting citations from/to a file, among other contributions, were mostly implemented by Dominic Dall'Osto.

Expand Down
28 changes: 17 additions & 11 deletions src/utils/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ function initLocale() {
typeof Localization === "undefined"
? ztoolkit.getGlobal("Localization")
: Localization
// using the Localization interface synchronously by passing true as the
// second parameter to the constructor, though "strongly discouraged by
// Mozilla"
)([`${config.addonRef}-addon.ftl`], true);
)(
// using the Localization interface synchronously by passing true as the
// second parameter to the constructor, though "strongly discouraged by
// Mozilla"
[`${config.addonRef}-addon.ftl`],
true,
);
addon.data.locale = {
current: l10n,
};

// Zotero 7 automatically registers Fluent sources for enabled plugins
// found in [plugin-root]/locale/{locale}/
// See https://www.zotero.org/support/dev/zotero_7_for_developers#registering_fluent_files
Expand All @@ -41,11 +44,14 @@ function initLocale() {
// back to English.
// TODO: Consider moving this code to bootstrap.js.

ztoolkit.getGlobal("L10nRegistry").getInstance().removeSources([config.addonID]);
ztoolkit
.getGlobal("L10nRegistry")
.getInstance()
.removeSources([config.addonID]);

let source = new (ztoolkit.getGlobal("L10nFileSource"))(
const source = new (ztoolkit.getGlobal("L10nFileSource"))(
config.addonID,
'app',
"app",
[
// List of locales supported by us
// TODO: consider picking this up from manifest.json, maybe using
Expand Down Expand Up @@ -82,11 +88,11 @@ function initLocale() {
"tr",
"uk",
"zh-hans",
"zh-hant"
"zh-hant",
],
rootURI + 'locale/{locale}/'
rootURI + "locale/{locale}/",
);

ztoolkit.getGlobal("L10nRegistry").getInstance().registerSources([source]);
}

Expand Down
2 changes: 1 addition & 1 deletion static/_locales/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Messages in this folder are only for localization of strings in the extension's
manifest.json file, according to WebExtensions internationalization guidelines:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Internationalization#internationalizing_manifest.json

Translations for the rest of the extension are found in ../chrome/locale/.
Translations for the rest of the extension are found in ../chrome/locale/.
18 changes: 9 additions & 9 deletions static/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"author": {
"message": "Diego de la Hera, Dominic Dall'Osto, and others",
"description": "Author of the extension"
},
"author": {
"message": "Diego de la Hera, Dominic Dall'Osto, and others",
"description": "Author of the extension"
},

"description": {
"message": "Citations metadata support for Zotero",
"description": "Description of the extension"
}
}
"description": {
"message": "Citations metadata support for Zotero",
"description": "Description of the extension"
}
}
18 changes: 9 additions & 9 deletions static/_locales/es/messages.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"author": {
"message": "Diego de la Hera, Dominic Dall'Osto, y otrxs",
"description": "Autor de la extensión"
},
"author": {
"message": "Diego de la Hera, Dominic Dall'Osto, y otrxs",
"description": "Autor de la extensión"
},

"description": {
"message": "Soporte para metadatos de citas en Zotero",
"description": "Descripción de la extensión"
}
}
"description": {
"message": "Soporte para metadatos de citas en Zotero",
"description": "Descripción de la extensión"
}
}
45 changes: 35 additions & 10 deletions static/chrome/content/citationEditor.xhtml
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
<window id="citation-editor" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<window
id="citation-editor"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
>
<linkset>
<html:link rel="stylesheet" href="chrome://global/skin/" type="text/css" />
<html:link rel="stylesheet" href="chrome://zotero/skin/zotero.css" type="text/css" />
<html:link rel="stylesheet" href="chrome://zotero-platform/content/zotero.css" type="text/css" />
<html:link rel="stylesheet" href="chrome://__addonRef__/content/skin/default/editor.css" type="text/css" />
<html:link rel="stylesheet" href="chrome://__addonRef__/content/skin/default/overlay.css" type="text/css" />
<html:link
rel="stylesheet"
href="chrome://global/skin/"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://zotero/skin/zotero.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://zotero-platform/content/zotero.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://__addonRef__/content/skin/default/editor.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://__addonRef__/content/skin/default/overlay.css"
type="text/css"
/>
<html:link rel="localization" href="__addonRef__-addon.ftl" />
</linkset>

<script type="text/javascript" src="chrome://zotero/content/include.js"></script>
<script
type="text/javascript"
src="chrome://zotero/content/include.js"
></script>
<!-- need customElements.js to pull in Zotero's item-box component -->
<script src="chrome://zotero/content/customElements.js"></script>
<script src="chrome://__addonRef__/content/scripts/dialogs/editor/index.js"></script>


<html:div id="citation-editor-container">
<html:div id="citation-editor-item-box-container">
<item-box id="citation-editor-item-box" />
</html:div>
<html:div id="root"></html:div>
</html:div>
</window>
</window>
39 changes: 30 additions & 9 deletions static/chrome/content/citationImporter.xhtml
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
<window id="citation-importer" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<window
id="citation-importer"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
>
<html:link rel="stylesheet" href="chrome://global/skin/" type="text/css" />
<html:link rel="stylesheet" href="chrome://zotero/skin/zotero.css" type="text/css" />
<html:link rel="stylesheet" href="chrome://zotero-platform/content/zotero.css" type="text/css" />
<html:link rel="stylesheet" href="chrome://__addonRef__/content/skin/default/citation-importer.css"
type="text/css" />
<html:link rel="stylesheet" href="chrome://__addonRef__/content/skin/default/overlay.css" type="text/css" />
<html:link
rel="stylesheet"
href="chrome://zotero/skin/zotero.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://zotero-platform/content/zotero.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://__addonRef__/content/skin/default/citation-importer.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://__addonRef__/content/skin/default/overlay.css"
type="text/css"
/>
<html:link rel="localization" href="__addonRef__-addon.ftl" />

<script type="text/javascript" src="chrome://zotero/content/include.js"></script>
<script
type="text/javascript"
src="chrome://zotero/content/include.js"
></script>
<script src="chrome://__addonRef__/content/scripts/dialogs/citation-importer/index.js"></script>

<html:div id="root"></html:div>
</window>
</window>
45 changes: 35 additions & 10 deletions static/chrome/content/identifierImporter.xhtml
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
<window id="identifier-importer" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<window
id="identifier-importer"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
>
<linkset>
<html:link rel="stylesheet" href="chrome://global/skin/" type="text/css" />
<html:link rel="stylesheet" href="chrome://zotero/skin/zotero.css" type="text/css" />
<html:link rel="stylesheet" href="chrome://zotero-platform/content/zotero.css" type="text/css" />
<html:link rel="stylesheet" href="chrome://__addonRef__/content/skin/default/identifier-importer.css"
type="text/css" />
<html:link rel="stylesheet" href="chrome://__addonRef__/content/skin/default/overlay.css" type="text/css" />
<html:link
rel="stylesheet"
href="chrome://global/skin/"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://zotero/skin/zotero.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://zotero-platform/content/zotero.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://__addonRef__/content/skin/default/identifier-importer.css"
type="text/css"
/>
<html:link
rel="stylesheet"
href="chrome://__addonRef__/content/skin/default/overlay.css"
type="text/css"
/>
<html:link rel="localization" href="__addonRef__-addon.ftl" />
</linkset>

<script type="text/javascript" src="chrome://zotero/content/include.js"></script>
<script
type="text/javascript"
src="chrome://zotero/content/include.js"
></script>
<script src="chrome://__addonRef__/content/scripts/dialogs/identifier-importer/index.js"></script>

<html:div id="root"></html:div>
</window>
</window>
20 changes: 15 additions & 5 deletions static/chrome/content/preferences.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
<html:div id="root">
<groupbox>
<label>
<html:h2 data-l10n-id="zotero-wikicite-wikicite_prefs_citation-storage"></html:h2>
<html:p data-l10n-id="zotero-wikicite-wikicite_prefs_citation-storage-desc"></html:p>
<html:h2
data-l10n-id="zotero-wikicite-wikicite_prefs_citation-storage"
></html:h2>
<html:p
data-l10n-id="zotero-wikicite-wikicite_prefs_citation-storage-desc"
></html:p>
</label>
<radiogroup preference="__prefsPrefix__.storage">
<!-- Note: need to manually make these .labels in the fluent during build -->
<radio value="note" data-l10n-id="zotero-wikicite-wikicite_prefs_citation-storage-note" />
<radio value="extra" data-l10n-id="zotero-wikicite-wikicite_prefs_citation-storage-extra" />
<radio
value="note"
data-l10n-id="zotero-wikicite-wikicite_prefs_citation-storage-note"
/>
<radio
value="extra"
data-l10n-id="zotero-wikicite-wikicite_prefs_citation-storage-extra"
/>
</radiogroup>
</groupbox>
</html:div>
</vbox>
</vbox>
Loading

0 comments on commit c0ee6f8

Please sign in to comment.