How to use mediawiki-title - 6 common examples

To help you get started, we’ve selected a few mediawiki-title examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wikimedia / parsoid / lib / config / MWParserEnvironment.js View on Github external
MWParserEnvironment.prototype._makeTitle = function(urlDecodedText, defaultNS, noExceptions) {
	try {
		if (this.page && /^(\#|\/|\.\.\/)/.test(urlDecodedText)) {
			defaultNS = this.page.ns;
		}
		urlDecodedText = this.resolveTitle(urlDecodedText);
		return Title.newFromText(urlDecodedText, this.conf.wiki.siteInfo, defaultNS);
	} catch (e) {
		if (noExceptions) {
			return null;
		} else {
			throw e;
		}
	}
};
github wikimedia / restbase / lib / mwUtil.js View on Github external
'use strict';

const uuidUtils = require('./uuidUtils');
const contentType = require('content-type');
const jwt = require('jsonwebtoken');
const P = require('bluebird');
const entities = require('entities');
const Title = require('mediawiki-title').Title;
const HyperSwitch = require('hyperswitch');
const querystring = require('querystring');
const cType = require('content-type');
const HTTPError = HyperSwitch.HTTPError;
const URI = HyperSwitch.URI;
const mwUtil = {};

/**
 * Create an etag value of the form
 * "//"
 * @param   {Integer}   rev         page revision number
 * @param   {string}    tid         page render UUID
 * @param   {string}    [suffix]    optional suffix
 * @return  {string}                the value of the ETag header
 */
mwUtil.makeETag = (rev, tid, suffix) => {
github wikimedia / restbase / v1 / lists.js View on Github external
'use strict';

const P = require('bluebird');
const mwUtil = require('../lib/mwUtil');
const Title = require('mediawiki-title').Title;
const HyperSwitch = require('hyperswitch');
const URI = HyperSwitch.URI;
const spec = HyperSwitch.utils.loadSpec(`${__dirname}/lists.yaml`);

class ReadingLists {
    /**
     * @param {!Object} options RESTBase options object.
     */
    constructor(options) {
        this.options = options;
    }

    /**
     * Transform the continuation data into a string so it is easier for clients to deal with.
     * @param  {!Object|undefined} continuation Continuation object returned by the MediaWiki API.
     * @return {!string|undefined}              Continuation string.
github wikimedia / parsoid / lib / config / MWParserEnvironment.js View on Github external
/**
 * Main parser environment object.  Holds configuration data that isn't
 * modified at runtime, debugging objects, a page object that represents
 * the article we're parsing, and more.
 *
 * @module
 */

'use strict';

require('../../core-upgrade.js');

var semver = require('semver');
var Title = require('mediawiki-title').Title;
var Promise = require('../utils/promise.js');
var WikiConfig = require('./WikiConfig.js').WikiConfig;
var ConfigRequest = require('../mw/ApiRequest.js').ConfigRequest;
var Batcher = require('../mw/Batcher.js').Batcher;
var ContentUtils = require('../utils/ContentUtils.js').ContentUtils;
var DOMUtils = require('../utils/DOMUtils.js').DOMUtils;
var DOMDataUtils = require('../utils/DOMDataUtils.js').DOMDataUtils;
var Util = require('../utils/Util.js').Util;
var JSUtils = require('../utils/jsutils.js').JSUtils;
var TokenUtils = require('../utils/TokenUtils.js').TokenUtils;
var PipelineUtils = require('../utils/PipelineUtils.js').PipelineUtils;
var ParserPipelineFactory = require('../wt2html/parser.js').ParserPipelineFactory;
var LintLogger = require('../logger/LintLogger.js').LintLogger;
var ParsoidLogger = require('../logger/ParsoidLogger.js').ParsoidLogger;
var Sanitizer = require('../wt2html/tt/Sanitizer.js').Sanitizer;
github wikimedia / restbase / v1 / lists.js View on Github external
return mwUtil.getSiteInfo(hyper, req, entry.project).then((siteinfo) => {
                const title = Title.newFromText(entry.title, siteinfo).getPrefixedDBKey();
                entry.summary = {
                    $merge: [
                        `${siteinfo.baseUri}/page/summary/${encodeURIComponent(title)}`
                    ]
                };
            }).catch(() => {});
        })
github wikimedia / restbase / lib / mwUtil.js View on Github external
.then((siteInfo) => {
    try {
        return Title.newFromText(title, siteInfo);
    } catch (e) {
        throw new HTTPError({
            status: 400,
            body: {
                type: 'bad_request',
                detail: e.message
            }
        });
    }
});

mediawiki-title

Title normalization library for mediawiki

Apache-2.0
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis