From 422853e02d76a8d248674acae77b95ac0c5fa21d Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 16 Aug 2015 01:01:40 +0200 Subject: [PATCH] Created Development (markdown) --- Development.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Development.md diff --git a/Development.md b/Development.md new file mode 100644 index 0000000..e7bbcc6 --- /dev/null +++ b/Development.md @@ -0,0 +1,57 @@ +This fork of the original ZeroBin of Sebsauvage was refactured into an object oriented MVC structure. The `index.php` only includes an autoloader and starts the application by instancing a `zerobin` object. + +## Structure + +The main code or **controller** is found in `lib/zerobin.php`. + +The data storage **models** are in the `lib/zerobin/` folder. + +The **view** is still implemented using the RainTPL library (`lib/RainTPL.php`) using a template file located in the `tpl/` folder. + +Any option that not every server administrator might want to use or provide should be implemented with **configuration** options in the file `cfg/conf.ini`. + +## Unit Tests + +For unit tests of the php code the folder `tst/` should be used. Apart from helping to implement new features correctly it should help us to keep regressions at bay. By default a code coverage report is generated after phpunit is run, the one of the latest release is [publicly available](https://zerobin.dssr.ch/coverage-report/). + +In order to run these tests, you will need the following packages and its dependencies: +* phpunit +* php5-gd +* php5-sqlite +* php5-xdebug + +Example installation for Debian and Ubuntu: + + $ sudo aptitude install phpunit php5-mysql php5-xdebug + +To run the tests, just change into the `tst/` directory and run phpunit: + + $ cd ZeroBin/tst + $ phpunit + +## Data Model + +If you want to create your own data models, you might want to know how the arrays, that you have to store, look like: + + public function create($pasteid, $paste) + { + $pasteid = substr(hash('md5', $paste['data']), 0, 16); + + $paste['data'] // text + $paste['meta']['postdate'] // int UNIX timestamp + $paste['meta']['expire_date'] // int UNIX timestamp + $paste['meta']['opendiscussion'] // true (if false it is unset) + $paste['meta']['burnafterreading'] // true (if false it is unset; if true, then opendiscussion is unset) + } + + public function createComment($pasteid, $parentid, $commentid, $comment) + { + $pasteid // the id of the paste this comment belongs to + $parentid // the id of the parent of this comment, may be the paste id itself + $commentid = substr(hash('md5', $paste['data']), 0, 16); + + $comment['data'] // text + $comment['meta']['nickname'] // text or null (if anonymous) + $comment['meta']['vizhash'] // text or null (if anonymous) + $comment['meta']['postdate'] // int UNIX timestamp + } \ No newline at end of file