Pinboard.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. declare(strict_types = 1);
  3. // {{{ License
  4. // This file is part of GNU social - https://www.gnu.org/software/social
  5. //
  6. // GNU social is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // GNU social is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  18. // }}}
  19. /**
  20. * Pinboard server API, doesn't (currently) allow importing from the
  21. * official website
  22. *
  23. * @package GNUsocial
  24. *
  25. * @author Hugo Sales <hugo@hsal.es>
  26. * @copyright 2022 Free Software Foundation, Inc http://www.fsf.org
  27. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  28. */
  29. namespace Plugin\Pinboard;
  30. use App\Core\Event;
  31. use App\Core\Modules\Plugin;
  32. use App\Core\Router;
  33. use EventResult;
  34. use Plugin\Pinboard\Controller as C;
  35. use Symfony\Component\HttpFoundation\Request;
  36. class Pinboard extends Plugin
  37. {
  38. public const controller_route = 'pinboard_settings';
  39. public function onAddRoute(Router $r): EventResult
  40. {
  41. $r->connect(self::controller_route, '/pinboard/settings', C\Settings::class, options: ['method' => 'post']);
  42. $r->connect('pinboard_posts_update', '/pinboard/v1/posts/update', [C\APIv1::class, 'posts_update']);
  43. $r->connect('pinboard_posts_add', '/pinboard/v1/posts/add', [C\APIv1::class, 'posts_add']);
  44. $r->connect('pinboard_posts_delete', '/pinboard/v1/posts/delete', [C\APIv1::class, 'posts_delete']);
  45. $r->connect('pinboard_posts_get', '/pinboard/v1/posts/get', [C\APIv1::class, 'posts_get']);
  46. $r->connect('pinboard_posts_recent', '/pinboard/v1/posts/recent', [C\APIv1::class, 'posts_recent']);
  47. $r->connect('pinboard_posts_all', '/pinboard/v1/posts/all', [C\APIv1::class, 'posts_all']);
  48. $r->connect('pinboard_posts_dates', '/pinboard/v1/posts/dates', [C\APIv1::class, 'unimplemented']);
  49. $r->connect('pinboard_posts_suggest', '/pinboard/v1/posts/suggest', [C\APIv1::class, 'unimplemented']);
  50. $r->connect('pinboard_tags_get', '/pinboard/v1/tags/get', [C\APIv1::class, 'tags_get']);
  51. $r->connect('pinboard_tags_delete', '/pinboard/v1/tags/delete', [C\APIv1::class, 'unimplemented']);
  52. $r->connect('pinboard_tags_rename', '/pinboard/v1/tags/rename', [C\APIv1::class, 'unimplemented']);
  53. $r->connect('pinboard_user_secret', '/pinboard/v1/user/secret', [C\APIv1::class, 'unimplemented']);
  54. $r->connect('pinboard_user_api_token', '/pinboard/v1/user/api_token', [C\APIv1::class, 'unimplemented']);
  55. $r->connect('pinboard_notes_list', '/pinboard/v1/notes/list', [C\APIv1::class, 'unimplemented']);
  56. $r->connect('pinboard_notes_id', '/pinboard/v1/notes/{id}', [C\APIv1::class, 'unimplemented']);
  57. return Event::next;
  58. }
  59. /**
  60. * @param SettingsTabsType $tabs
  61. */
  62. public function onPopulateSettingsTabs(Request $request, string $section, array &$tabs): EventResult
  63. {
  64. if ($section === 'api') {
  65. $tabs[] = [
  66. 'title' => 'Pinboard',
  67. 'desc' => 'Pinboard API settings',
  68. 'id' => 'settings-pinboard-api',
  69. 'controller' => C\Settings::setup(),
  70. ];
  71. }
  72. return Event::next;
  73. }
  74. }