Skip to content
Browse files

new docs

  • Loading branch information...
1 parent 5f1af2f commit 4322b4f15d6595c8d14eee806528c5f6e470e5e0 @linus committed Jul 21, 2011
Showing with 3 additions and 54 deletions.
  1. +3 −54 docs/discogs.html
View
57 docs/discogs.html
@@ -1,6 +1,4 @@
-<!DOCTYPE html> <html> <head> <title>discogs.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> discogs.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="nv">querystring = </span><span class="nx">require</span> <span class="s1">&#39;querystring&#39;</span>
-<span class="nv">request = </span><span class="nx">require</span> <span class="s1">&#39;request&#39;</span>
-<span class="nv">compress = </span><span class="nx">require</span> <span class="s1">&#39;compress&#39;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>This is the entry point.</p>
+<!DOCTYPE html> <html> <head> <title>discogs.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> discogs.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>This is the entry point.</p>
<p>Needs a <a href="https://www.discogs.com/users/login">Discogs API key</a>.</p>
@@ -12,55 +10,6 @@
}
client = discogs({api_key: 'foo4711'})
-</code></pre> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports = module.exports = </span><span class="nf">(config) -&gt;</span>
- <span class="nv">_config = </span><span class="p">{}</span>
- <span class="nv">_config.api_key = </span><span class="nx">config</span><span class="p">.</span><span class="nx">api_key</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Default format</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_config.f = </span><span class="nx">config</span><span class="p">.</span><span class="nx">f</span> <span class="o">or</span> <span class="s1">&#39;json&#39;</span>
- <span class="nv">params = </span><span class="nx">querystring</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">_config</span><span class="p">)</span>
-
- <span class="nv">gunzip = </span><span class="k">new</span> <span class="nx">compress</span><span class="p">.</span><span class="nx">Gunzip</span><span class="p">()</span>
- <span class="nx">gunzip</span><span class="p">.</span><span class="nx">init</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Return a proper url with api_key and format</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">getUrl = </span><span class="nf">(url) -&gt;</span>
- <span class="nv">url = </span><span class="s2">&quot;http://www.discogs.com/#{encodeURIComponent(url)}&quot;</span> <span class="k">if</span> <span class="nx">url</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span> <span class="o">isnt</span> <span class="s1">&#39;http://&#39;</span>
- <span class="nv">sep = </span><span class="k">if</span> <span class="s2">&quot;?&quot;</span> <span class="k">in</span> <span class="nx">url</span> <span class="k">then</span> <span class="s2">&quot;&amp;&quot;</span> <span class="k">else</span> <span class="s2">&quot;?&quot;</span>
-
- <span class="s2">&quot;#{url}#{sep}#{params}&quot;</span>
- </pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Make a request</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">discogsRequest = </span><span class="nf">(url, next) -&gt;</span>
- <span class="nx">request</span>
- <span class="nv">uri: </span><span class="nx">getUrl</span><span class="p">(</span><span class="nx">url</span><span class="p">),</span>
- <span class="nv">headers: </span><span class="p">{</span><span class="s1">&#39;accept-encoding&#39;</span><span class="o">:</span> <span class="s1">&#39;gzip&#39;</span><span class="p">},</span>
- <span class="nv">encoding: </span><span class="s1">&#39;binary&#39;</span><span class="p">,</span>
- <span class="p">(</span><span class="nx">error</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="o">=&gt;</span>
- <span class="k">if</span> <span class="o">not</span> <span class="nx">error</span> <span class="o">and</span> <span class="mi">200</span> <span class="o">&lt;=</span> <span class="nx">res</span><span class="p">.</span><span class="nx">statusCode</span> <span class="o">&lt;</span> <span class="mi">400</span>
- <span class="k">if</span> <span class="nx">body</span>
- <span class="nv">body = </span><span class="nx">gunzip</span><span class="p">.</span><span class="nx">inflate</span><span class="p">(</span><span class="nx">body</span><span class="p">)</span> <span class="k">if</span> <span class="s1">&#39;gzip&#39;</span> <span class="k">in</span> <span class="nx">res</span><span class="p">.</span><span class="nx">headers</span><span class="p">[</span><span class="s1">&#39;content-type&#39;</span><span class="p">]</span>
- <span class="nv">body = </span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">body</span><span class="p">)</span> <span class="k">if</span> <span class="s1">&#39;json&#39;</span> <span class="k">in</span> <span class="nx">res</span><span class="p">.</span><span class="nx">headers</span><span class="p">[</span><span class="s1">&#39;content-type&#39;</span><span class="p">]</span> <span class="o">or</span> <span class="nx">_config</span><span class="p">.</span><span class="nx">f</span> <span class="o">is</span> <span class="s1">&#39;json&#39;</span>
-
- <span class="nx">next</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span>
- <span class="k">else</span>
- <span class="nx">next</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span>
-
- <span class="nv">responseHandler = </span><span class="nf">(type, next) -&gt;</span>
- <span class="nf">(err, res) -&gt;</span>
- <span class="k">return</span> <span class="nx">next</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="k">if</span> <span class="nx">err</span> <span class="o">or</span> <span class="nx">res</span> <span class="o">not</span> <span class="k">instanceof</span> <span class="nb">Object</span> <span class="o">or</span> <span class="nx">type</span> <span class="o">not</span> <span class="k">of</span> <span class="nx">res</span><span class="o">?</span><span class="p">.</span><span class="nx">resp</span>
- <span class="nx">next</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">res</span><span class="p">.</span><span class="nx">resp</span><span class="p">[</span><span class="nx">type</span><span class="p">])</span>
-
- <span class="k">return</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Use this if you have a discogs url</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">get: </span><span class="nf">(url, next) -&gt;</span>
- <span class="nx">discogsRequest</span> <span class="nx">url</span><span class="p">,</span> <span class="nx">next</span>
- </pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Get a release</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">release: </span><span class="nf">(id, next) -&gt;</span>
- <span class="nx">discogsRequest</span> <span class="s1">&#39;release/&#39;</span> <span class="o">+</span> <span class="nx">id</span><span class="p">,</span>
- <span class="nx">responseHandler</span><span class="p">(</span><span class="s1">&#39;release&#39;</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span>
- </pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Get an artist</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">artist: </span><span class="nf">(name, next) -&gt;</span>
- <span class="nx">discogsRequest</span> <span class="s1">&#39;artist/&#39;</span> <span class="o">+</span> <span class="nx">name</span><span class="p">,</span>
- <span class="nx">responseHandler</span><span class="p">(</span><span class="s1">&#39;artist&#39;</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Get a label</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">label: </span><span class="nf">(name, next) -&gt;</span>
- <span class="nx">discogsRequest</span> <span class="s1">&#39;label/&#39;</span> <span class="o">+</span> <span class="nx">name</span><span class="p">,</span>
- <span class="nx">responseHandler</span><span class="p">(</span><span class="s1">&#39;label&#39;</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span>
- </pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Search for something
+</code></pre> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Default format</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Return a proper url with api_key and format</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Make a request</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>API</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Use this if you have a discogs url</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Get a release</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Get an artist</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Get a label</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Search for something
Valid types:
-<code>all</code>, <code>artists</code>, <code>labels</code>, <code>releases</code>, <code>needsvote</code>, <code>catno</code>, <code>forsale</code></p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">search: </span><span class="nf">(query, type, next) -&gt;</span>
- <span class="k">if</span> <span class="nx">type</span> <span class="k">instanceof</span> <span class="nb">Function</span>
- <span class="nv">next = </span><span class="nx">type</span>
- <span class="nv">type = </span><span class="s1">&#39;all&#39;</span>
- <span class="nx">discogsRequest</span> <span class="s1">&#39;search?&#39;</span> <span class="o">+</span> <span class="nx">querystring</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nv">type: </span><span class="nx">type</span><span class="p">,</span> <span class="nv">q: </span><span class="nx">query</span><span class="p">),</span>
- <span class="nx">responseHandler</span><span class="p">(</span><span class="s1">&#39;search&#39;</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span>
- <span class="p">}</span>
-
-</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
+<code>all</code>, <code>artists</code>, <code>labels</code>, <code>releases</code>, <code>needsvote</code>, <code>catno</code>, <code>forsale</code></p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>

0 comments on commit 4322b4f

Please sign in to comment.
Something went wrong with that request. Please try again.