mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +00:00
Make sure pageName is set in the web service, and handle empty page name in parser function
Change-Id: I5d36eefecc2f35a860d00a8960004f8e651ed17c
This commit is contained in:
parent
a862718ad8
commit
21286a50df
|
@ -57,12 +57,14 @@ var textarea = function ( res, content ) {
|
|||
* Form-based HTML DOM -> wikitext interface for manual testing
|
||||
*/
|
||||
app.get(/\/_html\/(.*)/, function(req, res){
|
||||
env.pageName = req.params[0];
|
||||
res.setHeader('Content-type', 'text/html; charset=UTF-8');
|
||||
res.write( "Your HTML DOM:" );
|
||||
textarea( res );
|
||||
res.end('');
|
||||
});
|
||||
app.post(/\/_html\/(.*)/, function(req, res){
|
||||
env.pageName = req.params[0];
|
||||
res.setHeader('Content-type', 'text/html; charset=UTF-8');
|
||||
var p = new html5.Parser();
|
||||
p.parse( req.body.content );
|
||||
|
@ -80,12 +82,14 @@ app.post(/\/_html\/(.*)/, function(req, res){
|
|||
* Form-based wikitext -> HTML DOM interface for manual testing
|
||||
*/
|
||||
app.get(/\/_wikitext\/(.*)/, function(req, res){
|
||||
env.pageName = req.params[0];
|
||||
res.setHeader('Content-type', 'text/html; charset=UTF-8');
|
||||
res.write( "Your wikitext:" );
|
||||
textarea( res );
|
||||
res.end('');
|
||||
});
|
||||
app.post(/\/_wikitext\/(.*)/, function(req, res){
|
||||
env.pageName = req.params[0];
|
||||
res.setHeader('Content-type', 'text/html; charset=UTF-8');
|
||||
var parser = parserPipelineFactory.makePipeline( 'text/x-mediawiki/full' );
|
||||
parser.on('document', function ( document ) {
|
||||
|
@ -111,7 +115,7 @@ app.post(/\/_wikitext\/(.*)/, function(req, res){
|
|||
* Regular article parsing
|
||||
*/
|
||||
app.get(/\/(.*)/, function(req, res){
|
||||
env.pageName = req.params.title;
|
||||
env.pageName = req.params[0];
|
||||
var parser = parserPipelineFactory.makePipeline( 'text/x-mediawiki/full' );
|
||||
parser.on('document', function ( document ) {
|
||||
res.end(document.body.innerHTML);
|
||||
|
@ -134,6 +138,7 @@ app.get(/\/(.*)/, function(req, res){
|
|||
* Regular article serialization using POST
|
||||
*/
|
||||
app.post(/\/(.*)/, function(req, res){
|
||||
env.pageName = req.params[0];
|
||||
res.setHeader('Content-type', 'text/plain; charset=UTF-8');
|
||||
var p = new html5.Parser();
|
||||
p.parse( req.body.content );
|
||||
|
|
|
@ -644,10 +644,10 @@ ParserFunctions.prototype.pf_namespacee = function ( token, frame, cb, args ) {
|
|||
cb( { tokens: [target.split(':').pop() || 'Main'] } );
|
||||
};
|
||||
ParserFunctions.prototype.pf_pagename = function ( token, frame, cb, args ) {
|
||||
cb( { tokens: [this.env.pageName] } );
|
||||
cb( { tokens: [this.env.pageName || ''] } );
|
||||
};
|
||||
ParserFunctions.prototype.pf_pagenamebase = function ( token, frame, cb, args ) {
|
||||
cb( { tokens: [this.env.pageName] } );
|
||||
cb( { tokens: [this.env.pageName || ''] } );
|
||||
};
|
||||
ParserFunctions.prototype.pf_scriptpath = function ( token, frame, cb, args ) {
|
||||
cb( { tokens: [this.env.wgScriptPath] } );
|
||||
|
|
|
@ -185,7 +185,7 @@ TemplateHandler.prototype._processTemplateAndTitle = function( token, frame, cb,
|
|||
|
||||
// Hook up the inputPipeline output events to our handlers
|
||||
pipeline.addListener( 'chunk', this._onChunk.bind ( this, cb ) );
|
||||
pipeline.addListener( 'end', this._onEnd.bind ( this ) );
|
||||
pipeline.addListener( 'end', this._onEnd.bind ( this, cb ) );
|
||||
// Feed the pipeline. XXX: Support different formats.
|
||||
this.manager.env.dp( 'TemplateHandler._processTemplateAndTitle', name, attribs );
|
||||
pipeline.process ( src, name );
|
||||
|
@ -205,9 +205,9 @@ TemplateHandler.prototype._onChunk = function( cb, chunk ) {
|
|||
* Handle the end event emitted by the parser pipeline after fully processing
|
||||
* the template source.
|
||||
*/
|
||||
TemplateHandler.prototype._onEnd = function( token, frame, cb ) {
|
||||
TemplateHandler.prototype._onEnd = function( cb ) {
|
||||
this.manager.env.dp( 'TemplateHandler._onEnd' );
|
||||
cb( { tokens: [token] } );
|
||||
cb( { tokens: [] } );
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue