AddResource

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

Release status: stable

Implementation Special page
Description This special page allows you to attach resources to a given page. This extension is part of the PerPageResources project.
Author(s) Mathias Ertl (Mati talk)
Version 2.1.0 (2012-10-07)
MediaWiki 1.19 or later
License GPL v3 or any later version.
Download see Download
Documentation
Changelog
Parameters $wgResourcesCategory, $wgAddResourceTab
Example Try this page
Hooks used

UploadCreateFromRequest
LanguageGetSpecialPageAliases
SkinTemplateNavigation::SpecialPage

This Extension, part of the PerPageResources-Project, enables you to add new resources to a given page. Simply call the provided special page (Special:AddResource) with the full page-name (as provided by {{FULLPAGENAME}}) as parameter, and any resources added through that interface will be automatically added to the corresponding Resources-Page. This extension can also display a tab linking to SpecialAddResource if Special:Resource is currently viewed.

Download

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

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

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.

Dependencies

  • Although this extension doesn't formally depend on the Resources-extension, it doesn't make much sense to install just one of the two.
  • The ExternalRedirects-Extension is required to add links to external pages. If the extension is not enabled, the corresponding chapter in the special page will not be shown.
  • If uploads are not enabled (see $wgEnableUploads), the chapter to add files to the page is not shown.
  • This extension cannot prefill text on new Subpages, you might want to use the NewArticleTemplates-Extension for that (we do).

Installation & Configuration

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

# AddResource extension
require_once("$IP/extensions/AddResource/AddResource.php");

# If you want new external redirects and files added through this interface to be in the category 'Resources':
$wgResourcesCategory = 'Resources';

# If you want to display a Tab for SpecialAddResources, you need this:
$wgResourcesTabs = true; # also used in resources-extension!
$wgAddResourceTab = true;

Thats it. No special configuration required! (Except for the dependencies noted above)

How it works

See PerPageResources for an explanation of how resources are associated with a page.

Changelog

2.1.0
  • Include most of the code from the ManipulateUpload extension, which is now deprecated.
  • Make extension compatible with MediaWiki 1.19
  • Use the HTMLForms API included in newer MediaWiki versions
  • Use the Upload API included in newer MediaWiki versions
  • Skin is now compatible with all Vector-based skins
  • Display the AddResource special page as a '+' similar to edits on discussion pages
  • Massive code-style cleanup (spaces instead of tabs, ...)
2.0.1-1.16.0
  • Add automatic acknowledgment of uploads (since they are automatically manipulated, which causes a warning).
  • Compute filename in a safer way.
  • Update some i18n messages.
  • This is the first version managed in git.
2.0-1.16.0 (rev. 339)
  • Updated homepage to this page
  • Add javascript variables to automatically fill in the destination filename in the upload form
  • Modified upload form so we get fewer warnings upon form submisson
  • Honor wpDestFile GET parameter, see version 2.0 of the ManipulateUpload extension.
1.6-1.13.1 (rev. 295)
  • Example for filename is now in a new line and in gray
  • Fixed the superfluous ':' in upload and link chapter
  • The filename example now always has the current date as date. Also fixed various äöü.
  • Explanation on top of the page now uses anchor links to link to individual chapters.
  • The Link to view all subpages no longer uses Special:Resources but Special:Prefixindex. There are two reasons for this:
  1. The showAllSubpages parameter of SpecialResources was never implemented anyway
  2. The showAllSubpages parameter was actually meant to only view subpages in the point of view of SpecialResources. This excludes external redirects and therefore kind of is besides the point in this context.
1.5.3-1.13.1 (rev. 283)
  • The addBanner function is now able to display the banner in grey.
  • Fixed permission-checking. The red-warning banner is now displayed only if the user is not able to do anything. Otherwise, grey banners are displayed in the chapters where the user will not experience the full functionality.
1.5.2-1.13.1 (rev. 267)
  • Added the i18n message 'specialpages-specialpagegroup-addresource'.
Note: This changelog entry is retroactive. I don't know anymore why I added this message.
1.5.1-1.13.1 (rev. 263)
  • The tabs now use getPrefixedDBkey to build the link-target
  • some code-restructuring (code is now cleaner and hopefully a bit faster)
1.5-1.13.0 (rev. 250)
  • minimal port to 1.13.0, otherwise identical to rev. 201
1.5 (rev. 201)

This is a major upgrade:

  • This extension now uses the Hook 'SkinTemplateContentActions' to display tabs to the article, talk-page and resources-page.
    • This requires the new variables $wgAddResourceTab and $wgResourcesTabs (the latter is actually of the Resources-extension) to be set to true.
    • Note that this is done without javascript
  • The page-title is now set by $wgOut->setPagetitle(). This means that you no longer need CSS to hide the real title.
    • As a result, the i18n-message 'addResource_Header' is deprecated and 'noParameterHelp no longer includes a header, a new message 'addResourcesPageTitle' is used instead.
  • update documentation somewhat
  • *really* updated link to this page (forgot last release)
1.5 (rev. 201)

This is a major upgrade:

  • This extension now uses the Hook 'SkinTemplateContentActions' to display tabs to the article, talk-page and resources-page.
    • This requires the new variables $wgAddResourceTab and $wgResourcesTabs (the latter is actually of the Resources-extension) to be set to true.
    • Note that this is done without javascript
  • The page-title is now set by $wgOut->setPagetitle(). This means that you no longer need CSS to hide the real title.
    • As a result, the i18n-message 'addResource_Header' is deprecated and 'noParameterHelp no longer includes a header, a new message 'addResourcesPageTitle' is used instead.
  • update documentation somewhat
  • *really* updated link to this page (forgot last release)
1.2.3 (rev. 197)
  • 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)
1.2.2 (rev. 194)
  • Slashes in new subpages are now replaced by dashes ('/' --> '-'). Thanx to Klausi for the fix.
1.2.1 (rev. 189)
  • fixed a critical bug that broke the creation of new external redirects
  • the parameters for the commit message were flipped. Commit messages now look cleaner.
1.2 (rev. 185)
  • The label for the link description for new external redirects now includes the string 'optional'
  • i18n-message "header" was renamed to "addResource_Header" to avoid collisions
  • The headline of the special page now links to the article (part of the same change as above)
  • The special-page now checks if the link for a new external redirect starts with one of the protocols mentioned in $wgExternalRedirectProtocols
  • the description field for new external links is now preserved through unsuccessfull posts
1.1.1 (rev. 177)
  • Renamed $wgResourcesAddCategory to $wgResourcesCategory.
1.1 (rev. 176)
  • It is now possible to have new ExternalRedirects be in a Category configurable by $wgResourcesAddCategory.
This is intended to become a more global variable used in all extensions that display or create new Resources.
1.0

first version documented here.

License

GPL v3 or any later version.

Feature Requests

  • If a file extension for the destination file name is missing, automatically append the file extension from the selected original source file