Commit graph

1244 commits

Author SHA1 Message Date
Timo Tijhof 6ba411fe2f Merge ext.geshi.data and ext.geshi.visualeditor modules
Until and unless there is an explicit need (and intent to support)
a public interface to use this data elsewhere, there is no need
for it to be a separate module.

It can be its own class, but at the resource level this data should
be considered a JavaScript file. And we don't create separate modules
for each file. They are in the same module unless they should be
semantically loaded in unrelated page contexts.

The module registery is not a javascript class autoloader. There
is a global cost to adding more modules to this registry.

Change-Id: Ifeddef8cfe00b6c115734f92eceab251a0b75bdb
2015-06-25 00:32:03 +00:00
Timo Tijhof e880ae6694 Removed unused getDefinitionSummary() implementation.
Follows-up b403b58. When using the content to version the module,
no summaries or modified hashes are used. The content itself is
hashed to naturally invalidate stale cache.

Change-Id: Ic6a20274e19fcf48cb8fe2ef39e48feb7c456391
2015-06-24 22:29:09 +00:00
Ed Sanders b403b58682 Add VisualEditor support
Most functionality is provided by MWExtensionNode & MWLiveExtensionInspector.

Bug: T45126
Bug: T60388
Bug: T69515
Change-Id: If502a8bd2199b6ceb824e02fdfd13c81c39b53b4
2015-06-24 22:43:42 +01:00
Translation updater bot 0e43b2dc8b Localisation updates from https://translatewiki.net.
Change-Id: I0da3c18f5d7f268b3b10c16b406769cf26640afe
2015-06-24 22:07:23 +02:00
jenkins-bot ef3e89cc7c Merge "Use <code> instead of <span> for inline code snippets" 2015-06-24 18:11:32 +00:00
Ori Livneh c134686c4f Follow-up for I07446ec98: update i18n messages for Pygments switch
Change-Id: Idb7e03aeeb3e428f6767c58b92c10b1b7ea58524
2015-06-24 17:13:12 +00:00
jenkins-bot 09cebbb56a Merge "On parser cache invalidation, purge Varnish as well." 2015-06-24 01:19:47 +00:00
Ori Livneh 32547b7657 On parser cache invalidation, purge Varnish as well.
This way, a visit by a logged-in user to a page with stale syntax highlighting
will also trigger a purge of the page for anons in Varnish.

Change-Id: I366563839c89d9546447d3e58bb9239a36bf70bd
2015-06-23 18:09:19 -07:00
jenkins-bot 100f57bd23 Merge "Support 'inline' as an alias for 'enclose="none"'" 2015-06-23 22:55:41 +00:00
Bartosz Dziewoński 8593fef342 Add 'direction: ltr;' to .mw-highlight
I'm not entirely sure that this will always behave correctly on RTL
wikis, but currently we never behave correctly on RTL wikis.

Bug: T85794
Change-Id: I8af2b18884ec619d581f9ceed737c5628b647086
2015-06-23 22:02:35 +00:00
Kunal Mehta 8dc96a9c0f RejectParserCacheValue may pass a WikiPage or Article
Change-Id: I03b6b00ab54037d1adf2b0abd17a88294dfc21ee
2015-06-23 14:56:33 -07:00
Kunal Mehta 01802ac3fb Use RejectParserCacheValue hook to invalidate caches that were using GeSHi
Change-Id: I47de88dc1c2f2380e41e6af0d3222b46c9c65569
2015-06-23 21:26:44 +00:00
Kunal Mehta 139f68c410 Render "xpp" as "java"
Per jayvdb on wikitech-l, who said it looks "quite good":
 https://lists.wikimedia.org/pipermail/wikitech-l/2015-June/082166.html

Change-Id: I234a4da51592cabddce356c692471e90e6f2a829
2015-06-23 11:29:08 -07:00
Ori Livneh 41db8dbe38 Add cache versioning and makeCacheKey method
* Don't json_encode() the whole code block, that's stupidly expensive when the
  code is a string already. It's only the options array that needs to be
  explicitly stringified.
* Incorporate a cache version parameter input in the cache key so we can manage
  changes to the extension's HTML output.
* Only use wfGlobalCacheKey if available, to maintain 1.25 compat.

Change-Id: I8d536f9011763f47667502225ed4459be7d2ed4a
2015-06-23 09:46:58 -07:00
Ori Livneh 04293baad9 Use <code> instead of <span> for inline code snippets
Change-Id: Ibc07169fc3b91509aa2d98b8ae910c901d2f1703
2015-06-23 08:38:56 -07:00
Ori Livneh fa6e77e167 Support 'inline' as an alias for 'enclose="none"'
I think it's easier to understand and easier to remember.

Change-Id: I3c0e8bc209956b8d2ba071baa40142c731f56524
2015-06-23 08:38:56 -07:00
jenkins-bot 9f5eade94c Merge "Add basic parser tests for functionality of non-recognized languages" 2015-06-23 15:29:31 +00:00
Bartosz Dziewoński 6a20c7f38d Correct whitespace around <syntaxhighlight> blocks
Remove trailing \n after closing </div>, as it results in multiple
newlines that confuse the MediaWiki parser into generating <p><br></p>
all over the place.

Bug: T85794
Change-Id: Iffaa73b49c29e94d8a1a659dd40b845a9f4ce0c1
2015-06-23 15:25:57 +00:00
Bartosz Dziewoński 5b7522a5fc Unbreak <syntaxhighlight enclose="none">
It was always "none" and not "span", this must've been an accidental change.

Also add a CSS tweak to better render the common pattern of
<code><syntaxhighlight enclose="none">...</syntaxhighlight></code>.

Bug: T85794
Change-Id: I3ed1b7f3c954374b49fc9a97881ea5236415cb6f
2015-06-23 15:21:29 +00:00
jenkins-bot ce197a5904 Merge "Correct behavior of <syntaxhighlight highlight="[lines]"> with more than one line" 2015-06-23 15:17:46 +00:00
Bartosz Dziewoński d30a5724eb Correct behavior of <syntaxhighlight highlight="[lines]"> with more than one line
* Restore parseHighlightLines() function from before
  6484894497, which introduced a
  regression in parsing line ranges. There are no tests for this and
  I'm not going to debug the regexes.
* Use a space rather than a comma as separator when passing the list
  of line numbers to Pygments.

Bug: T85794
Change-Id: Ib86c216308a973000a4129c2c46286ec1dc988e1
2015-06-23 16:03:17 +02:00
Derk-Jan Hartman d272c1e0e2 Enable syntaxhighlighting on mobile target
Now that we switched to pygments, there should be mo reason not to
enable this on mobile

Bug: T100563
Change-Id: I008b71d4cef04fb7dc7c2ad574032f9c4645b063
2015-06-23 13:17:03 +02:00
Timo Tijhof 9815331195 Use wfGlobalCacheKey()
Change-Id: I62666265e297b5dbcccaa1a64a07bb7bd01b89c4
2015-06-23 08:08:48 +01:00
Kunal Mehta fb0e430f47 Add basic parser tests for functionality of non-recognized languages
Change-Id: I07cecb588818fd4abb0b1b8e8de893cf6f72014a
2015-06-22 22:26:22 -07:00
Ori Livneh f36b6c66d3 If unable to shell out to Pygments, emit a warning and fall back to plain text.
Change-Id: I8beb0367405e8ea70385134e03302e8bd3ab91ff
2015-06-22 16:19:25 -07:00
Ori Livneh 648744325c Bundle Pygments 2.0.2
Include Pygments 2.0.2 as an executable zip bundle. Also include a script to
automate the process of creating such bundles and to make it reproducible and
verifiable.

Change-Id: I67e6f804e493f065311164c610dc541a5779654e
2015-06-22 22:54:42 +00:00
Ori Livneh a142c9194c Follow-up for I07446ec98: remove geshi/
Change-Id: I44df41362f9355b1176de08c93d44ff3b0fb8ec9
2015-06-22 15:52:27 -07:00
Ori Livneh f1941f8a56 Only look for a compatible lexer if a direct Pygments match is unavailable
If Pygments ever adds a dedicated lexer for 'cadlisp', for example, we'd want the
extension to use that, rather than use the compatibility map.

Change-Id: Icc610695ac2826bb526f7c69e867576c660ba6ef
2015-06-22 22:47:52 +00:00
Ori Livneh 6484894497 Highlight using Pygments rather than Geshi
GeSHi is unmaintained, lacks support for many popular modern languages, and
suffers from deep architectural flaws, chief among them the inconsistent
tokenization of different languages, each of which requires a custom
stylesheet.

Pygments is a well-maintained alternative. It is, by my count, the most popular
syntax highlighting library around. It is BSD-licensed, actively maintained,
and is widely used in PHP projects.

To keep this easy to review, this change does not include update for l10n
files, and it does not delete the geshi/ directory. I will do those in a
separate patch.

The chief change between this and the previous implementation is that errors
result in the code block not being highlighted, as opposed to not being printed
at all, having been replaced by an angry red error message. I think that is the
right user experience. If you go to StackOverflow or GitHub and try to mark up
your code block as being written in some language that their highlighter
doesn't know about, you don't get an error message -- the code simply doesn't
get highlighted.

Because we don't recursively load dependencies for extensions, to test this,
you will need to create a composer.local.json in $IP and add:

    {
        "extra": {
            "merge-plugin": {
                "include": [
                    "extensions/SyntaxHighlight_GeSHi/composer.json"
                ]
            }
        }
    }

Then run `composer update`.

Bug: T85794
Change-Id: I07446ec9893fae3d1e394f435d3d95cf8be6bc33
2015-06-22 23:37:15 +01:00
Translation updater bot f3476de015 Localisation updates from https://translatewiki.net.
Change-Id: I8e043e7790514542c6c9f3638dc6fa2fc14025f9
2015-06-21 20:05:35 +02:00
Ed Sanders 28ff155a6c Use normal line numbers
'Fancy' line numbers are a fairly useless feature, not seen
in any other code highlighter. As the extension doesn't let you
choose a line number mode, default to normal.

Bug: T101602
Change-Id: Iccbd3ba6c91c58b0ea0f0c09832f1422936cd475
2015-06-09 16:02:18 +01:00
jenkins-bot 2794062be2 Merge "Remove redundant ResourceLoaderModule::getModifiedTime implementation" 2015-06-08 16:24:24 +00:00
Timo Tijhof c81eb5978c Compare against '$geshi->error' instead of '$geshi->error()' in prepare()
Geshi::error() is a method that returns an HTML string representing
the error.

Geshi->$error is an integer error code.

This code clearly means to compare against the integer code given that
GESHI_ERROR_NO_SUCH_LANG is an integer.

Verified by using eval.php to instantiate "new Geshi( '', 'js' );"
and $geshi->error:
> 2
but $geshi->error():
> "<br /><strong>GeSHi Error:</strong> GeSHi could not find the language"

Change-Id: I1ca77733d4b6b5481c5db6aba9f6b7dda6803099
2015-06-08 16:05:46 +01:00
Kunal Mehta 207a5e27be build: Updating development dependencies
* grunt-banana-checker: 0.2.1 → 0.2.2

Change-Id: Ie02e44cc819e191ad0246f491988dbbf1856b5b0
2015-06-05 17:14:21 -07:00
Translation updater bot 761bcf3cf9 Localisation updates from https://translatewiki.net.
Change-Id: I755a0d381b52d3f9ae99ca0ed0067f22bc6cc669
2015-06-05 21:13:28 +02:00
Timo Tijhof 7229fff207 Remove redundant ResourceLoaderModule::getModifiedTime implementation
Follows-up f37cee996e which replaced the getHashMtime() and
getDefinitionMtime() methods with dummies that always return 1.

These getModifiedTime() implementation was only tracking the
definition, which is already tracked by getVersionHash().

