blog:2020-11-08:geogebra_plugin
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| blog:2020-11-08:geogebra_plugin [2020/11/08 08:59] – va7fi | blog:2020-11-08:geogebra_plugin [2024/11/24 12:38] (current) – va7fi | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Geogebra Plugin ====== | ||
| + | [[https:// | ||
| + | |||
| + | In the past, I had to export Geogbra files to html5 to embed them, but the process was pretty clunky and time consuming. I searched the Dokuwiki plugins but all the ones listed are too old and don't work anymore. | ||
| + | |||
| + | Here's what I got so far. If anyone has experience writing Dokuwiki plugin, please [[[email protected] |reach out]]. | ||
| + | |||
| + | Here's how to installed it: | ||
| + | < | ||
| + | * Add the following three files in the wiki folder: '' | ||
| + | * '' | ||
| + | installed=Sun, | ||
| + | * '' | ||
| + | base ggb2 | ||
| + | author Patrick Truchon | ||
| + | email [email protected] | ||
| + | date | ||
| + | name | ||
| + | desc | ||
| + | * '' | ||
| + | <?php | ||
| + | /** | ||
| + | * Plugin ggb2: Embeds Geogebra files into Dokuwiki. | ||
| + | * | ||
| + | * @license | ||
| + | * @author | ||
| + | * See: https:// | ||
| + | */ | ||
| + | |||
| + | // must be run within DokuWiki | ||
| + | if(!defined(' | ||
| + | if(!defined(' | ||
| + | require_once(DOKU_PLUGIN.' | ||
| + | |||
| + | |||
| + | /** | ||
| + | * All DokuWiki plugins to extend the parser/ | ||
| + | * need to inherit from this class | ||
| + | */ | ||
| + | class syntax_plugin_ggb2 extends DokuWiki_Syntax_Plugin { | ||
| + | |||
| + | function getType(){ return ' | ||
| + | function getSort(){ return 306; } | ||
| + | function connectTo($mode) { $this-> | ||
| + | |||
| + | |||
| + | /** | ||
| + | * Handle the match | ||
| + | */ | ||
| + | function handle($match, | ||
| + | $match = html_entity_decode(substr($match, | ||
| + | list($ggbfile, | ||
| + | if (preg_match('/ | ||
| + | $ggbfile = $matches[1]; | ||
| + | if (strpos($matches[2],',' | ||
| + | list($w, $h) = explode(',', | ||
| + | } | ||
| + | else { | ||
| + | $w = ' | ||
| + | $h = $matches[2]; | ||
| + | } | ||
| + | } | ||
| + | else { | ||
| + | $w = ' | ||
| + | $h = ' | ||
| + | } | ||
| + | |||
| + | if (!isset($index)) $index = ''; | ||
| + | return array($ggbfile, | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Create output | ||
| + | */ | ||
| + | function render($mode, | ||
| + | list($ggbfile, | ||
| + | if($mode == ' | ||
| + | $slash = strrpos($ggbfile, | ||
| + | if($slash > 0){ | ||
| + | | ||
| + | } | ||
| + | $ggbid = substr($ggbfile, | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | $renderer-> | ||
| + | return true; | ||
| + | } | ||
| + | return false; | ||
| + | } | ||
| + | } | ||
| + | ?> | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | The syntax is:< | ||
| + | {{ggb>/ | ||
| + | |||
| + | Note that at the moment, if a path is used, it must use ''/'' | ||
| + | |||
| + | Here's an example from one of [[hambasics/ | ||
| + | |||
| + | ===== Wave Addition ===== | ||
| + | |||
| + | When two waves overlap, they add up together at every point. | ||
| + | |||
| + | {{ggb>/ | ||
| + | |||
| + | |||
| + | Where do the blue and green waves need to be so that... | ||
| + | * the red wave is the biggest? | ||
| + | * the red wave is cancelled out?((Fun fact: This is how [[wp> | ||
| + | |||
| + | If you press the play button on the bottom left corner, you'll see the blue wave travel to the right and the green wave travel to the left. The red wave, which is the sum of the forward and reflected waves, oscillates up and down but doesn' | ||
| + | |||
| + | While the animation is running, slowly decrease the amplitude of the reflected wave (<fc # | ||
