Add apps page

This commit is contained in:
2021-01-12 14:07:55 +01:00
parent 4dd819d49f
commit ad03e0758b
13 changed files with 298 additions and 79 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
res/static/img/sharex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

69
res/template/apps.html Normal file
View File

@@ -0,0 +1,69 @@
{{ define "apps" }}<!DOCTYPE html>
<html lang="en">
<head>
{{template "meta_tags" "Apps"}}
{{template "user_style" .}}
</head>
<body>
{{template "page_top" .}}
<h1>Apps</h1>
<div class="page_content"><div class="limit_width">
<h2>ShareX (Windows only)</h2>
<p>
<img src="/res/img/sharex.png" style="float: left; height: 5em; margin: 0.5em;" />
</p>
<p>
ShareX is a Screen capture, file sharing and productivity tool.
Pixeldrain is supported as a custom uploader. You can <a
href="https://getsharex.com/" target="_blank">get ShareX
here</a>.
</p>
<p>
Here you can download our custom ShareX uploader which uses
pixeldrain to upload your files.
</p>
<div class="highlight_dark">
<a href="/misc/sharex/pixeldrain.com.sxcu" class="button button_highlight">
<i class="icon small">save</i>
Download ShareX Uploader
</a><br/>
{{if .Authenticated}}
This uploader is configured to upload files to your personal
pixeldrain account. Do not share the configuration file with
anyone, it contains your account credentials.
{{else}}
<a href="/login">Log in</a> to use ShareX with your own
pixeldrain account. {{end}}
</div>
<h3>Setting pixeldrain as default uploader</h3>
<p>
Download the uploader config and choose 'Open file'<br/>
<img src="/res/img/sharex_download.png" style="max-width: 100%;" /><br/>
Set pixeldrain.com as active uploader. Choose Yes<br/>
<img src="/res/img/sharex_default.png" style="max-width: 100%;" /><br/>
</p>
<h2>pdup (Linux only)</h2>
<p>
pdup is a little bash script for uploading files to pixeldrain
from the terminal. It's available <a
href="https://github.com/Fornax96/pdup" target="_blank">from
GitHub</a>.
</p>
<h2>More apps</h2>
<p>
If you know more open source apps which work with pixeldrain
please send them to
<a href="mailto:support@pixeldrain.com">support@pixeldrain.com</a>.
</p>
</div></div>
{{template "page_bottom" .}}
{{template "analytics"}}
</body>
</html>
{{ end }}

View File

@@ -155,33 +155,33 @@
<img src="/res/img/misc/banner_amarula_jobs.png" style="width: 100%; height: 100%" />
</a>
{{ else if eq .Other.AdType 8 }}
<div style="text-align: center; line-height: 1.4em; font-size: 26px;">
<img src="/res/img/pixeldrain_128.png" style="height: 2.6em; vertical-align: middle;"/>
<div style="margin: 4px 8px; display: inline-block; vertical-align: middle;">
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
Are your files expiring too quickly?<br/>
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
</div>
</div>
{{ else if eq .Other.AdType 9 }}
<div style="text-align: center; line-height: 1.4em; font-size: 26px;">
<img src="/res/img/pixeldrain_128.png" style="height: 2.6em; vertical-align: middle;"/>
<div style="margin: 4px 8px; display: inline-block; vertical-align: middle;">
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
Are your files too large to share?<br/>
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
</div>
</div>
{{ else if eq .Other.AdType 10 }}
<div style="text-align: center; line-height: 1.4em; font-size: 26px;">
<img src="/res/img/pixeldrain_128.png" style="height: 2.6em; vertical-align: middle;"/>
<div style="margin: 4px 8px; display: inline-block; vertical-align: middle;">
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
Are you tired of advertisements?<br/>
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
</div>
</div>
{{ else if eq .Other.AdType 11 }}
<div style="text-align: center; line-height: 1.4em; font-size: 26px;">
<img src="/res/img/pixeldrain_128.png" style="height: 2.6em; vertical-align: middle;"/>
<div style="margin: 4px 8px; display: inline-block; vertical-align: middle;">
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
Concerned about your online privacy?<br/>
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
</div>

View File

@@ -15,6 +15,7 @@
{{end}}
<hr />
<a href="/about">About</a>
<a href="/apps">Apps</a>
<a href="/appearance">Appearance</a>
<a href="/api">API</a>
<a href="/acknowledgements">Acknowledgements</a>

