From 1627e4f298e8653382f10a5697fcc35181f5c4b3 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Sat, 8 May 2021 20:07:23 +0200 Subject: move plugins Signed-off-by: Benjamin Brahmer --- docs/features/plugins.md | 206 +++++++++++++++++++++++++++++++++++++++++++++ old-docs/plugins/README.md | 206 --------------------------------------------- 2 files changed, 206 insertions(+), 206 deletions(-) create mode 100644 docs/features/plugins.md delete mode 100644 old-docs/plugins/README.md diff --git a/docs/features/plugins.md b/docs/features/plugins.md new file mode 100644 index 000000000..1b1dfee33 --- /dev/null +++ b/docs/features/plugins.md @@ -0,0 +1,206 @@ +# Plugins + +Plugins were created to keep the app maintainable while still making it possible to easily implement additional functionality. + +There are essentially three different use cases for plugins: +* Creating or extending server-side functionality, e.g. creating additional REST API endpoints +* Offering article actions such as share via Twitter or E-Mail +* Dropping in additional CSS or JavaScript + +## The Basics +Whatever plugin you want to create, you first need to create a basic structure. A plugin is basically just an app so you can take advantage of the full [Nextcloud app API](https://docs.nextcloud.org/server/latest/developer_manual/app/index.html). If you want you can [take a look at the developer docs](https://docs.nextcloud.org/server/latest/developer_manual/app/index.html) or [dig into the tutorial](https://docs.nextcloud.org/server/latest/developer_manual/app/tutorial.html). + +However if you just want to start slow, the full process is described below. + +First create the following directories and files: + +* **newsplugin/** + * **appinfo/** + * **app.php** + * **info.xml** + +The first folder name affects the name and namespace of your plugin and only one app can exist using the same name. Choose wisely. + +First let's add some meta data about our app. Open the **newsplugin/appinfo/info.xml** and add the following contents: + +```xml + + + newsplugin + Example News Plugin + This plugin allows you to share articles via Twitter + AGPL + Your Name Here + 0.0.1 + + + + + + +``` + +**Note**: You must license your app under the [AGPL 3 or later](http://www.gnu.org/licenses/agpl-3.0.en.html) to comply with the News app's license. Don't forget to add the license as plain text file if you want to distribute your app! + +Then we want to make sure that our code is only run if the News app is enabled. To do that put the following PHP code into the **newsplugin/appinfo/app.php** file: + +```php +') + .addClass('article-plugin-twitter'); + var $button = $('