VitaliyFilippov has uploaded a new change for review. https://gerrit.wikimedia.org/r/70814
Change subject: Allow to create new SVG files using SVGEdit ...................................................................... Allow to create new SVG files using SVGEdit Change-Id: I34a40c935313549fe1b271d61080d4007b7fe979 --- M SVGEdit.hooks.php M SVGEdit.i18n.php M SVGEdit.php M modules/ext.svgedit.editButton.js M modules/ext.svgedit.editor.js 5 files changed, 29 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SVGEdit refs/changes/14/70814/1 diff --git a/SVGEdit.hooks.php b/SVGEdit.hooks.php index a90d719..39e7073 100644 --- a/SVGEdit.hooks.php +++ b/SVGEdit.hooks.php @@ -66,4 +66,19 @@ $title->userCan( 'edit' ) && $title->userCan( 'upload' ); } + /** + * UploadForm:initial hook, suggests creating non-existing SVG files with SVGEdit + */ + public static function uploadFormInitial( $upload ) { + if ( strtolower( substr( $upload->mDesiredDestName, -4 ) ) == '.svg' ) { + $title = Title::newFromText( $upload->mDesiredDestName, NS_FILE ); + if ( $title ) { + $upload->uploadFormTextTop .= wfMsgNoTrans( + 'svgedit-suggest-create', $title->getFullUrl().'#!action=svgedit' + ); + } + } + return true; + } + } diff --git a/SVGEdit.i18n.php b/SVGEdit.i18n.php index 3e527a8..3a3d616 100644 --- a/SVGEdit.i18n.php +++ b/SVGEdit.i18n.php @@ -20,7 +20,9 @@ 'svgedit-desc' => 'In-browser editing of SVG drawings with [http://code.google.com/p/svg-edit/ SVG-Edit]', 'svgedit-edit-tab' => 'Edit drawing', 'svgedit-edit-tab-tooltip' => 'You can edit this SVG drawing in your browser', - 'svgedit-toolbar-insert' => 'SVG drawing' + 'svgedit-toolbar-insert' => 'SVG drawing', + 'svgedit-editbutton-create' => 'Create image with SVGEdit', + 'svgedit-suggest-create' => '<div style="display: inline-block; border: 1px dashed blue; padding: 4px; background: #f8f8ff">Also, you can <a href="$1">create/edit this SVG file with SVGEdit</a>.</div>', ); /** Message documentation (Message documentation) @@ -38,6 +40,8 @@ {{Identical|Cancel}}', 'svgedit-desc' => '{{desc|name=SVG Edit|url=http://www.mediawiki.org/wiki/Extension:SVGEdit}} {{doc-important|Do not alter the link target URL "<code>http://code.google.com/p/svg-edit/</code>".}}', + 'svgedit-editbutton-create' => 'Text label on create button on non-existing SVG File: pages', + 'svgedit-suggest-create' => 'HTML message displayed on the upload form initially opened for an SVG file', ); /** Arabic (العربية) @@ -746,6 +750,8 @@ 'svgedit-edit-tab' => 'Править рисунок', 'svgedit-edit-tab-tooltip' => 'Вы можете редактировать этот SVG-рисунок в вашем браузере', 'svgedit-toolbar-insert' => 'Рисование SVG', + 'svgedit-editbutton-create' => 'Создать рисунок в SVGEdit', + 'svgedit-suggest-create' => '<div style="display: inline-block; border: 1px dashed blue; padding: 4px; background: #f8f8ff">Также вы можете <a href="$1">создать/изменить этот SVG-файл с помощью SVGEdit</a>.</div>', ); /** Sinhala (සිංහල) diff --git a/SVGEdit.php b/SVGEdit.php index 91c5764..83fa713 100644 --- a/SVGEdit.php +++ b/SVGEdit.php @@ -22,6 +22,7 @@ $wgHooks['BeforePageDisplay'][] = 'SVGEditHooks::beforePageDisplay'; $wgHooks['MakeGlobalVariablesScript'][] = 'SVGEditHooks::makeGlobalVariablesScript'; +$wgHooks['UploadForm:initial'][] = 'SVGEditHooks::uploadFormInitial'; $wgAutoloadClasses['SVGEditHooks'] = dirname( __FILE__ ) . '/SVGEdit.hooks.php'; @@ -59,6 +60,7 @@ ), 'messages' => array( 'svgedit-editbutton-edit', + 'svgedit-editbutton-create', 'svgedit-edit-tab', 'svgedit-edit-tab-tooltip' ), diff --git a/modules/ext.svgedit.editButton.js b/modules/ext.svgedit.editButton.js index beb6129..689bb91 100644 --- a/modules/ext.svgedit.editButton.js +++ b/modules/ext.svgedit.editButton.js @@ -22,7 +22,7 @@ var trigger = function() { mw.svgedit.open({ filename: wgTitle, - replace: '#file', + replace: (wgArticleId ? '#file' : '#mw-imagepage-nofile'), onclose: function(filename) { if (filename) { // Saved! Refresh parent window... @@ -48,11 +48,11 @@ }); var button = $('<button></button>') - .text(mw.msg('svgedit-editbutton-edit')) + .text(mw.msg(wgArticleId ? 'svgedit-editbutton-edit' : 'svgedit-editbutton-create')) .click(function() { trigger(); }); - $('.fullMedia').append(button); + $(wgArticleId ? '.fullMedia' : '#mw-imagepage-nofile').append(button); if (window.location.hash.indexOf('!action=svgedit') !== -1) { window.location.hash = ''; diff --git a/modules/ext.svgedit.editor.js b/modules/ext.svgedit.editor.js index 0a8dc6c..98ee48c 100644 --- a/modules/ext.svgedit.editor.js +++ b/modules/ext.svgedit.editor.js @@ -31,7 +31,7 @@ if ('filename' in options) { // Get some basic info on the image before we go barrelling in... mwSVG.fetchInfo(options.filename, function(imageinfo) { - mw.svgedit.openEditor(options, imageinfo); + mw.svgedit.openEditor(options, imageinfo || {}); }); } else { mw.svgedit.openEditor(options, {}); @@ -60,7 +60,7 @@ url += '?dimensions=' + origWidth + ',' + origHeight; } - var preferredHeight = origHeight + 180; // leave space for toolbars and UI inside the iframe + var preferredHeight = origHeight ? origHeight + 180 : 500; // leave space for toolbars and UI inside the iframe var windowHeight = $(window).height() - 40; // leave space for our toolbar outside the iframe var minHeight = Math.min(windowHeight, preferredHeight); var initHeight = Math.max(minHeight, minHeight); -- To view, visit https://gerrit.wikimedia.org/r/70814 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I34a40c935313549fe1b271d61080d4007b7fe979 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SVGEdit Gerrit-Branch: master Gerrit-Owner: VitaliyFilippov <vita...@yourcmc.ru> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits