Skip to content

Commit

Permalink
refactor this repo; update contact info; update js library; fix the w…
Browse files Browse the repository at this point in the history
…ay to control the svg size
  • Loading branch information
ghbore committed Aug 9, 2023
1 parent 863ebd8 commit 3b8289a
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 14 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test-2022-07-31.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Dokuwiki 2022-07-31

on:
push:
paths-ignore:
- "*.md"
- "*.txt"
- "images/*"

jobs:
test-on-docker:
uses: "./.github/workflows/test-on-docker.yml"
with:
version: "2022-07-31a"
source_tag: "release-2022-07-31a"
docker_tag: "version-2022-07-31a"
16 changes: 16 additions & 0 deletions .github/workflows/test-2023-04-04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Dokuwiki 2023-04-04

on:
push:
paths-ignore:
- "*.md"
- "*.txt"
- "images/*"

jobs:
test-on-docker:
uses: "./.github/workflows/test-on-docker.yml"
with:
version: "2023-04-04a"
source_tag: "release-2023-04-04a"
docker_tag: "version-2023-04-04a"
50 changes: 50 additions & 0 deletions .github/workflows/test-on-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Test on Dokuwiki Docker

on:
workflow_call:
inputs:
version:
required: true
type: string
source_tag:
required: true
type: string
docker_tag:
required: true
type: string

jobs:
test-on-docker:
name: DokuWiki ${{inputs.version}}
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: flowchartjs

- name: Checkout Dokuwiki
uses: actions/checkout@v2
with:
repository: dokuwiki/dokuwiki
ref: ${{inputs.source_tag}}
path: dokuwiki

- name: Test on Dokuwiki Docker
run: |
docker run --rm \
-v ${{github.workspace}}/dokuwiki/_test:/app/www/public/_test \
-v ${{github.workspace}}/flowchartjs:/flowchartjs \
-w /app/www/public \
linuxserver/dokuwiki:${{inputs.docker_tag}} \
bash -c " \
cp -rp /flowchartjs /config/dokuwiki/lib/plugins/flowchartjs; \
apk update; \
apk search php-tokenize |cut -f-2 -d- |xargs -n 1 apk add; \
apk search php-phar |cut -f-2 -d- |xargs -n 1 apk add; \
cd _test; \
php fetchphpunit.php; \
php phpunit.phar --stderr --verbose --group plugin_flowchartjs; \
"
50 changes: 48 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# Flowchart Plugin for Dokuwiki
# [Flowchart Plugin]((http://dokuwiki.org/plugin:flowchartjs)) for Dokuwiki

