Resources

Aus Free Software
Wechseln zu: Navigation, Suche
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
Resources

Release status: stable

Implementation Special page
Description This special page allows you to view resources attached to a given page. This extension is part of the PerPageResources project.
Author(s) Mathias Ertl (Mati talk)
Version 1.5.2 (2012-10-07)
MediaWiki 1.19 or later
License GPL v3 or any later version.
Download see Download
Documentation
Changelog
Parameters $wgResourcesShowPages, $wgResourcesShowSubpages, $wgResourcesShowLinks, $wgResourcesDirectFileLinks, $wgResourcesSubpagesIncludeRedirects, $wgResourcesAddInfos, $wgResourcesTabs, $wgAddResourceTab, $wgResourcesCSSpath
Example try this page
Hooks used

LanguageGetSpecialPageAliases
SkinTemplateNavigation
SkinTemplateNavigation::SpecialPage

This Extension, part of the PerPageResources-Project, enables you to view Resources attached to a given page. Simply call the provided special page (Special:Resources) with the page-name (as provided by Resources) as parameter and the page will give you a category-style listing of all resources associated with that page. Such resources can be Files, Subpages or links to external websites. They can easily be added with Special:AddResource, but any kind of resource can also be added by hand. This extension can also be used to display a tab to Special:Resources next to the discussion-tab.

Download

The source code of this extension is managed on GitHub. You can find the repository at mathiasertl/Resources. To get the most recent version of this extension, fetch the current HEAD:

git clone https://github.com/mathiasertl/Resources.git Resources

Older versions are marked as tags, you can view available tags with git tag -l and move back to the current HEAD with git checkout <tag-name>. Versions for older versions of MediaWiki, if available, are managed as branches, use git branch and git checkout <branch> to move to a specific branch. To move back to the newest version, use git checkout master.

Note that GitHub allows you to download older different commits as tarball if you do not want to install git.

Installation & Configuration

Simply download all three files (Resources.php, Resources.i18n.php and SpecialResources.php) into you extensions-directory, preferably into their own directory and include Resources.php in your LocalSettings.php:

# Resources extension
require_once("$IP/extensions/Resources/Resources.php");
Default Settings

The extension is very configurable, the code below gives you a complete example of all configuration-variables set to their defaults:

    $wgResourcesShowPages = true;
    $wgResourcesShowSubpages = true;
    $wgResourcesShowLinks = true; #this also requires $wgEnableExternalRedirects=true
    $wgResourcesDirectFileLinks = false;
    $wgResourcesSubpagesIncludeRedirects == false; # note that this will never include broken redirects
    $wgResourcesAddInfos = false;
    $wgResourcesTabs = true;
    $wgAddResourceTab = true;
Settings in detail

The variables should be self-explanatory, but heres a specification anyway:

$wgResourcesShowPages 
Whether or not files linking to the given page should be included.
$wgResourcesShowSubpages 
Whether or not subpages of the given page should be included.
$wgResourcesShowLinks 
Whether or not external redirects (that are subpages of the given page) should be included
$wgResourcesDirectFileLinks 
Whether or not Files linking here should be directly linked to (true) or if their page in the media-namespaces should be linked (false).
$wgResourcesSubpagesIncludeRedirects 
Whether or not we should include (working) redirects.
$wgResourcesAddInfos 
Whether or not we should include comments (i.e. page-length, file-size, etc.) for each resource found.
$wgResourcesTabs 
Whether to display a tab to the resources-page
$wgAddResourceTab 
Whether to display a tab to the AddResources page if Special:Resources is currently viewed.;
$wgResourcesCSSpath 
if your extension is installed in an unusual location, or you want to have the CSS-file elsewhere, you can configure the path to it with this variable.
CSS for additional tabs

On default, the new tab is in the wrong position, the resources tab has a large space to the discussion tab and is very close to the edit-tab. To fix this, you can add a tiny bit of CSS to MediaWiki:Common.css:

/* This is for the Resources Tab. */
li#ca-view-resources {
	margin-left: -1.3em;
	margin-right: 1.6em;
}

