jenkins-bot has submitted this change and it was merged.
Change subject: Redirect GET requests for pages w/o oldid to oldid location
......................................................................
Redirect GET requests for pages w/o oldid to oldid location
* Redirects requests for the latest version of an existing page to the
proper ?oldid=12345 URL to hit the cached version.
* Adds no-cache if wt is passed in.
* Adds a favicon.
Bug: 56283
Change-Id: I527772e693334ed7efa5f013f690d882c134dbe4
---
M js/api/ParserService.js
A js/api/favicon.ico
2 files changed, 25 insertions(+), 9 deletions(-)
Approvals:
GWicke: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/api/ParserService.js b/js/api/ParserService.js
index 378bc25..43c392a 100644
--- a/js/api/ParserService.js
+++ b/js/api/ParserService.js
@@ -24,7 +24,8 @@
childProc = require('child_process'),
spawn = childProc.spawn,
cluster = require('cluster'),
- fs = require('fs');
+ fs = require('fs'),
+ path = require('path');
// local includes
var mp = '../lib/';
@@ -347,6 +348,10 @@
/* -------------------- web app access points below --------------------- */
var app = express.createServer();
+
+// favicon
+app.use(express.favicon(path.join(__dirname, "favicon.ico")));
+
// Increase the form field size limit from the 2M default.
app.use(express.bodyParser({maxFieldsSize: 15 * 1024 * 1024}));
@@ -624,6 +629,9 @@
var parser = Util.getParserPipeline( env,
'text/x-mediawiki/full' );
parser.on( 'document', function ( document ) {
res.setHeader( 'Content-Type', 'text/html;
charset=UTF-8' );
+ // Don't cache requests when wt is set in case
somebody uses
+ // GET for wikitext parsing
+ res.setHeader( 'Cache-Control',
'private,no-cache,s-maxage=0' );
sendRes( req.body.body ? document.body :
document );
});
@@ -641,13 +649,26 @@
if ( req.query.oldid && !req.headers.cookie ) {
oldid = req.query.oldid;
res.setHeader( 'Cache-Control', 's-maxage=2592000' );
+ tmpCb = parse.bind( null, env, req, res, function (
req, res, src, doc ) {
+ sendRes( doc.documentElement );
+ });
} else {
// Don't cache requests with a session or no oldid
res.setHeader( 'Cache-Control',
'private,no-cache,s-maxage=0' );
+ tmpCb = function ( err, src_and_metadata ) {
+ if ( err ) {
+ env.errCB( err );
+ return;
+ }
+
+ // Set the source
+ env.setPageSrcInfo( src_and_metadata );
+
+ // Redirect to oldid
+ res.redirect( req.path + "?oldid=" +
env.page.meta.revision.revid );
+ console.warn( "redirected " + prefix + ':' +
target + " to revision " + env.page.meta.revision.revid );
+ };
}
- tmpCb = parse.bind( null, env, req, res, function ( req, res,
src, doc ) {
- sendRes( doc.documentElement );
- });
}
var tpr = new TemplateRequest( env, target, oldid );
@@ -671,11 +692,6 @@
// 404 );
// return;
//}
-
- if ( env.page.name === 'favicon.ico' ) {
- res.send( 'no favicon yet..', 404 );
- return;
- }
wt2html( req, res );
});
diff --git a/js/api/favicon.ico b/js/api/favicon.ico
new file mode 100644
index 0000000..301cb2d
--- /dev/null
+++ b/js/api/favicon.ico
Binary files differ
--
To view, visit https://gerrit.wikimedia.org/r/92612
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I527772e693334ed7efa5f013f690d882c134dbe4
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits