#181 Fix links are not cleaned before being sent to the webui. Fix failed requests not being forwarded to the caller. Add size display to web ui.

This commit is contained in:
KZ
2015-09-21 18:48:53 +01:00
parent f45c58b2bd
commit e8bb1680f3
7 changed files with 1170 additions and 1115 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' /> <link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
<script src="/libs/filesize.min.js"></script>
<script src="/libs/jquery.min.js"></script> <script src="/libs/jquery.min.js"></script>
<script src="/libs/jquery.dataTables.min.js"></script> <script src="/libs/jquery.dataTables.min.js"></script>
<script src="/libs/handlebars.min.js"></script> <script src="/libs/handlebars.min.js"></script>
@@ -202,6 +203,8 @@
<th>First Seen</th> <th>First Seen</th>
<th>Tracker</th> <th>Tracker</th>
<th>Name</th> <th>Name</th>
<th>Size</th>
<th>Size</th>
<th>Category</th> <th>Category</th>
<th>Seeds</th> <th>Seeds</th>
<th>Leechers</th> <th>Leechers</th>
@@ -217,6 +220,8 @@
<td>{{jacketTimespan FirstSeen}}</td> <td>{{jacketTimespan FirstSeen}}</td>
<td>{{Tracker}}</td> <td>{{Tracker}}</td>
<td><a href="{{Comments}}">{{Title}}</a></td> <td><a href="{{Comments}}">{{Title}}</a></td>
<td>{{Size}}</td>
<td>{{jacketSize Size}}</td>
<td>{{CategoryDesc}}</td> <td>{{CategoryDesc}}</td>
<td>{{Seeders}}</td> <td>{{Seeders}}</td>
<td>{{Peers}}</td> <td>{{Peers}}</td>
@@ -296,6 +301,8 @@
<th>Published</th> <th>Published</th>
<th>Tracker</th> <th>Tracker</th>
<th>Name</th> <th>Name</th>
<th>Size</th>
<th>Size</th>
<th>Category</th> <th>Category</th>
<th>Seeds</th> <th>Seeds</th>
<th>Leechers</th> <th>Leechers</th>
@@ -309,6 +316,8 @@
<td>{{jacketTimespan PublishDate}}</td> <td>{{jacketTimespan PublishDate}}</td>
<td>{{Tracker}}</td> <td>{{Tracker}}</td>
<td><a href="{{Comments}}">{{Title}}</a></td> <td><a href="{{Comments}}">{{Title}}</a></td>
<td>{{Size}}</td>
<td>{{jacketSize Size}}</td>
<td>{{CategoryDesc}}</td> <td>{{CategoryDesc}}</td>
<td>{{Seeders}}</td> <td>{{Seeders}}</td>
<td>{{Peers}}</td> <td>{{Peers}}</td>

View File

@@ -0,0 +1,6 @@
/*
2015 Jason Mulligan
@version 3.1.2
*/
"use strict"; !function (a) { var b = /b$/, c = { bits: ["B", "kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"], bytes: ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] }, d = function (a) { var d = void 0 === arguments[1] ? {} : arguments[1], e = [], f = !1, g = 0, h = void 0, i = void 0, j = void 0, k = void 0, l = void 0, m = void 0, n = void 0, o = void 0, p = void 0, q = void 0, r = void 0; if (isNaN(a)) throw new Error("Invalid arguments"); return j = d.bits === !0, p = d.unix === !0, i = void 0 !== d.base ? d.base : 2, o = void 0 !== d.round ? d.round : p ? 1 : 2, q = void 0 !== d.spacer ? d.spacer : p ? "" : " ", r = void 0 !== d.suffixes ? d.suffixes : {}, n = void 0 !== d.output ? d.output : "string", h = void 0 !== d.exponent ? d.exponent : -1, m = Number(a), l = 0 > m, k = i > 2 ? 1e3 : 1024, l && (m = -m), 0 === m ? (e[0] = 0, e[1] = p ? "" : "B") : ((-1 === h || isNaN(h)) && (h = Math.floor(Math.log(m) / Math.log(k))), h > 8 && (g = 1e3 * g * (h - 8), h = 8), g = 2 === i ? m / Math.pow(2, 10 * h) : m / Math.pow(1e3, h), j && (g = 8 * g, g > k && (g /= k, h++)), e[0] = Number(g.toFixed(h > 0 ? o : 0)), e[1] = c[j ? "bits" : "bytes"][h], !f && p && (j && b.test(e[1]) && (e[1] = e[1].toLowerCase()), e[1] = e[1].charAt(0), "B" === e[1] ? (e[0] = Math.floor(e[0]), e[1] = "") : j || "k" !== e[1] || (e[1] = "K"))), l && (e[0] = -e[0]), e[1] = r[e[1]] || e[1], "array" === n ? e : "exponent" === n ? h : "object" === n ? { value: e[0], suffix: e[1] } : e.join(q) }; "undefined" != typeof exports ? module.exports = d : "function" == typeof define ? define(function () { return d }) : a.filesize = d }("undefined" != typeof global ? global : window);
//# sourceMappingURL=filesize.min.js.map

View File

@@ -1,33 +1,37 @@
 
Handlebars.registerHelper('dateFormat', function (context, block) { Handlebars.registerHelper('dateFormat', function (context, block) {
if (window.moment) { if (window.moment) {
var f = block.hash.format || "MMM DD, YYYY hh:mm:ss A"; var f = block.hash.format || "MMM DD, YYYY hh:mm:ss A";
return moment(context).format(f); //had to remove Date(context) return moment(context).format(f); //had to remove Date(context)
} else { } else {
return context; // moment plugin not available. return data as is. return context; // moment plugin not available. return data as is.
}; };
}); });
Handlebars.registerHelper('jacketTimespan', function (context, block) { Handlebars.registerHelper('jacketTimespan', function (context, block) {
var now = moment(); var now = moment();
var from = moment(context); var from = moment(context);
var timeSpan = moment.duration(now.diff(from)); var timeSpan = moment.duration(now.diff(from));
var minutes = timeSpan.asMinutes(); var minutes = timeSpan.asMinutes();
if (minutes < 120) { if (minutes < 120) {
return Math.round(minutes) + 'm ago'; return Math.round(minutes) + 'm ago';
} }
var hours = timeSpan.asHours(); var hours = timeSpan.asHours();
if (hours < 48) { if (hours < 48) {
return Math.round(hours) + 'h ago'; return Math.round(hours) + 'h ago';
} }
var days = timeSpan.asDays(); var days = timeSpan.asDays();
if (days < 365) { if (days < 365) {
return Math.round(days) + 'd ago'; return Math.round(days) + 'd ago';
} }
var years = timeSpan.asYears(); var years = timeSpan.asYears();
return Math.round(years) + 'y ago'; return Math.round(years) + 'y ago';
});
Handlebars.registerHelper('jacketSize', function (context, block) {
return filesize(context, { round: 1 });
}); });

File diff suppressed because it is too large Load Diff

View File

@@ -83,6 +83,11 @@ namespace Jackett.Indexers
public Uri UncleanLink(Uri link) public Uri UncleanLink(Uri link)
{ {
if (link.ToString().StartsWith(downloadUrlBase))
{
return link;
}
return new Uri(downloadUrlBase + link.ToString(), UriKind.RelativeOrAbsolute); return new Uri(downloadUrlBase + link.ToString(), UriKind.RelativeOrAbsolute);
} }
@@ -223,6 +228,11 @@ namespace Jackett.Indexers
public async virtual Task<byte[]> Download(Uri link) public async virtual Task<byte[]> Download(Uri link)
{ {
var response = await RequestBytesWithCookiesAndRetry(link.ToString()); var response = await RequestBytesWithCookiesAndRetry(link.ToString());
if(response.Status != System.Net.HttpStatusCode.OK && response.Status != System.Net.HttpStatusCode.Continue && response.Status != System.Net.HttpStatusCode.PartialContent)
{
throw new Exception($"Remote server returned {response.Status.ToString()}");
}
return response.Content; return response.Content;
} }

View File

@@ -368,6 +368,7 @@
<Content Include="Content\custom.js"> <Content Include="Content\custom.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\libs\filesize.min.js" />
<Content Include="Content\fonts\fontawesome-webfont.svg"> <Content Include="Content\fonts\fontawesome-webfont.svg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>