Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/73127


Change subject: Bug 50136: Allow editing of things other than wikitext
......................................................................

Bug 50136: Allow editing of things other than wikitext

This allows Mobile.js and User:x/vector.css and friends to
be editable

Change-Id: I2057a86bf2b1c140ecb95e76376de5aa40cfaff7
---
M javascripts/modules/editor/EditorApi.js
M javascripts/modules/editor/EditorOverlay.js
M javascripts/modules/editor/editor.js
3 files changed, 25 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/27/73127/1

diff --git a/javascripts/modules/editor/EditorApi.js 
b/javascripts/modules/editor/EditorApi.js
index 06cc38a..8c5d155 100644
--- a/javascripts/modules/editor/EditorApi.js
+++ b/javascripts/modules/editor/EditorApi.js
@@ -4,6 +4,7 @@
 
                initialize: function( options ) {
                        this._super( options );
+                       this.contentModel = options.contentModel;
                        this.title = options.title;
                        this._sectionCache = {};
                        this._sectionStage = {};
@@ -15,18 +16,21 @@
                },
 
                getSection: function( id ) {
-                       var self = this, result = $.Deferred();
+                       var self = this, result = $.Deferred(), options;
 
                        if ( this._sectionCache[id] ) {
                                result.resolve( this._sectionCache[id] );
                        } else {
-                               self.get( {
+                               options = {
                                        action: 'query',
                                        prop: 'revisions',
                                        rvprop: [ 'content', 'timestamp' ],
-                                       titles: self.title,
-                                       rvsection: id
-                               } ).done( function( resp ) {
+                                       titles: self.title
+                               };
+                               if ( self.isWikiText() ) {
+                                       options.rvsection = id;
+                               }
+                               self.get( options ).done( function( resp ) {
                                        var revision;
 
                                        if ( resp.error ) {
@@ -69,6 +73,9 @@
                        } ).length;
                },
 
+               isWikiText: function() {
+                       return this.contentModel === 'wikitext';
+               },
                save: function( summary ) {
                        var self = this, result = $.Deferred(),
                                sections = $.map( this._sectionStage, function( 
section ) {
@@ -80,18 +87,21 @@
                        }
 
                        function saveSection( token ) {
-                               var section = sections.pop();
+                               var section = sections.pop(), options;
 
-                               self.post( {
+                               options = {
                                        action: 'edit',
                                        title: self.title,
-                                       section: section.id,
                                        text: section.content,
                                        summary: summary,
                                        token: token,
                                        basetimestamp: section.timestamp,
                                        starttimestamp: section.timestamp
-                               } ).done( function( data ) {
+                               };
+                               if ( self.isWikiText() ) {
+                                       options.section = section.id;
+                               }
+                               self.post( options ).done( function( data ) {
                                        if ( data && data.error ) {
                                                result.reject( data.error.code 
);
                                        } else if ( !sections.length ) {
diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 91fc0c0..d1792f7 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -42,7 +42,7 @@
                },
 
                initialize: function( options ) {
-                       this.api = new EditorApi( { title: options.title, 
isNew: options.isNew } );
+                       this.api = new EditorApi( { title: options.title, 
isNew: options.isNew, contentModel: options.contentModel } );
                        this._super( options );
                },
 
diff --git a/javascripts/modules/editor/editor.js 
b/javascripts/modules/editor/editor.js
index 2af60ba..240c8c8 100644
--- a/javascripts/modules/editor/editor.js
+++ b/javascripts/modules/editor/editor.js
@@ -22,11 +22,15 @@
                var isNew = mw.config.get( 'wgArticleId' ) === 0;
 
                M.router.route( /^editor-(\d+)$/, function( section ) {
-                       var title = mw.config.get( 'wgTitle' ), ns = 
mw.config.get( 'wgCanonicalNamespace' );
+                       // FIXME: This doesn't work in alpha - doesn't 
represent latest page.
+                       var title = mw.config.get( 'wgTitle' ), ns = 
mw.config.get( 'wgCanonicalNamespace' ),
+                               model = mw.config.get( 'wgPageContentModel' );
+
                        section = parseInt( section, 10 );
                        new EditorOverlay( {
                                title: ns ? ns + ':' + title : title,
                                isNew: isNew,
+                               contentModel: model,
                                section: section
                        } ).show();
                } );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2057a86bf2b1c140ecb95e76376de5aa40cfaff7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

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

Reply via email to