All documentation for this plugin is avaliable online at [flowchartjs](http://dokuwiki.org/plugin:flowchartjs)
[![2023-04-04a](https://github.com/ghbore/flowchartjs/actions/workflows/test-2023-04-04.yml/badge.svg)](https://github.com/ghbore/flowchartjs/actions/workflows/test-2023-04-04.yml)
[![2022-07-31a](https://github.com/ghbore/flowchartjs/actions/workflows/test-2022-07-31.yml/badge.svg)](https://github.com/ghbore/flowchartjs/actions/workflows/test-2022-07-31.yml)

**Draw flowchart (SVG) based on [flowchart.js](flowchart.js.org)**

## Example
The example copied from [flowchart.js](flowchart.js.org):

```
<flowchartjs default>
st=>start: Start|past:>http://www.google.com[blank]
e=>end: End|future:>http://www.google.com
op1=>operation: My Operation|past
op2=>operation: Stuff|current
sub1=>subroutine: My Subroutine|invalid
cond=>condition: Yes
or No?|approved:>http://www.google.com
c2=>condition: Good idea|rejected
io=>inputoutput: catch something...|future
st->op1(right)->cond
cond(yes, right)->c2
cond(no)->sub1(left)->op1
c2(yes)->io->e
c2(no)->op2->e
</flowchartjs>
```

The output looks like:
![](https://www.dokuwiki.org/lib/exe/fetch.php?tok=02f4a0&media=https%3A%2F%2Fimg-fotki.yandex.ru%2Fget%2F108168%2F85226599.d%2F0_c9c93_de8fec8e_orig.png)

## Syntax
The Basic syntax is:
```
<flowchartjs style width height>...</flowchart>
```
where,
- *style*: This parameter refers to the chosen display style for the flowchart. At present, it offers the following options:
- (blank) — no style
- *default* — the default style
- Alternatively, you can select from other available styles (see below about how to manage the styles)
- *width* and *height*: These parameters accept CSS-style values that allow for the adjustment of the width and height of the associated SVG element. Leaving these fields blank will maintain the default measurements.
- *...*: This section encompasses the flowchart definition itself, which should adhere to the grammar outlined in [flowchart.js](flowchart.js.org)

## Configuration and Settings
Using the **Amin Plugin**, managers can upload new flowchart styles, or update existing ones through JSON files. These files must have the *.json* extension, and the filename serving as the designated style name. Manager also can remove any styles as needed.

Within the textbox, toolbar **FC** icon will insert a pair of *flowchartjs* tags, and **F<sub>c</sub><sup>s</sup>** toggles the comprehensive list of available styles.
27 changes: 27 additions & 0 deletions _test/render.test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace dokuwiki\plugin\flowchartjs\test;
use DokuWikiTest;

/**
* Render tests for the flowchartjs plugin
*
* @group plugin_flowchartjs
* @group plugins
*/
class plugin_flowchartjs_render_test extends DokuWikiTest {
public function test_render(){
// print_r(plugin_list("", true));
global $plugin_controller; $plugin_controller->enable("flowchartjs");
$info = array();
$instructions = p_get_instructions("xxx<flowchartjs>\n _cfg_\n</flowchartjs>\nxxx");
// print_r($instructions);
$xhtml = p_render("xhtml", $instructions, $info);
// print_r($xhtml);

$expected = "\n<p>\nxxx\n</p>\n<pre class='flowchartjs '>\n _cfg_\n</pre>\n<p>\nxxx\n</p>\n";

$this->assertEquals($expected, $xhtml);
}
}
//Setup VIM: ex: et ts=4 :
2 changes: 1 addition & 1 deletion action.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Action Component for the flowchartjs Plugin
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Hua GAO <gaoh@pku.edu.cn>
* @author Hua Gao <ghbore@gmail.com>
*/

// must be run within Dokuwiki
Expand Down
2 changes: 1 addition & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Flowchartjs Admin Plugin
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Hua GAO <gaoh@pku.edu.cn>
* @author Hua Gao <ghbore@gmail.com>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
Expand Down
8 changes: 4 additions & 4 deletions flowchart.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions plugin.info.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
base flowchartjs
author Hua GAO
email gaoh@pku.edu.cn
date 2021-01-15
author Hua Gao
email ghbore@gmail.com
date 2023-08-07
name Flowchartjs Plugin
desc draw flowchart based on flowchart.js
url https://www.dokuwiki.org/plugin:flowchartjs
12 changes: 10 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ function draw (style){
jQuery('<div class="' + classes + '" id="' + id + '"></div>')
);
obj.drawSVG(id, opt);
if (cls.length >= 3) jQuery('div#' + id + ' svg').attr('width', cls[2]);
if (cls.length >= 4) jQuery('div#' + id + ' svg').attr('height', cls[3]);

div_size_style = "";
if (cls.length >= 3) div_size_style = div_size_style + "width: " + cls[2] + ";";
if (cls.length >= 4) div_size_style = div_size_style + "height: " + cls[3] + ";";
if (div_size_style != "") jQuery('div#' + id).attr('style', div_size_style);

jQuery('div#' + id + ' svg').attr(
'style',
jQuery('div#' + id + ' svg').attr('style') + ' height: 100%; width: 100%;'
);
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Syntax: <flowchartjs style>...</flowchartjs> - will draw a flowchart
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author ghbore <gaoh@pku.edu.cn>
* @author Hua Gao <ghbore@gmail.com>
*/

if(!defined('DOKU_INC')) die();
Expand Down

0 comments on commit 3b8289a

Please sign in to comment.