Add torrent file explorer

This commit is contained in:
2022-01-11 18:53:01 +01:00
parent 8719d9b0f9
commit dabef31fa9
14 changed files with 260 additions and 227 deletions

View File

@@ -249,7 +249,7 @@ h1, h2, h3, h4, h5, h6, .light {
h1 {
font-size: 2.5em;
text-align: center;
margin-bottom: 50px;
margin-bottom: 1em;
}
h2 {
font-size: 2em;
@@ -405,24 +405,25 @@ input[type="color"],
select {
display: inline-block;
border-radius: 6px;
border: none;
margin: 3px;
background: linear-gradient(var(--input_color), var(--input_color_dark));
padding: 5px 5px 5px 5px;
box-shadow: 1px 1px 5px -3px var(--shadow_color);
line-height: 1em;
overflow: hidden;
font-size: 1em; /* Sometimes user-agents have different font sizes for buttons and links */
font-weight: normal;
text-decoration: none;
text-shadow: none;
color: #bfbfbf; /* Fallback */
color: var(--input_text_color);
outline: 0;
vertical-align: middle;
align-items: center;
cursor: pointer;
transition: padding 0.2s, box-shadow 0.2s;
/* Remove default styles set by the user-agent */
outline: 0;
font-size: 1em;
font-weight: normal;
line-height: 1em;
text-decoration: none;
text-shadow: none;
border: none;
}
button:hover,
.button:hover,
@@ -471,6 +472,11 @@ select:disabled , select.disabled {
padding: 4px 5px 4px 5px;
cursor: not-allowed;
}
button > *,
.button > * {
vertical-align: middle;
line-height: 1em;
}
.round {
border-radius: 32px;

230
svelte/package-lock.json generated
View File

@@ -8,8 +8,7 @@
"name": "svelte-app",
"version": "1.0.0",
"dependencies": {
"chart.js": "^3.6.2",
"sirv-cli": "^1.0.0"
"chart.js": "^3.6.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^14.0.0",
@@ -57,11 +56,6 @@
"node": ">=6.9.0"
}
},
"node_modules/@polka/url": {
"version": "1.0.0-next.21",
"resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.21.tgz",
"integrity": "sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g=="
},
"node_modules/@rollup/plugin-commonjs": {
"version": "14.0.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-14.0.0.tgz",
@@ -148,6 +142,20 @@
"@types/node": "*"
}
},
"node_modules/acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"dev": true,
"optional": true,
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
@@ -301,14 +309,6 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"node_modules/console-clear": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/console-clear/-/console-clear-1.1.1.tgz",
"integrity": "sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ==",
"engines": {
"node": ">=4"
}
},
"node_modules/deep-freeze": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/deep-freeze/-/deep-freeze-0.0.1.tgz",
@@ -377,14 +377,6 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"node_modules/get-port": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz",
"integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw=",
"engines": {
"node": ">=4"
}
},
"node_modules/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
@@ -564,14 +556,6 @@
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
},
"node_modules/kleur": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
"engines": {
"node": ">=6"
}
},
"node_modules/livereload": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/livereload/-/livereload-0.9.3.tgz",
@@ -596,14 +580,6 @@
"integrity": "sha512-w677WnINxFkuixAoUEXOStewzLYGI76XVag+0JWMMEyjJQKs0ibWZMxkTlB96Lm3EjZ7IeOxVziBEbtxVQqQZA==",
"dev": true
},
"node_modules/local-access": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/local-access/-/local-access-1.1.0.tgz",
"integrity": "sha512-XfegD5pyTAfb+GY6chk283Ox5z8WexG56OvM06RWLpAc/UHozO8X6xAxEkIitZOtsSMM1Yr3DkHgW5W+onLhCw==",
"engines": {
"node": ">=6"
}
},
"node_modules/magic-string": {
"version": "0.25.7",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
@@ -631,22 +607,6 @@
"node": "*"
}
},
"node_modules/mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
"engines": {
"node": ">=4"
}
},
"node_modules/mrmime": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.0.tgz",
"integrity": "sha512-a70zx7zFfVO7XpnQ2IX1Myh9yY4UYvfld/dikWRnsXxbyvMcfz+u6UfgNAtH+k2QqtJuzVpv6eLTx1G2+WKZbQ==",
"engines": {
"node": ">=10"
}
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@@ -810,17 +770,6 @@
"integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==",
"dev": true
},
"node_modules/sade": {
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/sade/-/sade-1.7.4.tgz",
"integrity": "sha512-y5yauMD93rX840MwUJr7C1ysLFBgMspsdTo4UVrDg3fXDvtwOyIqykhVAAm6fk/3au77773itJStObgK+LKaiA==",
"dependencies": {
"mri": "^1.1.0"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -841,14 +790,6 @@
}
]
},
"node_modules/semiver": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
"integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
"engines": {
"node": ">=6"
}
},
"node_modules/serialize-javascript": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
@@ -858,40 +799,6 @@
"randombytes": "^2.1.0"
}
},
"node_modules/sirv": {
"version": "1.0.19",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.19.tgz",
"integrity": "sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ==",
"dependencies": {
"@polka/url": "^1.0.0-next.20",
"mrmime": "^1.0.0",
"totalist": "^1.0.0"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/sirv-cli": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.14.tgz",
"integrity": "sha512-yyUTNr984ANKDloqepkYbBSqvx3buwYg2sQKPWjSU+IBia5loaoka2If8N9CMwt8AfP179cdEl7kYJ//iWJHjQ==",
"dependencies": {
"console-clear": "^1.1.0",
"get-port": "^3.2.0",
"kleur": "^3.0.0",
"local-access": "^1.0.1",
"sade": "^1.6.0",
"semiver": "^1.0.0",
"sirv": "^1.0.13",
"tinydate": "^1.0.0"
},
"bin": {
"sirv": "bin.js"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/source-map": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
@@ -972,14 +879,6 @@
}
}
},
"node_modules/tinydate": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/tinydate/-/tinydate-1.3.0.tgz",
"integrity": "sha512-7cR8rLy2QhYHpsBDBVYnnWXm8uRTr38RoZakFSW7Bs7PzfMPNZthuMLkwqZv7MTu8lhQ91cOFYS5a7iFj2oR3w==",
"engines": {
"node": ">=4"
}
},
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
@@ -992,14 +891,6 @@
"node": ">=8.0"
}
},
"node_modules/totalist": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/totalist/-/totalist-1.1.0.tgz",
"integrity": "sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==",
"engines": {
"node": ">=6"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
@@ -1055,11 +946,6 @@
"js-tokens": "^4.0.0"
}
},
"@polka/url": {
"version": "1.0.0-next.21",
"resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.21.tgz",
"integrity": "sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g=="
},
"@rollup/plugin-commonjs": {
"version": "14.0.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-14.0.0.tgz",
@@ -1128,6 +1014,14 @@
"@types/node": "*"
}
},
"acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"dev": true,
"optional": true,
"peer": true
},
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
@@ -1255,11 +1149,6 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"console-clear": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/console-clear/-/console-clear-1.1.1.tgz",
"integrity": "sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ=="
},
"deep-freeze": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/deep-freeze/-/deep-freeze-0.0.1.tgz",
@@ -1312,11 +1201,6 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"get-port": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz",
"integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw="
},
"glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
@@ -1459,11 +1343,6 @@
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
},
"kleur": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w=="
},
"livereload": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/livereload/-/livereload-0.9.3.tgz",
@@ -1482,11 +1361,6 @@
"integrity": "sha512-w677WnINxFkuixAoUEXOStewzLYGI76XVag+0JWMMEyjJQKs0ibWZMxkTlB96Lm3EjZ7IeOxVziBEbtxVQqQZA==",
"dev": true
},
"local-access": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/local-access/-/local-access-1.1.0.tgz",
"integrity": "sha512-XfegD5pyTAfb+GY6chk283Ox5z8WexG56OvM06RWLpAc/UHozO8X6xAxEkIitZOtsSMM1Yr3DkHgW5W+onLhCw=="
},
"magic-string": {
"version": "0.25.7",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
@@ -1511,16 +1385,6 @@
"brace-expansion": "^1.1.7"
}
},
"mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="
},
"mrmime": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.0.tgz",
"integrity": "sha512-a70zx7zFfVO7XpnQ2IX1Myh9yY4UYvfld/dikWRnsXxbyvMcfz+u6UfgNAtH+k2QqtJuzVpv6eLTx1G2+WKZbQ=="
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@@ -1652,25 +1516,12 @@
}
}
},
"sade": {
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/sade/-/sade-1.7.4.tgz",
"integrity": "sha512-y5yauMD93rX840MwUJr7C1ysLFBgMspsdTo4UVrDg3fXDvtwOyIqykhVAAm6fk/3au77773itJStObgK+LKaiA==",
"requires": {
"mri": "^1.1.0"
}
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"dev": true
},
"semiver": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
"integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg=="
},
"serialize-javascript": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
@@ -1680,31 +1531,6 @@
"randombytes": "^2.1.0"
}
},
"sirv": {
"version": "1.0.19",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.19.tgz",
"integrity": "sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ==",
"requires": {
"@polka/url": "^1.0.0-next.20",
"mrmime": "^1.0.0",
"totalist": "^1.0.0"
}
},
"sirv-cli": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.14.tgz",
"integrity": "sha512-yyUTNr984ANKDloqepkYbBSqvx3buwYg2sQKPWjSU+IBia5loaoka2If8N9CMwt8AfP179cdEl7kYJ//iWJHjQ==",
"requires": {
"console-clear": "^1.1.0",
"get-port": "^3.2.0",
"kleur": "^3.0.0",
"local-access": "^1.0.1",
"sade": "^1.6.0",
"semiver": "^1.0.0",
"sirv": "^1.0.13",
"tinydate": "^1.0.0"
}
},
"source-map": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
@@ -1761,11 +1587,6 @@
"source-map-support": "~0.5.20"
}
},
"tinydate": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/tinydate/-/tinydate-1.3.0.tgz",
"integrity": "sha512-7cR8rLy2QhYHpsBDBVYnnWXm8uRTr38RoZakFSW7Bs7PzfMPNZthuMLkwqZv7MTu8lhQ91cOFYS5a7iFj2oR3w=="
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
@@ -1775,11 +1596,6 @@
"is-number": "^7.0.0"
}
},
"totalist": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/totalist/-/totalist-1.1.0.tgz",
"integrity": "sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g=="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@@ -17,7 +17,6 @@
"svelte": "^3.0.0"
},
"dependencies": {
"chart.js": "^3.6.2",
"sirv-cli": "^1.0.0"
"chart.js": "^3.6.2"
}
}

