MyHandler.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. use Adepto\Slim3Init\HandlerCaller;
  3. use Adepto\Slim3Init\{
  4. Handlers\Handler,
  5. Handlers\Route
  6. };
  7. use Psr\Http\Message\{
  8. ServerRequestInterface,
  9. ResponseInterface
  10. };
  11. class MyHandler extends Handler {
  12. public function soos(ServerRequestInterface $request, ResponseInterface $response, \stdClass $args): ResponseInterface {
  13. $lel[] = 'A';
  14. $lel[] = 'B';
  15. $lel[] = 'C';
  16. $lal['t'] = 'A';
  17. $lal['tt'] = 'B';
  18. $lal['ttt'] = 'C';
  19. $lal['tttt'] = 'D';
  20. $lol['a'] = $lel;
  21. $lol['b'] = $lal;
  22. return $response->withJson($lol);
  23. }
  24. public function error(ServerRequestInterface $request, ResponseInterface $response, \stdClass $args): ResponseInterface {
  25. throw new Error('Lol', 42);
  26. }
  27. public function devblog(ServerRequestInterface $request, ResponseInterface $response, \stdClass $args): ResponseInterface {
  28. $blog = '
  29. Ecconia\'s dusty server-machine
  30. - For this project the webserver owned by Ecconia has been started again and a fresh Ubuntu 18.04 has been installed.
  31. - Basic setup has been made, editing bash, setting up ssh and vim.
  32. Sever software
  33. - Nginx shall be the server for this project, its easy to setup and all config files are at one place.
  34. Security
  35. - All traffic will be routed over Cloudflare. The connections from and to Cloudflare are encrypted with SSL.
  36. - The connection is as secure as Cloudflare is (lets trust it...). Cloudflare mainly caches files and protects against DDOS.
  37. Vue-Framework added to website
  38. - Vue is a framework which uses javascript to manipulate the HTML-DOM of the browser. This allows very easy web-developing.
  39. - Nice feature: Updating the website according to JS variables.
  40. - Downside: SEO may fail.
  41. After reading millions of documentation
  42. - The first simple version of the website has been written, a single HTMl file contains the whole website.
  43. Vue-Router
  44. - The website is using Vue-Router it allows natural page switching without actually doing so. The content will just be replaced by Vue.
  45. The small steps
  46. - The start page as well as the application page shall function the same as on the current website. Additional this devblog has been added. An Impressum is a must have as soon as the server is located in germany.
  47. Finally backend for frontend
  48. - Vue has \"components\" each mainpage is one, but later other parts of the website may be components (buttons, inputs, pager, posts etc....)
  49. - These components may be bundled and can be loaded on demand, this can be done by the frontend, by loading the components.
  50. - Webpack is a software which analyzes the source code on the server and bundles it as well as processes it. That way components can be bundled and provided. Additional this provides a fancy way to define components in single files. The code to load components will be generated by Webpack. Yay, less programming less mistakes.
  51. Transfered everything to new backend
  52. - With the new backend a new website structure has been created. The old pages had been transfered to the correct positions in the new backend.
  53. - Now that the backend is working, the frontend may be developed.
  54. Update for the devblog
  55. - The Development Blog got a new \"design\" and finally an update to its content.
  56. - One variable holds all the entries and will be parsed into a Vue entries array which are automatically visible when added.
  57. Update introductions
  58. - Startpage and Devblog have been rewritten
  59. ';
  60. $t = explode("\n", $blog);
  61. $entries = [];
  62. $entry['title'] = trim($t[1]);
  63. for ($i = 2; $i < sizeof($t) - 1; $i++) {
  64. $line = trim($t[$i]);
  65. if($line === '') {
  66. continue;
  67. }
  68. if($line[0] === '-') {
  69. $line = trim(substr($line, 1));
  70. $entry['paragraphs'][] = $line;
  71. } else {
  72. $entries[] = $entry;
  73. $entry['paragraphs'] = [];
  74. $entry['title'] = $line;
  75. }
  76. }
  77. return $response->withJson($entries);
  78. }
  79. public static function getRoutes(): array {
  80. return [
  81. new Route('GET', '/soos', 'soos'),
  82. new Route('GET', '/error', 'error'),
  83. new Route('GET', '/devblog', 'devblog'),
  84. ];
  85. }
  86. }