Reference:Replace Text and Setup:Installation Guide/Advanced/Maintenance scripts/export: Difference between pages

(Difference between pages)
No edit summary
 
No edit summary
 
Line 1: Line 1:
{{BSExtensionInfobox
== Running the script ==
|desc=Provides a form to let administrators do string replacements on the entire wiki, for both page contents and page titles.
The script to export wiki pages to PDF is executed from: <syntaxhighlight lang="text">
|status=stable
php {MW_ROOT}/extensions/BlueSpiceUniversalExport/maintenance/export.php --specification-file=spec.json
|developer=Yaron Koren, Niklas Laxström
</syntaxhighlight>The specification file <code>spec.json</code> can have the following content:<syntaxhighlight lang="text">
|type=MediaWiki
{
|edition=BlueSpice pro, BlueSpice free (deactivated), BlueSpice Farm, BlueSpice Cloud
    "module": "pdf",
|compatible=MediaWiki
    "attachments": 1,
|category=Administration
    "recursive": 1,
|license=GPL v2+
    "title": "MyPDF",
|docu=https://www.mediawiki.org/wiki/Extension:Replace_Text
    "target": "localfilesystem",
|features=<div class="hw-messagebox notification-note "><span class="boxlabel">Note:</span>The replace text operation is a deferred operation and is placed in the job queue. It is possible that the changes are not immediately shown on all affected pages.
    "target-file-name": "All.pdf",
    "target-file-path": "/path/to/target-file"
}
</syntaxhighlight>
{| class="wikitable" style="width: 100%;"
|+
! style="width:200px;" |Key
! style="width:200px;" |Value
!Description
|-
| style="width:200px;" |module
| style="width:200px;" |pdf
|Output type
|-
| style="width:200px;" |attachments
| style="width:200px;" |1
0
|Attachments will be included in the export
|-
| style="width:200px;" |recursive
| style="width:200px;" |1
0
|Linked pages (one level deep) will be included.
|-
| style="width:200px;" |title
| style="width:200px;" |string
|Title of the wiki page that contains the list of pages to be exported. <span class="col-red">The pages need to be links.</span>
|-
| style="width:200px;" |target
| style="width:200px;" |localfilesystem
|
|-
| style="width:200px;" |target-file-name
| style="width:200px;" |
|Name of the exported PDF file
|-
| style="width:200px;" |target-file-path
| style="width:200px;" |
|Target file location
|}


''runJobs.php'' can be run from the ''maintenance'' folder to do the replacement immediately and to process the job queue.</div><span></span>
== Creating a page list for the export ==
}}
The export list is defined in the wiki page that is shown as the <code>title</code> in the json-file. (In the example above, this is the page <code>MyPDF</code> .)
{{wcagCheck
|wcagStatus=2-testing complete
|wcagCheckedfor=Authoring tool
|wcagTestdate=2022-08-08
|wcagLevel=AA
|wcagSupport=partially supports
|wcagWorkaround=no
|wcagComments=keyboard accessible.


Screenreader issues: no form field labels, warning box has no aria-label; initial focus for replacement founds is not set, so it is difficult to select pages.
The page <code>MyPDF</code> now needs to list all pages  that will be exported to PDF.  
|extensionType=extended
|extensionFocus=admin
}}
'''ReplaceText''' is a MediaWiki extension that provides both a special page and a command line script that allows administrators to search and replace any text in wiki pages and titles across the wiki.


This list can be created with an [[SMW queries|SMW inline query]] (BlueSpice free) or with a [[Manual:Extension/DynamicPageList3|DPL3 list]] (BlueSpice free).
Example of an SMW query to create an export for all pages in the categories <code>Process</code> and <code>Work instruction</code>:


Replacing the text is done in 3 steps on the ''Special:ReplaceText'' page:
You would add the following to your <code>MyPDF</code> page in the wiki:<syntaxhighlight lang="text">
==All processes==
{{#ask:[[Process:+]]|format=ul|limit=99999}}


# Entering the existing and the new text as well as selecting the namespaces and other options
==All work instructions==
# Checking the pages on which the text appears. Possible adjustment of the page selection
{{#ask:[[Work instruction:+]]|format=ul|limit=99999}}
# Performing the replacement.
</syntaxhighlight>The same list can be created with the following DPL3 syntax:<syntaxhighlight lang="text">
==All processes==
{{#dpl:category=Process}}
 
==All work instructions==
{{#dpl:category=Work instruction}}
</syntaxhighlight>
 
== Setting up a CronJob ==
To automate the export, the following CronJob is available:<syntaxhighlight lang="text">
CronJob für Export
 
php {MW_ROOT}/extensions/BlueSpiceUniversalExport/maintenance/export.php --specification-file={MW_ROOT}/extensions/BlueSpiceFoundation/data/spec.json
</syntaxhighlight>
__FORCETOC__

Revision as of 09:47, 9 June 2023

Running the script

The script to export wiki pages to PDF is executed from:

php {MW_ROOT}/extensions/BlueSpiceUniversalExport/maintenance/export.php --specification-file=spec.json

The specification file spec.json can have the following content:

{
    "module": "pdf",
    "attachments": 1,
    "recursive": 1,
    "title": "MyPDF",
    "target": "localfilesystem",
    "target-file-name": "All.pdf",
    "target-file-path": "/path/to/target-file"
}
Key Value Description
module pdf Output type
attachments 1

0

Attachments will be included in the export
recursive 1

0

Linked pages (one level deep) will be included.
title string Title of the wiki page that contains the list of pages to be exported. The pages need to be links.
target localfilesystem
target-file-name Name of the exported PDF file
target-file-path Target file location

Creating a page list for the export

The export list is defined in the wiki page that is shown as the title in the json-file. (In the example above, this is the page MyPDF .)

The page MyPDF now needs to list all pages that will be exported to PDF.

This list can be created with an SMW inline query (BlueSpice free) or with a DPL3 list (BlueSpice free). Example of an SMW query to create an export for all pages in the categories Process and Work instruction:

You would add the following to your MyPDF page in the wiki:

==All processes==
{{#ask:[[Process:+]]|format=ul|limit=99999}}

==All work instructions==
{{#ask:[[Work instruction:+]]|format=ul|limit=99999}}

The same list can be created with the following DPL3 syntax:

==All processes==
{{#dpl:category=Process}}

==All work instructions==
{{#dpl:category=Work instruction}}

Setting up a CronJob

To automate the export, the following CronJob is available:

CronJob für Export

php {MW_ROOT}/extensions/BlueSpiceUniversalExport/maintenance/export.php --specification-file={MW_ROOT}/extensions/BlueSpiceFoundation/data/spec.json
No categories assignedEdit

Discussions