Bug: T94074
Change-Id: I6e37c3c2f85ef4599a8643b0efabc18de2f51ec4
2015-06-03 14:31:29 +00:00
Gilles Dubuc 097fc9069a Remove redundant position code defined in ResourceLoaderWikiModule
Depends on Ib1180c5b2126f4ba8ac5b54578fcce18a3f35d85

Bug: T97410
Change-Id: I2f78145200aec4ce57cb41a58f5b03266c903b67
2015-05-29 22:05:26 +02:00
James D. Forrester 0f8b00c709 build: Use npm for repo testing (jshint, jsonlint, jscs, banana)
Add three qqq messages to make it pass.

Change-Id: I77166ad79d8ad1497032ca7e571258bfc1850037
2015-05-29 17:21:59 +00:00
Gilles Dubuc 58c81408f5 Explicitly define module position
Style modules currently added through addModuleStyles default
to being in the head ("top" position). This is an unhealthy default,
since only critical styles that are needed at pageload should be
in the head. In order to be able to switch the default to "bottom",
existing module positions have to be defined explicitly.

Bug: T97410
Change-Id: Ie120a781ac1950abd7963d6f722aa316b5542b51
2015-05-29 15:28:06 +00:00
Kunal Mehta 0347b58a87 Set manifest_version in extension.json
Bug: T100745
Change-Id: I444f456011a62ccb36d59b624f7f1250e44c82f2
2015-05-28 20:39:54 -07:00
Translation updater bot c6b918cc81 Localisation updates from https://translatewiki.net.
Change-Id: If67080df2e761953c19874ab4e06948b1423194d
2015-05-25 22:38:22 +02:00
Translation updater bot 0c619cad8b Localisation updates from https://translatewiki.net.
Change-Id: Icc6d2763d1ad08bfcd0dba0ed4722aaaa4108cfa
2015-05-24 00:16:31 +02:00
Kunal Mehta b4853c7633 Revert "Revert "Add extension.json, empty PHP entry point""
Try #2. Our last attempt loaded $wgGeSHiSupportedLanguages late, and
would override anything if it was already set. We still load it late, but
only if it is not already set.

This reverts commit 033ca20746.

Bug: T88063
Change-Id: Iae0806e06a95b2d8932b3d9e078e6135dd6750a3
2015-05-20 14:36:46 -07:00
Legoktm 033ca20746 Revert "Add extension.json, empty PHP entry point"
This reverts commit 72d1e92263.

Change-Id: I47eab2842f195bf302de0ae3bf15beff1b48290f
2015-05-20 21:21:11 +00:00
Derk-Jan Hartman 72d1e92263 Add extension.json, empty PHP entry point
Bug: T88063
Change-Id: I42afa0bf81f4f89b81a11bcafcb8e4c032a2d173
2015-05-19 17:05:43 -07:00
Kunal Mehta a18bb2e699 Remove i18n shim
Change-Id: If73418a8ff66ae0155c1b798d817a26d0e14bb1e
2015-05-19 17:05:19 -07:00
Translation updater bot dcf27813a4 Localisation updates from https://translatewiki.net.
Change-Id: Iea83790f77e580a5f9481872e29e2a73b0db5b3b
2015-05-18 22:22:39 +02:00
Niklas Laxström 14fdd87897 Fix I062a2246
Change-Id: I38ef15c7cc162acb6101e327787631a586abfcde
2015-05-02 13:13:43 +02:00
Timo Tijhof 19a6005668 ResourceLoaderSchemaModule: Call parent getDefinitionSummary() method
This should've been the case already and will result in an exception
otherwise in MediaWiki core as of Ibb292d2416839.

Change-Id: I062a224662823224f3104d9e8d05abce47b1da81
2015-05-02 00:50:13 +01:00
Ori Livneh 4c92cbc430 Re-apply fix for Haskell syntax
See I210832c4.

Change-Id: I5e74332b22fe58a39f99c70adb429f795f18ae75
2015-04-17 10:46:29 -07:00