Commit graph

141 commits

Author SHA1 Message Date
Ed Sanders 33bfeeed41 Update oldid on successful page save (if a new id is generated)
New ID is now passed from the API to the save event, to the onSave
handler. Empty diffs won't generate a newrevid.

Bug: 47420
Change-Id: I12ce27c8dc57f7aa753bcf5840635d5fea6b4e80
2013-05-03 18:10:10 +01:00
Ed Sanders c428b954f9 Show message 'anoneditwarning' in notices when applicable
Currently this code is unreachable as line 27 of the hooks file
checks the user's options for 'visualeditor-enable' before allowing
VE to load. For testing just comment out that line.

Bug: 47842
Change-Id: Ib5c3284c646ebcc0a8cad0b02de559d7820e05a0
2013-05-03 11:40:54 +01:00
Gabriel Wicke 1d27c3cd26 Actually send oldid on POST like we promised Parsoid we would
VisualEditor did not send an oldid on POST so far, which disabled
selective serialization in production.

Bug: 47434
Change-Id: Ib1b7079a7fd3357903e5a14795ed0d2f2bdc5d16
2013-04-19 22:24:31 +00:00
Catrope 4511a9e6be Actually pass oldid parameter when serializing
Apparently Parsoid has always required this, and we've never sent it,
yet somehow the code in production works. This may well be the cause
of some of the selser issues we saw after the deployment attempt in
January.

Made oldid a required parameter in the API module, and default it to 0.
When we get 0, we translate that to the empty string for Parsoid's
benefit. We also need to explicitly get wgCurRevisionId in
ViewPageTarget, and that's also 0 on new pages.

Change-Id: I3a55025246014cd74e15d6d5b6c4ede7b823e5df
2013-04-17 11:31:20 +00:00
Ed Sanders 136a8a8d57 Pass through error message to VE if Parsoid is unreachable.
The Status is marked as 'ok' if it completes with errors. We need
to check for the Status is 'good' as well, and if not we can
pass through the error.

MWHttpRequest only sets fatal errors so it can be assumed that if
the Status is not 'good' then there is one error in the error array.

Bug: 45916
Change-Id: Icb2d0253faaf4e00a9a1fe3091458b914e5b7579
2013-03-11 18:01:36 +00:00
Ed Sanders 0195493099 Pass parsoid server errors through to VisualEditor.
Unfortunately the Http::get wapper provides no data if anything but
an OK status is returned, so ApiVisualEditor now uses MWHttpRequest
directly.

If a non-OK status in encountered the error code and message are
passed through to the JSON output, and rendered in the error
alert by VE.

The error code passed through is parsoidserver-http-NNN although
other suggestions are welcome.

Bug: 44354
Change-Id: I166ecf81c40f0f1c62663f2096753269d28f2916
2013-03-05 17:24:51 +00:00
James D. Forrester 82114467f1 Bump copyright notice year range to -2013 over -2012
199 files touched. Whee!

Change-Id: Id82ce4a32f833406db4a1cc585674f2bdb39ba0d
2013-02-19 15:37:34 -08:00
Catrope 1dbe1127e5 Make {{PAGENAME}} in edit notices work by setting $wgTitle
This is TERRIBLY DIRTY and I am ashamed

Change-Id: Ief6f7b81de966d5f87e802c4385ae041f98bde6d
2012-12-11 17:50:11 -08:00
Catrope 19bea9fd61 Add page_touched to Parsoid URLs for cache busting and set cache param
Parsoid support for this is in https://gerrit.wikimedia.org/r/38139

Change-Id: I5a128fe3599953d564b339b194b5466e2d324fd6
2012-12-11 10:53:09 -08:00
Trevor Parscal 5db88a3140 Added VisualEditor specific edit notices
Default message used is visualeditor-alphawarning

Configure in $wgVisualEditorEditNotices

Change-Id: Ie56dac47aa825dd7a2eb9f74be486ae4228672c6
2012-12-10 19:41:23 -08:00
Timo Tijhof 97fa232c8f (bug 42654) Implement Show changes in Save dialog.
Turned saveDialog-body into slide-based swapper.

Moved footer into saveDiaog-body so that the license text doesn't
stay under the diff-slide (and move body bottom padding to foot
top)

Wrapped buttons and title in a saveDialog-header and converted
closeButton from absolutely positioned to a floated layout.
This way the title doesn't need to be repositioned but will scooch
over if the prevButton gets shown/hidden.

Update API "diff" action to include table wrapper and table
header. Without it the mediawiki CSS for diff doesn't work
properly (needs colgroups for proper width of the "-" and "+" column etc)

Renamed -saving class to -disabled for consistency.

Set prop.disabled to really lock/unlock buttons, not just visual
(otherwise the click handlers are still triggered on click, can
potentially cause actions to be triggered when not expected)

Using a ve message for "Show your changes" title instead of
re-using core tooltip-savepage in a different context.

Diff slide triggers "auto width" on dialog (inline undo of width: 29em), keeping min-width, to allow it to expand as wide as needed.

Functions that I copied as base for onShowChanges and
onShowChangeError had some incorrect argument descriptions. Fixed
in both.

Note:
* Pass function to .off(), so that only that one is unbound
  instead of any "resize" handler on the page (by other extensions
  or gadgets or core)
* NB: ve.bind ($.proxy) preserves internal guid, so that $.Event
  can find the bound function by the original reference.
* keydown has an anonymous function, should either moved to
  prototype or namespaced, did latter for now, save enough and
  better than destructive .off('keydown')

Change-Id: I9d05ef6e3e2461bdcf363232f7b0fbad5e24f506
2012-12-08 02:26:24 +01:00
Trevor Parscal 78eb16035c (bug 41865) Save page behavior for oldid
ApiVisualEditor
* Reverted some of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 turned out to be full of problems - the race condition is only relevant to getting the HTML
* Fixed check for $content to be false before it was defined

ve.init.mw.ViewPageTarget
* Reverted some more of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 - wgCurRevisionId is not equal to oldid, it's equal to $title->getLatestRevId() - this was causing lots of oldid problems
* Added use of restored message
* Made save button not locked when using oldid
* Customized save buttons depending on oldid

ve.init.mw.Target
* Reverted even more of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 - we don't want to keep a copy of the wgCurRevisionId at all, we just want the oldid if it was given

VisualEditor.i18n, VisualEditor
* Added restored notification and restore save button label messages

Change-Id: I8b30c2a153911f44643e369b7c6a9b89c0fb2c5b
2012-12-05 06:44:41 +00:00
Krinkle 46e52ae7bc Merge "(bug 42220) Added support for edit notices, which appear on the toolbar" 2012-12-03 22:02:16 +00:00
Timo Tijhof 42757a724d Cleanup oldid: Use mw.config for page existence and revision id.
Use mw.config wgCurRevisionId for oldie instead of uri query.
That way it also set on regular views, and as a bonus it the
normalised value (e.g. if on a page with oldid in query but the id
doesn't exist or is somehow invalid, it won't use it).

Centralise page existence logic in JS and rename Target.oldId to
Target.pageRevId (to further indicate that it is always set, not
just on oldId views. To detect an oldId view, do a boolean check
on value from currentUri.query.oldid directly).

In PHP Api, move oldid logic to execute() method instead of
locally from the getHTML call. That way it is always set, avoids
hitting this bug in other methods instead of just getHTML().

Since the mw.Target constructor now retrieves the ID from
mw.config directly, the second argument was removed.

Change-Id: I223235a6ea8b4178c50beeaaedb709b2de7cf0b5
2012-12-03 12:22:30 -08:00
Trevor Parscal a63f812d52 (bug 42220) Added support for edit notices, which appear on the toolbar
ApiVisualEditor
* Including notices in response to parse actions

ve.init.mw.ViewPageTarget
* Added styles for editNoticeButton and editNotices

ve.init.mw.ViewPageTarget
* Added toolbarEditNoticeButton and toolbarEditNotices
* Combined toolbarEditNoticeButton and toolbarSaveButton setup
* Moved toolbar buttons setup to onLoad (it could vary per-parse now)
* Added tearDownToolbarButtons which fires on deactivate
* Renamed some instances of teardown to tearDown
* Added click handler for toolbarEditNoticeButton
* Added toolbarEditNotices setup method, called on load
* Made notices fade in and out, in by default on load if any
* Made notices hide when save dialog is opened

ve.init.mw.Target
* Added storing of notices on parse

icons, alert, ve.ui-Icons
* Added alert icon

VisualEditor.i18n, VisualEditor
* Added notices button message

