Increase text file preview size

This commit is contained in:
2021-12-09 22:16:52 +01:00
parent 893163bb4f
commit c161187fbe
4 changed files with 20 additions and 22 deletions

View File

@@ -42,7 +42,7 @@ let text_pre
const text = () => { const text = () => {
text_type = "text" text_type = "text"
if (file.size > 1 << 20) { // File larger than 1 MiB if (file.size > 1 << 22) { // File larger than 4 MiB
text_pre.innerText = "File is too large to view online.\nPlease download and view it locally." text_pre.innerText = "File is too large to view online.\nPlease download and view it locally."
return return
} }
@@ -62,7 +62,7 @@ let prettyprint = false
const code = () => { const code = () => {
text_type = "code" text_type = "code"
if (file.size > 1 << 20) { // File larger than 1 MiB if (file.size > 1 << 22) { // File larger than 4 MiB
code_pre.innerText = "File is too large to view online.\nPlease download and view it locally." code_pre.innerText = "File is too large to view online.\nPlease download and view it locally."
return return
} }

View File

@@ -74,9 +74,9 @@ let download = () => { dispatch("download", {}) }
<h1>This is a video file on pixeldrain</h1> <h1>This is a video file on pixeldrain</h1>
<img src={file.icon_href} alt="Video icon" style="display: inline-block; vertical-align: top;"> <img src={file.icon_href} alt="Video icon" style="display: inline-block; vertical-align: top;">
<div class="description"> <div class="description">
The online video player on pixeldrain has been disabled due to The online video player on pixeldrain has been disabled to prevent
repeated abuse. You can still watch videos online by upgrading to abuse. You can still watch videos online by upgrading to Pro. Or
Pro. Or download the video and watch it locally on your computer. download the video and watch it locally on your computer.
<br/> <br/>
<a href="https://www.patreon.com/join/pixeldrain/checkout?rid=5291427&cadence=12" class="button button_highlight"> <a href="https://www.patreon.com/join/pixeldrain/checkout?rid=5291427&cadence=12" class="button button_highlight">
<i class="icon">upgrade</i> Upgrade to Pro <i class="icon">upgrade</i> Upgrade to Pro
@@ -126,6 +126,6 @@ let download = () => { dispatch("download", {}) }
text-align: left; text-align: left;
padding-left: 8px; padding-left: 8px;
vertical-align: middle; vertical-align: middle;
max-width: 600px; max-width: 550px;
} }
</style> </style>

View File

@@ -141,21 +141,19 @@ onMount(() => {
deposit has to be used up. deposit has to be used up.
</p> </p>
<div class="indent" style="text-align: center;"> <div class="indent" style="text-align: center;">
<form on:submit|preventDefault={() => {checkout("")}} class="checkout_form"> Deposit amount €
Deposit amount € <input type="number" bind:value={credit_amount} min="1"/>
<input type="number" bind:value={credit_amount} min="1"/> <br/>
<br/> Pay with:<br/>
Pay with:<br/> <button on:click={() => {checkout("btc")}}>
<button on:click={() => {checkout("btc")}}> <span class="icon_unicode"></span> Bitcoin
<span class="icon_unicode"></span> Bitcoin </button>
</button> <button on:click={() => {checkout("btc_lightning")}}>
<button on:click={() => {checkout("btc_lightning")}}> <i class="icon">bolt</i> Lightning network
<i class="icon">bolt</i> Lightning network </button>
</button> <button on:click={() => {checkout("doge")}}>
<button on:click={() => {checkout("doge")}}> <span class="icon_unicode">Ð</span> Dogecoin
<span class="icon_unicode">Ð</span> Dogecoin </button>
</button>
</form>
</div> </div>
<h3>Open invoices</h3> <h3>Open invoices</h3>

View File

@@ -31,7 +31,7 @@ func (wc *WebController) serveFilePreview(w http.ResponseWriter, r *http.Request
if strings.HasPrefix(file.MimeType, "text") && if strings.HasPrefix(file.MimeType, "text") &&
(strings.HasSuffix(file.Name, ".md") || strings.HasSuffix(file.Name, ".markdown")) { (strings.HasSuffix(file.Name, ".md") || strings.HasSuffix(file.Name, ".markdown")) {
if file.Size > 1e6 { // Prevent out of memory errors if file.Size > 1<<22 { // Prevent out of memory errors
w.Write([]byte("File is too large to view online.\nPlease download and view it locally.")) w.Write([]byte("File is too large to view online.\nPlease download and view it locally."))
return return
} }