Commit graph

72 commits

Author SHA1 Message Date
petarpetkovic 50d556e8d2 Make link annotations more flexible
* When ve.ui.MWLinkAnnotationInspector is being initialized,
internal and external annotation inspectors are hardcoded to
new ve.ui.MWInternalLinkAnnotationWidget and
new ve.ui.MWExternalLinkAnnotationWidget. Make this creation
more flexible by creating these inspectors through a method,
which inheriting classes can override.
* In ve.ui.MWLinkAnnotationInspector.getAnnotationFromFragment,
factor out the creation of link annotations, so overriding
classes have the ability to provide different internal and
external annotations.
* In newFromTitle, static method of MWInternalLinkAnnotation,
creation of `element` isn't flexible for reusability with
slight changes to attributes passed to the constructor. By
factoring out the creation of attributes, inheriting classes
can reuse the existing structure and alter the attributes if
needed.

Bug: T195064
Change-Id: I2037464a7be77783837e9810691c8e372c8197c6
2018-07-26 15:12:19 +02:00
Ed Sanders 534b3d66cb Update VE core submodule to master (a1fd90540)
New changes:
71baf1c02 Create an 'htmlMsg' function for HTML messages with HTML or DOM arguments
9a7af223e Use ve.htmlMsg to highlight values in attribute changes
a1fd90540 DiffElement: Refactor describeChanges tests

Local changes:
Implement getHtmlMessage in mw.Platform and use for DiffElement

Bug: T195243
Depends-On: Ib4ad16858e4241d33d018830dbcfded63ff703af
Change-Id: Ib5fa39e4f2f529948354b03a141542e23d169fe0
2018-06-20 12:53:43 +02:00
Ed Sanders cb36c6ded3 Fix parsing of external links, now Parsoid adds 'external' classes
Bug: T196025
Bug: T188656
Change-Id: I89b8ba378108bde6c8db0144ed306cbc8471111b
2018-06-01 08:47:46 +00:00
David Lynch 909aecbd26 dm.MWInternalLinkAnnotation: account for ? in fragment
It was failing to properly ignore the fragment if it contained a ?. This
resulted in such fragment-selflinks being considered a link to a wikipage with
a title of their full URL. As such, only consider the pre-# section for ?s.

Bug: T194463
Change-Id: I205f86d2b4abcf91dd6a84e3013e899e953a6842
2018-05-18 19:58:21 +02:00
Ed Sanders 637d869d99 Convert href-less links to spans
Bug: T191598
Change-Id: I0993869ed53842f9de60ff7e68f79a69da1d23c7
2018-04-09 18:04:08 +00:00
David Lynch 4e10d5b975 Update rel attribute checks to be aware of multiple rel values
Various checks didn't think a rel attribute could contain multiple values.
Mostly they don't, but to play it safe let's adjust the checks.

Change-Id: I29823b7c8c65ef6b2ff41ce9a801840000972e9c
Depends-On: I33a456351ab025d0c81cfb1a1577d5a2ae9df51a
2018-03-08 14:34:56 -06:00
James D. Forrester d144599cea Update VE core submodule to master (ca771b8bc)
New changes:
7551f6c66 [BREAKING CHANGE] Rename class ve.dm.IndexValueStore->ve.dm.HashValueStore

Local changes:
Follow-through rename of IndexValueStore->HashValueStore

Bug: T188900
Change-Id: If60d0c637fe92f0e7afe916c064fafb17980d063
2018-03-06 12:55:30 +00:00
Bartosz Dziewoński 98a1bb09c0 Centralize Parsoid resource name parsing logic
Let's keep the ugly regexp and the comments about why we do this in a
single place.

