Comments (4)
I integrated ditaa with this plugin quite easily. The main difficulty was to convince ditaa to work in "pipe" mode instead of creating files on the filesystem. To achieve that I wrote the following python wrapper:
#!/usr/bin/python
"Wraps the ditaa diagram rendering tool to work in piped mode."
from tempfile import mkdtemp
from shutil import rmtree
from os.path import join
from os import system
from sys import stdin, exit
if __name__ == "__main__":
tmpdir, ret = mkdtemp(prefix='ditaa'), 1
try:
infile, outfile = join(tmpdir, "in.ditaa"), join(tmpdir, "out.png")
f = open(infile, "wb")
f.write(stdin.read())
f.close()
ret = system("/usr/bin/ditaa %s %s 1>&2" % (infile, outfile))
if ret == 0:
print open(outfile, "rb").read()
finally:
rmtree(tmpdir)
exit(ret)
Save the above program as /usr/local/bin/ditaa-pipe and make it executable.
Now edit the global config/wiki_external_filter.yml file to declare a ditaa macro in your environment.
ditaa:
description: "Constructs diagram image from its textual description in ditaa language, see http://ditaa.sourceforge.net/"
template: image
outputs:
- command: "/usr/local/bin/ditaa-pipe"
content_type: "image/png"
Restart redmine and enjoy!
To test, simply invoke the "ditaa" macro with the ditaa source as macro argument, like this:
{{ditaa(
/----\ /----\
|c33F| |cC02|
| | | |
\----/ \----/
/----\ /----\
|c1FF| |c1AB|
| | | |
\----/ \----/
)}}
Feel free to reuse my source (or better: integrate it into the official plugin).
from wiki_external_filter.
Good job. Just a tiny bug: ditaa-pipe
may fail if it is run twice simultaneously, because of similar output file name of out.png
shared between two Ditaa processes. Here is my own ditaa-pipe
shell script:
#!/bin/bash
base=`mktemp`
cat >"$base.ditaa"
ditaa "$base.ditaa" "$base.png" >/dev/null
cat "$base.png"
rm -f "$base.ditaa" "$base.png"
from wiki_external_filter.
Hello ebrahim and thank you for your contribution.
I used "mkdtemp" in my script to be sure that my work files are safe ; even if the basenames are fixed all files are created in a protected directory. Happy diagramming with ditaa in redmine!
from wiki_external_filter.
Oops! You're right.
from wiki_external_filter.
Related Issues (12)
- doesn't work on redmine 9.2.0 HOT 1
- Commands with non-zero expiration fail if caching is off
- SVG preview is broken
- Using Wiki External Filter with Redmine v1.0.3 (2010-10-31) HOT 3
- Commas are stripped off in latex HOT 6
- Video embedding failed HOT 1
- Graphviz doesn't work anymore HOT 1
- Not working for redmine 1.2.1 HOT 3
- Any plans to support 2.x plugin API HOT 1
- PlantUML fails as it needs a linebreak after @startuml HOT 1
- compatible with Redmine 3.x
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wiki_external_filter.