View File

@@ -57,15 +57,9 @@
margin: 5px 15px;
}
.table_container {
width: 100%;
overflow-x: auto;
overflow-y: hidden;
}
.feat_table {
display: flex;
flex-direction: column;
min-width: 400px;
}
.feat_table > div {
display: flex;
@@ -77,7 +71,7 @@
}
.feat_table > div > div {
flex: 1 1 0;
margin: 0.2em;
margin: 0.25em;
padding: 0.5em;
text-align: center;
word-wrap: break-word;
@@ -107,6 +101,13 @@
font-size: 1.1em;
font-weight: bold;
}
.feat_table > div > .cell_background {
background-position: center;
background-size: cover;
text-align: left;
font-size: 1.2em;
padding: 0.2em;
}
.feat_table > div > div.round_tl { border-top-left-radius: 0.5em; }
.feat_table > div > div.round_tr { border-top-right-radius: 0.5em; }
@@ -225,68 +226,149 @@
mission to make content sharing easier, safer and faster for
everyone.
</p>
<div class="table_container">
<div class="feat_table">
<div>
<div></div>
<div class="feat_normal round_tl">Free</div>
<div class="feat_pro feat_highlight round_tr">Pro</div>
<div class="feat_table">
<div>
<div></div>
<div class="feat_normal round_tl">Free</div>
<div class="feat_pro feat_highlight round_tr">Pro</div>
</div>
<div>
<div class="feat_label">Size limit per file</div>
<div class="feat_normal">5 GB per file</div>
<div class="feat_pro"><span class="text_highlight">15 GB</span> per file</div>
</div>
<div>
<div class="feat_label"><a href="javascript:void(0);" onclick="return explainFileExpiry();">File expiry</a></div>
<div class="feat_normal">30 days after the last time it is viewed</div>
<div class="feat_pro"><span class="text_highlight">90 days</span> after the last time it is viewed</div>
</div>
<div>
<div class="feat_label">Adver&shy;tise&shy;ments</div>
<div class="feat_normal">Pop-up or a banner ad on the file viewer page</div>
<div class="feat_pro">
<span class="text_highlight">No ads</span> on files
you share. No ads when viewing files uploaded by
other users
</div>
<div>
<div class="feat_label">Size limit per file</div>
<div class="feat_normal">5 GB per file</div>
<div class="feat_pro"><span class="text_highlight">15 GB</span> per file</div>
</div>
<div>
<div class="feat_label">Privacy</div>
<div class="feat_normal">
No trackers, but advertisers can see your IP address
and browser fingerprint
</div>
<div>
<div class="feat_label"><a href="javascript:void(0);" onclick="return explainFileExpiry();">File expiry</a></div>
<div class="feat_normal">30 days after the last time it is viewed</div>
<div class="feat_pro"><span class="text_highlight">90 days</span> after the last time it is viewed</div>
<div class="feat_pro">
<span class="text_highlight">Completely
private</span>. No third party scripts and no
logging
</div>
<div>
<div class="feat_label">Adver&shy;tise&shy;ments</div>
<div class="feat_normal">Pop-up or a banner ad on the file viewer page</div>
<div class="feat_pro">
<span class="text_highlight">No ads</span> on files
you share. No ads when viewing files uploaded by
other users
</div>
</div>
<div>
<div class="feat_label">Privacy</div>
<div class="feat_normal">
No trackers, but advertisers can see your IP address
and browser fingerprint
</div>
<div class="feat_pro">
<span class="text_highlight">Completely
private</span>. No third party scripts and no
logging
</div>
</div>
<div>
<div class="feat_label">Online file previews</div>
<div class="feat_pro">View image, video, audio, PDF and text files directly in your web browser</div>
</div>
<div>
<div class="feat_label"><a href="javascript:void(0);" onclick="return explainDirectLinking();">Direct linking</a></div>
<div class="feat_pro">Rate limiting mode will be enabled when a file has 3 times more downloads than views</div>
</div>
<div>
<div></div>
<div class="feat_normal round_bl">Free</div>
<div class="feat_pro feat_highlight round_br">
{{if ne .User.Subscription.ID ""}}
You have this plan<br/>
Thank you for supporting pixeldrain!
{{else}}
<a href="https://www.patreon.com/join/pixeldrain/checkout?rid=5291427" class="button button_highlight">Only € 2 per month!</a> (Excluding tax)
<br/>
Subscription managed by Patreon
{{end}}
</div>
</div>
<div>
<div class="feat_label">Online file previews</div>
<div class="feat_pro">View image, video, audio, PDF and text files directly in your web browser</div>
</div>
<div>
<div class="feat_label"><a href="javascript:void(0);" onclick="return explainDirectLinking();">Direct linking</a></div>
<div class="feat_pro">Rate limiting mode will be enabled when a file has 3 times more downloads than views</div>
</div>
<div>
<div></div>
<div class="feat_normal round_bl">Free</div>
<div class="feat_pro feat_highlight round_br">
{{if eq .User.Subscription.ID "patreon_1"}}
You have this plan<br/>
Thank you for supporting pixeldrain!
{{else}}
<a href="https://www.patreon.com/join/pixeldrain/checkout?rid=5291427" class="button button_highlight">Only € 2 per month!</a> (Excluding tax)
<br/>
Subscription managed by Patreon
{{end}}
</div>
</div>
</div>
<br/><br/>
<div style="text-align: center;">
Do you need even more time and space? Check out our other plans
</div>
<br/>
<div class="feat_table">
<div>
<div class="feat_label">Resolve</div>
<div class="feat_normal">
<span class="text_highlight">20 GB</span> file size,
<span class="text_highlight">120 days</span> file expiry
</div>
<div class="feat_normal round_tr round_br cell_background" style="background-image: url('/res/img/benefit_5_small.png');">
{{if eq .User.Subscription.ID "patreon_5"}}
You have this plan<br/>
Thank you for supporting pixeldrain!
{{else}}
<a href="https://www.patreon.com/join/pixeldrain/checkout?rid=5736701" class="button button_highlight">€ 4</a>
{{end}}
</div>
</div>
<div>
<div class="feat_label">Persistence</div>
<div class="feat_normal">
<span class="text_highlight">20 GB</span> file size,
<span class="text_highlight">240 days</span> file expiry
</div>
<div class="feat_normal round_tr round_br cell_background" style="background-image: url('/res/img/benefit_2_small.png');">
{{if eq .User.Subscription.ID "patreon_2"}}
You have this plan<br/>
Thank you for supporting pixeldrain!
{{else}}
<a href="https://www.patreon.com/join/pixeldrain/checkout?rid=5291482" class="button button_highlight">€ 8</a>
{{end}}
</div>
</div>
<div>
<div class="feat_label">Tenacity</div>
<div class="feat_normal">
<span class="text_highlight">20 GB</span> file size,
<span class="text_highlight">480 days</span> file expiry
</div>
<div class="feat_normal round_tr round_br cell_background" style="background-image: url('/res/img/benefit_3_small.png');">
{{if eq .User.Subscription.ID "patreon_3"}}
You have this plan<br/>
Thank you for supporting pixeldrain!
{{else}}
<a href="https://www.patreon.com/join/pixeldrain/checkout?rid=5291516" class="button button_highlight">€ 16</a>
{{end}}
</div>
</div>
<div>
<div class="feat_label">Eternity</div>
<div class="feat_normal">
<span class="text_highlight">20 GB</span> file size,
<span class="text_highlight">960 days</span> file expiry
</div>
<div class="feat_normal round_tr round_br cell_background" style="background-image: url('/res/img/benefit_4_small.png');">
{{if eq .User.Subscription.ID "patreon_4"}}
You have this plan<br/>
Thank you for supporting pixeldrain!
{{else}}
<a href="https://www.patreon.com/join/pixeldrain/checkout?rid=5291528" class="button button_highlight">€ 32</a>
{{end}}
</div>
</div>
<div>
<div class="feat_label">Infinity</div>
<div class="feat_normal">
<span class="text_highlight">20 GB</span> file size,
<span class="text_highlight">1920 days</span> file expiry
</div>
<div class="feat_normal round_tr round_br cell_background" style="background-image: url('/res/img/benefit_6_small.png');">
{{if eq .User.Subscription.ID "patreon_6"}}
You have this plan<br/>
Thank you for supporting pixeldrain!
{{else}}
<a href="https://www.patreon.com/join/pixeldrain/checkout?rid=6573749" class="button button_highlight">€ 64</a>
{{end}}
</div>
</div>
</div>
<br/>
<h2>Premium</h2>
<div class="highlight_dark">

61
webcontroller/misc.go Normal file
View File

@@ -0,0 +1,61 @@
package webcontroller
import (
"encoding/base64"
"fmt"
"net/http"
"github.com/Fornaxian/log"
"github.com/julienschmidt/httprouter"
)
// ServeFileViewerDemo is a dummy API response that responds with info about a
// non-existent demo file. This is required by the a-ads ad network to allow for
// automatic checking of the presence of the ad unit on this page.
func (wc *WebController) serveShareXConfig(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
templateData := wc.newTemplateData(w, r)
w.Header().Add("Content-Disposition", "attachment; filename=pixeldrain.com.sxcu")
if templateData.Authenticated {
sess, err := templateData.PixelAPI.UserSessionCreate()
if err != nil {
log.Error("Failed to create user session: %s", err)
wc.templates.Get().ExecuteTemplate(w, "500", templateData)
return
}
w.Write([]byte(fmt.Sprintf(
`{
"Version": "12.4.1",
"DestinationType": "ImageUploader, TextUploader, FileUploader",
"RequestMethod": "POST",
"RequestURL": "https://pixeldrain.com/api/file",
"Headers": {
"Authorization": "Basic %s"
},
"Body": "MultipartFormData",
"FileFormName": "file",
"URL": "https://pixeldrain.com/u/$json:id$",
"ThumbnailURL": "https://pixeldrain.com/api/file/$json:id$/thumbnail"
}
`,
base64.StdEncoding.EncodeToString([]byte(
templateData.User.Username+":"+sess.AuthKey.String(),
)),
)))
} else {
w.Write([]byte(fmt.Sprintf(
`{
"Version": "12.4.1",
"DestinationType": "ImageUploader, TextUploader, FileUploader",
"RequestMethod": "POST",
"RequestURL": "https://pixeldrain.com/api/file",
"Body": "MultipartFormData",
"FileFormName": "file",
"URL": "https://pixeldrain.com/u/$json:id$",
"ThumbnailURL": "https://pixeldrain.com/api/file/$json:id$/thumbnail"
}
`,
)))
}
}

