Skip to content

Commit

Permalink
osfile shim apparently dropped from Zotero 7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Aug 9, 2024
1 parent 5b3c7d4 commit 66df328
Show file tree
Hide file tree
Showing 4 changed files with 433 additions and 15 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"default": "array"
}
],
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/ban-types": "off",
Expand Down Expand Up @@ -199,10 +200,6 @@
"no-invalid-this": "off",
"no-irregular-whitespace": "error",
"no-magic-numbers": "off",
"@typescript-eslint/no-magic-numbers": [ "error", {
"ignore": [ -1, 0, 1, 2 ],
"ignoreEnums": true
}],
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-throw-literal": "error",
Expand Down
1 change: 1 addition & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ async function bundle(config) {
}

async function build() {

await bundle({
exportGlobals: true,
entryPoints: [ 'bootstrap.ts' ],
Expand Down
24 changes: 13 additions & 11 deletions lib.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
declare const Zotero: any
declare const Components: any
declare const Services: any
declare let OS: any

import { OS as $OS } from './osfile'
if (typeof OS === 'undefined') OS = $OS

const l10n = require('./locale/en-US/zotero-edtechhub.ftl')

Expand All @@ -22,9 +26,6 @@ var EdTechHub: EdTechHubMain // eslint-disable-line no-var
import { DebugLog as DebugLogSender } from 'zotero-plugin/debug-log'
import { patch as $patch$, unpatch as $unpatch$ } from './monkey-patch'

Components.utils.import('resource://gre/modules/osfile.jsm')
declare const OS: any

import sanitize_filename = require('sanitize-filename')

function flash(title, body = null, timeout = 8) { // eslint-disable-line @typescript-eslint/no-magic-numbers
Expand Down Expand Up @@ -420,16 +421,17 @@ class EdTechHubMain {
return merged // eslint-disable-line @typescript-eslint/no-unsafe-return
})

const addons = await Zotero.getInstalledExtensions()
// if (!addons.find(addon => addon.startsWith('Zotero DOI Manager '))) {
// flash('Zotero-ShortDOI not installed', 'The short-doi plugin is not available, please install it from https://github.com/bwiernik/zotero-shortdoi')
// }
if (!addons.find((addon: string) => addon.startsWith('ZotFile '))) {
flash('ZotFile not installed', 'The ZotFile plugin is not available, please install it from http://zotfile.com/')
/*
const checks = {
'Zotero DOI Manager ': [ 'Zotero-ShortDOI not installed', 'The short-doi plugin is not available, please install it from https://github.com/bwiernik/zotero-shortdoi' ],
'ZotFile ': [ 'ZotFile not installed', 'The ZotFile plugin is not available, please install it from http://zotfile.com/' ],
'Zutilo Utility for Zotero ': [ 'Zutilo not installed', 'The Zutilo plugin is not available, please install it from https://github.com/willsALMANJ/Zutilo' ],
}
if (!addons.find((addon: string) => addon.startsWith('Zutilo Utility for Zotero '))) {
flash('Zutilo not installed', 'The Zutilo plugin is not available, please install it from https://github.com/willsALMANJ/Zutilo')
const addons = await Zotero.getInstalledExtensions()
for (const [ name, [ title, body ] ] of Object.entries(checks)) {
if (!addons.find((addon: string) => addon.startsWith(name))) flash(title, body)
}
*/

try {
debug('installing translators')
Expand Down
Loading

0 comments on commit 66df328

Please sign in to comment.