From a338c75c9fe7c1d45d4c7274fafcb59bdc4c3764 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 1 May 2019 19:46:18 +0200 Subject: [PATCH 1/3] Update README for Modules --- src/Module/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Module/README.md b/src/Module/README.md index f888f26326..66a4967f33 100644 --- a/src/Module/README.md +++ b/src/Module/README.md @@ -3,6 +3,21 @@ The Module namespace contains the different modules of Friendica. Each module is loaded through the [`App`](https://github.com/friendica/friendica/blob/develop/src/App.php). +There are mainly two types of modules: +- frontend modules to interact with users +- backend modules to interact with machine requests + +### Frontend modules + +This type of modules mainly needs a template, which are generally located at +[view/templates/](https://github.com/friendica/friendica/tree/develop/view/templates). + +A frontend module should extend the [`BaseModule`](https://github.com/friendica/friendica/blob/develop/src/BaseModule.php), especially the `content()` method. + +### Backend modules + +This type of modules mainly responds either with `XML` or with `JSON`. + Rules for Modules: - Named like the call (i.e. https://friendica.test/contact => `Contact`) - Start with capitals and are **not** camelCased. From b3cee63745572e689490d221f8eb80438b87373b Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 1 May 2019 19:58:51 +0200 Subject: [PATCH 2/3] Update README for Modules --- src/Module/README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Module/README.md b/src/Module/README.md index 66a4967f33..a2f2b9de56 100644 --- a/src/Module/README.md +++ b/src/Module/README.md @@ -16,10 +16,16 @@ A frontend module should extend the [`BaseModule`](https://github.com/friendica/ ### Backend modules -This type of modules mainly responds either with `XML` or with `JSON`. +This type of modules mainly responds either with encoded `XML` or with `JSON` output. +It isn't intended to respond with human readable text. -Rules for Modules: -- Named like the call (i.e. https://friendica.test/contact => `Contact`) -- Start with capitals and are **not** camelCased. -- Directly interacting with a given request (POST or GET) -- Extending [`BaseModule`](https://github.com/friendica/friendica/blob/develop/src/BaseModule.php). \ No newline at end of file +A frontend module should extend the [`BaseModule`](https://github.com/friendica/friendica/blob/develop/src/BaseModule.php), especially the `rawContent()` method. + +### Routing + +Every module needs to be accessed within a route. +The routing mechanism is using a PSR-7 based routing and the routes are defined inside [`Router->collectRoutes()`](https://github.com/friendica/friendica/blob/develop/src/App/Router.php). + +Use the given routes as a pattern for further routes. + +The routing library can be found [here](https://github.com/thephpleague/route). \ No newline at end of file From 0b5db6238ee244dc58957f490186e805ad9b1b15 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 1 May 2019 20:17:15 +0200 Subject: [PATCH 3/3] fixing text --- src/Module/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module/README.md b/src/Module/README.md index a2f2b9de56..a723f6a290 100644 --- a/src/Module/README.md +++ b/src/Module/README.md @@ -24,8 +24,8 @@ A frontend module should extend the [`BaseModule`](https://github.com/friendica/ ### Routing Every module needs to be accessed within a route. -The routing mechanism is using a PSR-7 based routing and the routes are defined inside [`Router->collectRoutes()`](https://github.com/friendica/friendica/blob/develop/src/App/Router.php). +The routes are defined inside [`Router->collectRoutes()`](https://github.com/friendica/friendica/blob/develop/src/App/Router.php). Use the given routes as a pattern for further routes. -The routing library can be found [here](https://github.com/thephpleague/route). \ No newline at end of file +The routing library and further documentation can be found [here](https://github.com/nikic/FastRoute). \ No newline at end of file