Extension:PageSync

From mediawiki.org


This extension is maintained by a member of the MediaWiki Stakeholders' Group .
MediaWiki extensions manual
PageSync
Release status: stable
Implementation Parser extension , API
Description Export and import wiki pages
Author(s) Charlot Cobben (Sen-Saitalk)
Latest version 2.6.2 (12/10/2023)
Compatibility policy For every MediaWiki release that is a Long Term Support release there is a corresponding branch in the extension.
MediaWiki 1.35.+;1.39+
PHP 7+
Composer open-csp/page-sync
License GNU General Public License 2.0 only
Download
Readme
ChangeLog
PageSync

The PageSync extension allows for storing any wiki page content to a file on the server. Allowing for it be e.g. pushed to git or bitbucket and deployed on another server. The rationale for development of PageSync was to have all application artifacts, including templates, forms and other pages in the wiki, under version control.

PageSync has a maintenance script to import pages from file. This enables automatic deployment of wikis and transfer of content from one wiki to another.

PageSync is able to sync all Multi Revision Content slots and will also sync Files in the File namespace. Additionally you can save all synced files as a ZIP Archive and exchange the ZIP archive.

Detailed Documentation can be found at the link below

https://www.open-csp.org/DevOps:Doc/PageSync

Installation[edit]

  • Download and place the file(s) in a directory called PageSync in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    $wgPageSync['filePath']=<path where to store synced files>
    $wgPageSync['tempFilePath']=<path that PageSync can use as a Temporary folder>
    wfLoadExtension( 'PageSync' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Or install using Composer. Read more here : https://www.mediawiki.org/wiki/Composer/For_extensions

The Composer required name is : open-csp/page-sync

Configuration[edit]

PageSync needs a full path to a directory to store the file that can be synced. e.g. $IP/psFiles

This can be set in the localsettings as  :

$wgPageSync['filePath'] =  $IP . '/psFiles';

PageSync also needs a temporary file path to a directory to handle received Share file.

$wgPageSync['tempFilePath'] =  $IP . '/wspsTemp';

allowedGroups is a config setting telling PageSync what user groups can add pages to be synced. defaults to sysop.

$wgPageSync['allowedGroups'] = [ "sysop" ];

Make sure these maps have the correct rights for PageSync to store files.

It is also a good practice to store these files outside of your html folder. The content of pages are stored as raw wikitext and although you can store synced files in sub folders hidden within the root, they are potentially visible.

Files from the File namespace will also be synced.


You can define what slots you want to sync. Default value is all. If you change this value, make sure to add "main" for the main content-slot.

$wgPageSync['contentSlotsToBeSynced'] = "all";

or

$wgPageSync['contentSlotsToBeSynced'] = ['main', 'my-content-slot'];

Usage[edit]

See also the Special page section below.

Basically, if you are a sysop, any page that can be synced will have a slider in the top menu. Click on it and it will turn blue indicating it is synced ( a notification will also be shown ). If the slider is already blue when you visit a page, it simply means the page is already synced and is being monitored for changes. Click the slider again for the page to be excluded from syncing.

User rights[edit]

sysop/admins are allowed to set a page to be synced. All other users have no such ability.

Special Page[edit]

By default the special page shows a list of all Wiki pages set for syncing.

From the Special page you can also create, restore and delete ZIP backups. To be able to use ZIP Backups, make sure ZIPArchive is installed on your PHP setup.

The special page also allows for you to do a Semantic MediaWiki Query to quickly add certain pages to PageSync. This feature only works if you have SemanticMediaWiki extension installed.

The Special Page also shows all currently synced pages.

Creating PageSync Share files is also done from the Special page.

Finally you can also delete all synced pages from the Special page. This will not delete any pages in the Wiki, only the ones stored on the server by PageSync.

Update to version 0.9.9.9+[edit]

Since the structure of the files have changed as of version 0.9.9.9 to support Content Slots, some extra effort is needed if you are performing an upgrade. We have tried to make this very effortlessly. Once you have installed the 0.9.9.9+ update, visit the Wiki. You will notice the sync button in the admin menu has an exclamation mark. Click this and it will bring you to a Special page. Make sure you do not sync any pages to avoid possible failures. First thing you should do is use the new feature to create a backup. This will bring you to the backup tab and you can find your new backup file there. Click on the PageSync logo to go back to the convert page. Now click convert files preview. This will give you an overview of the files affected. Click on convert files to convert all the synced files to version 0.9.9.9.

Maintenance script[edit]

In order to import previous exported pages there is a Maintenance script that can be run.

Options[edit]

summary
Additional text that will be added to the files imported History.
user
Your username. Will be added to the import log. [mandatory]
rebuild-index
Rebuild the index file from existing files in export folder
force-rebuild-index
Used with 'rebuild-index' to suppress confirmation
rebuild-files
Will take the index file and re-create all files from the database
force-rebuild-files
Used with rebuild-files. This forces rebuild-files without prompting for user interaction

ShareFile import options

install-shared-file
Url or path on the server to a PageSync share file
install-shared-file-from-temp
Name of the PageSync Share file already in the PageSync TempPath
silent
Will show no output in the terminal until it is finished.

Example[edit]

SERVER_NAME=<myservername> php extensions/PageSync/maintenance/WSps.maintenance.php --user 'Maintenance script' --summary 'Fill database'

Scenario[edit]

We usually have a developing environment. When developing is done, we push our code to a repository. From there we create a Docker container and we deploy it to a Testing server. From there it is deployed to an Acceptance server and finally to production.

This is all fine with PHP and or JavaScript code, but we also create templates and widgets that are fundamental for it all to work properly.

With PageSync, we can now also push our Templates, Widgets or any important Wiki page to our repository. When deploying a container, the PageSync maintenance script is automatically run and therefore also updating pages in the Wiki.

Version 2.0.0 has a major change in its file management. Read the installation manual before installing this version as it is not compatible with previous versions. ( https://www.open-csp.org/DevOps:Doc/PageSync/2.0/Installing_PageSync )


Version history[edit]

Version 2.6.2

Composer update to reflect to Open CSP package

Version 2.6.1

Added support for installing PageSync Shared files that have been uploaded to the wiki.

Version 2.5.0

Added administrative function to manage tags and synced pages. Realtime search on index page.

Version 2.1.5

REL1_39 compatibility update. REL1_35 and main only version bumb

Version 2.1.4

Content aware slots added

Version 2.1.3

Maintenance script color difference between success and skipped

Version 2.1.2

Add before pagedisplay hook back in

Version 2.1.1

fixed bug when synced page was altered

Version 2.1.0

Add Installing Shared file from PageSync Repo. Rewrote code partly.

Version 2.0.10

Fixed installing Shared file bug

Version 2.0.9

Extra Share file checks added and non valid URL warning catched

Version 2.0.8

Seperated config from main

Version 2.0.6

Removed PHP notice and newline ( Gitlab #13 )

Version 2.0.5

Added maintenance option rebuild-files to rebuild all files from the index.

Version 2.0.4

Fixed bug in Shared file import

Version 2.0.3

Added onArticleDelete hook ( this is deprecated, but we only support LTS versions of MW )

Version 2.0.2

Fixed title look-up in conversion to version 2

Version 2.0.0

New file management system to fix a problem with multi-language wikis

Version 1.5.2

Added overview installing shared file through Maintenance script

Version 1.5.1

Made maintenance option silent more silent. Added special option.

Version 1.5.0

Sharing Files added. Rename to PageSync.

Version 1.1.0

Rewrote deprecated 1.35.1+ code. Unchanged pages will no longer updates synced files on server

Version 1.0.1

Added support for different content types

Version 1.0

release

Version 1alpha5

Created handlers classes and clean Special Page. Added requirements.

Version 1alpha4

Added consistency in maintenance script

Version 1alpha3

fixed on page save

Version 1alpha2

Fixed weird username JavaScript error on one specific wiki

Version 1alpha1

Added support message when files are not in index. Removed debug information.

Version 0.9.9.9

Removed Maintenance script option --rc, --overwrite and --timestamp. Added slot support. Added rebuild index option. Added backup and restore.

Version 0.9.9.8

MW codestyle

Version 0.9.9.7

Sub special pages visual fix for most MW skins

Version 0.9.9.6

Not using user received from API anymore. Added check to only show sync button if a page can actually be synced. ( introduced by SkinTemplateNavigation::Universal )

Version 0.9.9.5

Fix for skins other than Chameleon

Version 0.9.9.4

Delete un-used translations

Version 0.9.9.1 - 0.9.9.3

Clean-up

Version 0.9.9

Initial Community release

Discord[edit]

Ask any question at the PageSync Discord server : https://discord.gg/T8VTjtXGnV

See also[edit]

  • EMWCon Spring 2021  : There was a presentation on WSPageSync. The presentation file can be downloaded. You can also watch the presentation on Youtube.
  • Page import - overview of all page import tools