Loading...
 
Skip to main content

History: PluginCasperJS

Source of version: 8

Copy to clipboard
            ! {{page}}

New to ((Tiki17)). This new ((wiki plugin)) allows to use "CasperJS" in Tiki, which is a navigation scripting & testing utility for PhantomJS and SlimerJS (still experimental). It eases the process of defining a full navigation scenario and provides useful high-level functions, methods & syntactic sugar for doing common tasks. See more information at ((PhantomJS and CasperJS))

Code is here: https://sourceforge.net/p/tikiwiki/code/HEAD/tree/trunk/lib/wiki-plugins/wikiplugin_casperjs.php

__How to use the code:__

* Enable casper (pref wikiplugin_casperjs )
* Create a tiki page with the following content:
{CODE()}

{CASPERJS()}
{SOURCE()}
var casper = require('casper').create();
var links;

function getLinks() {
// Scrape the links from top-right nav of the website
    var links = document.querySelectorAll('ul.navigation li a');
    return Array.prototype.map.call(links, function (e) {
        return e.getAttribute('href')
    });
}

// Opens casperjs homepage
casper.start('http://casperjs.org/');

casper.then(function () {
    links = this.evaluate(getLinks);
    tikiBridge.add('links', links);
});

{SOURCE}
{CASPERJS}

{CODE}

* Run it :-) 

__What works__

Currently, it runs casperjs, and display back to the user:
* The (full) script that was run
* The output of the command line
* The results from the casperjs execution, using TikiBridge (is injected into the CasperJS script as a easy way to send results back to tiki).

How does the TikiBridge works:
* Before running the script it prefix and postfix the CasperJS script with some JS code (the TikiBridge)
* You can send variables back to Tiki by calling -+TikiBridge.add('variable_name', variable)+-
* At the end of the script (is appended) a call to -+TikiBridge.done+- that will format the variables to be sent back to tiki.

__Next Steps__


* Discuss specific implementations to see how to use this data and what is needed to make it useful to a tiki instance.
* Make some ((profiles))

        

History

Information Version
Josue Zirimwabagabo 17
Josue Zirimwabagabo 16
Josue Zirimwabagabo 15
Marc Laporte Code URL is now shown via {pluginmanager plugin="casperjs"} 14
Baraka Kinywa 13
lindon 12
Marc Laporte 11
Marc Laporte AutoTOC 10
Jorge Sá Pereira Update with examples 9
Xavier de Pedro 8
Xavier de Pedro 7
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 6
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 5
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 4
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 3
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 2
Marc Laporte Page created by rescue script 2017-04-24T18:09:12+00:00 1
Collapse/expand modules below