Change-Id: I581bf5a005a9c18422f952d71064d17d0ba9b540
2012-12-03 11:49:33 -08:00
Trevor Parscal 1d0ad9573e (bug 37828) Handle edit conflicts
ApiVisualEditor
* Added basetimestamp and starttimestamp to all methods where appropriate
* Added new serialize method which converts HTML to Wikitext

ve.init.mw.ViewPageTarget
* Added edit conflict handling
* Moved form value reading code into getSaveOptions method
* Prevented edit warning from appearing while submitting

ve.init.mw.Target
* Added serialize and submit methods
* Fixed some documentation
* Added support for baseTimeStamp and startTimeStamp

VisualEditor.i18n
* Added edit conflict confirmation box message

VisualEditor
* Included new edit conflict message to resource loader module

Change-Id: I002c5aa23704c1c46ef46fa1970a4254614b9eb1
2012-11-28 17:55:23 -08:00
Trevor Parscal 91c1f2e27f Merge "(bug 42403) Add Parsoid prefix to POST requests too." 2012-11-27 22:37:56 +00:00
Catrope ae0c4e6988 (bug 42403) Add Parsoid prefix to POST requests too.
This is a port of Mark's https://gerrit.wikimedia.org/r/#/c/31348

Change-Id: I3a57992fdbeffad1df1d97239e98dbec52fdd5cb
2012-11-26 17:50:55 -08:00
Catrope 43684f88fc (bug 42172) Tag edits made by VE
Uses MW's built-in change tagging. Made this configurable so it can be
turned off if it looks like we're blowing up the tags system with the
volume of VE edits.

Change-Id: I63052d90772906e34021035de496a65fea7945f7
2012-11-26 21:39:11 +00:00
Catrope 3fa434a7da Also increase the server-side timeout to 100s
Change-Id: Idff97fb7076251c481d1a8d7f83e6688ff0316d5
2012-11-14 17:16:13 -08:00
Catrope 50f94d53da Rewrite ve-parsoid API module
* Factor out getHTML(), postHTML(), saveWikitext() and parseWikitext()
* Use the API to save instead of using doEdit() directly
** This fixes a lot of integration bugs
** Get rid of the blocked user check, edit API checks this
* Check the namespace parameter
* Require tokens and POST
* Add diff functionality

Change-Id: I31891d1485985629db4e39532fb34e0e7fe23796
2012-11-14 14:47:20 -08:00
Catrope b05616892d (bug 37843) Trying to edit a blank page fails
Explicitly check for false, because the empty string does not signify a
failure.

Change-Id: I8857d39e1a20080c8419c6165be2b5ad0cdbacd2
2012-10-26 14:00:43 -07:00
Trevor Parscal fb09872781 Bug 37821 - Add support for oldid
* Added oldid param to the API
* Added oldId argument to ve.init.mw.ViewPageTarget
* Added redirect when saving an oldid page (which adds a new revision)
* Added venotify param to allow notifications even when redirected
* Added creation notification
* Added page title to saved/created notification

Change-Id: I9e957e6f5bc7920093481ffe3c33e299f87ce50a
2012-08-23 12:03:40 -07:00
Catrope 20a5aa48b7 Update API for Parsoid prefix changes
The format for wiki prefixes in Parsoid has changed from /mw:Pagename to
/mw/Pagename . Update the API module and the config+docs for this
change. The default value of the prefix ('localhost') should still work
for stock localhost setups.

Change-Id: Ic6f3793d175106cc1fae17980d20add63c3f783f
2012-08-13 17:56:30 -07:00
Catrope c4dc51fbaa Pass a (configurable) interwiki prefix to Parsoid
Change-Id: Id71e52836a367e0688f6c41e2c2e4d16b1b733ad
2012-08-06 16:42:18 -07:00
Catrope 122ddd0942 Oops, we were missing a slash here
Change-Id: I14da5070dbd3286e548eded8a71660777a566a83
2012-08-06 14:19:51 -07:00
Timo Tijhof c889292adf Kranitor #004: MediaWiki-specific clean up and minor fixes
* Default value of wgVisualEditorParsoidURL is broken.
  Slash is needed, else Api will request to
  http://hostnamePageName
  Roan says double slashes are okay, and look cleaner than string
  search checks etc.

* Use .clone() for mw.Uri instead of converting to string
  and letting mw.Uri parse it, again. Clone creates a basic
  instance and copies over properties internally (deep copy,
  no references).