Once that is done (and the cache is regenerated) the tabs should be in the right position (like in this wiki).

Changelog

1.5.2
  • Fix tabs for all skins
  • code-style cleanup
1.5.1
  • Add compatibility with MediaWiki 1.19.
  • Minimal required version is now changed to 1.19.
1.5
  • Implement limited functionality for the new 'Vector' skin. So far the resources tab can only be added to the normal pages, not to the special page itself, as there is no hook called in this case
  • Display the number of resources in the tab
  • Updated url of the extension to this page
  • This version should work with MediaWiki 1.11.1 or later.
1.4.1
  • The CSS required for the resources-tab must now be included in MediaWiki:Common.css (or Monobook.css). This should cut the load-time somewhat, because Common.css is included anyway.
1.4
  • The special page now shows another chapter that lists pages that redirect here. This chapter is only shown when there are actually any redirects here.
1.3
  • Massively optimized algorithms. getLinks now takes 1/6 the time it did before, getFiles is now 20% faster.
  • Each of getFiles, getLinks and getSubpages now takes a second, optional, parmater $count. If true, the function will do a SELECT count(*) instead of multiple fields. After the SQL-Query is made, it returns right away with the count returned by it. This lowers memory-consumption and Speeds up every such function-call by a factor of 15 or so.
  • As a result, getResourceListCount is now 60 times faster (really!). This alone speeds up load-times of entire pages by up to 200ms.
  • Fixed a nasty transient bug that multiple pages might have the same sortkey (and thus, one disappears in the Resources-view). Every sortkey now has the page_id (which is the key of the MySQL-Table) appended.
1.2.1
  • The target of the links in the tabs is now generated by getPrefixedDBkey instead of getPrefixedText. This is a bit faster.
1.2
  • updated to work with all wiki/user language combinations
  • if no parameter is given and $wgResourcesCategory is defined, the special page displays all pages in that category. This is achieved using the DynamicPageList-Extension. This is a rather quick hack and should be done in a better way.
  • various java-script-variables that where used by Common.js where removed.
  • removed a useless require_once (for ExternalRedirects)
  • renamed various functions to conform to standards (efResources...)
1.1
  • A very specific fix for our needs: ä/ö/ü/Ä/Ö/Ü are now sorted as ae/oe/ue/Ae/Oe/Ue.
  • The CSS is now added automatically.
1.0

this is a major upgrade:

  • This extension can now display a tab to the </nowiki>Special:Resources/Resources</nowiki> next to the discussion header. It is automatically red, if there are no resources for this page.
    • This deprecates Common.js and AddBasePage. The tab-functionality is now better integrated and has more features
    • for this to really look good, you need two lines of CSS (see above)
    • new i18n message 'resourcesTab' is used for the tab-text
  • $wgAddResourceTab is set to true (see AddResource-extension) a tab for the AddResource-Page is also displayed if Special:Resource is currently viewed.
  • Now use $wgOut->setPagetitle() to set the page title, causing it to be also displayed in the <title> html-tag.
    • This deprecates some of the css that was previously used to hide the real header
0.9.2
  • Updated to work with MediaWiki 1.11.1 and later by fixing LanguageGetSpecialPageAliases (This was a typo in 1.11.0, see Bug 11462)
  • Updated link to this page (This wiki now uses Very short URLs)
0.9.1
  • fixed a bug in the english translation that caused the creation of a broken link if no resources where found.
0.9
  • first version documented here.

ToDo

Some features of this special page are not yet implemented:

  • Some Request-parameters (?showFiles etc.)
  • For now, this extension is only able to find articles in the media-namespace linking here (the files), which is a hardcoded limitation which could be overcome easily. The variable to configure these namespaces is already in place (but nun functional) and is called $wgResourcesNamespaces.
  • The extension could use SimilarNamedArticles to find all resources for pages with a similar title if the page itself doesn't exist.
  • sortkey could be changeable, i.e. sort by last-change or so...

Licence

GPL v3 or any later version.