Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/141098
Change subject: [WIP] Update displaytitle on save (try #3)
......................................................................
[WIP] Update displaytitle on save (try #3)
Ignore for now, I think I have an idea which I will upload in PS2.
This reverts commit f84b880a548d0d1e35e68699e8aac5d28fe6cdb4.
Change-Id: I312bafb0e7d61b0abd42d6ca7ea2e4b5dcdc61be
---
M ApiVisualEditorEdit.php
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
M modules/ve-mw/init/ve.init.mw.Target.js
3 files changed, 28 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/98/141098/1
diff --git a/ApiVisualEditorEdit.php b/ApiVisualEditorEdit.php
index 9327a9f..743a0f0 100644
--- a/ApiVisualEditorEdit.php
+++ b/ApiVisualEditorEdit.php
@@ -116,6 +116,15 @@
}
$result['isRedirect'] = $page->isRedirect();
+ $parserOutput =
$this->getOutput()->getWikiPage()->getParserOutput(
+ $this->getOutput()->parserOptions()
+ );
+ if ( $parserOutput ) {
+ $result['displayTitleHtml'] =
$parserOutput->getDisplayTitle();
+ } else {
+ wfDebug( '[VE] ApiVisualEditorEdit -
parserOutput was false' );
+ }
+
if ( isset( $saveresult['edit']['newrevid'] ) ) {
$result['newrevid'] = intval(
$saveresult['edit']['newrevid'] );
}
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 9e801f9..3220a6f 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -421,9 +421,11 @@
* @method
* @param {string} html Rendered page HTML from server
* @param {string} categoriesHtml Rendered categories HTML from server
- * @param {number} [newid] New revision id, undefined if unchanged
+ * @param {number} newid New revision id, undefined if unchanged
+ * @param {boolean} isRedirect Whether this page is a redirect or not
+ * @param {string} displayTitle What HTML to show as the page title
*/
-ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml,
newid, isRedirect ) {
+ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml,
newid, isRedirect, displayTitle ) {
var newUrlParams, watchChecked;
if ( !this.pageExists || this.restoring ) {
// This is a page creation or restoration, refresh the page
@@ -466,7 +468,7 @@
}
this.saveDialog.close();
this.saveDialog.reset();
- this.replacePageContent( html, categoriesHtml, isRedirect );
+ this.replacePageContent( html, categoriesHtml, isRedirect,
displayTitle );
this.setupSectionEditLinks();
this.tearDownBeforeUnloadHandler();
this.deactivate( true );
@@ -1534,8 +1536,10 @@
* @method
* @param {string} html Rendered HTML from server
* @param {string} categoriesHtml Rendered categories HTML from server
+ * @param {boolean} isRedirect Whether this page is a redirect or not
+ * @param {string} displayTitle What HTML to show as the page title
*/
-ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html,
categoriesHtml, isRedirect ) {
+ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html,
categoriesHtml, isRedirect, displayTitle ) {
var $content = $( $.parseHTML( html ) ), $editableContent;
if ( $( '#mw-imagepage-content' ).length ) {
@@ -1555,6 +1559,9 @@
}
mw.hook( 'wikipage.content' ).fire( $editableContent.empty().append(
$content ) );
+ if ( displayTitle ) {
+ $( '#content > #firstHeading > span' ).html( displayTitle );
+ }
$( '#catlinks' ).replaceWith( categoriesHtml );
if ( isRedirect ) {
$( '#contentSub' ).text( ve.msg( 'redirectpagesub' ) );
diff --git a/modules/ve-mw/init/ve.init.mw.Target.js
b/modules/ve-mw/init/ve.init.mw.Target.js
index 4334238..4696684 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -543,7 +543,14 @@
} else if ( typeof data.content !== 'string' ) {
this.onSaveError( doc, saveData, null, 'Invalid HTML content in
response from server', response );
} else {
- this.emit( 'save', data.content, data.categorieshtml,
data.newrevid, data.isRedirect );
+ this.emit(
+ 'save',
+ data.content,
+ data.categorieshtml,
+ data.newrevid,
+ data.isRedirect,
+ data.displayTitleHtml || null
+ );
}
};
--
To view, visit https://gerrit.wikimedia.org/r/141098
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I312bafb0e7d61b0abd42d6ca7ea2e4b5dcdc61be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits