Commit graph

111 commits

Author SHA1 Message Date
Tim Starling 4c50307cd5 Fix duplicate wikitext parse for displaytitle
Instead of doing a whole new parse for displaytitle, just get it from
the same API action=parse internal request that is used for returning
the content HTML.

Also escape entities as in OutputPage::setPageTitle(). The format of
OutputPage::setPageTitle()/getPageTitle() is a bit confused -- it's
mostly treated as HTML, but Article::view() sets it to the unescaped
title text -- a historical error which was unfortunately wallpapered
over.

Change-Id: I387c1ccd9a75f9c6c6a006d83235c6c1c3d1ecb5
2014-12-10 09:50:59 +11:00
Brad Jorsch 7d4ecc09c8 Add i18n for API module help
MediaWiki core change I04b1a384 added support for i18n of API module
help. This takes advantage of that while still maintaining backwards
compatibility with earlier versions of MediaWiki.

Once support for MediaWiki before 1.25 is dropped, the methods marked
deprecated in this patch may be removed.

Change-Id: I67395aff48185f3e09da31b51a08aa2541fe6a17
2014-10-29 13:59:41 -07:00
Roan Kattouw 36060a2782 Apply pre-save transform to template previews
Because autoValues often involve {{subst:}}

Bug: 71157
Change-Id: I2787f2595f8c4b8838a3e9ac9ba898af0b43b58e
2014-10-22 15:47:51 -07:00
James D. Forrester dc99a82eac Mark action=visualeditor as an internal API
This will reduce the level to which the VisualEditor API looks like a
tempting target for third parties, given it is undocumented and isn't
supported.

Bug: 62452
Change-Id: Ib34e526fcee46ea4ffe76261012c706233461dad
2014-10-14 00:26:27 +00:00
jenkins-bot 2d92bdb9d1 Merge "Update anoneditwarning message per core change" 2014-09-02 19:05:03 +00:00
Alex Monk 100b70bd50 Update anoneditwarning message per core change
Follows up I687e47c2 by James, approved by Bartosz.
This should be merged before thursday.

Change-Id: Ia28f59a341e1a04b4d143abbfe5c63e4a420056f
2014-09-02 19:59:13 +01:00
Mark A. Hershberger 363b986879 Add debugging help to VisualEditor
VE doesn't use the debug log at all, it seems.  This adds a single
wfDebugLog call so that the person using the debug log can see that it
actually does hit VE.

Also, returns better information for parsoid errors.

For example, without it, a parsoid misconfiguration of setInterwiki()
gives:

    Error loading data from server: parsoidserver-http-bad-status:
    500. Would you like to retry?

with it, you get something like the following:

    Error loading data from server: parsoidserver-http-bad-status:
    500: Page Fetch failure for "BADURL": Error: getaddrinfo
    ENOTFOUND. Would you like to retry?

or

    Error loading data from server: parsoidserver-http-bad-status:
    500: Page Fetch failure for "BADURL": 404. Would you like to
    retry?

Bug: 39057
Bug: 43147
Bug: 63149
Change-Id: I52db9fac42d7c0228b93ce3caec470fff98254f0
2014-09-02 14:57:06 +00:00
addshore ef1c12e445 Fix @returns >> @return phpdoc
Change-Id: Ibff7dfb5e870a35e5e932658490de1923f9233ad
2014-08-17 20:43:56 +01:00
Kunal Mehta 5575bed67c Use Config instead of globals
Change-Id: Iecf6358fcd15fe578b3e0dcdfa6022e0a1a763c8
2014-08-15 15:50:26 -07:00
Alex Monk a75bf88f6e Give a notice if the user isn't allowed to create the page
Bug: 67550
Change-Id: I59bc9bf5efe0b2fe9261350276316bfab117e6cf
2014-07-19 15:38:36 +01:00
Ed Sanders 288da5b704 Compress HTML data with deflate before POSTing
Bug: 66914
Change-Id: I7b0a9cfd4d4c10986769a868884688ffca833cb6
2014-06-24 17:39:03 +01:00
Krenair f8d609a8c7 Add class name to protected pages, to allow for specific CSS styling of edit area
Also get rid of checking for NS_MEDIAWIKI explictly and use
MWNamespace::getRestrictionLevels instead

Bug: 50783
Change-Id: I5986ddb9b6f17e4a2aca12dbb551cce4a6cfd663
2014-04-30 13:59:30 -07:00
jenkins-bot 09d8df88d1 Merge "Apply PST when generating diff" 2014-04-23 20:03:08 +00:00
Krenair c32880049f Apply PST when generating diff
Bug: 52345
Change-Id: Ic676105d230baf77994224bd64ed40cb52bb2e8b
2014-04-23 20:49:39 +01:00
jenkins-bot 61674b4631 Merge "Check cascade protection and show notice if relevant" 2014-04-23 18:24:10 +00:00
jenkins-bot c034e31404 Merge "Show notice if user is globally blocked" 2014-04-22 23:02:26 +00:00
Krenair 820ff5e8a0 Check cascade protection and show notice if relevant
Bug: 53893
Change-Id: Ie34c193da5ae41db1908afae35e5ba4949630176
2014-04-22 19:36:57 +01:00
Alex Monk cb9022bfe3 Show notice if user is globally blocked
Bug: 53009
Change-Id: I5c8a31f40535e7495133738a03d83648d57fb526
2014-04-22 01:22:48 +01:00
jenkins-bot a24cffed00 Merge "Set context title when rendering edit notices and checkboxes" 2014-04-19 03:48:53 +00:00
Roan Kattouw ddb8d826e3 Set context title when rendering edit notices and checkboxes
Bug: 59608
Bug: 63600
Change-Id: Ia2fdb3b3d383415feaf122d235d0c9a9e0ba0900
2014-04-19 03:09:28 +01:00
Ed Sanders 509b3db9ba Use Parsoid API for action=parsefragment
Bug: 48524
Change-Id: I8a61d2fab87d2a2e88ec2f3bbdef9ede1c7ad773
2014-04-18 13:19:54 -07:00
Ed Sanders 46988b2bd4 Create requestParsoid method for all requests to Parsoid API
Merges logic for GET & POST requests.

Change-Id: I17578177a6fc28b32f7d41c7ca6e6cf4ccaab9d9
2014-04-18 13:17:02 -07:00
Niklas Laxström dc4015455b Remove getVersion from api module
This method is deprecated since 1.21, VE is marked to require 1.22.

Change-Id: I67d30777fe0b2ebdacffcb2d6ca92275321c4e68
2014-04-17 14:04:21 +00:00
Niklas Laxström 32446f3cb3 Add whitespace
Change-Id: Id4448bcd952b1b9664cf74a99be80b8129fafa4d
2014-04-17 14:03:46 +00:00
jenkins-bot 797430e9ef Merge "Kill $wgVisualEditorEditNotices" 2014-03-27 18:34:39 +00:00
jenkins-bot b55d28bd24 Merge "Show blockedtext message in edit notices" 2014-03-26 23:02:24 +00:00
Krenair f1afe2fb48 Kill $wgVisualEditorEditNotices
Global that isn't used outside of this function.

Change-Id: Ie967523df5d61491e0042ed159c59e45439bf19e
2014-03-26 22:23:58 +00:00
jenkins-bot d9741aef73 Merge "Update use of newarticletext for added parameter" 2014-03-26 22:00:43 +00:00
jenkins-bot 58f5c76f46 Merge "Block non-JSON API access to VisualEditor, as it won't work" 2014-03-26 21:49:02 +00:00
Krenair d23d2a5853 Update use of newarticletext for added parameter
I999b9772 added a new parameter to the message, since then VE has just
been pointing this link to $1.

Bug: 63146
Change-Id: Icbaa79e6db9536c5bba2b8b3537f0920b0439f52
2014-03-26 21:34:52 +00:00
Krenair 2dcb2419dd Possibly show blocked-notice-logextract or userpage-userdoesnotexist when editing a user page
Bug is just about blocked-notice-logextract, but the same EditPage code also deals with
userpage-userdoesnotexist so lets deal with that too while we're here as it's trivial.

Bug: 51454
Change-Id: Ic8a8f135c9f76f645c25a31d9432b5e2786dcfa0
2014-03-26 14:19:53 -07:00
James D. Forrester 64a0c983a9 Block non-JSON API access to VisualEditor, as it won't work
Bug: 61017
Change-Id: I1d8f4509fc012bf5da91d2fd431651e55291edfa
2014-03-24 18:25:57 -07:00
Krenair aec9279d84 Show blockedtext message in edit notices
Depends on If5b7ef401 in oojs-ui

Bug: 52004
Change-Id: Icf672dfec4f57bef3e485428d07759ab51470999
2014-03-24 15:13:30 -07:00
Roan Kattouw 78a52f1f80 Display links to nonexistent pages as red
* Add ve.init.mw.LinkCache to track page existence and
  transparently query it
* Populate it with initial data from the parser cache
  if available, obtained in the VE API module
* Use linkCache data in link annotation rendering

This doesn't yet integrate the LinkCache with other
components like the link inspector. That should be
done so we can deduplicate the existence checks.

Additionally, we should generalize LinkCache and use
it for the category existence/status checks as well.

Bug: 37901
Change-Id: I9fd43e8c3864dd375cf6dadfdeedd05e4fe9cf3b
2014-03-20 02:42:33 +00:00
Krenair 438f9df04f Show last protection log entry and link to full protection log on protection notice
Bug: 51215
Change-Id: I95e50451003f24bd37a2125dd21dbffcdd4fcafa
2014-03-17 22:17:17 +00:00
James D. Forrester 831141e692 Pass 'pst' as true in parse request for fragments
In our parse request for 'wikitext fragments', used in the transclusion dialog
and extension inspectors, we weren't passing 'pst' as true, so while [[Foo|Bar]]
came back as expected, [[Foo (bar)|]] just came back as plain text, confusing
users.

Bug: 60998
Change-Id: I9931ad8034273ceb19c027d5035c63422cc0e570
2014-02-11 17:06:26 -08:00
Antoine Musso ae5e922837 Global setting for Parsoid HTTP proxy
On sites using $wgHTTPProxy, any curl requests made via MWHttpRequest
would be passed through that proxy. The Parsoid daemon is most probably
reachable directly, hence we want to be able to disable the proxy.
This can be done using the new $wgVisualEditorParsoidHTTPProxy which is
passed to MWHttpRequest in VisualEditor API.

Change-Id: I855249950b1b368ae0afe662154eb48e5b1a14f2
2014-02-07 14:45:56 -08:00
Ed Sanders c74d7f1a21 Update categories HTML on page save
Because there's an API for that.

Bug: 48560
Change-Id: I410647d2b1aa740f606ddca64052b8d2b54671bf
2014-01-12 14:55:39 +00:00
Rob Moen 3577ca7f6d Provide content format faux reqeust now that content format is validated
Related core change: I6c1bb9774542e39bfb899a47.

Bug: 59867
Change-Id: I5cc44c5ef358d9b19e9964545be29662083bd55c
2014-01-09 21:29:37 +00:00
James D. Forrester 0ffd654bed Bump copyright like it's 2014
Change-Id: Ic469ebda2c061dc7da0b4c1625f43a7be55da4fa
2014-01-05 20:06:50 +08:00
Ed Sanders 1a5bdd5bd2 Show full language names in the MW language dialog
Bug: 54086
Change-Id: I099ac552638d666a447eb3aeaef68329ffacdfce
2013-12-06 13:10:33 +00:00
Roan Kattouw 0f21329770 Implement serialization cache in VisualEditor API
Add paction=serializeforcache, which serializes the given HTML, stores
the resulting wikitext in memcached, and returns a cache key. This
cache key can then be passed instead of HTML to paction=diff or
action=visualeditoredit for quick diff/save operations using the
cached wikitext, or to paction=serialize to just retrieve the wikitext.