* No need for hasOwnProperty (and its potential issues)

* Code clean up
 - Whitespace consistency
 - Variable hosting
 - Remove redundant `return false;` statements in event handlers
   e.preventDefault() is a jQuery.Event method that takes care
   of cross-browser issues.
 - Same for e.keyCode||e.which thing, this is already normalized
   by jQuery.Event
 - Add missing parameter to setTimeout
 - Consistent order in success/error handlers in $.ajax options

Change-Id: I5bc24e0cbdf01b3704d4ccb0b45b3052e3b58694
2012-08-03 23:55:52 -07:00
Alex Monk e2460342a4 Deglobalisation
Change-Id: I7665cc13be0457ee9932f7e96b8be7eef496e49a
2012-07-21 18:37:20 +01:00
Trevor Parscal 6b34f09df2 Removed some whitespace
And added a license to some files that didn't have it yet

Change-Id: I3a7e60374d1198d369a0475b8f65f7415012a337
2012-07-19 14:25:16 -07:00
Trevor Parscal c40174b60c Changed to use MIT license per agreement with the VisualEditor team
This license change is aimed at maximizing the reusability of this code
in other projects. VisualEditor is more than just an awesome editor for
MediaWiki, it's the new editor for the entire internet.

Added license and author files, plus mentions of the license to all
VisualEditor PHP, JavaScript and CSS files. Parser files have not been
modified but are effectively re-licensed since there's no overriding
license information. 3rd party libraries are not changed, but are all
already MIT licensed.

Change-Id: I895b256325db7c8689756edab34523de4418b0f2
2012-07-19 13:25:45 -07:00
Catrope e16346385d Actually block blocked users in the Parsoid API
Change-Id: I29b938bb5c1ea00886cb2b0ab04121e4d4cd1890
2012-06-21 13:55:33 -07:00
Catrope 563db3c4ad Make the API module handle missing pages and page creations
Change-Id: I91a43888435011b62e62cf4dde744b23a4ea65d6
2012-06-18 17:42:12 -07:00
Trevor Parscal bf643ded6a Fix escaping in API module
Let Http::post() handle the escaping of equals signs and newlines in the post data

Change-Id: I5ec91a7532918c807795442aaa0bc1c1a79c5705
2012-06-11 00:32:52 -07:00
Trevor Parscal 60fc5a3c58 Using MediaWiki facility for HTTP post
Change-Id: If800c4ecbcbecc8560bfd3e704e03acac2ac71d9
2012-06-08 16:00:53 -07:00
Trevor Parscal 925695da21 Switched to using MediaWiki facility for getting data over HTTP
Change-Id: I37aa48713632f7272b98c40bc6771ee23b068414
2012-06-08 15:19:13 -07:00
Catrope 41684c704a Quick hack to make Parsoid URL configurable
Change-Id: Id314ee13f4e7cc3d0efa3f55d89165acf79109f0
2012-06-06 16:08:41 -07:00
Rob Moen 3f3b525d56 Add MakeGlobalVariablesScript hook to add new global, vePageWatched.
This allows us to check the watchlist checkbox on save dialog.
Added watchlist toggling to ve save api.
Added some i18n messages to core integration.

Change-Id: Ibed8edb2c59ad49e1738c937c3bea518238d0845
2012-06-01 16:30:17 -07:00
Rob Moen b59d49a80d Restrict edit access to VisualEditor namespace to sysops
To allow non sysops to save via VE, refactored ve save api
to use doEdit which bypasses namespace protection.
Add edit link in view nav for non sysop so that they may edit
Add View source link in dropdown for non sysops
Add Edit source link in dropdown for sysops
Cleaned up some of the integration core code
UI tweaks

Change-Id: Ib4249bc5fb7ffa6410e4f2d278aafbb871800981
2012-05-30 17:12:25 -07:00
Rob Moen 0227de8c8e Remove edit token Ajax api request, get edit token from wgUser on save
Change-Id: Idb51da271d3eca61230d9948fc82190383fc7143
2012-05-25 16:20:48 -07:00
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
Rob Moen 61413c49eb Create base integration core module
Works on VisualEditor Namespace
Created VE api wrapper for parsoid service to roundtrip pages

Change-Id: I3f2967730c1a3ece31b7262a46bef31ea8b38613
2012-05-25 12:50:48 -07:00