aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhttps://www.google.com/accounts/o8/id?id=AItOawlSFgIlytGZgMLh_Cw4IA011V8pLKk5dVg <Brian@web>2013-11-28 17:19:13 -0400
committeradmin <admin@branchable.com>2013-11-28 17:19:13 -0400
commit426ed67b32c625a9274d71b02a879b82a5a7ee39 (patch)
treeaa8b490c28b248f71a5c78b3be6bd28ed28caf6e
parent1159e4de07676101946c3b6911cb34fbf6d29275 (diff)
downloadikiwiki-426ed67b32c625a9274d71b02a879b82a5a7ee39.tar
ikiwiki-426ed67b32c625a9274d71b02a879b82a5a7ee39.tar.gz
Start of thread
-rw-r--r--doc/forum/converting_binary_files.mdwn29
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/forum/converting_binary_files.mdwn b/doc/forum/converting_binary_files.mdwn
new file mode 100644
index 000000000..6b3187f38
--- /dev/null
+++ b/doc/forum/converting_binary_files.mdwn
@@ -0,0 +1,29 @@
+I would like to use ikiwiki to build a static site which needs some transformations to be made on binary assets. A simple example is to translate a .odp presentation to .pdf using (e.g.) unoconv. If I add a new .odp attachment, or push one into the repo, I want the corresponding .pdf to appear in the generated site. What's the right place to hook in to do this?
+
+I've made an experimental prototype which hooks into needsbuild, builds the pages then and there, and at the same time removes them from the list of pages to be built.
+
+~~~
+sub needsbuild {
+ my $files=shift;
+ my $nfiles=[];
+ foreach my $f (@$files) {
+ if ($f =~ /\.odp$/) {
+ my $g = $f;
+ $g =~ s/\.odp$/\.pdf/;
+ debug("building $f to $g");
+ will_render($f, $g);
+ if (system("unoconv","-f","pdf","-o",IkiWiki::dirname("$config{destdir}/$g"),srcfile($f)) != 0) {
+ error("unoconv: failed to translate $f to $g");
+ }
+ }
+ else {
+ push @$nfiles, $f;
+ }
+ };
+ return $nfiles;
+}
+~~~
+
+It appears to work, but is this the right way to do it, bearing in mind ikiwiki's dependency tracking and the like? And is the usage of will_render() correct?
+
+[[BrianCandler]]