This lays the groundwork for front-loading serialization in the editor,
and for avoiding the double serialization that occurs when the user
first views the diff, then saves.


Bug: 55979
Bug: 56011
Change-Id: I223b1717890632c39e2509967149551f807119f8
2013-11-20 10:26:47 +00:00
Roan Kattouw 6eabc783c3 Support private wikis by forwarding Cookie: headers to Parsoid
If configured to do so, the VE API will forward the Cookie: header to
Parsoid. This allows VisualEditor to be used on read-restricted wikis.

Bug: 44483
Change-Id: If4a0cf1e5785b332ec9b014b783412805cf8af75
2013-11-01 11:14:04 -07:00
Ori Livneh 370186ead1 Change X-Parsoid-Performance header value indicating cached response
The header should comprise 'key=value; ' pairs rather than 'key: value', and
the key name 'cached-response' is less tied to the particulars of the current
Parsoid storage setup (which is being revised). Follows I8085fdba3.

Change-Id: I8bcf947763512ba700793974ab0c48d65c171bbb
2013-10-06 23:30:27 +00:00
Ori Livneh 397b458e86 Have API pass through 'X-Parsoid-Performance' header from Parsoid
Change I1d7fd94f2 to Parsoid adds a custom header on Parsoid HTTP responses,
'X-Parsoid-Performance', which contains data about how long it took Parsoid to
handle the request. This patch makes the API pass through the header from
Parsoid to the client, where it will be logged as an event (along with
additional datapoints that are only available on the client). When the request
is fulfilled entirely by Varnish, the XPP value is replaced with
'backend-varnish-hit: true'.

Change-Id: I8085fdba35c860eaaa4df020d06d1d45d4ea5813
2013-10-04 19:03:08 +00:00
Timo Tijhof 9e687efdf9 ve.ce.MWTransclusionNode: Check for API errors
See ApiVisualEditor.php#parsefragment.

Error code is also incorrectly about Parsoid, method
parseWikitextFragment does a FauxRequest to MediaWiki. Fixed
error.info. Keeping the same error.code for now for consistency.

Bug: 52483
Change-Id: Ic473ae4a5c1e9706140f6ec4cc8157fadd02c318
2013-08-03 00:35:42 +02:00
Roan Kattouw 1c4c86e7e3 Fix notice caused by not passing the WebRequest object by reference
It makes no sense that we should have to pass this by reference but
if we don't do it, we get a PHP notice.

Bug: 52466
Change-Id: Ibc8e33c4776a325cd32b6526dacc200994a73f7f
2013-08-02 11:37:30 -07:00
Ed Sanders 67dbf621b6 Show newarticletext(anon) when creating a new page
Bug: 51459
Change-Id: Id8509c6c8b92a0355b97d7661affe749fcdfdcba
2013-07-24 10:43:21 +01:00
Roan Kattouw 393807462e Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.

ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them

ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
  through to EditPage thanks to Idab5b524b0e3 in core

ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
  and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
   ve.init.mw.Target.prototype.save(), because here we know which ones
   are checkboxes and we don't know that in save() without
   special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
  rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
   logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout

ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API

Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 00:02:14 -07:00
Timo Tijhof 114011bf95 API: Remove loading of unused globals
* non-edit doesn't use $wgVisualEditorUseChangeTagging.
* edit doesn't use $wgVisualEditorEditNotices.

Change-Id: I4ebbf855ca92ca1541013ce68a58e019b405137f
2013-07-12 18:37:22 +02:00