Template:Download PDF/doc

From Linux Web Expert


Use this template gadget to make a button that, when clicked, will prompt the user to print or download a PDF with a specified set of pages.

Usage

Markup Renders as
{{Download PDF
| pages = Help:Images, Help:Tables, Help:Templates
| text = Download help pages
}}
Download help pages

Installation

To install this template in your wiki:

  1. Create a template with any name and the following markup (you can adjust the parameter names and defaults to suit your wiki):
    <span data-pages="{{{pages|{{FULLPAGENAME}}}}}" data-separator="{{{separator|,}}}" class="DownloadPDF cdx-button cdx-button--fake-button cdx-button--fake-button--enabled">{{{text|Download PDF}}}</span>[[Category:DownloadPDF.js]]
  2. Create MediaWiki:Gadget-DownloadPDF.js with the following code:
    /**
     * DownloadPDF.js prompts the user to print or download a specified set of pages
     * Documentation: https://www.mediawiki.org/wiki/Template:DownloadPDF
     * Source code: https://www.mediawiki.org/wiki/MediaWiki:Gadget-DownloadPDF.js
     */
    mw.loader.load('//www.mediawiki.org/w/load.php?modules=ext.gadget.DownloadPDF&only=scripts');
    mw.loader.load('//www.mediawiki.org/w/load.php?modules=ext.gadget.DownloadPDF&only=styles','text/css');
    
  3. Add the following gadget to MediaWiki:Gadgets-definition:
    * DownloadPDF [ResourceLoader | hidden | default | categories=DownloadPDF.js] | DownloadPDF.js
    
  4. Done! Add your template to any page to verify that the installation was successful.

Template data

<templatedata>{ "description": "Use this template to make a button that, when clicked, will prompt the user to print or download a PDF with a specified set of pages.", "format": "block", "params": { "pages": { "label": "Pages", "description": "Comma-separated list of pages to print or download", "example": "Help:Images, Help:Tables, Help:Templates", "type": "string", "default": "The current page" }, "separator": { "label": "Separator", "description": "Separator in the list of pages", "example": ";", "type": "string", "default": "," }, "text": { "label": "Text", "description": "Text of the button", "example": "Download instructions", "type": "string", "default": "Download PDF" } } }</templatedata>

See also