Giter VIP home page Giter VIP logo

mwrestfulclients's Introduction

mwRESTfulClients

Scripts to handle Mediawiki content, using the RESTful API.

These scripts depend on the Snoopy PHP net client to simulate a browser.

/src - the sources
/src/wrappers - classes to call the API using PHP
/src/example.ini - an example configuration file. Copy this.
/src/exampleBasicImportCSV.php - basic PHP script to import a spreadsheet.
/src/exampleAdvancedImportCSV.php - same as above, but can customize the result.

/test - unit tests 
/test/testdata - data used for testing

Importing a spreadsheet into a wiki

The CSV importer will create a new page or add a new version to an existing page (but only if data has changed!). Data will generally be presented as a table.

Preparing the data

Before the spreadsheet can be imported, please do the following:

  1. Export the spreadsheet into CSV format.
  2. Make sure the CSV is in UTF-8, else convert it, e.g. using Notepad.

Preparing the page template

The table created from the spreadsheet will be inserted into a mediawiki page. Pages are formated using a template stored in a local file (the Mediawiki templating system is not required).

  1. To create your own page template, copy test/testdata/Test.tpl to e.g. src/page.tpl.
  2. Add the newly created .tpl file to Git ignore
  3. Edit the file to suit your requirements.

Basic usage

  1. Get Snoopy
  • Download from Snoopy PHP net client.
  • Put Snoopy.class.php into one of the directories specified in your php.ini include_path directive (e.g. /etc/php5/cli/php.ini).
  1. Copy example.ini as e.g. config.ini and edit it to suit your configuration. Add your configuration to Git ignore.
  2. For a simple spreadsheet import, copy exampleBasicImportsCSV.php to e.g. runImportCSV.php
  3. In the newly created file, make sure the following settings are correct:
  • The path to the CSV file
  • The path to the page template (a local file path, not a URL!)
  • The name of the page to be created
  • The path to the configuration file

Advanced usage

If you require more control over the format of the wiki table being created, you can extend CSVImporter and overwrite the makeWikiTable method. See exampleAdvancedImportCSV.php for how to do this.

Testing

Tests are written using PHPUnit. Please run the tests, specially if you edit the source code.

  1. Get PHP Unit
  2. Copy example.ini as e.g. test.ini and edit it to suit your configuration. Add your configuration to Git ignore.
  3. In each test file, make sure the path to the test configuration file is correct.

mwrestfulclients's People

Contributors

aot29 avatar

Watchers

Daniel Mietchen avatar Alvaro Ortiz-Troncoso avatar James Cloos avatar  avatar mel avatar Martin Pluta avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.