www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f2ffc307283afcde9a6f5d6b57aae5fab17496b6
parent 55d84bcbf34020b413bcf8589ad153ae2db31237
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 28 Jan 2015 22:57:10 -0500

Merge pull request #607 from rmzelle/rename-style-panes

Localize Style Editor and Preview and other improvements
Diffstat:
Achrome/content/zotero/tools/csledit.js | 209+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mchrome/content/zotero/tools/csledit.xul | 248+++++++++----------------------------------------------------------------------
Achrome/content/zotero/tools/cslpreview.js | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mchrome/content/zotero/tools/cslpreview.xul | 125++++++++++++++-----------------------------------------------------------------
Achrome/locale/en-US/zotero/csledit.dtd | 4++++
Achrome/locale/en-US/zotero/cslpreview.dtd | 9+++++++++
Mchrome/locale/en-US/zotero/preferences.dtd | 7+++----
Mchrome/locale/en-US/zotero/zotero.dtd | 4++--
Mchrome/locale/en-US/zotero/zotero.properties | 9+++++++++
9 files changed, 391 insertions(+), 331 deletions(-)

diff --git a/chrome/content/zotero/tools/csledit.js b/chrome/content/zotero/tools/csledit.js @@ -0,0 +1,209 @@ +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2009 Center for History and New Media + George Mason University, Fairfax, Virginia, USA + http://zotero.org + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see <http://www.gnu.org/licenses/>. + + ***** END LICENSE BLOCK ***** +*/ + +var Zotero_CSL_Editor = new function() { + this.init = init; + this.handleKeyPress = handleKeyPress; + this.loadCSL = loadCSL; + this.generateBibliography = generateBibliography; + this.refresh = refresh; + function init() { + var cslList = document.getElementById('zotero-csl-list'); + if (cslList.getAttribute('initialized') == 'true') { + if (currentStyle) { + loadCSL(currentStyle); + refresh(); + } + return; + } + + var rawDefaultStyle = Zotero.Prefs.get('export.quickCopy.setting'); + var defaultStyle = Zotero.QuickCopy.stripContentType(rawDefaultStyle); + + var styles = Zotero.Styles.getAll(); + var currentStyle = null; + var listPos = 0; + for each(var style in styles) { + if (style.source) { + continue; + } + var item = cslList.appendItem(style.title, style.styleID); + if (!currentStyle || defaultStyle == ('bibliography=' + style.styleID)) { + currentStyle = style.styleID; + cslList.selectedIndex = listPos; + } + listPos += 1; + } + if (currentStyle) { + loadCSL(currentStyle); + refresh(); + } + var pageList = document.getElementById('zotero-csl-page-type'); + var locators = Zotero.Cite.labels; + for each(var type in locators) { + var locator = type; + locator = locator[0].toUpperCase()+locator.substr(1); + pageList.appendItem(locator, type); + } + + pageList.selectedIndex = 0; + cslList.setAttribute('initialized', true); + } + function refresh() { + var editor = document.getElementById('zotero-csl-editor'); + generateBibliography(editor.value); + + } + this.save = function() { + var editor = document.getElementById('zotero-csl-editor'); + var style = editor.value; + const nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"] + .createInstance(nsIFilePicker); + fp.init(window, Zotero.getString('styles.editor.save'), nsIFilePicker.modeSave); + fp.appendFilter("Citation Style Language", "*.csl"); + //get the filename from the id; we could consider doing even more here like creating the id from filename. + var parser = new DOMParser(); + var doc = parser.parseFromString(style, 'text/xml'); + var filename = doc.getElementsByTagName("id"); + if (filename) { + filename = filename[0].textContent; + fp.defaultString = filename.replace(/.+\//, "") + ".csl"; + } + else { + fp.defaultString = "untitled.csl"; + } + var rv = fp.show(); + if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) { + var outputFile = fp.file; + Zotero.File.putContents(outputFile, style); + } + }; + + function handleKeyPress(event) { + if (event.keyCode == 9 && + (!event.shiftKey && !event.metaKey && !event.altKey && !event.ctrlKey)) { + _insertText("\t"); + event.preventDefault(); + } + } + + + function loadCSL(cslID) { + var editor = document.getElementById('zotero-csl-editor'); + var style = Zotero.Styles.get(cslID); + editor.value = Zotero.File.getContents(style.file); + editor.cslID = cslID; + editor.doCommand(); + document.getElementById('zotero-csl-list').value = cslID; + } + + + function generateBibliography(str) { + var editor = document.getElementById('zotero-csl-editor') + var iframe = document.getElementById('zotero-csl-preview-box'); + + var items = Zotero.getActiveZoteroPane().getSelectedItems(); + if (items.length == 0) { + iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">' + Zotero.getString('styles.editor.warning.noItems') + '</p></body></html>'; + return; + } + var styleObject, styleEngine; + try { + styleObject = new Zotero.Style(str); + styleEngine = styleObject.getCiteProc(); + } catch(e) { + iframe.contentDocument.documentElement.innerHTML = '<div>' + Zotero.getString('styles.editor.warning.parseError') + '</div><div>'+e+'</div>'; + throw e; + } + + var itemIds = [items[i].id for (i in items)]; + + styleEngine.updateItems(itemIds); + + // Generate multiple citations + var citation = {}; + citation.citationItems = []; + citation.properties = {}; + citation.properties.noteIndex = 1; + for (var i = 0, ilen = items.length; i < ilen; i += 1) { + citation.citationItems.push({id:itemIds[i]}); + } + + // Generate single citations + var author = document.getElementById("preview-suppress-author").checked; + var search = document.getElementById('preview-pages'); + var loc = document.getElementById('zotero-csl-page-type'); + var pos = document.getElementById('zotero-ref-position').selectedItem.value; + var citations = '<h3>' + Zotero.getString('styles.editor.output.individualCitations') + '</h3>'; + for (var i=0; i<citation.citationItems.length; i++) { + citation.citationItems[i]['suppress-author'] = author; + if (search.value !== '') { + citation.citationItems[i].locator = search.value; + citation.citationItems[i].label = loc.selectedItem.value; + } + if (pos == 4) { + //near note is a subsequent citation with near note set to true; + citation.citationItems[i].position = 1; + citation.citationItems[i]["near-note"] = true; + } + else { + citation.citationItems[i].position = parseInt(pos, 10); + } + var subcitation = [citation.citationItems[i]]; + citations += styleEngine.makeCitationCluster(subcitation) + '<br />'; + } + + try { + var multCitations = '<hr><h3>' + Zotero.getString('styles.editor.output.singleCitation') + '</h3>' + + styleEngine.previewCitationCluster(citation, [], [], "html"); + + // Generate bibliography + styleEngine.updateItems(itemIds); + var bibliography = '<hr/><h3>' + Zotero.getString('styles.bibliography') + '</h3>' + + Zotero.Cite.makeFormattedBibliography(styleEngine, "html"); + + iframe.contentDocument.documentElement.innerHTML = + '<div>' + citations + multCitations + bibliography + '</div>'; + } catch(e) { + iframe.contentDocument.documentElement.innerHTML = '<div>' + Zotero.getString('styles.editor.warning.renderError') + '</div><div>'+e+'</div>'; + throw e; + } + } + + + // From http://kb.mozillazine.org/Inserting_text_at_cursor + function _insertText(text) { + var command = "cmd_insertText"; + var controller = document.commandDispatcher.getControllerForCommand(command); + if (controller && controller.isCommandEnabled(command)) { + controller = controller.QueryInterface(Components.interfaces.nsICommandController); + var params = Components.classes["@mozilla.org/embedcomp/command-params;1"]; + params = params.createInstance(Components.interfaces.nsICommandParams); + params.setStringValue("state_data", "\t"); + controller.doCommandWithParams(command, params); + } + } +}(); diff --git a/chrome/content/zotero/tools/csledit.xul b/chrome/content/zotero/tools/csledit.xul @@ -26,241 +26,47 @@ <?xml-stylesheet href="chrome://global/skin/global.css"?> <?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?> +<!DOCTYPE window [ + <!ENTITY % csleditDTD SYSTEM "chrome://zotero/locale/csledit.dtd"> %csleditDTD; + <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; +]> + <window id="csl-edit" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="Zotero_CSL_Editor.init();" - title="Zotero Reference Test pane"> + title="&styles.editor;"> <script src="chrome://zotero/content/include.js"/> - - <script> - <![CDATA[ - var Zotero_CSL_Editor = new function() { - this.init = init; - this.handleKeyPress = handleKeyPress; - this.loadCSL = loadCSL; - this.generateBibliography = generateBibliography; - this.refresh = refresh; - function init() { - var cslList = document.getElementById('zotero-csl-list'); - if (cslList.getAttribute('initialized') == 'true') { - if (currentStyle) { - loadCSL(currentStyle); - refresh(); - } - return; - } - - var rawDefaultStyle = Zotero.Prefs.get('export.quickCopy.setting'); - var defaultStyle = Zotero.QuickCopy.stripContentType(rawDefaultStyle); - - var styles = Zotero.Styles.getAll(); - var currentStyle = null; - var listPos = 0; - for each(var style in styles) { - if (style.source) { - continue; - } - var item = cslList.appendItem(style.title, style.styleID); - if (!currentStyle || defaultStyle == ('bibliography=' + style.styleID)) { - currentStyle = style.styleID; - cslList.selectedIndex = listPos; - } - listPos += 1; - } - if (currentStyle) { - loadCSL(currentStyle); - refresh(); - } - var pageList = document.getElementById('zotero-csl-page-type'); - var locators = Zotero.Cite.labels; - for each(var type in locators) { - var locator = type; - locator = locator[0].toUpperCase()+locator.substr(1); - pageList.appendItem(locator, type); - } - - pageList.selectedIndex = 0; - cslList.setAttribute('initialized', true) - } - function refresh() { - var editor = document.getElementById('zotero-csl-editor') - generateBibliography(editor.value); - - } - this.save = function() { - var editor = document.getElementById('zotero-csl-editor') - var style = editor.value; - const nsIFilePicker = Components.interfaces.nsIFilePicker; - var fp = Components.classes["@mozilla.org/filepicker;1"] - .createInstance(nsIFilePicker); - fp.init(window, "Save Citation Style", nsIFilePicker.modeSave); - fp.appendFilter("Citation Style Language", "*.csl"); - //get the filename from the id; we could consider doing even more here like creating the id from filename. - var parser = new DOMParser(); - var doc = parser.parseFromString(style, 'text/xml'); - var filename = doc.getElementsByTagName("id"); - if (filename) { - filename = filename[0].textContent; - fp.defaultString = filename.replace(/.+\//, "") + ".csl"; - } - else { - fp.defaultString = "untitled.csl"; - } - var rv = fp.show(); - if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) { - var outputFile = fp.file; - Zotero.File.putContents(outputFile, style); - } - } - - function handleKeyPress(event) { - if (event.keyCode == 9 && - (!event.shiftKey && !event.metaKey && !event.altKey && !event.ctrlKey)) { - _insertText("\t"); - event.preventDefault(); - } - } - - - function loadCSL(cslID) { - var editor = document.getElementById('zotero-csl-editor') - var style = Zotero.Styles.get(cslID); - editor.value = Zotero.File.getContents(style.file); - editor.cslID = cslID; - editor.doCommand(); - document.getElementById('zotero-csl-list').value = cslID; - } - - - function generateBibliography(str) { - var editor = document.getElementById('zotero-csl-editor') - var iframe = document.getElementById('zotero-csl-preview-box'); - - var items = Zotero.getActiveZoteroPane().getSelectedItems(); - if (items.length == 0) { - iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">No references selected in Zotero.</p></body></html>'; - return; - } - var styleObject, styleEngine; - if (str.indexOf("<defaults") != -1) { - iframe.contentDocument.documentElement.innerHTML = - '<div>' - + "Old-style CSLs are no longer supported." - + '</div>'; - return; - } - else { - try { - styleObject = new Zotero.Style(str); - styleEngine = styleObject.getCiteProc(); - } catch(e) { - iframe.contentDocument.documentElement.innerHTML = '<div>Error parsing '+ - 'style: </div><div>'+e+'</div>'; - throw e; - } - } - - var itemIds = [items[i].id for (i in items)]; - - styleEngine.updateItems(itemIds); - - // Generate multiple citations - var citation = {}; - citation.citationItems = []; - citation.properties = {}; - citation.properties.noteIndex = 1; - for (var i = 0, ilen = items.length; i < ilen; i += 1) { - citation.citationItems.push({id:itemIds[i]}); - } - - // Generate single citations - var author = document.getElementById("preview-suppress-author").checked; - var search = document.getElementById('preview-pages'); - var loc = document.getElementById('zotero-csl-page-type'); - var pos = document.getElementById('zotero-ref-position').selectedItem.value; - var citations = '<h1>Single Citations</h1>'; - for (var i=0; i<citation.citationItems.length; i++) { - citation.citationItems[i]['suppress-author'] = author; - if (search.value != '') { - citation.citationItems[i].locator = search.value; - citation.citationItems[i].label = loc.selectedItem.value; - } - if (pos == 4) { - //near note is a subsequent citation with near note set to true; - citation.citationItems[i].position = 1; - citation.citationItems[i]["near-note"] = true; - } - else { - citation.citationItems[i].position = parseInt(pos, 10); - } - var subcitation = [citation.citationItems[i]]; - citations += styleEngine.makeCitationCluster(subcitation) + '<br />'; - } - - try { - var multCitations = '<hr><h1>Multi Citations <span style="font-size:smaller;">(all with position "first")</span></h1>' + - styleEngine.previewCitationCluster(citation, [], [], "html"); - - // Generate bibliography - styleEngine.updateItems(itemIds); - var bibliography = '<hr/><h1>Bibliography</h1>' + - Zotero.Cite.makeFormattedBibliography(styleEngine, "html"); - - iframe.contentDocument.documentElement.innerHTML = - '<div style="white-space: pre-wrap">' - + citations + multCitations + bibliography - + '</div>'; - } catch(e) { - iframe.contentDocument.documentElement.innerHTML = '<div>Error generating citations '+ - 'and bibliography: </div><div>'+e+'</div>'; - throw e; - } - } - - - // From http://kb.mozillazine.org/Inserting_text_at_cursor - function _insertText(text) { - var command = "cmd_insertText"; - var controller = document.commandDispatcher.getControllerForCommand(command); - if (controller && controller.isCommandEnabled(command)) { - controller = controller.QueryInterface(Components.interfaces.nsICommandController); - var params = Components.classes["@mozilla.org/embedcomp/command-params;1"]; - params = params.createInstance(Components.interfaces.nsICommandParams); - params.setStringValue("state_data", "\t"); - controller.doCommandWithParams(command, params); - } - } - } - ]]> - </script> + <script src="csledit.js"/> <vbox flex="1"> <hbox align="center"> - <button id="preview-refresh-button" label="Refresh" oncommand="Zotero_CSL_Editor.refresh()"/> - <button id="zotero-csl-save" label="Save" oncommand="Zotero_CSL_Editor.save()"/> - <menulist id="zotero-csl-page-type" style="min-height: 1.6em; min-width: 50px" oncommand="Zotero_CSL_Editor.refresh()" /> - <label value=":" /> - <textbox size="5" id="preview-pages" type="timed" timeout="250" oncommand="Zotero_CSL_Editor.refresh()"/> - <checkbox oncommand="Zotero_CSL_Editor.refresh()" id="preview-suppress-author" label="Suppress author" /> - <label value="Citation is:" /> - <menulist id="zotero-ref-position" oncommand="Zotero_CSL_Editor.refresh()"> - <menupopup> - <menuitem label="First" value="0"/> - <menuitem label="Subsequent" value="1"/> - <menuitem label="Ibid" value="2"/> - <menuitem label="Ibid+Locator" value="3"/> - <menuitem label="Near Note" value="4"/> - </menupopup> - </menulist> - <menulist id="zotero-csl-list" style="min-height: 1.6em; min-width: 100px" initialized="false" flex="1" oncommand="Zotero_CSL_Editor.loadCSL(this.selectedItem.value)"/> + <button id="preview-refresh-button" label="&zotero.general.refresh;" oncommand="Zotero_CSL_Editor.refresh()"/> + <button id="zotero-csl-save" label="&zotero.general.saveAs;" oncommand="Zotero_CSL_Editor.save()"/> + <menulist id="zotero-csl-page-type" style="min-height: 1.6em; min-width: 50px" oncommand="Zotero_CSL_Editor.refresh()" /> + <label value=":" /> + <textbox size="5" id="preview-pages" type="timed" timeout="250" oncommand="Zotero_CSL_Editor.refresh()"/> + <checkbox oncommand="Zotero_CSL_Editor.refresh()" id="preview-suppress-author" label="&styles.editor.suppressAuthor;" /> + <label value="&styles.editor.citePosition;" /> + <menulist id="zotero-ref-position" oncommand="Zotero_CSL_Editor.refresh()"> + <menupopup> + <menuitem label="first" value="0"/> + <menuitem label="subsequent" value="1"/> + <menuitem label="ibid" value="2"/> + <menuitem label="ibid-with-locator" value="3"/> + <menuitem label="near-note" value="4"/> + </menupopup> + </menulist> + <menulist id="zotero-csl-list" style="min-height: 1.6em; min-width: 100px" initialized="false" flex="1" oncommand="Zotero_CSL_Editor.loadCSL(this.selectedItem.value)"/> </hbox> <textbox id="zotero-csl-editor" type="timed" timeout="250" multiline="true" flex="1" onkeypress="Zotero_CSL_Editor.handleKeyPress(event)" oncommand="document.getElementById('zotero-csl-list').selectedIndex = -1; Zotero_CSL_Editor.generateBibliography(this.value)"/> - <splitter/> + <splitter id="csledit-splitter" collapse="before" persist="state"> + <grippy/> + </splitter> <iframe id="zotero-csl-preview-box" flex="1" style="padding: 0 1em;background:white" overflow="auto" type="content"/> </vbox> diff --git a/chrome/content/zotero/tools/cslpreview.js b/chrome/content/zotero/tools/cslpreview.js @@ -0,0 +1,107 @@ +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2009 Center for History and New Media + George Mason University, Fairfax, Virginia, USA + http://zotero.org + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see <http://www.gnu.org/licenses/>. + + ***** END LICENSE BLOCK ***** + Contributed by Julian Onions +*/ + +var Zotero_CSL_Preview = new function() { + this.init = init; + this.refresh = refresh; + this.generateBibliography = generateBibliography; + + function init() { + //refresh(); + + var iframe = document.getElementById('zotero-csl-preview-box'); + iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p>' + Zotero.getString('styles.preview.instructions') + '</p></body></html>'; + } + function refresh() { + var iframe = document.getElementById('zotero-csl-preview-box'); + var items = Zotero.getActiveZoteroPane().getSelectedItems(); + if (items.length === 0) { + iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">' + Zotero.getString('styles.editor.warning.noItems') + '</p></body></html>'; + return; + } + var progressWin = new Zotero.ProgressWindow(); + // XXX needs its own string really! + progressWin.changeHeadline(Zotero.getString("pane.items.menu.createBib.multiple")); + var icon = 'chrome://zotero/skin/treeitem-attachment-file.png'; + progressWin.addLines(document.title, icon); + progressWin.show(); + progressWin.startCloseTimer(); + var f = function() { + var styles = Zotero.Styles.getAll(); + // XXX needs its own string really for the title! + var str = '<html><head><title></title></head><body>'; + for each(var style in styles) { + if (style.source) { + continue; + } + Zotero.debug("Generate Bib for " + style.title); + var cite = generateBibliography(style); + if (cite) { + str += '<h3>' + style.title + '</h3>'; + str += cite; + str += '<hr>'; + } + } + + str += '</body></html>'; + iframe.contentDocument.documentElement.innerHTML = str; + }; + // Give progress window time to appear + setTimeout(f, 100); + } + + function generateBibliography(style) { + var iframe = document.getElementById('zotero-csl-preview-box'); + + var items = Zotero.getActiveZoteroPane().getSelectedItems(); + if (items.length === 0) { + return ''; + } + + var citationFormat = document.getElementById("citation-format").selectedItem.value; + if (citationFormat != "all" && citationFormat != style.categories) { + Zotero.debug("CSL IGNORE: citation format is " + style.categories); + return ''; + } + var styleEngine = style.getCiteProc(); + + // Generate multiple citations + var citations = styleEngine.previewCitationCluster( + {"citationItems":[{"id":item.id} for each(item in items)], "properties":{}}, + [], [], "html"); + + // Generate bibliography + var bibliography = ''; + if(style.hasBibliography) { + styleEngine.updateItems([item.id for each(item in items)]); + bibliography = Zotero.Cite.makeFormattedBibliography(styleEngine, "html"); + } + + return '<p>' + citations + '</p>' + bibliography; + } + + +}(); diff --git a/chrome/content/zotero/tools/cslpreview.xul b/chrome/content/zotero/tools/cslpreview.xul @@ -27,120 +27,37 @@ <?xml-stylesheet href="chrome://global/skin/global.css"?> <?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?> +<!DOCTYPE window [ + <!ENTITY % cslpreviewDTD SYSTEM "chrome://zotero/locale/cslpreview.dtd"> %cslpreviewDTD; + <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; +]> + <window id="csl-preview" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="Zotero_CSL_Preview.init();" - title="Zotero Preview pane"> + title="&styles.preview;"> <script src="chrome://zotero/content/include.js"/> - - <script> - <![CDATA[ - var Zotero_CSL_Preview = new function() { - this.init = init; - this.refresh = refresh; - this.generateBibliography = generateBibliography; + <script src="cslpreview.js"/> - function init() { - //refresh(); - - var iframe = document.getElementById('zotero-csl-preview-box'); - iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p>Select one or more items in Zotero and click the "Refresh" button to see how these items are rendered by the installed CSL citation styles.</p></body></html>'; - } - function refresh() { - var iframe = document.getElementById('zotero-csl-preview-box'); - var items = Zotero.getActiveZoteroPane().getSelectedItems(); - if (items.length === 0) { - iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">No items selected in Zotero.</p></body></html>'; - return; - } - var progressWin = new Zotero.ProgressWindow(); - // XXX needs its own string really! - progressWin.changeHeadline(Zotero.getString("pane.items.menu.createBib.multiple")); - var icon = 'chrome://zotero/skin/treeitem-attachment-file.png'; - progressWin.addLines(document.title, icon); - progressWin.show(); - progressWin.startCloseTimer(); - var f = function() { - var styles = Zotero.Styles.getAll(); - // XXX needs its own string really for the title! - var str = '<html><head><title></title></head><body>'; - for each(var style in styles) { - if (style.source) { - continue; - } - Zotero.debug("Generate Bib for " + style.title); - var cite = generateBibliography(style); - if (cite) { - str += '<h3>' + style.title + '</h3>'; - str += cite; - str += '<hr>'; - } - } - - str += '</body></html>'; - iframe.contentDocument.documentElement.innerHTML = str; - }; - // Give progress window time to appear - setTimeout(f, 100); - } - - function generateBibliography(style) { - var iframe = document.getElementById('zotero-csl-preview-box'); - - var items = Zotero.getActiveZoteroPane().getSelectedItems(); - if (items.length === 0) { - return ''; - } - - var citationFormat = document.getElementById("citation-format").selectedItem.value; - if (citationFormat != "all" && citationFormat != style.categories) { - Zotero.debug("CSL IGNORE: citation format is " + style.categories); - return ''; - } - var styleEngine = style.getCiteProc(); - - // Generate multiple citations - var citations = styleEngine.previewCitationCluster( - {"citationItems":[{"id":item.id} for each(item in items)], "properties":{}}, - [], [], "html"); - - // Generate bibliography - var bibliography = ''; - if(style.hasBibliography) { - styleEngine.updateItems([item.id for each(item in items)]); - bibliography = Zotero.Cite.makeFormattedBibliography(styleEngine, "html"); - } - - return '<p>' + citations + '</p>' + bibliography; - } - - - }(); - ]]> - </script> - <!-- NEEDS LOCALISING --> <vbox flex="1"> - <hbox > <hbox align="center"> - <button id="preview-refresh-button" label="Refresh" oncommand="Zotero_CSL_Preview.refresh()"/> - <groupbox orient="horizontal" align="center"> - <label value="Citation format:" /> - <menulist id="citation-format" oncommand="Zotero_CSL_Preview.refresh()"> - <menupopup> - <menuitem label="all" value="all"/> - <menuitem label="author" value="author"/> - <menuitem label="author-date" value="author-date"/> - <menuitem label="label" value="label"/> - <menuitem label="note" value="note"/> - <menuitem label="numeric" value="numeric"/> - </menupopup> - </menulist> - </groupbox> + <button id="preview-refresh-button" label="&zotero.general.refresh;" oncommand="Zotero_CSL_Preview.refresh()"/> + + <label value="&styles.preview.citationFormat;" /> + <menulist id="citation-format" oncommand="Zotero_CSL_Preview.refresh()"> + <menupopup> + <menuitem value="all" label="&styles.preview.citationFormat.all;"/> + <menuitem value="author" label="&styles.preview.citationFormat.author;"/> + <menuitem value="author-date" label="&styles.preview.citationFormat.authorDate;"/> + <menuitem value="label" label="&styles.preview.citationFormat.label;"/> + <menuitem value="note" label="&styles.preview.citationFormat.note;"/> + <menuitem value="numeric" label="&styles.preview.citationFormat.numeric;"/> + </menupopup> + </menulist> </hbox> - </hbox> - <iframe id="zotero-csl-preview-box" flex="1" style="padding: 0 1em; background:white;" overflow="auto" type="content"/> + <iframe id="zotero-csl-preview-box" flex="1" style="padding: 0 1em; background:white;" overflow="auto" type="content"/> </vbox> </window> diff --git a/chrome/locale/en-US/zotero/csledit.dtd b/chrome/locale/en-US/zotero/csledit.dtd @@ -0,0 +1,4 @@ +<!ENTITY styles.editor "Zotero Style Editor"> + +<!ENTITY styles.editor.suppressAuthor "Suppress Author"> +<!ENTITY styles.editor.citePosition "Cite Position:"> diff --git a/chrome/locale/en-US/zotero/cslpreview.dtd b/chrome/locale/en-US/zotero/cslpreview.dtd @@ -0,0 +1,9 @@ +<!ENTITY styles.preview "Zotero Style Preview"> + +<!ENTITY styles.preview.citationFormat "Citation Format:"> +<!ENTITY styles.preview.citationFormat.all "all"> +<!ENTITY styles.preview.citationFormat.author "author"> +<!ENTITY styles.preview.citationFormat.authorDate "author-date"> +<!ENTITY styles.preview.citationFormat.label "label"> +<!ENTITY styles.preview.citationFormat.note "note"> +<!ENTITY styles.preview.citationFormat.numeric "numeric"> diff --git a/chrome/locale/en-US/zotero/preferences.dtd b/chrome/locale/en-US/zotero/preferences.dtd @@ -204,6 +204,6 @@ <!ENTITY zotero.preferences.debugOutputLogging.submitToServer "Submit to Zotero Server"> <!ENTITY zotero.preferences.openAboutConfig "Open about:config"> -<!ENTITY zotero.preferences.openCSLEdit "Open CSL Editor"> -<!ENTITY zotero.preferences.openCSLPreview "Open CSL Preview"> -<!ENTITY zotero.preferences.openAboutMemory "Open about:memory"> -\ No newline at end of file +<!ENTITY zotero.preferences.openCSLEdit "Open Style Editor"> +<!ENTITY zotero.preferences.openCSLPreview "Open Style Preview"> +<!ENTITY zotero.preferences.openAboutMemory "Open about:memory"> diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd @@ -6,6 +6,8 @@ <!ENTITY zotero.general.delete "Delete"> <!ENTITY zotero.general.ok "OK"> <!ENTITY zotero.general.cancel "Cancel"> +<!ENTITY zotero.general.refresh "Refresh"> +<!ENTITY zotero.general.saveAs "Save As…"> <!ENTITY zotero.errorReport.title "Zotero Error Report"> <!ENTITY zotero.errorReport.unrelatedMessages "This may include messages unrelated to Zotero."> @@ -288,5 +290,3 @@ <!ENTITY zotero.attachLink.title "Attach Link to URI"> <!ENTITY zotero.attachLink.label.link "Link:"> <!ENTITY zotero.attachLink.label.title "Title:"> - - diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -968,3 +968,12 @@ firstRunGuidance.quickFormat = Type a title or author to search for a reference. firstRunGuidance.quickFormatMac = Type a title or author to search for a reference.\n\nAfter you've made your selection, click the bubble or press Cmd-\u2193 to add page numbers, prefixes, or suffixes. You can also include a page number along with your search terms to add it directly.\n\nYou can edit citations directly in the word processor document. firstRunGuidance.toolbarButton.new = Click here to open Zotero, or use the %S keyboard shortcut. firstRunGuidance.toolbarButton.upgrade = The Zotero icon can now be found in the Firefox toolbar. Click the icon to open Zotero, or use the %S keyboard shortcut. + +styles.bibliography = Bibliography +styles.editor.save = Save Citation Style +styles.editor.warning.noItems = No items selected in Zotero. +styles.editor.warning.parseError = Error parsing style: +styles.editor.warning.renderError = Error generating citations and bibliography: +styles.editor.output.individualCitations = Individual Citations +styles.editor.output.singleCitation = Single Citation (with position "first") +styles.preview.instructions = Select one or more items in Zotero and click the "Refresh" button to see how these items are rendered by the installed CSL citation styles.