]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Added developer documentation
authorNicolas Lœuillet <nicolas@loeuillet.org>
Tue, 16 Feb 2016 06:55:18 +0000 (07:55 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Mon, 29 Feb 2016 20:28:25 +0000 (21:28 +0100)
src/Wallabag/CoreBundle/Controller/DeveloperController.php
src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/howto_app.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig

index 3cb8688149ede0972893b15a1dd994b83699d530..edbcec4b52ebbc20c4433c1adb6cd39d1d8eab01 100644 (file)
@@ -12,6 +12,8 @@ class DeveloperController extends Controller
      * @param Request $request
      *
      * @Route("/developer", name="developer")
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
      */
     public function indexAction(Request $request)
     {
@@ -22,6 +24,8 @@ class DeveloperController extends Controller
      * @param Request $request
      *
      * @Route("/developer/client/create", name="create_client")
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
      */
     public function createClientAction(Request $request)
     {
@@ -33,6 +37,19 @@ class DeveloperController extends Controller
 
         return $this->render('WallabagCoreBundle:Developer:client.html.twig', array(
             'client_id' => $client->getPublicId(),
+            'client_secret' => $client->getSecret(),
         ));
     }
+
+    /**
+     * @param Request $request
+     *
+     * @Route("/developer/howto/first-app", name="howto-firstapp")
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function howtoFirstAppAction(Request $request)
+    {
+        return $this->render('WallabagCoreBundle:Developer:howto_app.html.twig');
+    }
 }
index edebc7ee7ddaa31acfb1618e160c6fe28ede4bd6..5ab357003bb2464af3ed81254f1ffd6f4e9cd242 100644 (file)
@@ -1,9 +1,24 @@
 {% extends "WallabagCoreBundle::layout.html.twig" %}
 
-{% block title %}{% trans %}New client{% endtrans %}{% endblock %}
+{% block title %}{% trans %}New application{% endtrans %}{% endblock %}
 
 {% block content %}
+<div class="row">
+    <div class="col s12">
+        <div class="card-panel settings">
 
-    Client ID: {{ client_id }}
+            <div class="row">
+                <h3>My application parameters</h3>
+                <p>Here are your application parameters.</p>
+                <ul>
+                    <li>Client ID: {{ client_id }}</li>
+                    <li>Client Secret: {{ client_secret }}</li>
+                </ul>
+                <a class="waves-effect waves-light btn" href="{{ path('developer') }}">Back to Developer main page</a>
+            </div>
+
+        </div>
+    </div>
+</div>
 
 {% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/howto_app.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/howto_app.html.twig
new file mode 100644 (file)
index 0000000..2db15b1
--- /dev/null
@@ -0,0 +1,68 @@
+{% extends "WallabagCoreBundle::layout.html.twig" %}
+
+{% block title %}{% trans %}How to create my first application{% endtrans %}{% endblock %}
+
+{% block content %}
+<div class="row">
+    <div class="col s12">
+        <div class="card-panel settings">
+
+            <div class="row">
+                <p>The following commands make use of the <a href="https://github.com/jkbrzt/httpie">HTTPie library</a>. Make sure it is installed on your system before using it.</p>
+                <p>You need a token to communicate between your 3rd application and wallabag API.</p>
+                <p>To create this token, you need <a href="{{ path('create_client') }}">to create a new client</a>.</p>
+                <p>Now, create your token (replace client_id, client_secret, username and password with the good values):</p>
+                <p>
+                    <code>
+                        <pre>
+http POST http://v2.wallabag.org/oauth/v2/token \
+    grant_type=password \
+    client_id=12_5um6nz50ceg4088c0840wwc0kgg44g00kk84og044ggkscso0k \
+    client_secret=3qd12zpeaxes8cwg8c0404g888co4wo8kc4gcw0occww8cgw4k \
+    username=yourUsername \
+    password=yourPassw0rd
+                        </pre>
+                    </code>
+                </p>
+                <p>The API will return a response like this:</p>
+                <p>
+                    <code>
+                        <pre>
+HTTP/1.1 200 OK
+Cache-Control: no-store, private
+Connection: close
+Content-Type: application/json
+Date: Tue, 06 Oct 2015 18:24:03 GMT
+Host: localhost:8000
+Pragma: no-cache
+X-Debug-Token: be00a1
+X-Debug-Token-Link: /profiler/be00a1
+X-Powered-By: PHP/5.5.9-1ubuntu4.13
+{
+    "access_token": "ZWFjNjA3ZWMwYWVmYzRkYTBlMmQ3NTllYmVhOGJiZDE0ZTg1NjE4MjczOTVlNzM0ZTRlMWQ0MmRlMmYwNTk5Mw",
+    "expires_in": 3600,
+    "refresh_token": "ODBjODU1NWUwNmUzZTBkNDQ5YWVlZTVlMjQ2Y2I0OWM2NTM1ZGM2M2Y3MDhjMTViM2U2MzYxYzRkMDk5ODRlZg",
+    "scope": null,
+    "token_type": "bearer"
+}
+                        </pre>
+                    </code>
+                </p>
+                <p>The access_token is useful to do a call to the API endpoint. For example:</p>
+                <p>
+                    <code>
+                        <pre>
+http GET http://v2.wallabag.org/api/entries.json \
+    "Authorization:Bearer ZWFjNjA3ZWMwYWVmYzRkYTBlMmQ3NTllYmVhOGJiZDE0ZTg1NjE4MjczOTVlNzM0ZTRlMWQ0MmRlMmYwNTk5Mw"
+                        </pre>
+                    </code>
+                </p>
+                <p>This call will return all the entries for your user.</p>
+                <p>If you want to see all the API endpoints, you can have a look <a href="{{ path('nelmio_api_doc_index') }}">to our API documentation</a>.</p>
+                <p><a class="waves-effect waves-light btn" href="{{ path('developer') }}">Back to Developer main page</a></p>
+            </div>
+
+        </div>
+    </div>
+</div>
+{% endblock %}
index 9e06005f45445028f10dc3e6d54420ad38ea7c2b..36d5c2bdf71e00322fcf6f2fae5df7080f03f83b 100644 (file)
@@ -3,7 +3,31 @@
 {% block title %}{% trans %}Developer{% endtrans %}{% endblock %}
 
 {% block content %}
+<div class="row">
+    <div class="col s12">
+        <div class="card-panel settings">
+
+            <div class="row">
+                <h3>Welcome to the wallabag API</h3>
+
+                <h4>Documentation</h4>
+
+                <ul>
+                    <li><a href="{{ path('howto-firstapp') }}">How to create my first application</a></li>
+                    <li><a href="{{ path('nelmio_api_doc_index') }}">View full API documentation</a></li>
+                </ul>
+
+                <h4>My applications</h4>
+                <ul>
+                    <li><a href="{{ path('create_client') }}">Create a new application</a></li>
+                    <li><a href="#">See my applications</a></li>
+                </ul>
+
+            </div>
+
+        </div>
+    </div>
+</div>
 
-    <a href="{{ path('create_client') }}">Create a new client</a>
 
 {% endblock %}
index aff8dd2b897cbb11e18a5de4db760877b32a9c40..6c786951aa9d1e1f989b01cd7601e10e408cf3e3 100644 (file)
                         <li><a href="{{ path('import_pocket') }}">{% trans %}Migrate from Pocket{% endtrans %}</a></li>
                         <li><a href="{{ path('import_wallabag_v1') }}">{% trans %}Migrate from wallabag v1{% endtrans %}</a></li>
                     </ul>
+                    <h4>{% trans %}Developers{% endtrans %}</h4>
+                    <ul>
+                        <li><a href="{{ path('developer') }}">{% trans %}Create your third application{% endtrans %}</a></li>
+                    </ul>
                     <h4>{% trans %}Full documentation{% endtrans %}</h4>
                     <ul>
                         <li><a href="http://wallabag.readthedocs.org">{% trans %}Convert your articles into ePUB or PDF{% endtrans %}</a></li>