From 9e0818ffa5bb65b51acde7882c525f21135c8333 Mon Sep 17 00:00:00 2001 From: AllThatIsTheCase Date: Sat, 18 Apr 2015 23:52:22 +0200 Subject: [PATCH] auto-export is here, folks! --- chrome/content/zotero-better-bibtex/cache.coffee | 6 +++--- .../content/zotero-better-bibtex/preferences.coffee | 12 ++++++------ chrome/content/zotero-better-bibtex/preferences.xul | 2 +- .../zotero-better-bibtex/zotero-better-bibtex.coffee | 7 ++++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/chrome/content/zotero-better-bibtex/cache.coffee b/chrome/content/zotero-better-bibtex/cache.coffee index c3d3189f06..8a50eba5fd 100644 --- a/chrome/content/zotero-better-bibtex/cache.coffee +++ b/chrome/content/zotero-better-bibtex/cache.coffee @@ -1,9 +1,9 @@ Zotero.BetterBibTeX.auto = {} -Zotero.BetterBibTeX.auto.add = (collection, path, options) -> +Zotero.BetterBibTeX.auto.add = (collectionID, path, options) -> eo = Zotero.BetterBibTeX.cache.exportOptions(options) - Zotero.DB.query("insert or replace into betterbibtex.autoexport (collection, path, exportoptions, includeChildCollections, status) - values (?, ?, ?, ?, 'done')", [state.collection.id, state.target, eo, "#{!!@recursive()}"]) + Zotero.DB.query("insert or replace into betterbibtex.autoexport (collection, path, exportOptions, exportedRecursively, status) + values (?, ?, ?, ?, 'done')", [collectionID, path, eo, "#{!!@recursive()}"]) return Zotero.BetterBibTeX.auto.recursive = -> diff --git a/chrome/content/zotero-better-bibtex/preferences.coffee b/chrome/content/zotero-better-bibtex/preferences.coffee index a8e6fafc3b..b66f95e1fb 100644 --- a/chrome/content/zotero-better-bibtex/preferences.coffee +++ b/chrome/content/zotero-better-bibtex/preferences.coffee @@ -105,13 +105,13 @@ Zotero.BetterBibTeX.pref.update = -> selectedExport = -1 for ae in Zotero.DB.query("select * from betterbibtex.autoexport order by path") selectedExport = 0 - Zotero.BetterBibTeX.log(':::ae', @clone(ae)) + Zotero.BetterBibTeX.log(':::ae', Zotero.BetterBibTeX.pref.clone(ae)) if refill itemNode = document.createElement('listitem') itemNode.setAttribute('value', ae.id) itemNode.setAttribute('label', "collection_name -> #{ae.path.replace(/^.*[\\\/]/, '')}") itemNode.setAttribute('class', "export-state-#{if Zotero.BetterBibTeX.auto.running == ae.id then 'running' else ae.status}") - itemNode.setAttribute('tooltiptext', "#{@collectionPath(ae.collection_id)} -> #{ae.path}") + itemNode.setAttribute('tooltiptext', "#{@collectionPath(ae.collection)} -> #{ae.path}") exportlist.appendChild(itemNode) if selectedExport >= 0 @autoexport.selected(selectedIndex) @@ -133,11 +133,11 @@ Zotero.BetterBibTeX.pref.autoexport = document.getElementById('auto-export-mark').setAttribute('disabled', false) ae = Zotero.DB.rowQuery('select * from betterbibtex.autoexport ae join betterbibtex.exportoptions eo on ae.exportoptions = eo.id where ae.id = ?', [selectedItem.getAttribute('value')]) - Zotero.BetterBibTeX.log(':::selected', @clone(ae)) + Zotero.BetterBibTeX.log(':::selected', Zotero.BetterBibTeX.pref.clone(ae)) - @display('id-better-bibtex-preferences-auto-export-collection', 'ae.collection_name') - @display('id-better-bibtex-preferences-auto-export-target', ae.path) - @display('id-better-bibtex-preferences-auto-export-translator', 'ae.translatorID') + Zotero.BetterBibTeX.pref.display('id-better-bibtex-preferences-auto-export-collection', 'ae.collection_name') + Zotero.BetterBibTeX.pref.display('id-better-bibtex-preferences-auto-export-target', ae.path) + Zotero.BetterBibTeX.pref.display('id-better-bibtex-preferences-auto-export-translator', 'ae.translatorID') document.getElementById('id-better-bibtex-preferences-auto-export-auto-abbrev').checked = (ae.useJournalAbbreviation == 'true') document.getElementById('id-better-bibtex-preferences-auto-export-notes').checked = (ae.exportNotes == 'true') document.getElementById('id-better-bibtex-preferences-auto-export-preserve-bibvars').checked = (ae.preserveBibTeXVariables == 'true') diff --git a/chrome/content/zotero-better-bibtex/preferences.xul b/chrome/content/zotero-better-bibtex/preferences.xul index c21b5e163b..edae0be56a 100644 --- a/chrome/content/zotero-better-bibtex/preferences.xul +++ b/chrome/content/zotero-better-bibtex/preferences.xul @@ -201,7 +201,7 @@ - + diff --git a/chrome/content/zotero-better-bibtex/zotero-better-bibtex.coffee b/chrome/content/zotero-better-bibtex/zotero-better-bibtex.coffee index d7fdb2fb5a..8630ac1a29 100755 --- a/chrome/content/zotero-better-bibtex/zotero-better-bibtex.coffee +++ b/chrome/content/zotero-better-bibtex/zotero-better-bibtex.coffee @@ -219,6 +219,7 @@ Zotero.BetterBibTeX.updateSchema = -> columns = Object.create(null) for table in ['keys', 'autoexport', 'exportoptions'] columns[table] = @SQLColumns(table) + Zotero.DB.query("drop table if exists betterbibtex._#{table}_") Zotero.DB.query("alter table betterbibtex.#{table} rename to _#{table}_") if columns[table] Zotero.DB.query('drop table if exists betterbibtex.keys2') Zotero.DB.query('drop table if exists betterbibtex.cache') @@ -543,14 +544,14 @@ Zotero.BetterBibTeX.itemAdded = { unless collections.length == 0 || Zotero.BetterBibTeX.pref.get('autoExport') == 'disabled' collections = Zotero.BetterBibTeX.withParentCollections(collections) - Zotero.DB.query("update betterbibtex.autoexport set status = 'pending' where collection_id in #{Zotero.BetterBibTeX.SQLSet(collections)}") + Zotero.DB.query("update betterbibtex.autoexport set status = 'pending' where collection in #{Zotero.BetterBibTeX.SQLSet(collections)}") Zotero.BetterBibTeX.auto.process('collectionChanged') return } Zotero.BetterBibTeX.collectionChanged = notify: (event, type, ids, extraData) -> - Zotero.DB.query("delete from betterbibtex.autoexport where collection_id in #{Zotero.BetterBibTeX.SQLSet(extraData)}") if event == 'delete' && extraData.length > 0 + Zotero.DB.query("delete from betterbibtex.autoexport where collection in #{Zotero.BetterBibTeX.SQLSet(extraData)}") if event == 'delete' && extraData.length > 0 return Zotero.BetterBibTeX.SQLSet = (values) -> '(' + ('' + v for v in values).join(', ') + ')' @@ -581,7 +582,7 @@ Zotero.BetterBibTeX.itemChanged = notify: (event, type, ids, extraData) -> collections = Zotero.Collections.getCollectionsContainingItems(ids, true) unless collections.length == 0 || Zotero.BetterBibTeX.pref.get('autoExport') == 'disabled' collections = Zotero.BetterBibTeX.withParentCollections(collections) - Zotero.DB.query("update betterbibtex.autoexport set status = 'pending' where collection_id in #{Zotero.BetterBibTeX.SQLSet(collections)}") + Zotero.DB.query("update betterbibtex.autoexport set status = 'pending' where collection in #{Zotero.BetterBibTeX.SQLSet(collections)}") Zotero.BetterBibTeX.auto.process('itemChanged') return