jenkins-bot has submitted this change and it was merged.

Change subject: Add credit line for Zotero citations
......................................................................


Add credit line for Zotero citations

The citoid service as of  I44eec8a77f3c08
provides a "source" field with every
response. This change adds a credit line for
Zotero only.

Bug: T145464
Change-Id: If181b9bfc8384fa31b2d6e3b082cc0470bf96546
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/ve.ui.CiteFromIdInspector.css
M modules/ve.ui.CiteFromIdInspector.js
5 files changed, 28 insertions(+), 2 deletions(-)

Approvals:
  Esanders: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 6d771d4..1a01d7b 100644
--- a/extension.json
+++ b/extension.json
@@ -47,6 +47,7 @@
                                "citoid-520-error",
                                "citoid-citation-widget-insert-button",
                                "citoid-citefromiddialog-back",
+                               "citoid-citefromiddialog-credit",
                                "citoid-citefromiddialog-lookup-button",
                                "citoid-citefromiddialog-mode-auto",
                                "citoid-citefromiddialog-mode-manual",
diff --git a/i18n/en.json b/i18n/en.json
index f36eee3..84d8c86 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -5,6 +5,7 @@
        "citoid-520-error": "Unable to retrieve information from the provided 
identifier.",
        "citoid-citation-widget-insert-button": "Insert",
        "citoid-citefromiddialog-back": "Back",
+       "citoid-citefromiddialog-credit": "Powered by $1",
        "citoid-citefromiddialog-lookup-button": "Generate",
        "citoid-citefromiddialog-mode-auto": "Automatic",
        "citoid-citefromiddialog-mode-manual": "Manual",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 9498378..b2ffbd2 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -14,6 +14,7 @@
        "citoid-520-error": "Error message for when citoid service returns a 
520 error",
        "citoid-citation-widget-insert-button": "Label for the button to insert 
a chosen reference.\n{{Identical|Insert}}",
        "citoid-citefromiddialog-back": "Label for the button to go back to the 
generate panel in the inspector.\n{{Identical|Back}}",
+       "citoid-citefromiddialog-credit": "Text giving credit for the source of 
the retrieved citation; variable is name of source, i.e. 'Zotero'.",
        "citoid-citefromiddialog-lookup-button": "Label for the generate button 
for citation inputs. Unlike \"search\", \"generate\" is a process in which 
there is certainty that a particular result will be found, for example, 
matching a valid ISBN to a book title.\n{{Identical|Generate}}",
        "citoid-citefromiddialog-mode-auto": "Label of tab in citation dialog 
({{msg-mw|Citoid-citefromiddialog-title}}), used to select mode. The other tabs 
are {{msg-mw|Citoid-citefromiddialog-mode-manual}} and 
{{msg-mw|Citoid-citefromiddialog-mode-reuse}}.\n{{Identical|Automatic}}",
        "citoid-citefromiddialog-mode-manual": "Label of tab in citation 
dialog, used to select mode.\n{{Identical|Manual}}",
diff --git a/modules/ve.ui.CiteFromIdInspector.css 
b/modules/ve.ui.CiteFromIdInspector.css
index 9b998ed..a79bb64 100644
--- a/modules/ve.ui.CiteFromIdInspector.css
+++ b/modules/ve.ui.CiteFromIdInspector.css
@@ -55,6 +55,12 @@
        z-index: 1;
 }
 
+.ve-ui-citeFromIdInspector-credit {
+       font-size: x-small;
+       text-align: right;
+       color: #888;
+}
+
 .ve-ui-citeFromIdInspector-dialog-error {
        margin-top: 1em;
        color: #c00;
diff --git a/modules/ve.ui.CiteFromIdInspector.js 
b/modules/ve.ui.CiteFromIdInspector.js
index 9689e3d..ac6d633 100644
--- a/modules/ve.ui.CiteFromIdInspector.js
+++ b/modules/ve.ui.CiteFromIdInspector.js
@@ -199,6 +199,11 @@
 
        // Preview fieldset
        this.previewSelectWidget = new ve.ui.CiteFromIdGroupWidget();
+       this.credit = new OO.ui.Element( {
+               tag: 'div',
+               text: OO.ui.deferMsg( 'citoid-citefromiddialog-credit', [ 
'Zotero' ] ),
+               classes: [ 've-ui-citeFromIdInspector-credit' ]
+       } );
        this.autoProcessPanels.result.$element.append( 
this.previewSelectWidget.$element );
 
        // Manual mode
@@ -480,6 +485,9 @@
                        // Clear selection
                        this.sourceSelect.selectItem();
 
+                       // Clear credit line
+                       this.credit.$element.remove();
+
                        // Reset
                        if ( this.lookupPromise ) {
                                this.lookupPromise.abort();
@@ -516,6 +524,8 @@
                return new OO.ui.Process( function () {
                        // Clear the results
                        this.setModePanel( 'auto', 'lookup' );
+                       // Clear credit line
+                       this.credit.$element.remove();
                }, this );
        }
        // Fallback to parent handler
@@ -631,6 +641,7 @@
                this.results.push( {
                        templateName: templateName,
                        template: null,
+                       source: citation.source, // May be undefined or Array
                        transclusionModel: new ve.dm.MWTransclusionModel()
                } );
                result = this.results[ this.results.length - 1 ];
@@ -646,7 +657,8 @@
 
        return $.when.apply( $, partPromises )
                .then( function () {
-                       var optionWidgets = [];
+                       var sources = [],
+                               optionWidgets = [];
                        // Create option widgets
                        for ( i = 0; i < inspector.results.length; i++ ) {
                                refWidget = new ve.ui.CiteFromIdReferenceWidget(
@@ -657,12 +669,17 @@
                                                templateName: 
inspector.results[ i ].templateName,
                                                citeTools: inspector.citeTools
                                        } );
+                               sources.push( inspector.results[ i ].source ); 
// source may be undefined or Array of strings
                                optionWidgets.push( refWidget );
                                renderPromises.push( 
refWidget.getRenderPromise() );
                        }
                        if ( optionWidgets.length > 0 ) {
-                               // Add to the select widget
+                               // Add citations to the select widget
                                inspector.previewSelectWidget.addItems( 
optionWidgets );
+                               // Add credit item only for result to the 
widget, currently for Zotero only
+                               if ( sources[ 0 ] && ( sources[ 0 ].indexOf( 
'Zotero' ) > -1 ) ) {
+                                       
inspector.previewSelectWidget.$element.append( inspector.credit.$element );
+                               }
                                return $.when.apply( $, renderPromises );
                        }
                        // failed, so go back

-- 
To view, visit https://gerrit.wikimedia.org/r/314712
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If181b9bfc8384fa31b2d6e3b082cc0470bf96546
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Citoid
Gerrit-Branch: master
Gerrit-Owner: Mvolz <mv...@wikimedia.org>
Gerrit-Reviewer: DLynch <dly...@wikimedia.org>
Gerrit-Reviewer: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Mvolz <mv...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to