MyHandler.php 4.6 KB

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