17 Sep 2009 16:42
TAGS: dev wikidot
Some of you, following Wikidot code on GitHub may see it's nicely split into templates, php, web and conf directories. But this is the first impression.
This all become quite complicated, so we decided to make things really clear and simple in the source code. The primary rule: make the source code (updatable from git) separate from files uploaded by users and generated by Wikidot. Second rule: make files that are automatically generated during installation (not in the runtime) separate from persistent files (like the uploaded by users) and from source code.
And at the end there needs to be some place for logs and a place for temporary data (we need this to generate some random cool stuff, but after generating them, files are deleted).
So we end up with something like this:
- avatars/ — user avatars
- sites/ — site files (both generated thumbnails and uploaded files)
- static/ — generated static files. This dir can be server directly by a fast non-PHP webserver for static.wikidot.com in case we don't want CloudFront anymore
- tmp/ — temporary files including Smarty compiled versions of templates. Content of this dir can be safely removed
- logs/ — Wikidot logs
- everything else — comes from git and is unchangeable by application
Application needs write-access to data, tmp and logs. Generated dir needs write access to one installing or upgrading application.
Wikidot persistent data is now ONLY database and data/ directory, so it's easy to backup and restore the application (if you have enough time to make full backup of this).
There is still one exception to this nice schema which is php/db/base directory, which is autogenerated during installation from XML database definition files, but the cleaning is not over, I still work on this.
Nice thing about this work is that it does not need a lot of code changing, because directory paths are usually stored in one (max two) places in application, so this kind of totally reorganizing directory structure does not break things. As such, it is very very worth doing it. In the end we get clean internal structure of files and it's clear which files you can safely remove, which you can restore from git (and thus you can experiment a little on them — in case of crash, just re-download application), which are "state" of the Wikidot and where to look for logs.
This all is also very important, because we aim to make current Wikidot.com source open and as such we want it to be a nice code.