Commit graph

98 commits

Author SHA1 Message Date
thiemowmde 80c8eaf3ce Convert (almost) all .css files to .less
Intentionally no other change is made (yet). This is for a later,
separate patch.

Intentionally not touching the huge list of per-language
ext.cite.style.*.css files for the moment. Again, I would prefer to
do this in a separate patch.

Change-Id: I4e392c7bd1c69849a6c7946676a64c749ddbcd60
2024-01-21 15:39:08 +01:00
jenkins-bot b14d007859 Merge "Hook up Parsoid implementation of Cite" 2024-01-19 17:23:33 +00:00
C. Scott Ananian 234da84418 Hook up Parsoid implementation of Cite
This commit also moves certain parser tests involving <ref> from
the Parsoid repo to citeParserTests.txt in this repo.

Bug: T354215
Change-Id: Ie5b211d2af01a56684473723c68a9ab2775542e3
2024-01-19 11:57:11 -05:00
WMDE-Fisch b59eef1cfe Fix event logging for the reference previews baseline
The current tracking is wrong for several reasons. Mainly because
of a race condition if the Popups extension fininshed loading
before the Cite tracking script is executed. But further more
wgPopupsReferencePreviews was not a good choice to see if the user
sees previews or not.

The logging now uses the monoschema and only checks for enabled
previews when the click events are fired. The chances that Popups
finished initilizing then are much higher then. We still can see
if the init is not finished and the variable not set though.

Also we won't track the overall pageviews in here but use the
generic pageview_hourly from the data lake instead.

Bug: T353798
Depends-On: I1c434f0098ae23bd62256686a658e3d5ef7f70b9
Change-Id: I7a9524274efb58286f520c6148d5463bb0a78dbf
2024-01-17 13:11:17 +01:00
Adam Wight 262fbe24eb Encapsulate ref object: limited to ReferenceStack
This encapsulation gives us field name, type validation and code
documentation.

This patch only affects ReferenceStack and continues to return
approximately the same array outputs to callers.  Some additional
information is included and the placeholder column has a new name.

Bug: T353451
Change-Id: I405fe7ac241f6991fd4c526bfbb58fbc34f2e147
2024-01-09 09:59:16 +01:00
thiemowmde ddda536792 Drop unused cite_reference(s)_link_prefix messages
Same as Icfa8215 where we removed the …_suffix messages.

This patch is not blocked on anything according to CodeSearch:
https://codesearch.wmcloud.org/search/?q=cite_references%3F_link_prefix

According to GlobalSearch there are 2 usages we need to talk about:
https://global-search.toolforge.org/?q=.&regex=1&namespaces=8&title=Cite.references%3F.link.prefix.*

zh.wiktionary replaces "cite_ref-" with "_ref-", and "cite_note-"
with "_note-", i.e. they did nothing but remove the word "cite". This
happened in 2006, with no explanation.

ka.wikibooks and ka.wikiquote replace "cite_note-" with "_შენიშვნა-",
which translates back to "_note-". One user did this in 2007,
16 seconds apart.

It appears like both are attempts to localize what can be localized,
no matter if it's really necessary or not.
https://zh.wiktionary.org/wiki/Special:Contributions/Shibo77?offset=20060510
https://ka.wikiquote.org/wiki/Special:Contributions/Trulala?offset=20070219
Note how one user experimented with an "a" in some of the edits to
see what effect the change might have, to imediatelly revert it.

The modifications don't really have an effect on anything, except on
the anchors in the resulting <a href="#_ref-5"> and <sup id="_ref-5">
HTML. It might also be briefly visible in the browser's address bar
when such a link is clicked. We can only assume the two users did this
to make the URL appear shorter (?). A discussion apparently never
happened. Bot users are inactive.

Both pieces of HTML are generated in the Cite code. Removing the
messages will change all places the same time. All links will
continue to work. The only possible effect is that hard-coded
weblinks to an individual reference will link to the top of the
article instead. But:
a) This is extremely unlikely to happen. There is no reason to link
   to a reference from outside of the article.
b) Such links are not guaranteed to work anyway as they can break
   for a multitude of other reasons, e.g. the <ref> being renamed,
   removed, or replaced.
