Skip to content

Commit

Permalink
Merge branch 'master' into gh-3102
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Jan 6, 2025
2 parents b10f884 + c004aa7 commit 77a612b
Show file tree
Hide file tree
Showing 20 changed files with 448 additions and 234 deletions.
33 changes: 2 additions & 31 deletions content/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,6 @@ function log(msg) {
}
}

// Loads default preferences from prefs.js in Zotero 6
function setDefaultPrefs(rootURI) {
const branch = Services.prefs.getDefaultBranch('')
const obj = {
pref: (pref, value) => {
switch (typeof value) {
case 'boolean':
branch.setBoolPref(pref, value)
break
case 'string':
branch.setStringPref(pref, value)
break
case 'number':
branch.setIntPref(pref, value)
break
default:
log(`Invalid type '${ typeof (value) }' for pref '${ pref }'`)
}
},
}
Services.scriptloader.loadSubScriptWithOptions(`${ rootURI }prefs.js`, {
target: obj,
charset: 'utf-8',
// ignoreCache: true
})
}

export function install(_data: any, _reason: ReasonId) {
log('install, nothing to do')
}
Expand All @@ -82,8 +55,6 @@ export async function startup({ resourceURI, rootURI = resourceURI.spec }, reaso

if (Zotero.BetterBibTeX) throw new Error('Better BibTeX is already started')

setDefaultPrefs(rootURI)

const $window = Cc['@mozilla.org/appshell/appShellService;1'].getService(Ci.nsIAppShellService).hiddenDOMWindow
Services.scriptloader.loadSubScriptWithOptions(`${ rootURI }content/better-bibtex.js`, {
charset: 'utf=8',
Expand Down Expand Up @@ -128,8 +99,8 @@ export async function startup({ resourceURI, rootURI = resourceURI.spec }, reaso
onMainWindowLoad({ window: Zotero.getMainWindow() })
}
catch (err) {
alert({ title: 'Better BibTeX startup failed', text: `${ err }` })
log(`${ err }\n${ err.stack }`)
alert({ title: 'Better BibTeX startup failed', text: `${err}\n${err.stack}` })
log(`${ err }\n${err.stack}`)
}
}

Expand Down
21 changes: 17 additions & 4 deletions content/key-manager/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,24 @@ export class PatternFormatter {
}
}

/** returns the name of the shared group library, or nothing if the item is in your personal library */
/** Tests whether the item is in the user library */
public $library(): this {
if (this.item.libraryID === Zotero.Libraries.userLibraryID) return this.$text('')
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return this.$text(Zotero.Libraries.get(this.item.libraryID).name)
if (this.item.libraryID !== Zotero.Libraries.userLibraryID) this.next = true
return this.$text('')
}

/**
* Tests whether the item is in the given group library
* @param name group name
*/
public $group(name: string): this {
if (this.item.libraryID === Zotero.Libraries.userLibraryID) {
this.next = true
}
else if (Zotero.Libraries.get(this.item.libraryID)?.name !== name) {
this.next = true
}
return this.$text('')
}

/**
Expand Down
4 changes: 2 additions & 2 deletions content/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export const Preference = new class PreferenceManager extends PreferenceManagerB
break
}
}
catch {
error = `could not set default for ${ pref } to ${ typeof value } ${ JSON.stringify(value) }`
catch (err) {
error = `could not set default for ${pref} to ${typeof value} ${JSON.stringify(value)} (${err.message})`
}
if (error) {
const v = Zotero.Prefs.get(`translators.better-bibtex.${ pref }`)
Expand Down
54 changes: 54 additions & 0 deletions content/spreadsheet.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
doctype xml
office:document(
office:version="1.3"
office:mimetype="application/vnd.oasis.opendocument.spreadsheet"
xmlns:office='urn:oasis:names:tc:opendocument:xmlns:office:1.0'
xmlns:config='urn:oasis:names:tc:opendocument:xmlns:config:1.0'
xmlns:loext='urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0'
xmlns:table='urn:oasis:names:tc:opendocument:xmlns:table:1.0'
xmlns:fo='urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'
xmlns:ooo='http://openoffice.org/2004/office'
xmlns:style='urn:oasis:names:tc:opendocument:xmlns:style:1.0'
xmlns:calcext='urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0'
xmlns:text='urn:oasis:names:tc:opendocument:xmlns:text:1.0'
)
office:settings
config:config-item-set(config:name="ooo:view-settings")
config:config-item-map-indexed(config:name="Views")
config:config-item-map-entry
config:config-item(config:name="ViewId" config:type="string") view1
config:config-item-map-named(config:name="Tables")
each rows, name in sheets
config:config-item-map-entry(config:name=name)
config:config-item(config:name="HorizontalSplitMode" config:type="short") 0
config:config-item(config:name="VerticalSplitMode" config:type="short") 2
config:config-item(config:name="HorizontalSplitPosition" config:type="int") 0
config:config-item(config:name="VerticalSplitPosition" config:type="int") 1
config:config-item(config:name="ActiveSplitRange" config:type="short") 0
config:config-item(config:name="PositionLeft" config:type="int") 0
config:config-item(config:name="PositionRight" config:type="int") 0
config:config-item(config:name="PositionTop" config:type="int") 0
config:config-item(config:name="PositionBottom" config:type="int") 1
office:styles
loext:theme(loext:name="Office")
loext:theme-colors(loext:name="LibreOffice")
office:automatic-styles
style:style(style:name="ce1" style:family="table-cell" style:parent-style-name="Default")
style:text-properties(fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold")
office:body
office:spreadsheet
each rows, name in sheets
table:table(table:name=name table:style-name="ta1")
- const columns = Object.keys(rows[0])
table:table-column(table:style-name="co1" table:number-columns-repeated="16384" table:default-cell-style-name="ce1")
table:table-row(table:style-name="ro1")
each column in columns
table:table-cell(office:value-type="string" calcext:value-type="string")
text:p= column
table:table-cell(table:number-columns-repeated="16382")
each row in rows
table:table-row(table:style-name="ro1")
each column in columns
table:table-cell(table:style-name="Default" office:value-type="string" calcext:value-type="string")
text:p= row[column]
table:table-cell(table:style-name="Default" table:number-columns-repeated="16382")
Loading

0 comments on commit 77a612b

Please sign in to comment.