User:PerfektesChaos/js/pageLinkHelper

JavaScript gadget – several little helpers for links related to pages:
 * diff – put a wiki formatted link source on diff pages for c&p
 * permalink – put a wiki formatted link source on some pages for c&p
 * purge – add a link to purge the current page into portlet
 * redirect – insert an entry in browsing history if redirected here

Usage

 * If your project has registered this as a gadget, just activate on your Preferences page.
 * Otherwise include the following lines into your common.js, global.js etc.:

Difflink source code
If you visit a diff page, comparing two revisions of a page, you get a link code for copy&paste in the upper right corner of the content, looking like this:

Such Special:Diff/ is much shorter than an URL and works also in edit summary or as reason for some action, where URL is not evaluated.

The generated element has two selectors:

Permalink source code
If you visit an older revision of a page, you get two link codes for copy&paste in the upper right corner of the content, looking like this: [&#91;[ Special:Redirect/page/]]]
 * [&#91;[ Special:PermanentLink/]]]

Such links are much shorter than an URL and work also in edit summary or as reason for some action, where URL is not evaluated.

The first permalink yields the current revision, the second one points always to the same page, even if had been moved meanwhile. There is an URL available within the copy pattern that contains also the informative parameter  which memorizes the page name.

On some pages there is a link on “” available within the toolbox, usually in left sidebar. The functionality of this standard link is modified to insert the link source codes as mentioned.

The generated element has two selectors:

Purge server cache
Add a link into your portlet to purge the current page on the server.

On “Vector” skin, this will be appended to the menu below the ▼ fly-out on top of the page. No further action is required.

On any other skin or if you want another place for the link you need to specify where to add that link by a statement like this: It should appear on your common.js, global.js or skin dependant JS best before an  call as described in “Usage” section.

The assigned code specifies where to place the link:
 * – end of content actions (usually horizontal menu at top of page) – default
 * – end of toolbox (usually in left sidebar) – see example
 * – end of navigation box (usually in left sidebar)
 * – any particular portlet element after which you want to insert the purge link

The generated link has one if these selectors, depending on context:
 * (default)

Purging for experts: forcerecursivelinkupdate
This feature causes more updating than simple page purging, but might be confusing. Therefore it is disabled by default. Experts will know when to use this and which consequences to be expected.

By (Vector) or the same selectors as mentioned in the section on purging a link can be inserted into a portlet-container, which starts a link update via API.

Depending on chosen container the generated link has a selector like:

Redirects in browser history
If you reach a page following a redirect link, you get a small note in the upper left corner of the content, including a link to the redirect page. However, if you continue to work, especially if you edited that page, this tiny note and link will vanish. If you need to open the redirect page later, there is no simple way to reach that particular redirect again.

This gadget inserts an entry in browsing history when a redirect has been processed. The rendered page is still the target page, but one step before in history you get the redirection URL displayed in address bar. After clicking that one you can view and edit the redirect.

Required Browser
This feature depends on the browser and requires a recent version: Chromium 5, Firefox 4, Gecko 2, IE 10, Opera 11.50, Safari 5.0.

Address bar until 2014
Until summer 2014 address bar did not show the URL of the current page but of the redirect page, if forwarded by a redirect link.

If this behaviour shall be simulated, the following statement may be used: It should appear on your common.js, global.js or skin dependant JS best before an  call as described in “Usage” section.

History, contributions, watchlist
Every entry begins with some links on diffpage and particular revisions. These URL are converted into links to special pages, which may be transformed into internal links much easier.

qqx – make system messages visible
This feature is needed more for project maintenance rather than by regular users. Therefore it is disabled by default. It makes the identifiers of system messages in page visible.

By (Vector) or the same selectors as mentioned in the section on purging a link can be inserted into a portlet-container, which opens the same page again but under  circumstances.

Depending on chosen container the generated link has a selector like:

Multiple user options
If more than one option is to be provided, the statements above would erase each other. A slightly different notation is needed, e.g. as follows: It should appear on your common.js, global.js or skin dependant JS best before an  call as described in “Usage” section.

Other languages
This gadget is prepared for multilingual support. Intermediately, programmers can override any  component by providing a respective component at:
 * If you like a version in your own language, please forward translations to me:
 * This documentation page.
 * The  mapping on top of source code.
 * Further ISO 639 language codes your translation might support.

Codes
de:User:PerfektesChaos/js/pageLinkHelper