c) Even if such a link breaks, it still links to the correct article.

There is also no on-wiki code on zh.wiktionary that would do anything
with the shortened prefix:
https://zh.wiktionary.org/w/index.php?search=insource%3A%2F_%28ref%7Cnote%29-%2F&title=Special%3A%E6%90%9C%E7%B4%A2&profile=advanced&fulltext=1&ns2=1&ns4=1&ns8=1&ns10=1&ns12=1&ns828=1&ns2300=1

I argue this is safe to remove, even without contacting the mentioned
communities first.

Bug: T321217
Change-Id: I160a119710dc35679dbdc2f39ddf453dbd5a5dfa
2024-01-04 13:17:42 +01:00
thiemowmde 13138d4ed0 Avoid the term "book referencing" in a few places
We are discussing this for a long time and finally renamed the tag
on Phabricator: https://phabricator.wikimedia.org/tag/cite-extends

This patch updates only places where it can't have any negative
consequences.

This is also a direct follow-up to Ic73f1b7 where this class was
created.

Bug: T353269
Change-Id: I644fe41d3386b9bf02b83366654301633efd535f
2023-12-15 15:49:04 +01:00
gerritbot c26cc4fa44 Update UserOptionsLookup's FQN
User-options related classes are being moved to the MediaWiki\User\Options namespace in MediaWiki Core; reflect that change here.

Bug: T352284
Depends-On: I9822eb1553870b876d0b8a927e4e86c27d83bd52
Change-Id: I04337d15d32c1e8bdfdcfa272f1750ffecc8e47e
2023-11-29 12:38:22 +00:00
Ed Sanders ada0820622 ve-cite: Remove unused messages for fake refernce headings
These were removed upstream in Iedc17c8ac9c.

Change-Id: Ic1240329de348a687db0373a9d247d3cd0780b46
2023-11-08 12:07:47 +00:00
Subramanya Sastry 70031b299e Remove unused ext.cite.style module
All references in all repositories have been renamed to its new name
ext.cite.parsoid.styles

Change-Id: I7b6b951f6d2b9a872e67c4edb9f366ceeccfb8e6
2023-08-29 21:12:06 +02:00
James D. Forrester 9dcfabc49e build: Update MediaWiki requirement to 1.41
All extensions in the MediaWiki tarball are expected to track MediaWiki's release directly.

Change-Id: I3bc415bd5f561f08a4e3e2d45fb89906c8062415
2023-08-19 11:29:54 +00:00
WMDE-Fisch 90499a6f76 Bump MW dependency to >= 1.40.0
Forgot to do that in Id2992d5beb0bc226a9acdfd28b2c7b37eee7e06a

Bug: T328497
Change-Id: I3633e17418529c5970eb456d055565433f2c3b80
2023-08-16 08:49:56 +02:00
WMDE-Fisch 29ed8bde7d Targets no longer needed in Cite
All match current default.

Bug: T328497
Change-Id: Id2992d5beb0bc226a9acdfd28b2c7b37eee7e06a
2023-08-15 19:48:34 +02:00
Subramanya Sastry 09df6301d7 Rename ext.cite.style VE dependency to ext.cite.parsoid.styles
Follows-Up: a5b8640928
Change-Id: If697936b8107b43be6019aa612f9fce8a21e87a4
2023-07-20 12:23:55 -05:00
Subramanya Sastry a5b8640928 Rename ext.cite.style.css to ext.cite.parsoid.styles.css
ext.cite.style.css is very close to ext.cite.styles.css and is
often confusing.

In about 3 weeks (the current PC expiry time), we should be able to
get rid of the ext.cite.style module from extension.json after
removing all references to it from other repos and caches.

I don't see a reason to rename all the other language specific
CSS files since there is no room for being confused there.

Change-Id: I3a41f435b0cbe51f8c9a6dde8a9f6eb13a9879f7
2023-07-13 11:31:41 -05:00
jenkins-bot 0a3240e217 Merge "Revert "Add extends warning to reference dialog"" 2023-06-29 16:58:33 +00:00
Awight 42e13cb3c3 Revert "Add extends warning to reference dialog"
This reverts commit da30b2b626.

Reason for revert: Caused a regression.  Feature is not enabled on public wikis so reverting is harmless for now.

