From 5bdb71b20a220be3dc2f8d482499e41dce5fd7a3 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Fri, 3 Jun 2016 00:39:08 +0200 Subject: wiki to docs --- docs/plugins/README.md | 203 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 docs/plugins/README.md (limited to 'docs/plugins') diff --git a/docs/plugins/README.md b/docs/plugins/README.md new file mode 100644 index 000000000..4116de3d7 --- /dev/null +++ b/docs/plugins/README.md @@ -0,0 +1,203 @@ +# How To Write 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://doc.owncloud.org/server/9.0/developer_manual/app/index.html). If you want you can [take a look at the developer docs](https://doc.owncloud.org/server/9.0/developer_manual/app/index.html) or [dig into the tutorial](http://doc.owncloud.org/server/9.0/developer_manual/app/appframework/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 = $('