Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix most go lint warnings

Cette révision appartient à :
PantsuDev 2017-07-23 15:46:29 +10:00
Parent a931b47bff
révision d9142a73c3
54 fichiers modifiés avec 7161 ajouts et 7275 suppressions

25
.htmlhintrc Fichier normal
Voir le fichier

@ -0,0 +1,25 @@
{
"alt-require": true,
"attr-lowercase": true,
"attr-no-duplication": true,
"attr-unsafe-chars": true,
"attr-value-double-quotes": false,
"attr-value-not-empty": false,
"doctype-first": true,
"doctype-html5": true,
"head-script-disabled": true,
"href-abs-or-rel": false,
"id-class-ad-disabled": true,
"id-class-value": "dash",
"id-unique": true,
"inline-script-disabled": true,
"inline-style-disabled": true,
"space-tab-mixed-disabled": "space2",
"spec-char-escape": true,
"src-not-empty": true,
"style-disabled": true,
"tag-pair": true,
"tag-self-close": false,
"tagname-lowercase": true,
"title-require": true
}

Voir le fichier

@ -16,4 +16,3 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Voir le fichier

@ -1,5 +1,5 @@
define({ "api": [
{
define({
"api": [{
"type": "get",
"url": "/search/",
"title": "Search Torrents",
@ -8,8 +8,7 @@ define({ "api": [
"group": "Torrents",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "String[]",
"optional": false,
@ -133,45 +132,37 @@ define({ "api": [
},
"success": {
"fields": {
"Success 200": [
{
"Success 200": [{
"group": "Success 200",
"type": "Object[]",
"optional": false,
"field": "torrents",
"description": "<p>List of torrent object (see view for the properties).</p>"
}
]
}]
},
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": " HTTP/1.1 200 OK\n {\n\t\t\t\"torrents\": [...],\n\t\t\t\"queryRecordCount\": 50,\n\t\t\t\"totalRecordCount\": 798414\n\t\t}",
"type": "json"
}
]
}]
},
"filename": "controllers/api/api.go",
"groupTitle": "Torrents",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "String[]",
"optional": false,
"field": "errors",
"description": "<p>List of errors messages with a 404 error message in it.</p>"
}
]
}]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": "HTTP/1.1 404 Not Found\n{\n \"errors\": [ \"404_not_found\", ... ]\n}",
"type": "json"
}
]
}]
}
},
{
@ -183,8 +174,7 @@ define({ "api": [
"group": "Torrents",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "String[]",
"optional": false,
@ -308,45 +298,37 @@ define({ "api": [
},
"success": {
"fields": {
"Success 200": [
{
"Success 200": [{
"group": "Success 200",
"type": "Object[]",
"optional": false,
"field": "torrents",
"description": "<p>List of torrent object (see view for the properties).</p>"
}
]
}]
},
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": " HTTP/1.1 200 OK\n {\n\t\t\t[...]\n\t\t}",
"type": "json"
}
]
}]
},
"filename": "controllers/api/_apidoc.js",
"groupTitle": "Torrents",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "String[]",
"optional": false,
"field": "errors",
"description": "<p>List of errors messages with a 404 error message in it.</p>"
}
]
}]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": "HTTP/1.1 404 Not Found\n{\n \"errors\": [ \"404_not_found\", ... ]\n}",
"type": "json"
}
]
}]
}
},
{
@ -358,21 +340,18 @@ define({ "api": [
"group": "Torrents",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "Number",
"optional": false,
"field": "id",
"description": "<p>Torrent unique ID.</p>"
}
]
}]
}
},
"success": {
"fields": {
"Success 200": [
{
"Success 200": [{
"group": "Success 200",
"type": "Number",
"optional": false,
@ -535,35 +514,29 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": " HTTP/1.1 200 OK\n\t{\n\t\"id\": 952801,\n\t\"name\": \"[HorribleSubs] Uchouten Kazoku S2 [720p]\",\n\t\"status\": 1,\n\t\"hash\": \"6E4D96F7A0B0456672E80B150CCB7C15868CD47D\",\n\t\"date\": \"2017-07-05T11:01:39Z\",\n\t\"filesize\": 4056160259,\n\t\"description\": \"<p>Unofficial batch</p>\\n\",\n\t\"comments\": [],\n\t\"sub_category\": \"5\",\n\t\"category\": \"3\",\n\t\"anidb_id\": \"\",\n\t\"downloads\": 0,\n\t\"uploader_id\": 7177,\n\t\"uploader_name\": \"DarAR92\",\n\t\"uploader_old\": \"\",\n\t\"website_link\": \"http://horriblesubs.info/\",\n\t\"languages\": [\n\t\"en-us\"\n\t],\n\t\"magnet\": \"magnet:?xt=urn:btih:6E4D96F7A0B0456672E80B150CCB7C15868CD47D&dn=%5BHorribleSubs%5D+Uchouten+Kazoku+S2+%5B720p%5D&tr=http://nyaa.tracker.wf:7777/announce&tr=http://nyaa.tracker.wf:7777/announce&tr=udp://tracker.doko.moe:6969&tr=http://tracker.anirena.com:80/announce&tr=http://anidex.moe:6969/announce&tr=udp://tracker.opentrackr.org:1337&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://zer0day.ch:1337&tr=udp://9.rarbg.com:2710/announce&tr=udp://tracker2.christianbro.pw:6969/announce&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://eddie4.nl:6969/announce&tr=udp://tracker.doko.moe:6969/announce\",\n\t\"torrent\": \"https://nyaa.pantsu.cat/download/6E4D96F7A0B0456672E80B150CCB7C15868CD47D\",\n\t\"seeders\": 4,\n\t\"leechers\": 2,\n\t\"completed\": 28,\n\t\"last_scrape\": \"2017-07-07T07:48:32.509635Z\",\n\t\"file_list\": [\n\t{\n\t\"path\": \"[HorribleSubs] Uchouten Kazoku S2 - 01[720p].mkv\",\n\t\"filesize\": 338250895\n\t},\n\t{\n\t\"path\": \"[HorribleSubs] Uchouten Kazoku S2 - 12 [720p].mkv\",\n\t\"filesize\": 338556275\n\t}\n\t]\n\t}",
"type": "json"
}
]
}]
},
"filename": "controllers/api/api.go",
"groupTitle": "Torrents",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "String[]",
"optional": false,
"field": "errors",
"description": "<p>List of errors messages with a 404 error message in it.</p>"
}
]
}]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": "HTTP/1.1 404 Not Found\n{\n \"errors\": [ \"404_not_found\", ... ]\n}",
"type": "json"
}
]
}]
}
},
{
@ -575,47 +548,39 @@ define({ "api": [
"group": "Torrents",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "Number",
"optional": false,
"field": "id",
"description": "<p>Torrent unique ID.</p>"
}
]
}]
}
},
"success": {
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": "HTTP/1.1 200 OK",
"type": "json"
}
]
}]
},
"filename": "controllers/api/api.go",
"groupTitle": "Torrents",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "String[]",
"optional": false,
"field": "errors",
"description": "<p>List of errors messages with a 404 error message in it.</p>"
}
]
}]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": "HTTP/1.1 404 Not Found\n{\n \"errors\": [ \"404_not_found\", ... ]\n}",
"type": "json"
}
]
}]
}
},
{
@ -627,21 +592,18 @@ define({ "api": [
"group": "Torrents",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "Number",
"optional": false,
"field": "id",
"description": "<p>Torrent unique ID.</p>"
}
]
}]
}
},
"success": {
"fields": {
"Success 200": [
{
"Success 200": [{
"group": "Success 200",
"type": "Object[]",
"optional": false,
@ -664,35 +626,29 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": " HTTP/1.1 200 OK\n {\n\t\t\t\"torrents\": [...],\n\t\t\t\"queryRecordCount\": 50,\n\t\t\t\"totalRecordCount\": 798414\n\t\t}",
"type": "json"
}
]
}]
},
"filename": "controllers/api/api.go",
"groupTitle": "Torrents",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "String[]",
"optional": false,
"field": "errors",
"description": "<p>List of errors messages with a 404 error message in it.</p>"
}
]
}]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": "HTTP/1.1 404 Not Found\n{\n \"errors\": [ \"404_not_found\", ... ]\n}",
"type": "json"
}
]
}]
}
},
{
@ -704,8 +660,7 @@ define({ "api": [
"group": "Torrents",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "String",
"optional": false,
@ -780,8 +735,7 @@ define({ "api": [
},
"success": {
"fields": {
"Success 200": [
{
"Success 200": [{
"group": "Success 200",
"type": "Boolean",
"optional": false,
@ -804,20 +758,17 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": "HTTP/1.1 200 OK",
"type": "json"
}
]
}]
},
"filename": "controllers/api/api.go",
"groupTitle": "Torrents",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "Boolean",
"optional": false,
@ -840,13 +791,11 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": " HTTP/1.1 200 OK\n {\n \"ok\": false,\n \"errors\": [ ... ]\n \"all_errors\": {\n\t\t \t\"username\": [ ... ],\n }\n }",
"type": "json"
}
]
}]
}
},
{
@ -858,8 +807,7 @@ define({ "api": [
"group": "Torrents",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "String",
"optional": false,
@ -941,8 +889,7 @@ define({ "api": [
},
"success": {
"fields": {
"Success 200": [
{
"Success 200": [{
"group": "Success 200",
"type": "Boolean",
"optional": false,
@ -965,20 +912,17 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": "HTTP/1.1 200 OK",
"type": "json"
}
]
}]
},
"filename": "controllers/api/api.go",
"groupTitle": "Torrents",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "Boolean",
"optional": false,
@ -1001,13 +945,11 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": " HTTP/1.1 200 OK\n {\n \"ok\": false,\n \"errors\": [ ... ]\n \"all_errors\": {\n\t\t \t\"username\": [ ... ],\n }\n }",
"type": "json"
}
]
}]
}
},
{
@ -1019,8 +961,7 @@ define({ "api": [
"group": "Users",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "String",
"optional": false,
@ -1039,8 +980,7 @@ define({ "api": [
},
"success": {
"fields": {
"Success 200": [
{
"Success 200": [{
"group": "Success 200",
"type": "Boolean",
"optional": false,
@ -1063,20 +1003,17 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": " HTTP/1.1 200 OK\n\t\t{\n\t\t\tdata:\n \t\t[{\n\t\t\t\t\tuser_id:1,\n\t\t\t\t\tusername:\"username\",\n\t\t\t\t\tstatus:1,\n\t\t\t\t\ttoken:\"token\",\n\t\t\t\t\tmd5:\"\",\n\t\t\t\t\tcreated_at:\"date\",\n\t\t\t\t\tliking_count:0,\n\t\t\t\t\tliked_count:0\n\t\t\t\t}],\n\t\t\tinfos: [\"Logged\", ... ],\n\t\t\tok:true\n\t\t}",
"type": "json"
}
]
}]
},
"filename": "controllers/api/api.go",
"groupTitle": "Users",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "Boolean",
"optional": false,
@ -1099,13 +1036,11 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": " HTTP/1.1 200 OK\n {\n \"ok\": false,\n \"errors\": [ ... ]\n \"all_errors\": {\n\t\t \t\"username\": [ ... ],\n }\n }",
"type": "json"
}
]
}]
}
},
{
@ -1117,21 +1052,18 @@ define({ "api": [
"group": "Users",
"parameter": {
"fields": {
"Parameter": [
{
"Parameter": [{
"group": "Parameter",
"type": "Number",
"optional": false,
"field": "id",
"description": "<p>User ID.</p>"
}
]
}]
}
},
"success": {
"fields": {
"Success 200": [
{
"Success 200": [{
"group": "Success 200",
"type": "Boolean",
"optional": false,
@ -1154,20 +1086,17 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Success-Response:",
"content": " HTTP/1.1 200 OK\n\t\t{\n\t\t\tdata:\n \t\t[{\n\t\t\t\t\tuser_id:1,\n\t\t\t\t\tusername:\"username\",\n\t\t\t\t\tstatus:1,\n\t\t\t\t\tmd5:\"\",\n\t\t\t\t\tcreated_at:\"date\",\n\t\t\t\t\tliking_count:0,\n\t\t\t\t\tliked_count:0\n\t\t\t\t}],\n\t\t\tinfos: [\"Logged\", ... ],\n\t\t\tok:true\n\t\t}",
"type": "json"
}
]
}]
},
"filename": "controllers/api/api.go",
"groupTitle": "Users",
"error": {
"fields": {
"Error 4xx": [
{
"Error 4xx": [{
"group": "Error 4xx",
"type": "Boolean",
"optional": false,
@ -1190,13 +1119,12 @@ define({ "api": [
}
]
},
"examples": [
{
"examples": [{
"title": "Error-Response:",
"content": " HTTP/1.1 200 OK\n {\n \"ok\": false,\n \"errors\": [ ... ]\n \"all_errors\": {\n\t\t \t\"username\": [ ... ],\n }\n }",
"type": "json"
}]
}
}
]
}
}
] });
});

Voir le fichier

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Loading...</title>
@ -11,6 +12,7 @@
<link href="img/favicon.ico" rel="icon" type="image/x-icon">
<script src="vendor/polyfill.js"></script>
</head>
<body>
<script id="template-sidenav" type="text/x-handlebars-template">
@ -20,29 +22,23 @@
<span class="search-reset">x</span>
</div>
<ul class="sidenav nav nav-list list">
{{#each nav}}
{{#if title}}
{{#if isHeader}}
{{#if isFixed}}
{{#each nav}} {{#if title}} {{#if isHeader}} {{#if isFixed}}
<li class="nav-fixed nav-header navbar-btn nav-list-item" data-group="{{group}}"><a href="#api-{{group}}">{{underscoreToSpace title}}</a></li>
{{else}}
<li class="nav-header nav-list-item" data-group="{{group}}"><a href="#api-{{group}}">{{underscoreToSpace title}}</a></li>
{{/if}}
{{else}}
{{/if}} {{else}}
<li class="{{#if hidden}}hide {{/if}}" data-group="{{group}}" data-name="{{name}}" data-version="{{version}}">
<a href="#api-{{group}}-{{name}}" class="nav-list-item">{{title}}</a>
</li>
{{/if}}
{{/if}}
{{/each}}
{{/if}} {{/if}} {{/each}}
</ul>
</nav>
</script>
<script id="template-project" type="text/x-handlebars-template">
<div class="pull-left">
<h1>{{name}}</h1>
{{#if description}}<h2>{{{nl2br description}}}</h2>{{/if}}
<h1>{{name}}</h1> {{#if description}}
<h2>{{{nl2br description}}}</h2>{{/if}}
</div>
{{#if template.withCompare}}
<div class="pull-right">
@ -77,22 +73,18 @@
</script>
<script id="template-generator" type="text/x-handlebars-template">
{{#if template.withGenerator}}
{{#if generator}}
{{#if template.withGenerator}} {{#if generator}}
<div class="content">
{{__ "Generated with"}} <a href="{{{generator.url}}}">{{{generator.name}}}</a> {{{generator.version}}} - {{{generator.time}}}
</div>
{{/if}}
{{/if}}
{{/if}} {{/if}}
</script>
<script id="template-sections" type="text/x-handlebars-template">
<section id="api-{{group}}">
<h1>{{underscoreToSpace title}}</h1>
{{#if description}}
<h1>{{underscoreToSpace title}}</h1> {{#if description}}
<p>{{{nl2br description}}}</p>
{{/if}}
{{#each articles}}
{{/if}} {{#each articles}}
<div id="api-{{group}}-{{name}}">
{{{article}}}
</div>
@ -123,32 +115,20 @@
<div class="clearfix"></div>
{{#if article.deprecated}}
<p class="deprecated"><span>{{__ "DEPRECATED"}}</span>
{{{markdown article.deprecated.content}}}
<p class="deprecated"><span>{{__ "DEPRECATED"}}</span> {{{markdown article.deprecated.content}}}
</p>
{{/if}}
{{#if article.description}}
{{/if}} {{#if article.description}}
<p>{{{nl2br article.description}}}</p>
{{/if}}
<span class="type type__{{toLowerCase article.type}}">{{toLowerCase article.type}}</span>
<pre class="prettyprint language-html" data-type="{{toLowerCase article.type}}"><code>{{article.url}}</code></pre>
{{#if article.permission}}
<pre class="prettyprint language-html" data-type="{{toLowerCase article.type}}"><code>{{article.url}}</code></pre> {{#if article.permission}}
<p>
{{__ "Permission:"}}
{{#each article.permission}}
{{name}}
{{#if title}}
{{__ "Permission:"}} {{#each article.permission}} {{name}} {{#if title}}
<button type="button" class="btn btn-info btn-xs" data-title="{{title}}" data-content="{{nl2br description}}" data-html="true" data-toggle="popover" data-placement="right" data-trigger="hover">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</button>
{{/if}}
{{/each}}
</button> {{/if}} {{/each}}
</p>
{{/if}}
{{#if_gt article.examples.length compare=0}}
{{/if}} {{#if_gt article.examples.length compare=0}}
<ul class="nav nav-tabs nav-tabs-examples">
{{#each article.examples}}
<li{{#if_eq @index compare=0}} class="active" {{/if_eq}}>
@ -164,26 +144,21 @@
</div>
{{/each}}
</div>
{{/if_gt}}
{{subTemplate "article-param-block" params=article.header _hasType=_hasTypeInHeaderFields section="header"}}
{{subTemplate "article-param-block" params=article.parameter _hasType=_hasTypeInParameterFields section="parameter"}}
{{subTemplate "article-param-block" params=article.success _hasType=_hasTypeInSuccessFields section="success"}}
{{subTemplate "article-param-block" params=article.error _col1="Name" _hasType=_hasTypeInErrorFields section="error"}}
{{subTemplate "article-sample-request" article=article id=id}}
{{/if_gt}} {{subTemplate "article-param-block" params=article.header _hasType=_hasTypeInHeaderFields section="header"}} {{subTemplate "article-param-block" params=article.parameter _hasType=_hasTypeInParameterFields section="parameter"}} {{subTemplate
"article-param-block" params=article.success _hasType=_hasTypeInSuccessFields section="success"}} {{subTemplate "article-param-block" params=article.error _col1="Name" _hasType=_hasTypeInErrorFields section="error"}} {{subTemplate "article-sample-request"
article=article id=id}}
</article>
</script>
<script id="template-article-param-block" type="text/x-handlebars-template">
{{#if params}}
{{#each params.fields}}
{{#if params}} {{#each params.fields}}
<h2>{{__ @key}}</h2>
<table>
<thead>
<tr>
<th style="width: 30%">{{#if ../_col1}}{{__ ../_col1}}{{else}}{{__ "Field"}}{{/if}}</th>
{{#if ../_hasType}}<th style="width: 10%">{{__ "Type"}}</th>{{/if}}
{{#if ../_hasType}}
<th style="width: 10%">{{__ "Type"}}</th>{{/if}}
<th style="width: {{#if ../_hasType}}60%{{else}}70%{{/if}}">{{__ "Description"}}</th>
</tr>
</thead>
@ -197,13 +172,11 @@
</td>
{{/if}}
<td>
{{{nl2br description}}}
{{#if defaultValue}}<p class="default-value">{{__ "Default value:"}} <code>{{{defaultValue}}}</code></p>{{/if}}
{{#if size}}<p class="type-size">{{__ "Size range:"}} <code>{{{size}}}</code></p>{{/if}}
{{#if allowedValues}}<p class="type-size">{{__ "Allowed values:"}}
{{#each allowedValues}}
<code>{{{this}}}</code>{{#unless @last}}, {{/unless}}
{{/each}}
{{{nl2br description}}} {{#if defaultValue}}
<p class="default-value">{{__ "Default value:"}} <code>{{{defaultValue}}}</code></p>{{/if}} {{#if size}}
<p class="type-size">{{__ "Size range:"}} <code>{{{size}}}</code></p>{{/if}} {{#if allowedValues}}
<p class="type-size">{{__ "Allowed values:"}} {{#each allowedValues}}
<code>{{{this}}}</code>{{#unless @last}}, {{/unless}} {{/each}}
</p>
{{/if}}
</td>
@ -211,8 +184,7 @@
{{/each}}
</tbody>
</table>
{{/each}}
{{#if_gt params.examples.length compare=0}}
{{/each}} {{#if_gt params.examples.length compare=0}}
<ul class="nav nav-tabs nav-tabs-examples">
{{#each params.examples}}
<li{{#if_eq @index compare=0}} class="active" {{/if_eq}}>
@ -228,8 +200,7 @@
</div>
{{/each}}
</div>
{{/if_gt}}
{{/if}}
{{/if_gt}} {{/if}}
</script>
<script id="template-article-sample-request" type="text/x-handlebars-template">
@ -245,10 +216,8 @@
</div>
</div>
{{#if article.header}}
{{#if article.header.fields}}
<h3>{{__ "Headers"}}</h3>
{{#each article.header.fields}}
{{#if article.header}} {{#if article.header.fields}}
<h3>{{__ "Headers"}}</h3> {{#each article.header.fields}}
<h4><input type="radio" data-sample-request-header-group-id="sample-request-header-{{@index}}" name="{{../id}}-sample-request-header" value="{{@index}}" class="sample-request-header sample-request-switch" {{#if_eq @index compare=0}} checked{{/if_eq}} />{{@key}}</h4>
<div class="{{../id}}-sample-request-header-fields{{#if_gt @index compare=0}} hide{{/if_gt}}">
{{#each this}}
@ -261,27 +230,20 @@
</div>
{{/each}}
</div>
{{/each}}
{{/if}}
{{/if}}
{{#if article.parameter}}
{{#if article.parameter.fields}}
<h3>{{__ "Parameters"}}</h3>
{{#each article.parameter.fields}}
{{/each}} {{/if}} {{/if}} {{#if article.parameter}} {{#if article.parameter.fields}}
<h3>{{__ "Parameters"}}</h3> {{#each article.parameter.fields}}
<h4><input type="radio" data-sample-request-param-group-id="sample-request-param-{{@index}}" name="{{../id}}-sample-request-param" value="{{@index}}" class="sample-request-param sample-request-switch" {{#if_eq @index compare=0}} checked{{/if_eq}} />{{@key}}</h4>
<div class="form-group {{../id}}-sample-request-param-fields{{#if_gt @index compare=0}} hide{{/if_gt}}">
{{#each this}}
<label class="col-md-3 control-label" for="sample-request-param-field-{{field}}">{{field}}</label>
<div class="input-group">
<input id="sample-request-param-field-{{field}}" type="text" placeholder="{{field}}" class="form-control sample-request-param" data-sample-request-param-name="{{field}}" data-sample-request-param-group="sample-request-param-{{@../index}}" {{#if optional}}data-sample-request-param-optional="true"{{/if}}>
<input id="sample-request-param-field-{{field}}" type="text" placeholder="{{field}}" class="form-control sample-request-param" data-sample-request-param-name="{{field}}" data-sample-request-param-group="sample-request-param-{{@../index}}" {{#if optional}}data-sample-request-param-optional="true"
{{/if}}>
<div class="input-group-addon">{{{type}}}</div>
</div>
{{/each}}
</div>
{{/each}}
{{/if}}
{{/if}}
{{/each}} {{/if}} {{/if}}
<div class="form-group">
<div class="controls pull-right">
@ -327,312 +289,209 @@
{{#if article.description}}
<p>{{{showDiff article.description compare.description "nl2br"}}}</p>
{{else}}
{{#if compare.description}}
{{else}} {{#if compare.description}}
<p>{{{showDiff "" compare.description "nl2br"}}}</p>
{{/if}}
{{/if}}
{{/if}} {{/if}}
<pre class="prettyprint language-html" data-type="{{toLowerCase article.type}}"><code>{{{showDiff article.url compare.url}}}</code></pre>
{{subTemplate "article-compare-permission" article=article compare=compare}}
<pre class="prettyprint language-html" data-type="{{toLowerCase article.type}}"><code>{{{showDiff article.url compare.url}}}</code></pre> {{subTemplate "article-compare-permission" article=article compare=compare}}
<ul class="nav nav-tabs nav-tabs-examples">
{{#each_compare_title article.examples compare.examples}}
{{#if typeSame}}
{{#each_compare_title article.examples compare.examples}} {{#if typeSame}}
<li{{#if_eq index compare=0}} class="active" {{/if_eq}}>
<a href="#compare-examples-{{../../article.id}}-{{index}}">{{{showDiff source.title compare.title}}}</a>
</li>
{{/if}}
{{#if typeIns}}
{{/if}} {{#if typeIns}}
<li{{#if_eq index compare=0}} class="active" {{/if_eq}}>
<a href="#compare-examples-{{../../article.id}}-{{index}}"><ins>{{{source.title}}}</ins></a>
</li>
{{/if}}
{{#if typeDel}}
{{/if}} {{#if typeDel}}
<li{{#if_eq index compare=0}} class="active" {{/if_eq}}>
<a href="#compare-examples-{{../../article.id}}-{{index}}"><del>{{{compare.title}}}</del></a>
</li>
{{/if}}
{{/each_compare_title}}
{{/if}} {{/each_compare_title}}
</ul>
<div class="tab-content">
{{#each_compare_title article.examples compare.examples}}
{{#if typeSame}}
{{#each_compare_title article.examples compare.examples}} {{#if typeSame}}
<div class="tab-pane{{#if_eq index compare=0}} active{{/if_eq}}" id="compare-examples-{{../../article.id}}-{{index}}">
<pre class="prettyprint language-{{source.type}}" data-type="{{source.type}}"><code>{{{showDiff source.content compare.content}}}</code></pre>
</div>
{{/if}}
{{#if typeIns}}
{{/if}} {{#if typeIns}}
<div class="tab-pane{{#if_eq index compare=0}} active{{/if_eq}}" id="compare-examples-{{../../article.id}}-{{index}}">
<pre class="prettyprint language-{{source.type}}" data-type="{{source.type}}"><code>{{{source.content}}}</code></pre>
</div>
{{/if}}
{{#if typeDel}}
{{/if}} {{#if typeDel}}
<div class="tab-pane{{#if_eq index compare=0}} active{{/if_eq}}" id="compare-examples-{{../../article.id}}-{{index}}">
<pre class="prettyprint language-{{source.type}}" data-type="{{compare.type}}"><code>{{{compare.content}}}</code></pre>
</div>
{{/if}}
{{/each_compare_title}}
{{/if}} {{/each_compare_title}}
</div>
{{subTemplate "article-compare-param-block" source=article.parameter compare=compare.parameter _hasType=_hasTypeInParameterFields section="parameter"}}
{{subTemplate "article-compare-param-block" source=article.success compare=compare.success _hasType=_hasTypeInSuccessFields section="success"}}
{{subTemplate "article-compare-param-block" source=article.error compare=compare.error _col1="Name" _hasType=_hasTypeInErrorFields section="error"}}
{{subTemplate "article-sample-request" article=article id=id}}
{{subTemplate "article-compare-param-block" source=article.parameter compare=compare.parameter _hasType=_hasTypeInParameterFields section="parameter"}} {{subTemplate "article-compare-param-block" source=article.success compare=compare.success _hasType=_hasTypeInSuccessFields
section="success"}} {{subTemplate "article-compare-param-block" source=article.error compare=compare.error _col1="Name" _hasType=_hasTypeInErrorFields section="error"}} {{subTemplate "article-sample-request" article=article id=id}}
</article>
</script>
<script id="template-article-compare-permission" type="text/x-handlebars-template">
<p>
{{__ "Permission:"}}
{{#each_compare_list_field article.permission compare.permission field="name"}}
{{#if source}}
{{#if typeSame}}
{{source.name}}
{{#if source.title}}
{{__ "Permission:"}} {{#each_compare_list_field article.permission compare.permission field="name"}} {{#if source}} {{#if typeSame}} {{source.name}} {{#if source.title}}
<button type="button" class="btn btn-info btn-xs" data-title="{{source.title}}" data-content="{{nl2br source.description}}" data-html="true" data-toggle="popover" data-placement="right" data-trigger="hover">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</button>
{{#unless _last}}, {{/unless}}
{{/if}}
{{/if}}
{{#if typeIns}}
<ins>{{source.name}}</ins>
{{#if source.title}}
</button> {{#unless _last}}, {{/unless}} {{/if}} {{/if}} {{#if typeIns}}
<ins>{{source.name}}</ins> {{#if source.title}}
<button type="button" class="btn btn-info btn-xs" data-title="{{source.title}}" data-content="{{nl2br source.description}}" data-html="true" data-toggle="popover" data-placement="right" data-trigger="hover">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</button>
{{#unless _last}}, {{/unless}}
{{/if}}
{{/if}}
{{#if typeDel}}
<del>{{source.name}}</del>
{{#if source.title}}
</button> {{#unless _last}}, {{/unless}} {{/if}} {{/if}} {{#if typeDel}}
<del>{{source.name}}</del> {{#if source.title}}
<button type="button" class="btn btn-info btn-xs" data-title="{{source.title}}" data-content="{{nl2br source.description}}" data-html="true" data-toggle="popover" data-placement="right" data-trigger="hover">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</button>
{{#unless _last}}, {{/unless}}
{{/if}}
{{/if}}
{{else}}
{{#if typeSame}}
{{compare.name}}
{{#if compare.title}}
</button> {{#unless _last}}, {{/unless}} {{/if}} {{/if}} {{else}} {{#if typeSame}} {{compare.name}} {{#if compare.title}}
<button type="button" class="btn btn-info btn-xs" data-title="{{compare.title}}" data-content="{{nl2br compare.description}}" data-html="true" data-toggle="popover" data-placement="right" data-trigger="hover">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</button>
{{#unless _last}}, {{/unless}}
{{/if}}
{{/if}}
{{#if typeIns}}
<ins>{{compare.name}}</ins>
{{#if compare.title}}
</button> {{#unless _last}}, {{/unless}} {{/if}} {{/if}} {{#if typeIns}}
<ins>{{compare.name}}</ins> {{#if compare.title}}
<button type="button" class="btn btn-info btn-xs" data-title="{{compare.title}}" data-content="{{nl2br compare.description}}" data-html="true" data-toggle="popover" data-placement="right" data-trigger="hover">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</button>
{{#unless _last}}, {{/unless}}
{{/if}}
{{/if}}
{{#if typeDel}}
<del>{{compare.name}}</del>
{{#if compare.title}}
</button> {{#unless _last}}, {{/unless}} {{/if}} {{/if}} {{#if typeDel}}
<del>{{compare.name}}</del> {{#if compare.title}}
<button type="button" class="btn btn-info btn-xs" data-title="{{compare.title}}" data-content="{{nl2br compare.description}}" data-html="true" data-toggle="popover" data-placement="right" data-trigger="hover">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</button>
{{#unless _last}}, {{/unless}}
{{/if}}
{{/if}}
{{/if}}
{{/each_compare_list_field}}
</button> {{#unless _last}}, {{/unless}} {{/if}} {{/if}} {{/if}} {{/each_compare_list_field}}
</p>
</script>
<script id="template-article-compare-param-block" type="text/x-handlebars-template">
{{#if source}}
{{#each_compare_keys source.fields compare.fields}}
{{#if typeSame}}
{{#if source}} {{#each_compare_keys source.fields compare.fields}} {{#if typeSame}}
<h2>{{__ source.key}}</h2>
<table>
<thead>
<tr>
<th style="width: 30%">{{#if ../_col1}}{{__ ../_col1}}{{else}}{{__ "Field"}}{{/if}}</th>
{{#if ../_hasType}}<th style="width: 10%">{{__ "Type"}}</th>{{/if}}
{{#if ../_hasType}}
<th style="width: 10%">{{__ "Type"}}</th>{{/if}}
<th style="width: {{#if ../_hasType}}60%{{else}}70%{{/if}}">{{__ "Description"}}</th>
</tr>
</thead>
{{subTemplate "article-compare-param-block-body" source=source.value compare=compare.value _hasType=../_hasType}}
</table>
{{/if}}
{{#if typeIns}}
{{/if}} {{#if typeIns}}
<h2><ins>{{__ source.key}}</ins></h2>
<table class="ins">
<thead>
<tr>
<th style="width: 30%">{{#if ../_col1}}{{__ ../_col1}}{{else}}{{__ "Field"}}{{/if}}</th>
{{#if ../_hasType}}<th style="width: 10%">{{__ "Type"}}</th>{{/if}}
{{#if ../_hasType}}
<th style="width: 10%">{{__ "Type"}}</th>{{/if}}
<th style="width: {{#if ../_hasType}}60%{{else}}70%{{/if}}">{{__ "Description"}}</th>
</tr>
</thead>
{{subTemplate "article-compare-param-block-body" source=source.value compare=source.value _hasType=../_hasType}}
</table>
{{/if}}
{{#if typeDel}}
{{/if}} {{#if typeDel}}
<h2><del>{{__ compare.key}}</del></h2>
<table class="del">
<thead>
<tr>
<th style="width: 30%">{{#if ../_col1}}{{__ ../_col1}}{{else}}{{__ "Field"}}{{/if}}</th>
{{#if ../_hasType}}<th style="width: 10%">{{__ "Type"}}</th>{{/if}}
{{#if ../_hasType}}
<th style="width: 10%">{{__ "Type"}}</th>{{/if}}
<th style="width: {{#if ../_hasType}}60%{{else}}70%{{/if}}">{{__ "Description"}}</th>
</tr>
</thead>
{{subTemplate "article-compare-param-block-body" source=compare.value compare=compare.value _hasType=../_hasType}}
</table>
{{/if}}
{{/each_compare_keys}}
{{#if source.examples}}
{{/if}} {{/each_compare_keys}} {{#if source.examples}}
<ul class="nav nav-tabs nav-tabs-examples">
{{#each_compare_title source.examples compare.examples}}
{{#if typeSame}}
{{#each_compare_title source.examples compare.examples}} {{#if typeSame}}
<li{{#if_eq index compare=0}} class="active" {{/if_eq}}>
<a href="#{{../../section}}-compare-examples-{{../../article.id}}-{{index}}">{{{showDiff source.title compare.title}}}</a>
</li>
{{/if}}
{{#if typeIns}}
{{/if}} {{#if typeIns}}
<li{{#if_eq index compare=0}} class="active" {{/if_eq}}>
<a href="#{{../../section}}-compare-examples-{{../../article.id}}-{{index}}"><ins>{{{source.title}}}</ins></a>
</li>
{{/if}}
{{#if typeDel}}
{{/if}} {{#if typeDel}}
<li{{#if_eq index compare=0}} class="active" {{/if_eq}}>
<a href="#{{../../section}}-compare-examples-{{../../article.id}}-{{index}}"><del>{{{compare.title}}}</del></a>
</li>
{{/if}}
{{/each_compare_title}}
{{/if}} {{/each_compare_title}}
</ul>
<div class="tab-content">
{{#each_compare_title source.examples compare.examples}}
{{#if typeSame}}
{{#each_compare_title source.examples compare.examples}} {{#if typeSame}}
<div class="tab-pane{{#if_eq index compare=0}} active{{/if_eq}}" id="{{../../section}}-compare-examples-{{../../article.id}}-{{index}}">
<pre class="prettyprint language-{{source.type}}" data-type="{{source.type}}"><code>{{{showDiff source.content compare.content}}}</code></pre>
</div>
{{/if}}
{{#if typeIns}}
{{/if}} {{#if typeIns}}
<div class="tab-pane{{#if_eq index compare=0}} active{{/if_eq}}" id="{{../../section}}-compare-examples-{{../../article.id}}-{{index}}">
<pre class="prettyprint language-{{source.type}}" data-type="{{source.type}}"><code>{{{source.content}}}</code></pre>
</div>
{{/if}}
{{#if typeDel}}
{{/if}} {{#if typeDel}}
<div class="tab-pane{{#if_eq index compare=0}} active{{/if_eq}}" id="{{../../section}}-compare-examples-{{../../article.id}}-{{index}}">
<pre class="prettyprint language-{{source.type}}" data-type="{{compare.type}}"><code>{{{compare.content}}}</code></pre>
</div>
{{/if}}
{{/each_compare_title}}
{{/if}} {{/each_compare_title}}
</div>
{{/if}}
{{/if}}
{{/if}} {{/if}}
</script>
<script id="template-article-compare-param-block-body" type="text/x-handlebars-template">
<tbody>
{{#each_compare_field source compare}}
{{#if typeSame}}
{{#each_compare_field source compare}} {{#if typeSame}}
<tr>
<td class="code">
{{{splitFill source.field "." "&nbsp;&nbsp;"}}}
{{#if source.optional}}
{{#if compare.optional}} <span class="label label-optional">{{__ "optional"}}</span>
{{else}} <span class="label label-optional label-ins">{{__ "optional"}}</span>
{{/if}}
{{else}}
{{#if compare.optional}} <span class="label label-optional label-del">{{__ "optional"}}</span>{{/if}}
{{/if}}
{{{splitFill source.field "." "&nbsp;&nbsp;"}}} {{#if source.optional}} {{#if compare.optional}} <span class="label label-optional">{{__ "optional"}}</span> {{else}} <span class="label label-optional label-ins">{{__ "optional"}}</span> {{/if}}
{{else}} {{#if compare.optional}} <span class="label label-optional label-del">{{__ "optional"}}</span>{{/if}} {{/if}}
</td>
{{#if source.type}}
{{#if compare.type}}
{{#if source.type}} {{#if compare.type}}
<td>{{{showDiff source.type compare.type}}}</td>
{{else}}
<td>{{{source.type}}}</td>
{{/if}}
{{else}}
{{#if compare.type}}
{{/if}} {{else}} {{#if compare.type}}
<td>{{{compare.type}}}</td>
{{else}}
{{#if ../../../../_hasType}}<td></td>{{/if}}
{{/if}}
{{/if}}
{{else}} {{#if ../../../../_hasType}}
<td></td>{{/if}} {{/if}} {{/if}}
<td>
{{{showDiff source.description compare.description "nl2br"}}}
{{#if source.defaultValue}}<p class="default-value">{{__ "Default value:"}} <code>{{{showDiff source.defaultValue compare.defaultValue}}}</code><p>{{/if}}
{{{showDiff source.description compare.description "nl2br"}}} {{#if source.defaultValue}}
<p class="default-value">{{__ "Default value:"}} <code>{{{showDiff source.defaultValue compare.defaultValue}}}</code>
<p>{{/if}}
</td>
</tr>
{{/if}}
{{#if typeIns}}
{{/if}} {{#if typeIns}}
<tr class="ins">
<td class="code">
{{{splitFill source.field "." "&nbsp;&nbsp;"}}}
{{#if source.optional}} <span class="label label-optional label-ins">{{__ "optional"}}</span>{{/if}}
{{{splitFill source.field "." "&nbsp;&nbsp;"}}} {{#if source.optional}} <span class="label label-optional label-ins">{{__ "optional"}}</span>{{/if}}
</td>
{{#if source.type}}
<td>{{{source.type}}}</td>
{{else}}
{{{typRowTd}}}
{{/if}}
{{else}} {{{typRowTd}}} {{/if}}
<td>
{{{nl2br source.description}}}
{{#if source.defaultValue}}<p class="default-value">{{__ "Default value:"}} <code>{{{source.defaultValue}}}</code><p>{{/if}}
{{{nl2br source.description}}} {{#if source.defaultValue}}
<p class="default-value">{{__ "Default value:"}} <code>{{{source.defaultValue}}}</code>
<p>{{/if}}
</td>
</tr>
{{/if}}
{{#if typeDel}}
{{/if}} {{#if typeDel}}
<tr class="del">
<td class="code">
{{{splitFill compare.field "." "&nbsp;&nbsp;"}}}
{{#if compare.optional}} <span class="label label-optional label-del">{{__ "optional"}}</span>{{/if}}
{{{splitFill compare.field "." "&nbsp;&nbsp;"}}} {{#if compare.optional}} <span class="label label-optional label-del">{{__ "optional"}}</span>{{/if}}
</td>
{{#if compare.type}}
<td>{{{compare.type}}}</td>
{{else}}
{{{typRowTd}}}
{{/if}}
{{else}} {{{typRowTd}}} {{/if}}
<td>
{{{nl2br compare.description}}}
{{#if compare.defaultValue}}<p class="default-value">{{__ "Default value:"}} <code>{{{compare.defaultValue}}}</code><p>{{/if}}
{{{nl2br compare.description}}} {{#if compare.defaultValue}}
<p class="default-value">{{__ "Default value:"}} <code>{{{compare.defaultValue}}}</code>
<p>{{/if}}
</td>
</tr>
{{/if}}
{{/each_compare_field}}
{{/if}} {{/each_compare_field}}
</tbody>
</script>
@ -652,13 +511,22 @@
<div id="loader">
<div class="spinner">
<div class="spinner-container container1">
<div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div>
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container2">
<div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div>
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container3">
<div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div>
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<p>Loading...</p>
</div>
@ -666,4 +534,5 @@
<script data-main="main.js" src="vendor/require.min.js"></script>
</body>
</html>

Voir le fichier

@ -107,14 +107,21 @@ require([
// sort api within a group by title ASC and custom order
//
var newList = [];
var umlauts = { 'ä': 'ae', 'ü': 'ue', 'ö': 'oe', 'ß': 'ss' }; // TODO: remove in version 1.0
var umlauts = {
'ä': 'ae',
'ü': 'ue',
'ö': 'oe',
'ß': 'ss'
}; // TODO: remove in version 1.0
$.each(apiByGroupAndName, function (index, groupEntries) {
// get titles from the first entry of group[].name[] (name has versioning)
var titles = [];
$.each(groupEntries, function (titleName, entries) {
var title = entries[0].title;
if (title !== undefined) {
title.toLowerCase().replace(/[äöüß]/g, function($0) { return umlauts[$0]; });
title.toLowerCase().replace(/[äöüß]/g, function ($0) {
return umlauts[$0];
});
titles.push(title + '#~#' + titleName); // '#~#' keep reference to titleName after sorting
}
});
@ -293,7 +300,9 @@ require([
$('#generator').append(templateGenerator(apiProject));
// render Project
_.extend(apiProject, { versions: apiVersions});
_.extend(apiProject, {
versions: apiVersions
});
$('#project').append(templateProject(apiProject));
// render apiDoc, header/footer documentation
@ -375,14 +384,19 @@ require([
$('#sections').append(content);
// Bootstrap Scrollspy
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
$(this).scrollspy({
target: '#scrollingNav',
offset: 18
});
// Content-Scroll on Navigation click.
$('.sidenav').find('a').on('click', function (e) {
e.preventDefault();
var id = $(this).attr('href');
if ($(id).length > 0)
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 400);
$('html,body').animate({
scrollTop: parseInt($(id).offset().top)
}, 400);
window.location.hash = $(this).attr('href');
});
@ -390,7 +404,9 @@ require([
if (window.location.hash) {
var id = window.location.hash;
if ($(id).length > 0)
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0);
$('html,body').animate({
scrollTop: parseInt($(id).offset().top)
}, 0);
}
/**
@ -403,7 +419,9 @@ require([
function _hasTypeInFields(fields) {
var result = false;
$.each(fields, function (name) {
result = result || _.some(fields[name], function(item) { return item.type; });
result = result || _.some(fields[name], function (item) {
return item.type;
});
});
return result;
}
@ -519,7 +537,9 @@ require([
if (window.location.hash) {
var id = window.location.hash;
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) - 18 }, 0);
$('html,body').animate({
scrollTop: parseInt($(id).offset().top) - 18
}, 0);
}
}
@ -549,8 +569,7 @@ require([
$('span.search-reset').on('click', function () {
$('#scrollingNav .sidenav-search input.search')
.val("")
.focus()
;
.focus();
endpointsList.search();
});
@ -687,7 +706,9 @@ require([
reversed.forEach(function (item, index) {
var parts = item.field.split(".");
if (parts.length - 1 == dot_count) {
var fields_names = fields.map(function (item) { return item.field; });
var fields_names = fields.map(function (item) {
return item.field;
});
if (parts.slice(1).length >= 1) {
var prefix = parts.slice(0, parts.length - 1).join(".");
var prefix_index = fields_names.indexOf(prefix);

Voir le fichier

@ -13,8 +13,11 @@ import (
var config *Config
var once sync.Once
// Configpaths default configuration file paths
var Configpaths = []string{"config/config.yml", "config/default_config.yml"}
// Get config variable
func Get() *Config {
once.Do(func() {
config = &Config{}

Voir le fichier

@ -54,7 +54,7 @@ func getTorrentList(c *gin.Context) (torrents []models.Torrent, createdAsTime ti
}
if userID != "" {
userIDnum := 0
var userIDnum int
userIDnum, err = strconv.Atoi(html.EscapeString(userID))
// Should we have a feed for anonymous uploads?
if err != nil || userIDnum == 0 {

Voir le fichier

@ -17,7 +17,7 @@ import (
// RSSTorznabHandler : Controller for displaying rss feed, accepting common search arguments
func RSSTorznabHandler(c *gin.Context) {
t := c.Query("t")
rss := ""
var rss string
title := "Nyaa Pantsu"
if config.IsSukebei() {
title = "Sukebei Pantsu"

Voir le fichier

@ -11,7 +11,7 @@ import (
"github.com/gin-gonic/gin"
)
// Middleware for managing errors on status
// ErrorMiddleware for managing errors on status
func ErrorMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
c.Next()

Voir le fichier

@ -113,7 +113,7 @@ func torrentManyAction(c *gin.Context) {
}
/* Changes are done, we save */
_, err := torrent.UpdateUnscope()
_, err = torrent.UpdateUnscope()
if err == nil {
if torrent.Uploader == nil {
torrent.Uploader = &models.User{}

Voir le fichier

@ -14,7 +14,7 @@ func TorrentReassignModPanel(c *gin.Context) {
templates.Form(c, "admin/reassign.jet.html", torrentValidator.ReassignForm{})
}
// ExecuteAction : Function for applying the changes from ReassignForm
// ExecuteReassign : Function for applying the changes from ReassignForm
func ExecuteReassign(f *torrentValidator.ReassignForm) (int, error) {
var toBeChanged []uint
var err error

Voir le fichier

@ -17,13 +17,13 @@ import (
func SeePublicSettingsHandler(c *gin.Context) {
_, Tlang := publicSettings.GetTfuncAndLanguageFromRequest(c)
availableLanguages := publicSettings.GetAvailableLanguages()
languagesJson := templates.LanguagesJSONResponse{Tlang.Tag, availableLanguages}
languagesJSON := templates.LanguagesJSONResponse{Tlang.Tag, availableLanguages}
contentType := c.Request.Header.Get("Content-Type")
if contentType == "application/json" {
c.Header("Content-Type", "application/json")
c.JSON(http.StatusOK, languagesJson)
c.JSON(http.StatusOK, languagesJSON)
} else {
templates.Form(c, "site/user/public/settings.jet.html", languagesJson)
templates.Form(c, "site/user/public/settings.jet.html", languagesJSON)
}
}

Voir le fichier

@ -4,4 +4,4 @@ You can use this API without being logged or any token API
## Except for Upload
When you upload, you have to provide your username and api token!
When you upload, you have to provide your username and API token!

Voir le fichier

@ -6,6 +6,7 @@ import (
"github.com/patrickmn/go-cache"
)
// C global cache variable
var C *cache.Cache
func init() {

Voir le fichier

@ -12,10 +12,12 @@ type Category struct {
Name string
}
// Cateogories is a struct defining an array of categories
// Categories is a struct defining an array of categories
type Categories []Category
var categories Categories
// Index variable
var Index map[string]int
// InitCategories init the categories and index variables. Exported for tests

Voir le fichier

@ -159,7 +159,7 @@ func setUserToContext(c *gin.Context, val *models.User) {
context.Set(c.Request, UserContextKey, val)
}
// RetrieveUser retrieves a user.
// RetrieveUserFromRequest retrieves a user.
func RetrieveUserFromRequest(c *gin.Context, id uint) (*models.User, bool, uint, int, error) {
var user models.User
var currentUserID uint

Voir le fichier

@ -13,7 +13,7 @@ import (
"github.com/gorilla/feeds"
)
// private wrapper around the RssFeed which gives us the <rss>..</rss> xml
// rssFeedXML private wrapper around the RssFeed which gives us the <rss>..</rss> xml
type rssFeedXML struct {
XMLName xml.Name `xml:"rss"`
Xmlns string `xml:"xmlns:torznab,attr,omitempty"`
@ -23,6 +23,7 @@ type rssFeedXML struct {
Caps *RssCaps `xml:"caps,omitempty"`
}
// RssImage RSS image struct
type RssImage struct {
XMLName xml.Name `xml:"image"`
URL string `xml:"url"`
@ -32,6 +33,7 @@ type RssImage struct {
Height int `xml:"height,omitempty"`
}
// RssTextInput RSS text struct
type RssTextInput struct {
XMLName xml.Name `xml:"textInput"`
Title string `xml:"title"`
@ -40,11 +42,13 @@ type RssTextInput struct {
Link string `xml:"link"`
}
// RssMagnetLink RSS struct for magnet links
type RssMagnetLink struct {
XMLName xml.Name `xml:"link"`
Text string `xml:",cdata"`
}
// RssFeed RSS feed struct
type RssFeed struct {
XMLName xml.Name `xml:"channel"`
Xmlns string `xml:"-"`
@ -70,6 +74,7 @@ type RssFeed struct {
Items []*RssItem
}
// RssItem struct for rss feed items
type RssItem struct {
XMLName xml.Name `xml:"item"`
Title string `xml:"title"` // required
@ -86,6 +91,7 @@ type RssItem struct {
Torznab []*RssTorznab
}
// RssCaps xml struct for torznab caps
type RssCaps struct {
XMLName xml.Name `xml:"caps"`
Server *RssServer `xml:"server,omitempty"`
@ -95,6 +101,7 @@ type RssCaps struct {
Categories *RssCategories `xml:"categories,omitempty"`
}
// RssServer basic server information
type RssServer struct {
XMLName xml.Name `xml:"server"`
Xmlns string `xml:"xmlns,attr"`
@ -106,18 +113,21 @@ type RssServer struct {
Image string `xml:"image,attr"`
}
// RssLimits struct for max results
type RssLimits struct {
XMLName xml.Name `xml:"limits"`
Max string `xml:"max,attr"`
Default string `xml:"default,attr"`
}
// RssRegistration torznab registration information
type RssRegistration struct {
XMLName xml.Name `xml:"registration"`
Available string `xml:"available,attr"`
Open string `xml:"open,attr"`
}
// RssSearching struct for supported search types
type RssSearching struct {
XMLName xml.Name `xml:"searching"`
Search *RssSearch `xml:"search,omitempty"`
@ -125,16 +135,19 @@ type RssSearching struct {
MovieSearch *RssSearch `xml:"movie-search,omitempty"`
}
// RssSearch struct for supported searching params
type RssSearch struct {
Available string `xml:"available,attr"`
SupportedParams string `xml:"supportedParams,attr,omitempty"`
}
// RssCategories categories for rss
type RssCategories struct {
XMLName xml.Name `xml:"categories"`
Category []*RssCategoryTorznab
}
// RssCategoryTorznab categories for torznab
type RssCategoryTorznab struct {
XMLName xml.Name `xml:"category"`
ID string `xml:"id,attr"`
@ -143,6 +156,7 @@ type RssCategoryTorznab struct {
Description string `xml:"description,attr,omitempty"`
}
// RssSubCat sub category
type RssSubCat struct {
XMLName xml.Name `xml:"subcat"`
ID string `xml:"id,attr"`
@ -150,6 +164,7 @@ type RssSubCat struct {
Description string `xml:"description,attr,omitempty"`
}
// RssTorrent item for torrents
type RssTorrent struct {
XMLName xml.Name `xml:"torrent"`
Xmlns string `xml:"xmlns,attr"`
@ -159,6 +174,7 @@ type RssTorrent struct {
MagnetURI string `xml:"magnetUri,omitempty"`
}
// RssTorznab feed for torznab
type RssTorznab struct {
XMLName xml.Name `xml:"torznab:attr,omitempty"`
Name string `xml:"name,attr,omitempty"`
@ -171,6 +187,7 @@ type RssCategory struct {
Domain string `xml:"domain"`
}
// RssEnclosure enclosure for downloads
type RssEnclosure struct {
//RSS 2.0 <enclosure url="http://example.com/file.mp3" length="123456789" type="audio/mpeg" />
XMLName xml.Name `xml:"enclosure"`
@ -179,6 +196,7 @@ type RssEnclosure struct {
Type string `xml:"type,attr"`
}
// Rss struct
type Rss struct {
*feeds.Feed
}
@ -241,22 +259,22 @@ func (r *Rss) RssFeed() *RssFeed {
return channel
}
// FeedXml : return an XML-Ready object for an Rss object
func (r *Rss) FeedXml() interface{} {
// FeedXML : return an XML-Ready object for an Rss object
func (r *Rss) FeedXML() interface{} {
// only generate version 2.0 feeds for now
return r.RssFeed().FeedXml()
return r.RssFeed().FeedXML()
}
// FeedXml : return an XML-ready object for an RssFeed object
func (r *RssFeed) FeedXml() interface{} {
// FeedXML : return an XML-ready object for an RssFeed object
func (r *RssFeed) FeedXML() interface{} {
if r.Xmlns != "" {
return &rssFeedXML{Version: "2.0", Encoding: "UTF-8", Channel: r, Xmlns: r.Xmlns}
}
return &rssFeedXML{Version: "2.0", Encoding: "UTF-8", Channel: r}
}
// FeedXml : return an XML-ready object for an RssFeed object
func (r *RssCaps) FeedXml() interface{} {
// FeedXML : return an XML-ready object for an RssFeed object
func (r *RssCaps) FeedXML() interface{} {
return r
}

Voir le fichier

@ -29,10 +29,11 @@ var htmlFlags = 0 |
md.HTML_HREF_TARGET_BLANK
func init() {
HtmlMdRenderer = md.HtmlRenderer(htmlFlags, "", "")
HTMLMdRenderer = md.HtmlRenderer(htmlFlags, "", "")
}
var HtmlMdRenderer md.Renderer
// HTMLMdRenderer render for markdown to html
var HTMLMdRenderer md.Renderer
// MarkdownToHTML : convert markdown to html
// TODO: restrict certain types of markdown
@ -41,7 +42,7 @@ func MarkdownToHTML(markdown string) template.HTML {
markdown = ">" + markdown[4:]
}
markdown = strings.Replace(markdown, "\n&gt;", "\n>", -1)
unsafe := md.MarkdownOptions([]byte(markdown), HtmlMdRenderer, md.Options{Extensions: mdOptions})
unsafe := md.MarkdownOptions([]byte(markdown), HTMLMdRenderer, md.Options{Extensions: mdOptions})
html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
return template.HTML(html)
}

Voir le fichier

@ -2,6 +2,7 @@ package structs
import "github.com/NyaaPantsu/nyaa/models"
// TorrentCache torrent cache struct
type TorrentCache struct {
Torrents []models.Torrent
Count int

Voir le fichier

@ -17,19 +17,34 @@ import (
)
const (
// ShowAll by default show all torrents
ShowAll Status = 0
// FilterRemakes filter torrent remakes
FilterRemakes = 2
// Trusted trusted torrents
Trusted = 3
// APlus torrents not used anymore
APlus = 4
)
// Status torrent status
type Status uint8
// SortMode selected sort mode
type SortMode uint8
// Category torrent categories
type Category struct {
Main, Sub uint8
}
// SizeBytes size in bytes
type SizeBytes uint64
// DateFilter date to filter for
type DateFilter string
// Categories multiple torrent categories
type Categories []*Category
// TorrentParam defines all parameters that can be provided when searching for a torrent

Voir le fichier

@ -13,6 +13,7 @@ var intEvents struct {
funcs []func()
}
// OnInterrupt handles signal interupts
func OnInterrupt(fn func()) {
intEvents.lock.Lock()
intEvents.funcs = append(intEvents.funcs, fn)

Voir le fichier

@ -8,6 +8,7 @@ import (
"syscall"
)
// Handle handles unix interupts
func Handle() {
chnl := make(chan os.Signal)
signal.Notify(chnl, syscall.SIGHUP, os.Interrupt)

Voir le fichier

@ -139,6 +139,7 @@ func IsUTFLetterNumericValidator(fl validator.FieldLevel) bool {
return IsUTFLetterNumeric(value)
}
// DefaultValidator default validator
func DefaultValidator(fl validator.FieldLevel) bool {
switch fl.Field().Kind() {
case reflect.String: