From c65edd1f8b360afcbdbe6b57be6b467de0312e2f Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sat, 30 Apr 2016 15:05:55 +0200 Subject: Move plugin spec into repo --- docs/developer/plugins/README.md | 200 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 docs/developer/plugins/README.md (limited to 'docs/developer/plugins/README.md') diff --git a/docs/developer/plugins/README.md b/docs/developer/plugins/README.md new file mode 100644 index 000000000..8ee16bc8b --- /dev/null +++ b/docs/developer/plugins/README.md @@ -0,0 +1,200 @@ +# 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 [ownCloud 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 = $('