the flame browser and how to split huge flame files

Important

The little tutorial is a very specific one and should work on linux/unix like operating systems.
It depends on the way you choose to work with jwf.

The flame browser

The flame browser is a useful tool and it is becoming an important part of my work. Before working with jwf i used apophysis. The philosophy of presenting flames in apophysis is slightly different. The left ribbon, in apophysis has a double function : a browser and and a call to action. You can find the same functionality in jwf with the left ribbon.

But this is not a real browser. Apophysis creates one single file into which multiples flames are added. So you may have a single one flame file which contains 50 or more flames inside it.

The flame browser philosophy from jwf is quite different. It is a real browser of flames inside a folder and not a browser of flames inside a huge flame file. Plus each flame file must contain on single flame not multiple flames. The drawback of that philosophy is this : the browser can load this one huge file from apophysis but it only shows the first one and the 49 others are not.

Well i wish to look and browse each flame of the huge file inside the browser.

The first solution is to load this huge flame file directly into jwf and the ribbon does the job of splitting
the huge file into multiple flames. This solution does not answer to what i wish to get.

Splitting a huge flame file

The idea is to split this huge file into multiple single ones, the flame browser can read them easily
and i can really browse and dive into them.

By opening the huge flame file into a text editor you can see how the file is constructed :

<flames>

<flame name="one">
.....
.....
</flame>

<flame name="two">
.......
.......
</flame>

<flame name="three">
......
......
</flame>

<flames>

And by opening in a text editor a single flame file from jwf, you can see how the flame is constructed :

<flame name="one">
.....
.....
</flame>

By comparing the two files, many things become clear :

  • the first and last lines are <flames>and </flames> . I do not want them, they have to be removed.
  • As each flame has the same construction pattern <flame> </flame> i have to look at this pattern and each time it is met, this one will be split into a single file with a specific name.

As i’m not a good programmer, i wish to make the thing as simple as possible (so i can grasp and understand what the command does). In linux, many great tools exist in command line for making things like that.

The code

For the example, let’s say we work with the huge file : test.flame. Before, do not forget to create a testing folder into which you have made a copy of the file test.flame so you can work safely.

Once inside the testing folder, open a terminal and enter this line of command :

sed '1d;$d;' /path/to/the/test.flame | awk '/<flame/ {x="new_name"++i;}{ print > x".flame";}'
  • sed ‘1d;$d;’ will remove the first and last line of the file test.flame.
  • the | says : don’t stop and continue now.
  • awk says : match that pattern /<flame/ and each time you will meet it split them, with the name ‘new_name’ and awk will automatically increment each file by adding “new_name0”, “new_name1”, etc, and, finally print each split flame with the extension “.flame” into a new flame file.

At the end, in your test folder you should have new_name0.flame, new_name1.flame, etc, alongside with the original test.flame without breaking it.

Then you copy all the files in a directory for the flame browser !

In the hope that this little script can help you.

1 thought on “the flame browser and how to split huge flame files

Leave a Comment