[Pkg-owncloud-commits] [owncloud-doc] 68/270: add js docs

David Prévot taffit at moszumanska.debian.org
Thu Jul 31 03:53:02 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud-doc.

commit 38d8138fbe457a445927bd1a88517a655976c399
Author: Bernhard Posselt <dev at bernhard-posselt.com>
Date:   Mon May 12 00:14:46 2014 +0200

    add js docs
---
 developer_manual/app/js.rst | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/developer_manual/app/js.rst b/developer_manual/app/js.rst
index 0c88d11..f1e723c 100644
--- a/developer_manual/app/js.rst
+++ b/developer_manual/app/js.rst
@@ -1,4 +1,41 @@
+==========
 JavaScript
 ==========
 
-.. sectionauthor:: Bernhard Posselt <dev at bernhard-posselt.com>
\ No newline at end of file
+.. sectionauthor:: Bernhard Posselt <dev at bernhard-posselt.com>
+
+The JavaScript files reside in the **js/** folder and should be included in the template:
+
+.. code-block:: php
+
+  <?php
+  \OCP\Util::addScript('myapp', 'script');  // adds js/script.js
+
+The recommended JavaScript framework to use is `AngularJS <https://angularjs.org/#>`_. A nice tutorial screencast collection can be found on `Egghead.io <https://egghead.io/technologies/angularjs>`_
+
+Sending the CSRF token
+======================
+If any other JavaScript request library than jQuery is being used, the requests need to send the CSRF token as an HTTP header named **requesttoken**. The token is available in the global variable **oc_requesttoken**.
+
+For AngularJS the following lines would need to be added:
+
+.. code-block:: js
+
+    var app = angular.module('MyApp', [).config(['$httpProvider', function($httpProvider) {
+        $httpProvider.defaults.headers.common.requesttoken = oc_requesttoken;
+    }]);
+
+
+Generating URLs
+===============
+To send requests to ownCloud the base URL where ownCloud is currently running is needed. To get the base URL use:
+
+.. code-block:: js
+
+    var baseUrl = OC.generateUrl('');
+
+Full URLs can be genrated by using:
+
+.. code-block:: js
+
+    var authorUrl = OC.generateUrl('/apps/myapp/authors/1');
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-doc.git



More information about the Pkg-owncloud-commits mailing list