aoinan v2.1.0

website·Indexed 32 days ago

https://projects.pixelastic.com/aoinan/

Documentation for aoinan v2.1.0, covering installation, initialization, and configuration options such as cacheLocation.

Tokens
1.7K
Snippets
18
Records
22
Agent score
53%

What's inside aoinan

  1. Initialize aoinan to connect to a MediaWiki server

    Before using aoinan, you must initialize it with the server details of the MediaWiki instance you wish to query. This setup allows the library to locate the API endpoint used for retrieving raw page data.
    const aoinan = require('aoinan');
    aoinan.init({
      server: 'pathfinderwiki.com',
      path: '/mediawiki',
      cacheLocation: './tmp',
    });
  2. Query a page using aoinan

    After initializing aoinan, you can retrieve an instance of an aoinan Page object by passing the page title to the aoinan.page method.
    const scenario = await aoinan.page('The Burden of Envy');
  3. Install aoinan via yarn

    Install the aoinan package using the yarn package manager to begin extracting structured data from MediaWiki pages.
    yarn add aoinan
  4. Query a page using aoinan

    After initializing aoinan, you can retrieve an instance of an aoinan Page object by passing the page title to the aoinan.page method.
    const scenario = await aoinan.page('The Burden of Envy');
  5. Initialize aoinan for a MediaWiki server

    Before querying pages, you must initialize aoinan by providing the server domain and the base path to the MediaWiki installation.
    const aoinan = require('aoinan');
    aoinan.init({
      server: 'pathfinderwiki.com',
      path: '/mediawiki',
    });
  6. Initialize aoinan with server configuration

    Before querying pages, you must initialize aoinan by providing the server hostname and the base path to the MediaWiki installation.
    const aoinan = require('aoinan');
    aoinan.init({
      server: 'pathfinderwiki.com',
      path: '/mediawiki',
    });
  7. Manage the aoinan API response cache

    aoinan downloads copies of pages to the directory specified in cacheLocation during the first call. Subsequent calls read from this local cache instead of requesting data from the MediaWiki API to improve performance. To clear the cache and force a fresh download, delete the cacheLocation folder.
  8. Extract infobox data from a page

    The infobox() method returns data from the page's infobox as a JavaScript object. If the target website uses a custom infobox format, you can specify the template name or a regular expression to match the desired infobox.
    // Default infobox
    scenario.infobox();
    
    // Custom infobox using a template name
    scenario.infobox('Adventure');
    
    // Custom infobox matched by regexp
    scenario.infobox(/Adventure/);
  9. Initialize aoinan to connect to a MediaWiki server

    Before using aoinan, you must initialize it with the server details. This allows the library to connect to the MediaWiki API endpoint to query raw page data. After calling aoinan.init(), you can use aoinan.page and aoinan.category.
    const aoinan = require('aoinan');
    aoinan.init({
      server: 'pathfinderwiki.com',
      path: '/mediawiki',
      cacheLocation: './tmp',
    });
  10. Query a single MediaWiki page

    Retrieve structured data for a specific page by passing the page title to the aoinan.page method.
    const scenario = await aoinan.page('The Burden of Envy');
  11. Extract page sections and content

    The sections() method returns an array of all page sections (delimited by titles) and their corresponding textual content. Results can be filtered by providing a section name or a regular expression.
    // Get all sections
    scenario.sections();
    
    // Get section named "Factions"
    scenario.sections('Factions');
    
    // Get sections with a name starting with "Season"
    scenario.sections(/^Season/);