View File

@@ -34,7 +34,9 @@ export const file_set_href = file => {
file.timeseries_href = window.api_endpoint+"/file/"+file.id+"/timeseries"
}
export const file_type = file => {
if (file.mime_type.startsWith("image")) {
if (file.mime_type === "application/bittorrent" || file.mime_type === "application/x-bittorrent") {
return "torrent"
} else if (file.mime_type.startsWith("image")) {
return "image"
} else if (
file.mime_type.startsWith("video") ||

View File

@@ -140,7 +140,8 @@ let submit = async e => {
</p>
<div style="text-align: right;">
<button class="button_highlight abuse_report_submit" type="submit">
<i class="icon">send</i> Send
<i class="icon">send</i>
<span>Send</span>
</button>
</div>
</form>

View File

@@ -87,7 +87,7 @@ const toggle_play = () => playing ? player.pause() : player.play()
</audio>
{/if}
<br/>
<br/><br/>
<LargeFileMessage file={file}></LargeFileMessage>
</div>

View File

@@ -23,17 +23,18 @@ let file = {
No preview is available for this file type. Download to view it locally.
<br/>
<button class="button_highlight" on:click={() => {dispatch("download")}}>
<i class="icon">save</i> Download
<i class="icon">save</i>
<span>Download</span>
</button>
</div>
<br/>
<br/><br/>
<LargeFileMessage file={file}></LargeFileMessage>
</div>
<style>
.icon {
display: inline-block;
vertical-align: top;
vertical-align: middle;
}
.description {
display: inline-block;
@@ -41,6 +42,9 @@ let file = {
padding-left: 8px;
vertical-align: middle;
max-width: 600px;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 16px;
padding: 8px;
}
.container {
position: relative;

View File

@@ -11,6 +11,7 @@ import File from "./File.svelte";
import Abuse from "./Abuse.svelte";
import { file_type } from "../FileUtilities.svelte";
import RateLimit from "./RateLimit.svelte";
import Torrent from "./Torrent.svelte";
let viewer
let viewer_type = "loading"
@@ -61,6 +62,8 @@ const loading = e => {dispatch("loading", e.detail)}
<PDF bind:this={viewer}></PDF>
{:else if viewer_type === "text"}
<Text bind:this={viewer}></Text>
{:else if viewer_type === "torrent"}
<Torrent bind:this={viewer} on:loading={loading} on:download={download}></Torrent>
{:else if viewer_type === "file"}
<File bind:this={viewer} on:download={download}></File>
{/if}

View File

@@ -12,7 +12,6 @@ export let file = {
{#if file.show_ads && file.size > 1e8}
<!-- If the file is larger than 100 MB we show a warning about the transfer speed -->
<div class="description">
<hr/>
Your download speed is currently limited to 4 MiB/s. Downloading this
file for free will take at least
{formatDuration((file.size/4194304)*1000)} (under ideal conditions).
@@ -31,5 +30,8 @@ export let file = {
padding-left: 8px;
vertical-align: middle;
max-width: 700px;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 16px;
padding: 8px;
}
</style>

View File

@@ -0,0 +1,159 @@
<script>
import { createEventDispatcher } from "svelte";
import Magnet from "../../icons/Magnet.svelte";
import { formatDate } from "../../util/Formatting.svelte"
import { copy_text } from "../../util/Util.svelte";
import TorrentItem from "./TorrentItem.svelte"
let dispatch = createEventDispatcher()
let status = "loading"
export const set_file = async f => {
file = f
dispatch("loading", true)
try {
let resp = await fetch(f.info_href+"/torrent")
if (resp.status >= 400) {
let json = await resp.json()
if (json.value === "torrent_too_large") {
status = "too_large"
return
} else {
status = "parse_failed"
return
}
}
torrent = await resp.json()
// Generate magnet link
magnet = "magnet:?xt=urn:btih:" + torrent.info_hash +
"&dn=" + encodeURIComponent(Object.keys(torrent.files.children)[0])
torrent.trackers.forEach(tracker => {
magnet += "&tr="+encodeURIComponent(tracker)
})
} catch (err) {
console.error(err)
} finally {
dispatch("loading", false)
}
status = "finished"
}
let file = {
id: "",
size: 0,
name: "",
mime_type: "",
icon_href: "",
show_ads: false,
}
let torrent = {
trackers: [],
comment: "",
created_by: "",
created_at: "",
info_hash: "",
files: null,
}
let magnet = ""
let copy_magnet_status = "" // empty, copied, or error
const copy_magnet = () => {
if (copy_text(magnet)) {
copy_magnet_status = "copied"
} else {
copy_magnet_status = "error"
alert("Your browser does not support copying text.")
}
setTimeout(() => { copy_magnet_status = "" }, 60000)
}
</script>
<div class="container">
<h1>Torrent file on pixeldrain</h1>
<img src={file.icon_href} alt="File icon" class="icon">
<div class="description" style="max-width: 650px">
Name: {file.name}<br/>
{#if status === "finished"}
Created by: {torrent.created_by}<br/>
Created at: {formatDate(new Date(torrent.created_at), true, true, true)}<br/>
Info hash: {torrent.info_hash}<br/>
Comment: {torrent.comment}<br/>
<a href={magnet} class="button button_highlight">
<Magnet></Magnet>
<span>Open magnet link</span>
</a>
<button
on:click={copy_magnet}
class="button"
class:button_highlight={copy_magnet_status === "copied"}
class:button_red={copy_magnet_status === "erorr"}
>
<Magnet></Magnet>
<span>
{#if copy_magnet_status === ""}
Copy magnet link
{:else if copy_magnet_status === "copied"}
Copied magnet
{:else if copy_magnet_status === "error"}
Error!
{/if}
</span>
</button>
{:else if status === "too_large"}
<p>
Torrent file is too large to parse. Please download the file and
add it to your torrent client locally.
</p>
{:else if status === "parse_failed"}
<p>
Torrent file could not be parsed. It may be corrupted.
</p>
{/if}
<button on:click={() => {dispatch("download")}} class="button">
<i class="icon">download</i>
<span>Download torrent file</span>
</button>
</div>
{#if status === "finished"}
<br/>
<br/>
<div class="description">
<h2>Files in this torrent</h2>
<TorrentItem item={torrent.files} />
</div>
{/if}
</div>
<style>
.icon {
display: inline-block;
vertical-align: middle;
}
.description {
display: inline-block;
text-align: left;
padding-left: 8px;
vertical-align: middle;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 16px;
padding: 8px;
}
.container {
position: relative;
display: block;
height: 100%;
width: 100%;
text-align: center;
overflow: auto;
}
</style>

View File

@@ -0,0 +1,28 @@
<script>
import { formatDataVolume } from "../../util/Formatting.svelte";
export let item = {
size: 0,
children: null,
}
</script>
<ul class="list_open">
{#each Object.entries(item.children) as [name, child]}
<li class:list_closed={!child.children}>
{name} ({formatDataVolume(child.size, 3)})<br/>
{#if child.children}
<svelte:self item={child}></svelte:self>
{/if}
</li>
{/each}
</ul>
<style>
.list_open {
list-style-type: disclosure-open;
}
.list_closed {
list-style-type: disc;
}
</style>

View File

@@ -88,7 +88,7 @@ let download = () => { dispatch("download", {}) }
<i class="icon">save</i> Download
</button>
</div>
<br/>
<br/><br/>
<LargeFileMessage file={file}></LargeFileMessage>
{/if}
</div>

View File

@@ -0,0 +1,13 @@
<script>export let style;</script>
<svg style={style} xmlns="http://www.w3.org/2000/svg" version="1.1" width="24" height="24" viewBox="0 0 987.525 987.525">
<path fill="currentColor" d="M132.138,855.425c43,43,93.2,76.301,149.3,99.101c54.1,21.899,111.1,33,169.6,33s115.601-11.101,169.601-33
c56-22.7,106.199-56,149.3-99.101l60.899-60.899l-176.8-176.8l-60.899,60.899c-38,38-88.4,58.9-142.101,58.9
s-104.2-20.9-142.1-58.9c-78.4-78.399-78.4-205.899,0-284.3l60.899-60.899l-176.8-176.7l-60.9,60.899
c-43,43-76.3,93.2-99.1,149.301c-21.9,54.1-33,111.1-33,169.6s11.1,115.6,33,169.6C55.738,762.226,89.038,812.425,132.138,855.425z
"/>
<path fill="currentColor" d="M878.038,478.625c-23.399-23.399-61.399-23.399-84.899,0l-82.601,82.601l176.8,176.8l82.601-82.601
c23.399-23.399,23.399-61.399,0-84.899L878.038,478.625z"/>
<path fill="currentColor" d="M332.139,17.625l-82.601,82.601l176.8,176.8l82.601-82.6c23.399-23.4,23.399-61.4,0-84.9l-91.9-91.9
C393.538-5.875,355.639-5.875,332.139,17.625z"/>
</svg>

View File

@@ -333,7 +333,7 @@ func (wc *WebController) serveEmailConfirm(
if err != nil && err.Error() == "not_found" {
status = "not_found"
} else if err != nil {
log.Error("E-mail reset fail: %s", err)
log.Debug("E-mail reset fail: %s", err)
status = "internal_error"
} else {
status = "success"