This is mostly without behavior changes, with three exceptions:
* ve.dm.MWImageModel#attachScalable now passes a title with spaces
  instead of underscores to the Scalable (this doesn't matter because
  it's normalized to use spaces later anyway).
* ve.dm.MWImageNode#getFilename now returns a title with spaces
  instead of underscores. This is used in some API queries and when
  rendering thumbnails for missing files, and this format is actually
  more correct for both of these.
* ve.dm.MWTemplateModel now URI-decodes the template title. This
  actually fixes a bug where trying to edit a template transclusion
  whose title contains a '?' would throw an exception about invalid
  title.

Also, clarify that the return value of ve.dm.MWImageModel#getFilename
and ve.dm.MWImageNode#getFilename is different :(

Change-Id: I8e09015cea82308017ed925ec755b7231518126e
2018-02-28 03:01:05 +01:00
James D. Forrester 0a7a845a42 doc: Bump copyright year
Change-Id: I0b299c840ede1a1b8552cecfc70c5760ab036181
2018-01-03 17:45:07 +00:00
C. Scott Ananian fde0c180aa Interwiki links are a type of external link
Bug: T97093
Change-Id: I13325075deba127dc620adb0ad1d18ef99352ab2
2017-12-13 15:56:58 +00:00
David Lynch 88f3191926 tests: MWInternalLinkAnnotation getFragment
Also, fix docs for it. It could also return null for a missing fragment.

Change-Id: Ib6df379c5c3686a59026b6b66f26b3050ede231a
2017-04-27 11:21:58 -05:00
David Lynch d5ac18a466 LinkCache: don't treat a link with a fragment as a selflink
This matches the rendered output for the page.

Bug: T162669
Change-Id: I1ea0ab37a2751c0b4669da8a23adf0ce271facea
2017-04-11 12:19:01 -05:00
Ed Sanders 738d3aff47 Use original title or normalized title when inserting link text
Original title will preserve the case of what the user entered
into the inspector. Noramlized title will remove any unwanted
leading colons from file/category links.

Bug: T118408
Bug: T124410
Bug: T160977
Change-Id: I92ffc19eab4eead0d124e84afc1e5a0a3e535867
2017-03-24 22:16:31 +00:00
Ed Sanders 9cd8faea8b VisualDiff: Add custom messages for change descriptions
Bug: T151403
Change-Id: I469a3c7897f2417c1850364f65da51c0deca2386
2017-03-16 14:36:09 -07:00
jenkins-bot 50e7fd0653 Merge "Fix MWInternalLinkAnnotation.getTargetDataFromHref's behaviour with URLs containing query parts" 2017-01-05 15:08:33 +00:00
James D. Forrester 122f49b2dd build: Bump file copyright notices for 2017
Change-Id: I3c20809e71cc0da58123e1b5f29c4f3aac945496
2017-01-03 08:58:33 -08:00
Alex Monk 4c061de2e0 Fix MWInternalLinkAnnotation.getTargetDataFromHref's behaviour with URLs containing query parts
ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref(
	'http://mediawiki.krenair.dev/mediawiki_dev/wiki/Main_Page?veaction=editsource',
	ve.init.target.surface.model.documentModel.htmlDocument
)

Wrong, current result:
Object {
	title: "Main Page?veaction=editsource",
	rawTitle: "Main_Page?veaction=editsource",
	hrefPrefix: "",
	isInternal: true
}

New result:
Object {
	title: "http://mediawiki.krenair.dev/mediawiki dev/wiki/Main Page?veaction=editsource",
	rawTitle: "http://mediawiki.krenair.dev/mediawiki_dev/wiki/Main_Page?veaction=editsource",
	hrefPrefix: "",
	isInternal: false
}

Change-Id: I3d6d7fcfeb0d8354623026c831605c7633c3e11a
2016-12-24 20:12:44 +01:00
Roan Kattouw bb45d984ca dm.MWInternalLinkAnnotation: Fix href normalization for special characters
<a href="Foo%3F"> would dirty-diff to <a href="Foo?"> and also render
as such, pointing to the wrong page.

We also called decodeURIComponent() on the href twice, which can't
have been good.

Move URI decoding and underscore normalization into
getTargetDataFromHref(), and add rawTitle for callers that need it.
Put rawTitle in the origTitle attribute, so that equivalence
comparisons (decode(origTitle) === title) work as intended.

Bug: T145978
Change-Id: I29331a4ab0f8f7ef059c109f6813fa670a2c7390
2016-09-22 09:10:41 -07:00
Ed Sanders adaa47804f Search all RDFa attributes when looking for type
Bug: T144561
Change-Id: Ib42daa52796cd72babbd8a317bae948cff779c99
2016-09-02 16:43:30 -07:00
jenkins-bot b656f3d5f1 Merge "Use super property to call parent methods" 2016-09-01 17:04:39 +00:00
Ed Sanders 5788340b49 Update VE core submodule to master (632f0a9)
New changes:
14b5fbc [BREAKING CHANGE] Move originalDomElements to the IV store and use MD5
c5d21f0 Provide methods to (de)serialize transactions

Local changes to move originalDomElements to IV store

Depends-On: I8a71c1a40ec35108d0a9a388da6f75632f8dc53c
Depends-On: I32c9b5f984fcf96e3354841ecfcd444149e8f159
Change-Id: I0fbb6324eede94558426178cbdad6b5daf0f8318
2016-08-24 18:14:14 +00:00
Ed Sanders 62bdaac13b Use super property to call parent methods
Change-Id: I76982b844cf2871d7583463def4393e5bdc33aa2
2016-08-23 11:56:47 -07:00
Alex Monk 818c6e4928 Take link fragments into account
TODO: Do we need to do anything special here to handle multiple hash symbols in a URL?

Bug: T112898
Change-Id: I4773cb04ae2533e8125bc55d9ebb606d63b3bf48
2016-08-06 01:20:24 +01:00
jenkins-bot 913d3c0cf4 Merge "New decodeURIComponentIntoArticleTitle method" 2016-06-29 16:15:41 +00:00
David Chan 367bc2437f New decodeURIComponentIntoArticleTitle method
This replaces ve.safeDecodeURIComponent(...).replace( /_/g, ' ' ) . This action
is really specific to the quirks of mediawiki title processing.

Change-Id: Ia9e525c9340e6de9e485355899996c97867ccb48
2016-06-14 23:31:23 +01:00
David Lynch cc78cb2d06 Decode encoded link titles when generating them from text
Percent-encoded characters are forbidden in titles. Copying URLs around will
tend to wind up when them percent-encoded when you paste. Therefore, when
trying to build a title from a pasted link, decode it first.

Change-Id: Ia0abcb2d903b04d99c7db16eb0a5962480b138d5
2016-06-13 08:58:54 -05:00
Ed Sanders 6fad9ecdee MWExternalLinkAnnotation: Only match plain external <a>s with hrefs
We now accept non-Parsoid generated external links from paste,
so make sure they have href attributes otherwise they aren't
really external links and will throw exceptions later on.

Bug: T131430
Change-Id: Ifb565b1ce30cfe80ae72b17f6a9551ea40b36453
2016-04-02 18:51:56 +03:00
Ed Sanders b7d25d92bc Detect the type of plain pasted links
Using the same logic we used for converting pasted URLs, detect
internal links by matching their base.

Currently link pasting is still disabled in the VE target, but
has been enabled elsewhere (Flow).

Change-Id: Iebd61abbe1fe82fd18d129e1dbc815ca75f44e87
2016-03-17 19:30:13 +00:00
Ed Sanders 5e6cbc187c Link pasting: Match RDFa-less links as external
Now that some targets support link pasting (Flow) we need to
make sure that pasted links match to an allowed type ('link/mwExternal')
instead of plain 'link' annotations which should never exist
in an MW document.

In a later commit we should auto-detect internal links.

Change-Id: I7faae834aa6e730c3cf93a691331a05fd0fe3d5c
2016-03-17 17:18:41 +00:00
James D. Forrester ada58df361 build: Bump file copyright notices for 2016
Change-Id: I3c618c196e504a80ca297a4132a17f1977a24fb7
2016-01-03 14:57:25 -08:00
Ed Sanders 63184600d4 Use wgNamespaceIds constants instead of hard-coded numbers
Change-Id: I71b80e59a5e24d63e68637a1ae8422974643bd3a
2015-12-04 19:57:56 +00:00
Ed Sanders 8e63c9e991 MWInternalLinkAnnotation: Make protocol matching case-insensitive
This was causing a regression in the behaviour that takes you
to the external link tab automatically when 'http://' is typed,
as internally it is normalised to 'Http://'.

Bug: T112158
Change-Id: Id7cff07e89caafe5b350f4fb27b99c6c89498990
2015-09-16 23:49:55 +00:00
C. Scott Ananian 7cc23367f6 Specialized inspector for ISBN magic links
Implement a special node type, context item, and inspector for
ISBN/PMID/RFC magic links.  Add buttons to the link inspectors
to convert back and forth between "simple" links, and magic links.

Depends on I5d000d8b63dafdfe0a2753069d3f0ac5b03b8829 in Parsoid
for clean round-tripping of localized ISBN magic links.

Bug: T63558
Change-Id: Id5b7a2ae3c80b0e5eed598f0bd024d3e94f7e9aa
2015-09-01 14:25:59 -04:00
Ed Sanders a67965a888 MWInternalLinkAnnotation: Override new getDisplayTitle method
This allows the URL paste handler to use the normalized title
as the text content. Add a test to cover this behaviour.

Depends on Ica48fea69cc in core.

Bug: T109980
Change-Id: I2784adaf2949a73256049921227dde0917ef9aef
2015-08-24 14:29:49 -07:00
C. Scott Ananian 2852f6368f Builder for ve.dm.MWInternalLinkAnnotation
Add ve.dm.MWInternalLinkAnnotation.static.newFromTitle to build an
appropriate internal link annotation from a mw.Title.  Tweaked some
method signatures to avoid repeated reparsing of the title text.

Also refactor ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref
to explicitly return a boolean indicating whether the result was determined
to be an internal link.

Bug: T64816
Change-Id: I74385d7b3ede1794398dabb749185f4080509b99
2015-08-19 16:57:06 -04:00
James D. Forrester 00d3226be1 build: Enable jscs jsDoc rule 'checkParamNames' and make pass
Change-Id: Ifcd3f67524c32148ff3591263d6374b31ee57d3b
2015-08-19 11:33:59 -07:00
James D. Forrester 85f91f394e build: Enable jscs jsDoc rule 'requireNewlineAfterDescription' and make pass
Change-Id: I7c0fabc93834d19198caea8f5dd1834e9e473d0a
2015-08-19 11:21:01 -07:00
James D. Forrester 945242a55a build: Enable jscs jsDoc rule 'checkAnnotations' and make pass
Change-Id: I76abb1eb1f3e1a2e8a4c03f577a080f4889b3a6d
2015-08-19 11:09:34 -07:00
James D. Forrester 19df1d4c8a build: Enable jscs rule 'requireVarDeclFirst' and make pass
Change-Id: Ia2f765d12bde001c329c2ff4c080a36b71de9803
2015-08-19 11:05:01 -07:00
James D. Forrester f5c6f61163 build: Enable jscs rule 'requireSpacesInsideBrackets' and make pass
Change-Id: I846d36c15e1b1f810d2ef7fd422f8412790bcb0f
2015-08-19 10:33:02 -07:00
James D. Forrester 57f8fc5368 build: Drop last jscs over-ride and make pass
Change-Id: I4ff60af79cfc6e09e284d51f9b7ac2afa900f0f5
2015-07-22 15:13:09 -07:00
Alex Monk 6f17fde4cd Convert 'external' links to internal pages pasted into the search field
Bug: T94334
Change-Id: I0ed67e6579b9ed0a0565968fd253fdf5c6151683
2015-04-29 16:11:32 +01:00
jenkins-bot 5de7b8a461 Merge "Merge MW internal link annotations if they have the same target" 2015-04-06 19:32:05 +00:00
Ed Sanders dfdf7c3f28 Merge MW internal link annotations if they have the same target
Currently we compare some HTML attributes, but as wikitext doesn't
allow you to set arbitrary attributes on a link they can never
represent a meaningful difference (unlike <b style="color:red;"> vs. <b>)

Bug: T95028
Change-Id: I267604e4b2140d3c4fe4f9ab07961c6f17a1f2fa
2015-04-06 12:07:03 +01:00
Roan Kattouw dd5608598f Use .apply() in MWInternalLinkAnnotation.static.toDomElements
Otherwise other parameters (there are 4 in total) get dropped.

Change-Id: I91cbb8391218cb7e9179b6b655bbfe22d21ade26
2015-04-03 08:54:45 +00:00
Roan Kattouw f3b7ccdefb Use ve.safeDecodeURIComponent()
Depends on Iacc50230a in VE core.

Change-Id: I7fc505c261726f8d83c86a9cc352a0bf9fcb455a
2015-03-31 22:08:46 +00:00
Roan Kattouw 5026e9b4f5 MWInternalLinkAnnotation: Remove useless .toString() call
ve.resolveUrl() always returns a string, so .toString() is not needed.

Change-Id: Ia699821148687ca16ef642bf94740384779ecb5a
2015-03-30 21:14:27 -07:00
Roan Kattouw 3611664663 Update VE core submodule to master (7d2a68e)
New changes:
0ceafd5 Fix V8 deopt for ve.ce.BranchNode#onSplice
01d2d4b [BREAKING CHANGE] Store originalDomElements instead of htmlAttributes
96005a7 Localisation updates from https://translatewiki.net.
42e672e ve.ui.Toolbar: Don't call #updateToolState from #initialize
373562d Localisation updates from https://translatewiki.net.

Local changes:
Update for htmlAttributes going away

Change-Id: I576a1e5d5883b03d1fff6666926f80a5682a280f
2015-02-18 15:35:46 -08:00
Roan Kattouw 2bdb20b3c1 Don't corrupt href="./" in internal links
href="./" was being corrupted to href=""

Change-Id: Ieedd71a991c6b52225f2ac41ebe1a20e7533c19e
2015-01-30 18:44:57 -08:00
James D. Forrester 2f8b3e0d96 build: Bump copyright notices to 2015
Change-Id: Ie92dab7411116d3410195c3fb0a3513c664c0c30
2015-01-12 20:34:19 -08:00