mirror of
https://github.com/misterunknown/ifm.git
synced 2025-10-04 02:51:51 +02:00
Updated Contributing (markdown)
@@ -1,19 +1,47 @@
|
|||||||
# introduction
|
## introduction
|
||||||
The source code of the IFM is a bit different from other projects you might know. Historically I developed it literally in one single file. As this became very confusing, I splitted the parts up into the `src` directory and searched for a nice way to compile it into a single file in the end. Other single-file script solutions, like [Adminer](https://github.com/vrana/adminer), use custom compilers for their scripts, so I decided to do it in a similar way.
|
The source code of the IFM is a bit different from other projects you might know. Historically I developed it literally in one single file. As this became very confusing, I splitted the parts up into the `src` directory and searched for a nice way to compile it into a single file in the end. Other single-file script solutions, like [Adminer](https://github.com/vrana/adminer), use custom compilers for their scripts, so I decided to do it in a similar way.
|
||||||
|
|
||||||
## compiler
|
## compiler
|
||||||
The compiler script is written in PHP and does essentialy three things:
|
The compiler script is written in PHP and assembles all the source files into one single script. The following tasks are part of the process:
|
||||||
* replace the includes with actual file content
|
|
||||||
* concat PHP files while removing the first line (`<?php`)
|
* concat PHP files while removing the first line (`<?php`)
|
||||||
|
* insert all file includes
|
||||||
|
* insert all variable includes (languages)
|
||||||
* add snippet to start the IFM
|
* add snippet to start the IFM
|
||||||
|
|
||||||
Includes can be made by putting the filename enclosed by three at signs (`@@@`) anywhere in the code.
|
Includes can be made by putting the filename enclosed by three at signs (`@@@`) anywhere in the code.
|
||||||
|
|
||||||
|
The compiler updates the following files:
|
||||||
|
* ifm.php (standalone IFM)
|
||||||
|
* build/libifm.php (IFM library for the use in other projects)
|
||||||
|
|
||||||
## files
|
## files
|
||||||
Here is a short explanation of what does what:
|
Here is a short explanation of what does what:
|
||||||
* `src/main.php`: IFM class, core of the IFM
|
* `src/htpasswd.php`: htpasswd class for authentication
|
||||||
* `src/ifm.js`: IFM client application, written in JS
|
* `src/i18n/*`: language files
|
||||||
* `src/ifmarchive.php`: archive class used by the IFM
|
* `src/ifmarchive.php`: archive class used by the IFM
|
||||||
|
* `src/ifm.js`: IFM client application, written in JS
|
||||||
|
* `src/includes/*`: external sources like bootstrap, jquery, ace etc.
|
||||||
|
* `src/main.php`: IFM class, core of the IFM
|
||||||
* `src/style.css`: some custom css
|
* `src/style.css`: some custom css
|
||||||
* `src/includes/*`: external sources like bootstrap etc.
|
* `src/templates/*`: mustache templates
|
||||||
* `src/templates/*`: HTML templates
|
|
||||||
|
## example
|
||||||
|
After you checked out the IFM, you can compile the script like this:
|
||||||
|
```
|
||||||
|
./compiler.php --languages=en,de
|
||||||
|
```
|
||||||
|
|
||||||
|
## advanced topics
|
||||||
|
### compressed build
|
||||||
|
I experimented with compressing the IFM code to minimize the filesize. This worked, but was not quite fancy. If you have a very small webspace where every megabyte counts, you can build a compressed version. This is slightly less performant, as the server has to unzip the script with every request you do. To build the compressed version, just uncomment the following lines in the compiler:
|
||||||
|
```php
|
||||||
|
/* // build compressed ifm
|
||||||
|
file_put_contents(
|
||||||
|
IFM_STANDALONE_GZ,
|
||||||
|
'<?php eval( gzdecode( file_get_contents( __FILE__, false, null, 85 ) ) ); exit(0); ?>'
|
||||||
|
. gzencode( file_get_contents( "ifm.php", false, null, 5 ) )
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
Why isn't this enabled by default? Simply because there are very few use cases and no one wants to execute code which he cannot inspect.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user