Mvolz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/154960
Change subject: use templatemap from visualeditor data
......................................................................
use templatemap from visualeditor data
Change-Id: I1ce63ed136f1d9d934d664858e9bda4d17a7a0ae
---
M Citoid.php
M modules/ve.ui.CiteFromURLDialog.js
2 files changed, 58 insertions(+), 40 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Citoid
refs/changes/60/154960/1
diff --git a/Citoid.php b/Citoid.php
index e4c2762..51a38bb 100644
--- a/Citoid.php
+++ b/Citoid.php
@@ -25,6 +25,7 @@
// Register files
$wgAutoloadClasses['CitoidHooks'] = __DIR__ . '/Citoid.hooks.php';
+$wgAutoloadClasses['CitoidDataModule'] = $dir . 'CitoidDataModule.php';
$wgMessagesDirs['Citoid'] = __DIR__ . '/i18n';
// Register hooks
@@ -44,9 +45,14 @@
'citoid-citeFromURLDialog-search',
'citoid-citeFromURLDialog-search-progress',
'citoid-citeFromURLTool-title',
- 'citoid-citeFromURLDialog-title'
+ 'citoid-citeFromURLDialog-title',
),
'targets' => array( 'desktop'), //mwreferences doesn't work in mobile
currently
+
+ // 'ext.citoid.data' => array(
+ // 'class' => 'CitoidDataModule',
+ // ),
+
'localBasePath' => __DIR__,
'remoteExtPath' => 'Citoid',
);
diff --git a/modules/ve.ui.CiteFromURLDialog.js
b/modules/ve.ui.CiteFromURLDialog.js
index 80343dd..1953304 100644
--- a/modules/ve.ui.CiteFromURLDialog.js
+++ b/modules/ve.ui.CiteFromURLDialog.js
@@ -27,41 +27,41 @@
var content, plainObject, d, templateHref, templateName,
citation = jQuery.parseJSON( JSON.stringify(
searchResults ) )[0], //uses the first citation result for the time being
- templateTypeMap = {
- book: 'Cite book',
- bookSection: 'Cite book',
- journalArticle: 'Cite journal',
- magazineArticle: 'Cite news',
- newspaperArticle: 'Cite news',
- thesis: 'Cite journal',
- letter: 'Citation',
- manuscript: 'Cite book',
- interview: 'Citation',
- film: 'Citation',
- artwork: 'Citation',
- webpage: 'Cite web',
- report: 'Cite journal',
- bill: 'Citation',
- hearing: 'Citation',
- patent: 'Citation',
- statute: 'Citation',
- email: 'Cite web',
- map: 'Citation',
- blogPost: 'Cite web',
- instantMessage: 'Citation',
- forumPost: 'Cite web',
- audioRecording: 'Citation',
- presentation: 'Cite journal',
- videoRecording: 'Citation',
- tvBroadcast: 'Citation',
- radioBroadcast: 'Citation',
- podcast: 'Citation',
- computerProgram: 'Citation',
- conferencePaper: 'Cite journal',
- 'document': 'Citation',
- encyclopediaArticle: 'Cite journal',
- dictionaryEntry: 'Cite journal'
- },
+ // templateTypeMap = {
+ // book: 'Cite book',
+ // bookSection: 'Cite book',
+ // journalArticle: 'Cite journal',
+ // magazineArticle: 'Cite news',
+ // newspaperArticle: 'Cite news',
+ // thesis: 'Cite journal',
+ // letter: 'Citation',
+ // manuscript: 'Cite book',
+ // interview: 'Citation',
+ // film: 'Citation',
+ // artwork: 'Citation',
+ // webpage: 'Cite web',
+ // report: 'Cite journal',
+ // bill: 'Citation',
+ // hearing: 'Citation',
+ // patent: 'Citation',
+ // statute: 'Citation',
+ // email: 'Cite web',
+ // map: 'Citation',
+ // blogPost: 'Cite web',
+ // instantMessage: 'Citation',
+ // forumPost: 'Cite web',
+ // audioRecording: 'Citation',
+ // presentation: 'Cite journal',
+ // videoRecording: 'Citation',
+ // tvBroadcast: 'Citation',
+ // radioBroadcast: 'Citation',
+ // podcast: 'Citation',
+ // computerProgram: 'Citation',
+ // conferencePaper: 'Cite journal',
+ // 'document': 'Citation',
+ // encyclopediaArticle: 'Cite journal',
+ // dictionaryEntry: 'Cite journal'
+ // },
//Parameter map for Template:Citation on en-wiki
//In the format citation-template-field:citoid-field
@@ -199,6 +199,11 @@
//This will contain the correct template with the
fields filled out
paramObj = {};
+ try {
+ //Must use mw.message to avoid JSON being parsed as
Wikitext
+ templateTypeMap = jQuery.parseJSON( mw.message(
'citoid-template-type-map.json' ).plain() );
+ } catch ( e ) { }
+
templateName = templateTypeMap[citation.itemType];
templateHref = 'Template:' + templateName;
@@ -274,6 +279,9 @@
);
panel.$element.append( inputsFieldset.$element );
this.$body.append( panel.$element );
+
+ this.modules= ['ext.visualEditor.data'];
+ this.modulesLoaded = $.Deferred();
};
@@ -353,10 +361,8 @@
return
ve.ui.CiteFromURLDialog.super.super.prototype.getActionProcess.call( this,
action );
};
- /**
- * [onTransclusionReady description]
- * @return {[type]} [description]
- */
+ //hack for inheriting from template dialog
+ //enables apply/insert buttons
ve.ui.CiteFromURLDialog.prototype.onTransclusionReady = function () {
// Parent method
ve.ui.CiteFromURLDialog.super.prototype.onTransclusionReady.call( this );
@@ -364,6 +370,12 @@
this.actions.setAbilities( { 'apply': true, 'insert': true } );
};
+ //hack for inheriting from template dialog
+ //Sets the title of the dialog correctly
+ ve.ui.CiteFromURLDialog.prototype.getTemplatePartLabel = function (
part ) {
+ return ve.msg( 'citoid-citeFromURLTool-title' );
+ };
+
ve.ui.windowFactory.register( ve.ui.CiteFromURLDialog );
} );
--
To view, visit https://gerrit.wikimedia.org/r/154960
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ce63ed136f1d9d934d664858e9bda4d17a7a0ae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Citoid
Gerrit-Branch: master
Gerrit-Owner: Mvolz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits