mediawiki-extensions-Visual.../VisualEditor.php
Rob Moen 237c0fd21f Created VE parsoid API save action.
Save action
1) posts html to parsoid service in exchange for wikitext
2) saves wikitext
3) returns parsed content.
On save, VE is hidden and page content is replaced.
Demoing save in toolbar, followup commit will redesign save options

Change-Id: Ibfbe52de08e3483e1a33f0740c03f96ec2b7f90a
2012-05-25 15:27:58 -07:00

242 lines
6.9 KiB
PHP

<?php
/**
* VisualEditor extension
*
* @file
* @ingroup Extensions
*
* @author Trevor Parscal <trevor@wikimedia.org>
* @author Inez Korczyński <inez@wikia-inc.com>
* @author Roan Kattouw <roan.kattouw@gmail.com>
* @author Neil Kandalgaonkar <neilk@wikimedia.org>
* @author Gabriel Wicke <gwicke@wikimedia.org>
* @author Brion Vibber <brion@wikimedia.org>
* @license GPL v2 or later
* @version 0.1.0
*/
/* Setup */
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'VisualEditor',
'author' => array(
'Trevor Parscal',
'Inez Korczyński',
'Roan Kattouw',
'Neil Kandalgaonkar',
'Gabriel Wicke',
'Brion Vibber',
),
'version' => '0.1.0',
'url' => 'https://www.mediawiki.org/wiki/Extension:VisualEditor',
'descriptionmsg' => 'visualeditor-desc',
);
$dir = dirname( __FILE__ ) . '/';
$wgExtensionMessagesFiles['VisualEditor'] = $dir . 'VisualEditor.i18n.php';
$wgExtensionMessagesFiles['VisualEditorAliases'] = $dir . 'VisualEditor.alias.php';
$wgAutoloadClasses['SpecialVisualEditorSandbox'] = $dir . 'SpecialVisualEditorSandbox.php';
$wgSpecialPages['VisualEditorSandbox'] = 'SpecialVisualEditorSandbox';
$wgSpecialPageGroups['VisualEditorSandbox'] = 'other';
$wgVisualEditorResourceTemplate = array(
'localBasePath' => dirname( __FILE__ ) . '/modules',
'remoteExtPath' => 'VisualEditor/modules',
'group' => 'ext.visualEditor',
);
$wgResourceModules += array(
'rangy' => $wgVisualEditorResourceTemplate + array(
'scripts' => array(
'rangy/rangy-core.js',
'rangy/rangy-position.js',
),
),
'ext.visualEditor.special.sandbox' => $wgVisualEditorResourceTemplate + array(
'scripts' => array(
'sandbox/special.js',
),
'messages' => array(
'visualeditor-feedback-prompt',
'visualeditor-feedback-dialog-title',
'visualeditor-sandbox-title',
),
'dependencies' => array(
'ext.visualEditor.sandbox',
'mediawiki.feedback',
'mediawiki.Uri',
)
),
'ext.visualEditor.sandbox' => $wgVisualEditorResourceTemplate + array(
'scripts' => array(
'sandbox/sandbox.js',
),
'messages' => array(
'visualeditorsandbox',
),
'styles' => 'sandbox/sandbox.css',
'dependencies' => array(
'ext.visualEditor.ve',
),
),
'ext.visualEditor.core' => $wgVisualEditorResourceTemplate + array(
'scripts' => array(
'core/ve.Core.js',
),
'messages' => array(
'',
),
'styles' => 'core/ve.Core.css',
'dependencies' => array(
'jquery',
'mediawiki.util'
),
),
'ext.visualEditor.ve' => $wgVisualEditorResourceTemplate + array(
'scripts' => array(
// ve
'jquery/jquery.json.js',
've2/ve.js',
've2/ve.NodeFactory.js',
've2/ve.Position.js',
've2/ve.Range.js',
've2/ve.EventEmitter.js',
've2/ve.Node.js',
've2/ve.BranchNode.js',
've2/ve.LeafNode.js',
've2/ve.Surface.js',
've2/ve.Document.js',
// dm
've2/dm/ve.dm.js',
've2/dm/ve.dm.NodeFactory.js',
've2/dm/ve.dm.Node.js',
've2/dm/ve.dm.BranchNode.js',
've2/dm/ve.dm.LeafNode.js',
've2/dm/ve.dm.TransactionProcessor.js',
've2/dm/ve.dm.Transaction.js',
've2/dm/ve.dm.Surface.js',
've2/dm/ve.dm.Document.js',
've2/dm/ve.dm.HTMLConverter.js',
've2/dm/nodes/ve.dm.AlienInlineNode.js',
've2/dm/nodes/ve.dm.AlienBlockNode.js',
've2/dm/nodes/ve.dm.DefinitionListItemNode.js',
've2/dm/nodes/ve.dm.DefinitionListNode.js',
've2/dm/nodes/ve.dm.DocumentNode.js',
've2/dm/nodes/ve.dm.HeadingNode.js',
've2/dm/nodes/ve.dm.ImageNode.js',
've2/dm/nodes/ve.dm.ListItemNode.js',
've2/dm/nodes/ve.dm.ListNode.js',
've2/dm/nodes/ve.dm.ParagraphNode.js',
've2/dm/nodes/ve.dm.PreformattedNode.js',
've2/dm/nodes/ve.dm.TableCellNode.js',
've2/dm/nodes/ve.dm.TableNode.js',
've2/dm/nodes/ve.dm.TableRowNode.js',
've2/dm/nodes/ve.dm.TextNode.js',
've/dm/serializers/ve.dm.AnnotationSerializer.js',
've/dm/serializers/ve.dm.HtmlSerializer.js',
've/dm/serializers/ve.dm.JsonSerializer.js',
've/dm/serializers/ve.dm.WikitextSerializer.js',
// ce
've2/ce/ve.ce.js',
've2/ce/ve.ce.NodeFactory.js',
've2/ce/ve.ce.Document.js',
've2/ce/ve.ce.Node.js',
've2/ce/ve.ce.BranchNode.js',
've2/ce/ve.ce.LeafNode.js',
've2/ce/ve.ce.Surface.js',
've2/ce/nodes/ve.ce.AlienInlineNode.js',
've2/ce/nodes/ve.ce.AlienBlockNode.js',
've2/ce/nodes/ve.ce.DefinitionListItemNode.js',
've2/ce/nodes/ve.ce.DefinitionListNode.js',
've2/ce/nodes/ve.ce.DocumentNode.js',
've2/ce/nodes/ve.ce.HeadingNode.js',
've2/ce/nodes/ve.ce.ImageNode.js',
've2/ce/nodes/ve.ce.ListItemNode.js',
've2/ce/nodes/ve.ce.ListNode.js',
've2/ce/nodes/ve.ce.ParagraphNode.js',
've2/ce/nodes/ve.ce.PreformattedNode.js',
've2/ce/nodes/ve.ce.TableCellNode.js',
've2/ce/nodes/ve.ce.TableNode.js',
've2/ce/nodes/ve.ce.TableRowNode.js',
've2/ce/nodes/ve.ce.TextNode.js',
// ui
've2/ui/ve.ui.js',
've2/ui/ve.ui.Inspector.js',
've2/ui/ve.ui.Tool.js',
've2/ui/ve.ui.Toolbar.js',
've2/ui/ve.ui.Context.js',
've2/ui/ve.ui.Menu.js',
've2/ui/inspectors/ve.ui.LinkInspector.js',
've2/ui/tools/ve.ui.ButtonTool.js',
've2/ui/tools/ve.ui.AnnotationButtonTool.js',
've2/ui/tools/ve.ui.ClearButtonTool.js',
've2/ui/tools/ve.ui.HistoryButtonTool.js',
've2/ui/tools/ve.ui.ListButtonTool.js',
've2/ui/tools/ve.ui.IndentationButtonTool.js',
've2/ui/tools/ve.ui.DropdownTool.js',
've2/ui/tools/ve.ui.FormatDropdownTool.js'
),
'styles' => array(
// ce
've2/ce/styles/ve.ce.Surface.css',
've2/ce/styles/ve.ce.Content.css',
've2/ce/styles/ve.ce.Document.css',
// ui
've2/ui/styles/ve.ui.Surface.css',
've2/ui/styles/ve.ui.Context.css',
've2/ui/styles/ve.ui.Inspector.css',
've2/ui/styles/ve.ui.Toolbar.css',
've2/ui/styles/ve.ui.Menu.css',
),
'dependencies' => array(
'jquery',
'rangy',
),
'messages' => array(
'visualeditor-tooltip-wikitext',
'visualeditor-tooltip-json',
'visualeditor-tooltip-html',
'visualeditor-tooltip-render',
'visualeditor-tooltip-history',
'visualeditor-tooltip-help',
'visualeditor',
),
)
);
/*
VisualEditor Namespace
Using 2500 range as it appears available in
MW Extension_namespace_registration
*/
$wgExtraNamespaces[2500] = "VisualEditor";
$wgExtraNamespaces[2501] = "VisualEditor_talk";
$wgContentNamespaces[] = 2500;
$wgContentNamespaces[] = 2501;
// Parsoid Wrapper API
$wgAutoloadClasses['ApiVisualEditor'] = $dir . 'ApiVisualEditor.php';
$wgAPIModules['ve-parsoid'] = 'ApiVisualEditor';
// Integration Hooks
$wgAutoloadClasses['VisualEditorHooks'] = $dir . 'VisualEditor.hooks.php';
$wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onPageDisplay';
// API for retrieving wikidom parse results
$wgAutoloadClasses['ApiQueryParseTree'] = $dir . 'api/ApiQueryParseTree.php';
$wgAPIPropModules['parsetree'] = 'ApiQueryParseTree';
// external cmd, accepts wikitext and returns parse tree in JSON. Also set environment variables needed by script here.
putenv('NODE_PATH=/usr/local/bin/node_modules' );
$wgVisualEditorParserCmd = '/usr/local/bin/node ' . $dir . 'modules/parser/parse.js';