Bug: T247922
Bug: T340757
Change-Id: I83434afaf1b76425bddb575dd724f462a247c83d
2023-06-29 16:36:47 +00:00
Jon Harald Søby c66371b3d9 Move Cite-specific settings from WikiEditor
The WikiEditor extension has a button and some help text that
is only applicable if the Cite extension is enabled. Move
that (with some modifications) to the Cite extension instead.

Bug: T339973
Depends-On: I8256660f9c6886d6764b45735284e00308fc56e5
Change-Id: Ib3fdc897dd3330f69c5832003d4c3cb1e6dba2f3
2023-06-28 20:22:14 +02:00
Svantje Lilienthal da30b2b626 Add extends warning to reference dialog
To warn users when they are editing a sub-reference we
add a warning containing the text of the parent reference.
This is hidden behind a feature flag.

Bug: T247922
Change-Id: I3749683d8a18e502bf16e5bd5f2fe385581625be
2023-06-12 16:24:58 +00:00
Svantje Lilienthal 227b50d964 Adding extendsRef to reference model
* reads the new attribute extends from wikitext
* saves it into the reference model
* adds a message to the VE popup of an extension as a first demo
* tests will be added in a separate patch

Bug: T247922
Change-Id: If4d309c4678022642f39e21565950dc45e557d47
2023-05-30 11:56:47 +02:00
thiemowmde b9d5ce7730 Document config flags in extension.json
Change-Id: Ife0c18b8e06980cdd23dae976749afdfb0cbd7e5
2023-05-16 09:57:54 +02:00
Tim Starling 5315297f38 Migrate CiteVisualEditorModule to a virtual file callback
Depends-On: I97d61b5793159cea365740e0563f7b733e0f16de
Bug: T47514
Change-Id: Iabfbb6751707813b7ec68f49b35441ab5dbb5622
2023-05-05 16:25:14 +10:00
Ed Sanders ca9ef93409 ve-cite: Convert .css files to .less
Change-Id: If831c23721cc2c3ec3cc17d4cd9c9533a0aa4cb4
2023-03-27 15:01:45 +01:00
Bartek Łukawski 780f9e1439 Highlight markup inside <references> in CodeMirror
See also: 9fd55c5f38
Bug: T294546
Change-Id: I55747e89242f0b53ec1f41c86c3523ad545e8470
2023-01-02 19:21:06 +00:00
Jon Robson 27baae7766 Add 'ext.cite.ux-enhancements to mobile pages
This code is being silently removed from mobile pages.
This code is never utilized on mobile because a reference
drawer shows on references click so no back link is necessary,
however given the size of the code, it doesn't seem like a good
idea to split the parser for this, so we should just add it.

In future perhaps the reference drawer feature in Minerva could be
moved to this module.

Bug: T324723
Change-Id: Ib49dcd647df765524887b4f3cc4bd0ccdb5b5ff0
2022-12-08 10:03:32 -08:00
Tim Starling bb72bc65f5 Use new ResourceLoader namespace
Extensions using Phan need to be updated simultaneously with core due
to T308443.

Bug: T308718
Depends-On: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
Change-Id: Iebc5768a3125ce2b173e9b55fc3ea20616553824
2022-05-24 23:00:08 +00:00
Timo Tijhof fb2c7c37db Combine ext.cite.visualEditor.data into ext.cite.visualEditor
Rather than depending on a separate module with one line of generated
JS code, generate it as a prepended statement to the same module.

Should be a no-op.

Depends-On: I809951d34feb2dbd01b7ae0f4bd98dac7c3f6fe2
Change-Id: I5886bf9f82025048976b7750e8cb751681021fb4
2021-11-19 16:56:51 +00:00
C. Scott Ananian 30cfb7c05a Rename deprecated usage of ParserOutput::{get,set}Property()
Bug: T287216
Depends-On: Ie963eea5aa0f0e984ced7c4dfa0fd65d57313cfa
Change-Id: Id4581c6c45f9fc4690900a30d8172951bc461a1b
2021-10-08 10:12:05 -04:00
Adam Wight 095ed57165 Finalize event platform migration
Bug: T275007
Bug: T275008
Change-Id: Ic0d94016b3cadead87bd879cab0cf7d2417bf272
2021-02-25 08:52:18 +00:00
Ed Sanders c763fb5cc3 MWReferenceNode: Ignore changes to reference list index
This means that all reference nodes are treated as comparable
in the diff (provided they are in the same group) so will
not show up in the article diff if their index changes.

Changes to the reference list are already handled separately
by the visual diff.

Bug: T170235
Change-Id: I8c26686d7b2fe3bf91af7d4dcab1caf3247dbe47
2021-01-21 14:40:15 +00:00
Taavi Väänänen 9293e2d5ca Update Cite to use the new HookContainer/HookRunner system
Bug: T270875
Change-Id: Ieb29603cde24a1c52829c12ae431eca09ba37bf9
2020-12-28 17:55:34 +02:00
jenkins-bot 3350aacbdf Merge "Move ext.cite.ux-enhancements to extension.json" 2020-12-14 16:39:50 +00:00
Ed Sanders 6e3eedd40a Show reason and/or date in CitationNeededContextItem
Bug: T270107
Depends-On: I7fdd4810118e72b9719b840fa5e0887006a74a25
Change-Id: I873fb28f5e8fbac469f0fe050818c58dc782fea9
2020-12-14 08:06:02 -08:00
Ed Sanders 35b704dc2f Move ext.cite.ux-enhancements to extension.json
Change-Id: Ia6a0c34800b018e76b9e246898ddfb991f238d55
2020-12-14 10:38:32 +00:00
Ed Sanders 10c525b5b7 Unconditionally register the VisualEditor integration statically
This is how we handle this in othe repos; CI ensures that VisualEditor
is indeed loaded alongside the Cite extension whenever it's required,
and this significantly reduces the complexity of the code in the repo
and the processing time needed from Cite's hooks on every PHP init.

I'm leaving the "ux-enhancements" module for now, as you can't mix
static (late) module registration with dynamic (immediate) code.

Change-Id: I974654d00687b0dea6aed342d8fa9dcb6ef90768
2020-12-13 22:11:27 +00:00
James D. Forrester c35d47fe0b Use QUnitTestModule instead of deprecated ResourceLoaderTestModules
CI already ensures that VisualEditor is loaded alongside Cite, so
the defensive check in the code isn't needed; ext.cite.visualEditor is
defined statically, it's just injected into the page dynamically in the
VisualEditor code handling VisualEditorPluginModules.

Bug: T232875
Change-Id: Ie5e096feca92f9c3ef13c732f3f1ae491e2b7d03
2020-05-11 20:51:24 +00:00
Thiemo Kreuz bcbc356c14 Remove misleading version number 1.0.0
I would like to argue that calling the current state of this codebase
"version 1.0.0" is plain wrong. A more meaningful version number can
easily be introduced later if one is needed.

Bug: T213066
Change-Id: I4854263592784feb072acea2d9efe99f1f04ab28
2020-01-10 21:31:38 +01:00
Adam Wight a227395e3a Lazy instantiation of Cite
Only create a Cite object if we need one.  Never clearState, just
destroy and recreate later.

This makes it less likely that we leak state between parsers, and
saves memory and processing on pages without references.

It's also preparation to decouple Cite logic from state.

Change-Id: I3db517591f4131c23151c76c223af7419cc00ae9
2019-12-12 11:12:17 +01:00
Thiemo Kreuz a7c4e14f42 Remove obsolete ParserBeforeTidy hook handler
I was able to track this code down to I093d85d from 2012, which was done
right after the ParserAfterParse hook was introduced. I believe the
redundant code path was left to keep the Cite extension compatible with
old MediaWiki versions that did not had this hook yet.

I also noticed this code path is most probably entirely redundant with
the current version of MediaWiki. The *only* thing this code does is
blocking the ParserBeforeTidy hook from doing the same thing a second
time if the ParserAfterParse hook was called before. But it does *not*
block any other compination, e.g. if the two hooks are called the other
way around, or the same hook twice.

In core, it looks like it is impossible for the ParserBeforeTidy hook
being fired without the ParserAfterParse hook being fired before. If this
is true, this is in fact dead code.

Change-Id: Iacf8b600c7abdeaf89c22c2fc31e646f57245e47
2019-12-04 16:56:43 +01:00
Adam Wight a176e22097 Remove ApiQueryReferences support
This API was never used in Wikimedia production, and would have caused
performance problems.  Removing the dead code will simplify our refactoring.

Bug: T238195
Change-Id: I7088f257ec034c0d089e0abdaa5a739910598300
2019-11-28 11:08:46 +01:00
Thiemo Kreuz ab3063fee5 Move all code to PSR-4 compatible namespaces
This patch does intentionally not touch any file name. Some of the
file names are a little weird now, e.g. \Cite\Cite. These can more
easily be renamed in later patches.

I used https://codesearch.wmflabs.org/search/?q=new%20Cite%5C( and it
looks like this code is not used anywhere else.

Change-Id: I5f93a224e9cacf45b7a0d68c216a78723364dd96
2019-11-20 17:00:13 +01:00
jenkins-bot 7018e82352 Merge "Extract all error reporting to a CiteErrorReporter" 2019-11-19 15:53:29 +00:00
Thiemo Kreuz 7c1e098b7c Fix bad settings name CiteCacheReferencesDataOnParse
* CiteCacheReferencesDataOnParse doesn't exist in any code.
* CiteCacheRawReferencesOnParse does.

Change-Id: Idc65d483cf5b7a7b25fd0aed7915c9c0958611f0
2019-11-19 16:13:07 +01:00
Thiemo Kreuz 342e231a22 Extract all error reporting to a CiteErrorReporter
Change-Id: Icf61c9a27fd03266c98caf443bb9f00a421e31f6
2019-11-19 14:53:31 +01:00
Thiemo Kreuz 7ce10d7539 Remove lazy registration of Parser related hooks
To be honest I don't get why this lazy registration was done in the
first place. None of the 4 other hooks should ever be called before
the ParserFirstCallInit hook got called.

Also, under which circumstances can the ParserFirstCallInit hook be
called more than once?

Both scenarios would be wrong, as far as I'm concerned. Either I'm
missing something, or this code can indeed be simplified. Maybe it was
something to make it more compatible with older MediaWiki versions?

The only reason I can think of is: in all situations that do not
involve a parser, having the 4 extra hooks registered is pointless.
Does this waste space and/or runtime in the $wgHooks registry?

Change-Id: I5ef1495f4ce7bce940fa5f8e700af3d2c4851a01
2019-11-12 11:47:55 +01:00
Thiemo Kreuz 1a371ec6a5 Extract all hook handler functions to small glue classes
As of now, this patch does not touch the existing code. However, the
goal is to remove a lot of the related code from the Cite class. This
will be done in later patches. This here is a separate patch to make
reviewing the later patches much easier.

The existing parser tests should be proof enough this chain of patches
is not changing any behavior.

Change-Id: I27ae972f81071bb4036bd452560768fae409417b
2019-11-07 09:45:32 +01:00
jenkins-bot 96b4903da4 Merge "Stop sampling when Reference Previews is enabled" 2019-10-25 11:06:30 +00:00
Thiemo Kreuz 28dd373d24 Move misplaced ParserFirstCallInit hook handler to CiteHooks
All other hook handlers are in the dedicated CiteHooks class.

Main motivation here is to make the huge Cite class smaller,
especially by removing static code that does not rely on anything
else the class does.

Bug: T236260
Change-Id: If0b3f6c989e44283428cda4b2c4d8d5303385d22
2019-10-25 10:34:35 +02:00
Thiemo Kreuz a037f76317 Streamline Hooks section in extension.json
Main motivation here is to make the list easier to read. We are not
going to have more than a single hook handler per hook anyway.

Bug: T236260
Change-Id: I72357a89402e6febfa1e99f825a3fd699c5561b7
2019-10-25 10:28:08 +02:00
Adam Wight f6b5615e4b Stop sampling when Reference Previews is enabled
There are so few users with this configuration that we need to stop
sampling in order to get data.  Sampling is still in effect for
"baseline" users with the feature disabled.

We use separate schemas to simplify analytics on the two populations.

Bug: T214493
Change-Id: I16e4ed236e50e1e246ff28ff0dba3e52e4b56caf
2019-10-24 22:23:18 +02:00