Skip to content

Commit

Permalink
Fixing / refactoring prepare(), fixes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Apr 14, 2015
1 parent a36b0b6 commit 61cf632
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion doc/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ <h5>Returns:</h5>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on 2015-04-09T18:25:48-04:00 using the <a
on 2015-04-13T21:30:38-04:00 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
Expand Down
6 changes: 5 additions & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ <h2>REST / Hypermedia</h2>
hypermedia links.</p>
<p>For example, if the key <code>user_id</code> was found, it would be mapped to <code>/users/:id</code> with a link <code>rel</code> of <code>related</code>.</p>
<p>Tensō will bend the rules of REST when using authentication strategies provided by passport.js, or CSRF if is enabled, because they rely on a session. Session storage is in memory, or Redis. You have the option of a stateless or stateful API.</p>
<h2>Browsable API / Renderers</h2>
<p>Tensō 1.4.0 added a few common format renderers, such as CSV, HTML, YAML, &amp; XML. The HTML interface is a browsable API! You can use it to verify requests &amp; responses, or simply poke around your API to see how it behaves.</p>
<p>Custom renderers can be registered with <code>server.renderer('name', fn, 'mimetype');</code>.</p>
<h2>Cache</h2>
<p>Tensō has a robust multi-level cache strategy, starting at the response headers. If a response can be cached, an <code>Etag</code> will be sent to the <code>Client</code>, and registered in an <code>Etag LRU cache</code> which Tensō
uses along with a 'cache compressed asset to disk' strategy, allowing Tensō to stream the last known version of a resource to the next <code>Client</code> that supports the same compression (gzip or deflate).
Expand Down Expand Up @@ -192,6 +195,7 @@ <h2>Configuration</h2>
&quot;cert&quot;: null,
&quot;key&quot;: null
},
&quot;title&quot;: &quot;My API&quot;, /* Page title for browsable API */
&quot;uid&quot;: N /* Optional, system account uid to drop to after starting with elevated privileges to run on a low port */
}</code></pre>
<h2>Authentication</h2>
Expand Down Expand Up @@ -386,7 +390,7 @@ <h2>License</h2>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on 2015-04-09T18:25:48-04:00 using the <a
on 2015-04-13T21:30:38-04:00 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
Expand Down
4 changes: 2 additions & 2 deletions doc/module-tenso.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ <h2>
<dt class="tag-version">Version:</dt>
<dd class="tag-version">
<ul class="dummy">
<li>1.4.2</li>
<li>1.4.4</li>
</ul>
</dd>

Expand Down Expand Up @@ -344,7 +344,7 @@ <h5>Type:</h5>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on 2015-04-09T18:25:48-04:00 using the <a
on 2015-04-13T21:30:38-04:00 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
Expand Down
2 changes: 1 addition & 1 deletion doc/modules.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ <h2>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on 2015-04-09T18:25:48-04:00 using the <a
on 2015-04-13T21:30:38-04:00 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
Expand Down
6 changes: 3 additions & 3 deletions lib/tenso.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* @license BSD-3 <https://raw.github.com/avoidwork/tenso/master/LICENSE>
* @link http://avoidwork.github.io/tenso
* @module tenso
* @version 1.4.3
* @version 1.4.4
*/
const CONFIG = require( __dirname + "/../config.json" );
const VERSION = "1.4.3";
const VERSION = "1.4.4";
const SERVER = "tenso/" + VERSION;

let keigai = require( "keigai" ),
Expand Down Expand Up @@ -1142,7 +1142,7 @@ let renderers = {
} ).join( "\n" ) )
.replace( "{{body}}", JSON.stringify( arg, null, 2 ) )
.replace( "{{year}}", new Date().getFullYear() )
.replace( "{{version}}", "1.4.3" )
.replace( "{{version}}", "1.4.4" )
.replace( "{{allow}}", headers[ "allow" ] )
.replace( "{{methods}}", string.explode( headers[ "allow" ].replace( "GET, HEAD, OPTIONS", "" ) ).filter( function ( i ) {
return i !== "";
Expand Down
6 changes: 3 additions & 3 deletions lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ var _classCallCheck = function (instance, Constructor) { if (!(instance instance
* @license BSD-3 <https://raw.github.com/avoidwork/tenso/master/LICENSE>
* @link http://avoidwork.github.io/tenso
* @module tenso
* @version 1.4.3
* @version 1.4.4
*/
var CONFIG = require(__dirname + "/../config.json");
var VERSION = "1.4.3";
var VERSION = "1.4.4";
var SERVER = "tenso/" + VERSION;

var keigai = require("keigai"),
Expand Down Expand Up @@ -1193,7 +1193,7 @@ var renderers = {
return "<tr><td>" + i + "</td><td>" + sanitize(headers[i]) + "</td></tr>";
}).join("\n")).replace("{{formats}}", req.server.config.renderers.map(function (i) {
return "<option value='" + i + "'>" + i.toUpperCase() + "</option>";
}).join("\n")).replace("{{body}}", JSON.stringify(arg, null, 2)).replace("{{year}}", new Date().getFullYear()).replace("{{version}}", "1.4.3").replace("{{allow}}", headers.allow).replace("{{methods}}", string.explode(headers.allow.replace("GET, HEAD, OPTIONS", "")).filter(function (i) {
}).join("\n")).replace("{{body}}", JSON.stringify(arg, null, 2)).replace("{{year}}", new Date().getFullYear()).replace("{{version}}", "1.4.4").replace("{{allow}}", headers.allow).replace("{{methods}}", string.explode(headers.allow.replace("GET, HEAD, OPTIONS", "")).filter(function (i) {
return i !== "";
}).map(function (i) {
return "<option value='" + i + "'>" + i + "</option>";
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is a REST API facade for node.js, designed to simplify the implementation of APIs.",
"version": "1.4.3",
"version": "1.4.4",
"homepage": "http://avoidwork.github.io/tenso",
"author": {
"name": "Jason Mulligan",
Expand Down Expand Up @@ -43,7 +43,7 @@
"passport-oauth2": "~1.1.2",
"passport-saml": "~0.9.1",
"passport-twitter": "~1.0.2",
"turtle.io": "~3.2.18",
"turtle.io": "~3.2.19",
"yamljs": "^0.2.1"
},
"devDependencies": {
Expand Down
14 changes: 4 additions & 10 deletions template.html
Original file line number Diff line number Diff line change
Expand Up @@ -507,18 +507,12 @@ <h3>Result</h3>
var matches, replaces;

// Preparing to change <pre> into Elements
matches = array.unique( html.match( /([^\s*]+)/g )
.filter( function ( i ) {
return !/(\{|\[|\]|\})/.test( i );
} ) );
matches = array.unique( html.match( /([^\s*]+)/g ).filter( function ( i ) {
return !/(\{|\[|\]|\})/.test( i ) && /\"/.test( i );
} ) );

replaces = matches.map( function ( i ) {
if ( i.indexOf( '"' ) > -1 ) {
return i.replace( /(\".*\")/, "<span class='item'>$1</span>" );
}
else {
return i;
}
return i.replace( /(\".*\")/, "<span class='item'>$1</span>" );
} );

array.each( matches, function ( i, idx ) {
Expand Down

0 comments on commit 61cf632

Please sign in to comment.