View File

@@ -71,7 +71,7 @@ func (wc *WebController) newTemplateData(w http.ResponseWriter, r *http.Request)
if err.Error() == "authentication_required" || err.Error() == "authentication_failed" {
// Disable API authentication
t.PixelAPI = wc.api
t.PixelAPI = wc.api.RealIP(util.RemoteAddress(r))
// Remove the authentication cookie
log.Debug("Deleting invalid API key")

View File

@@ -148,8 +148,10 @@ func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
}
if f.ReadInput(r) {
loginResp, err := td.PixelAPI.UserLogin(f.FieldVal("username"), f.FieldVal("password"))
if err != nil {
if session, err := td.PixelAPI.UserLogin(
f.FieldVal("username"),
f.FieldVal("password"),
); err != nil {
formAPIError(err, &f)
} else {
// Request was a success
@@ -159,7 +161,7 @@ func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
// Set the autentication cookie
f.Extra.SetCookie = &http.Cookie{
Name: "pd_auth_key",
Value: loginResp.APIKey,
Value: session.AuthKey.String(),
Path: "/",
Expires: time.Now().AddDate(50, 0, 0),
Domain: wc.sessionCookieDomain,

View File

@@ -123,6 +123,7 @@ func New(
{GET, "acknowledgements" /**/, wc.serveMarkdown("acknowledgements.md", false)},
{GET, "business" /* */, wc.serveMarkdown("business.md", false)},
{GET, "server_status" /* */, wc.serveTemplate("server_status", false)},
{GET, "apps" /* */, wc.serveTemplate("apps", false)},
// User account pages
{GET, "register" /* */, wc.serveForm(wc.registerForm, false)},
@@ -164,6 +165,9 @@ func New(
{GET, "click/:id" /* */, wc.serveAdClick},
{GET, "campaign/:id" /* */, wc.serveCampaignPartner},
{GET, "ad/revenuehits" /**/, wc.serveTemplate("revenuehits", false)},
// Misc
{GET, "misc/sharex/pixeldrain.com.sxcu", wc.serveShareXConfig},
} {
r.Handle(h.method, prefix+"/"+h.path, h.handler)
}