Added the first work on an API.
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
<div id="hd">
|
||||
<p class="top"><a href="#title" accesskey="2"></a>
|
||||
{if !$user.isAnonymous()}{aurl 'url', 'IDF_Views_User::myAccount'}{blocktrans}Welcome, <strong><a class="userw" href="{$url}">{$user}</a></strong>.{/blocktrans} <a href="{url 'IDF_Views::logout'}">{trans 'Sign Out'}</a>{else}<a href="{url 'IDF_Views::login'}">{trans 'Sign in or create your account'}</a>{/if}
|
||||
| <a href="{url 'IDF_Views::faq'}">{trans 'Help'}</a>
|
||||
| <a href="{url 'IDF_Views::faq'}" title="{trans 'Help and accessibility features'}">{trans 'Help'}</a>
|
||||
</p>
|
||||
<h1 id="title" class="title">{block title}{$page_title}{/block}</h1>
|
||||
|
||||
|
@@ -37,7 +37,7 @@
|
||||
<p class="top"><a href="#title" accesskey="2"></a>
|
||||
{if !$user.isAnonymous()}{aurl 'url', 'IDF_Views_User::myAccount'}{blocktrans}Welcome, <strong><a class="userw" href="{$url}">{$user}</a></strong>.{/blocktrans} <a href="{url 'IDF_Views::logout'}">{trans 'Sign Out'}</a>{else}<a href="{url 'IDF_Views::login'}">{trans 'Sign in or create your account'}</a>{/if}
|
||||
{if $project} | <a href="{url 'IDF_Views::index'}">{trans 'Project List'}</a>{/if}
|
||||
| <a href="{url 'IDF_Views::faq'}">{trans 'Help'}</a>
|
||||
| <a href="{url 'IDF_Views::faq'}" title="{trans 'Help and accessibility features'}">{trans 'Help'}</a>
|
||||
</p>
|
||||
<div id="header">
|
||||
<div id="main-tabs">
|
||||
|
83
src/IDF/templates/idf/faq-api.html
Normal file
83
src/IDF/templates/idf/faq-api.html
Normal file
@@ -0,0 +1,83 @@
|
||||
{extends "idf/base-simple.html"}
|
||||
{block docclass}yui-t3{/block}
|
||||
{block body}
|
||||
<p>At the moment, this documentation is only available in English.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="#q-overview">How to access the API?</a></li>
|
||||
<li><a href="#q-authentication">How to authenticate the queries?</a></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="q-overview">How to access the API?</h2>
|
||||
|
||||
<p>
|
||||
The API is a REST API and you can access it by using the same URL you
|
||||
are using for the web interface but with the <code>/api/</code>
|
||||
prefix.
|
||||
</p>
|
||||
<p>
|
||||
For example, if you access a project with the
|
||||
URL <code>http://www.example.com/p/myproject/</code>, you have the
|
||||
following API URLs available:
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>http://www.example.com/api/p/myproject/issues/</code>: list the open issues.</li>
|
||||
<li><code>http://www.example.com/api/p/myproject/issues/create/</code>: create a new issue.</li>
|
||||
</ul>
|
||||
<p>
|
||||
The answer you get is JSON and UTF-8 encoded.
|
||||
</p>
|
||||
|
||||
|
||||
<h2 id="q-authentication">How to authenticate the queries?</h2>
|
||||
|
||||
<p>
|
||||
Authentication is really simple and is optional. If you do not
|
||||
authenticate your queries, you will have the same rights as an
|
||||
anonymous user visiting the normal web interface.
|
||||
</p>
|
||||
<p>
|
||||
To authenticate your query, you need to provide 3 parameters to your
|
||||
requests, the parameters are the followings:
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>_login</code>: your login.</li>
|
||||
<li><code>_salt</code>: a random salt string.</li>
|
||||
<li><code>_hash</code>: the sha1 hash created from the concatenation of the random salt string and the API key.</li>
|
||||
</ul>
|
||||
<p>
|
||||
Please note that the 3 parameters are all starting with the underscore
|
||||
"_" character.
|
||||
</p>
|
||||
<p>
|
||||
An example of PHP code to generate the <code>_hash</code> value is:
|
||||
</p>
|
||||
<pre>
|
||||
<?php
|
||||
$api_key = '1234567890abcdefghijklmnopqrstuvwxyz';
|
||||
$_salt = rand(10000, 999999);
|
||||
$_hash = sha1($_salt.$api_key);
|
||||
echo sprintf("_salt: %s\n", $_salt);
|
||||
echo sprintf("_hash: %s\n", $_hash);
|
||||
?>
|
||||
</pre>
|
||||
<p>
|
||||
If you replace the string '123...xyz' with your own API key and
|
||||
execute this script, you will have as output something like that:
|
||||
</p>
|
||||
<pre>
|
||||
_salt: 123456
|
||||
_hash: 1357924680acegikmoqsuwybdfhjlnprtvxz
|
||||
</pre>
|
||||
<p>
|
||||
Together with your login, you will be able to use those values to
|
||||
authenticate a query.
|
||||
</p>
|
||||
|
||||
{/block} {block context}
|
||||
<p>{trans 'Here we are, just to help you.'}</p>
|
||||
<h2>{trans 'Projects'}</h2>
|
||||
<ul>{foreach $projects as $p}
|
||||
<li><a href="{url 'IDF_Views_Project::home', array($p.shortname)}">{$p}</a></li>
|
||||
{/foreach}</ul>
|
||||
{/block}
|
@@ -4,6 +4,7 @@
|
||||
<ul>
|
||||
<li><a href="#q-keyboard">{trans 'What are the keyboard shortcuts?'}</a></li>
|
||||
<li><a href="#q-duplicate">{trans 'How to mark an issue as duplicate?'}</a></li>
|
||||
<li><a href="#q-api">{trans 'What is the API and how to use it?'}</a></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="q-keyboard">{trans 'What are the keyboard shortcuts?'}</h2>
|
||||
@@ -37,6 +38,11 @@
|
||||
<li>Change the status of the current issue to <em>Duplicate</em>.</li>
|
||||
<li>Submit the changes.</li>
|
||||
</ol>{/blocktrans}
|
||||
|
||||
<h2 id="q-api">{trans 'What is the API and how to use it?'}</h2>
|
||||
|
||||
<p>{blocktrans}The API (Application Programming Interface) is used to interact with InDefero with another program. For example, this can be used to create a desktop program to submit new tickets easily.{/blocktrans}</p>{aurl 'url', 'IDF_Views::faqApi'}
|
||||
<p>{blocktrans}<a href="{$url}">Learn more about the API</a>.{/blocktrans}</p>
|
||||
|
||||
{/block}
|
||||
{block context}
|
||||
|
@@ -41,6 +41,12 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{trans 'API key'}:</th>
|
||||
<td><span class="mono">{$api_key}</span><br />
|
||||
<span class="helptext">{trans 'Your API key will automatically be regenerated if you change your password.'}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><input type="submit" value="{trans 'Update Your Account'}" name="submit" /> | <a href="{url 'IDF_Views::index'}">{trans 'Cancel'}</a>
|
||||
</td>
|
||||
@@ -51,7 +57,9 @@
|
||||
{block context}
|
||||
<div class="issue-submit-info">
|
||||
<p>{trans 'If possible, use your real name. By using your real name, people will have more trust in your comments and remarks.'}</p>
|
||||
<p>{trans 'The API key is used to interact with this website using a program.'}</p>
|
||||
</div>{/block}
|
||||
|
||||
{block javascript}<script type="text/javascript">
|
||||
document.getElementById('id_first_name').focus()
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user