Remove demo file viewer, update dependencies
This commit is contained in:
8
go.mod
8
go.mod
@@ -8,7 +8,7 @@ require (
|
||||
fornaxian.tech/config v0.0.0-20211108212237-6133aed90586
|
||||
fornaxian.tech/log v0.0.0-20211102185326-552e9b1f8640
|
||||
fornaxian.tech/pixeldrain_api_client v0.0.0-20221207191816-6872676df741
|
||||
fornaxian.tech/util v0.0.0-20220603201140-7b74b1181b98
|
||||
fornaxian.tech/util v0.0.0-20230510125310-1bc41b5fe13b
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
github.com/microcosm-cc/bluemonday v1.0.23
|
||||
github.com/russross/blackfriday/v2 v2.1.0
|
||||
@@ -17,11 +17,11 @@ require (
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.1 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/gocql/gocql v1.3.1 // indirect
|
||||
github.com/gocql/gocql v1.4.0 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/gorilla/css v1.0.0 // indirect
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
|
||||
golang.org/x/crypto v0.7.0 // indirect
|
||||
golang.org/x/net v0.8.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
)
|
||||
|
22
go.sum
22
go.sum
@@ -2,8 +2,8 @@ fornaxian.tech/config v0.0.0-20211108212237-6133aed90586 h1:/4a0Iq3cYeyTWcPHsN9p
|
||||
fornaxian.tech/config v0.0.0-20211108212237-6133aed90586/go.mod h1:ULIXF4J1DbBw4EsIPRNQDf6J3hl4P/jlihjy6UCm9FM=
|
||||
fornaxian.tech/log v0.0.0-20211102185326-552e9b1f8640 h1:UPDxJwLRCfh/cv80UMSanzmZ0jIcfS1mcd0Y06HYuLw=
|
||||
fornaxian.tech/log v0.0.0-20211102185326-552e9b1f8640/go.mod h1:sN82qMToeHhP2u3ehvrcE8y1IudRZJAZO9yG5OBYblo=
|
||||
fornaxian.tech/util v0.0.0-20220603201140-7b74b1181b98 h1:d0FsJgwiHunT4X6Hyz7FRBQF+ix/RDagKj2/2VnlY14=
|
||||
fornaxian.tech/util v0.0.0-20220603201140-7b74b1181b98/go.mod h1:lCmtcb4/SVt2ol55/EHDWGySY7o0ONbj97RR9CdsN4M=
|
||||
fornaxian.tech/util v0.0.0-20230510125310-1bc41b5fe13b h1:ZJXnWqTReW9OElnanpLlpl8ElVErbYZb4cK4zjnlM1E=
|
||||
fornaxian.tech/util v0.0.0-20230510125310-1bc41b5fe13b/go.mod h1:lCmtcb4/SVt2ol55/EHDWGySY7o0ONbj97RR9CdsN4M=
|
||||
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
|
||||
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||
@@ -13,8 +13,8 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCS
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gocql/gocql v1.3.1 h1:BTwM4rux+ah5G3oH6/MQa+tur/TDd/XAAOXDxBBs7rg=
|
||||
github.com/gocql/gocql v1.3.1/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
||||
github.com/gocql/gocql v1.4.0 h1:NIlXAJXsjzjGvVn36njh9OLYWzS3D7FdvsifLj4eDEY=
|
||||
github.com/gocql/gocql v1.4.0/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
@@ -29,8 +29,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/microcosm-cc/bluemonday v1.0.21 h1:dNH3e4PSyE4vNX+KlRGHT5KrSvjeUkoNPwEORjffHJg=
|
||||
github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM=
|
||||
github.com/microcosm-cc/bluemonday v1.0.23 h1:SMZe2IGa0NuHvnVNAZ+6B38gsTbi5e4sViiWJyDDqFY=
|
||||
github.com/microcosm-cc/bluemonday v1.0.23/go.mod h1:mN70sk7UkkF8TUr2IGBpNN0jAgStuPzlK76QuruE/z4=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@@ -38,13 +36,9 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
|
||||
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
||||
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 312 KiB After Width: | Height: | Size: 51 KiB |
@@ -8,7 +8,7 @@ let text_type = ""
|
||||
export const set_file = file => {
|
||||
console.log("loading text file", file.id)
|
||||
|
||||
if (file.name.endsWith(".md") || file.name.endsWith(".markdown") || file.mime_type === "text/demo") {
|
||||
if (file.name.endsWith(".md") || file.name.endsWith(".markdown")) {
|
||||
markdown(file)
|
||||
} else if (file.name.endsWith(".txt") || file.size > 524288) {
|
||||
// If the file is larger than 512KiB we do not enable code highlighting
|
||||
|
@@ -19,7 +19,7 @@ onMount(() => {
|
||||
</div>
|
||||
<div>
|
||||
<div class="feat_label">Size limit per file</div>
|
||||
<div class="feat_normal">10 GB per file (9.31 GiB)</div>
|
||||
<div class="feat_normal">20 GB per file (18.63 GiB)</div>
|
||||
<div class="feat_pro">
|
||||
<span class="text_highlight">50 GB</span> per file (46.57 GiB)
|
||||
</div>
|
||||
@@ -29,7 +29,7 @@ onMount(() => {
|
||||
Data transfer limit
|
||||
</div>
|
||||
<div class="feat_normal">
|
||||
Download limit of <span class="text_highlight">10 GB</span> per day
|
||||
Download limit of <span class="text_highlight">20 GB</span> per day
|
||||
(24 hours). When this threshold is reached your download speed will
|
||||
be reduced to 1 MiB/s
|
||||
</div>
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"fornaxian.tech/log"
|
||||
"fornaxian.tech/pixeldrain_api_client/pixelapi"
|
||||
"fornaxian.tech/util"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
@@ -58,11 +59,6 @@ func (vd *fileViewerData) themeOverride(r *http.Request, files []pixelapi.ListFi
|
||||
|
||||
// ServeFileViewer controller for GET /u/:id
|
||||
func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||
if p.ByName("id") == "demo" {
|
||||
wc.serveViewerDemo(w, r) // Required for a-ads.com quality check
|
||||
return
|
||||
}
|
||||
|
||||
// If the user agent is Wget we redirect it to the API so that the file can
|
||||
// be downloaded directly
|
||||
if strings.HasPrefix(r.UserAgent(), "Wget/") {
|
||||
@@ -140,7 +136,7 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
|
||||
err = wc.templates.Get().ExecuteTemplate(w, templateName, templateData)
|
||||
if err != nil && !isNetError(err) {
|
||||
if err != nil && !util.IsNetError(err) {
|
||||
log.Error("Error executing template file_viewer: %s", err)
|
||||
}
|
||||
}
|
||||
@@ -202,38 +198,7 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
|
||||
err = wc.templates.Get().ExecuteTemplate(w, templateName, templateData)
|
||||
if err != nil && !isNetError(err) {
|
||||
if err != nil && !util.IsNetError(err) {
|
||||
log.Error("Error executing template file_viewer: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 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) serveViewerDemo(w http.ResponseWriter, r *http.Request) {
|
||||
templateData := wc.newTemplateData(w, r)
|
||||
templateData.Other = fileViewerData{
|
||||
Type: "file",
|
||||
CaptchaKey: wc.captchaSiteKey,
|
||||
UserAdsEnabled: true,
|
||||
APIResponse: map[string]interface{}{
|
||||
"id": "demo",
|
||||
"name": "Demo file",
|
||||
"date_upload": "2017-01-01 12:34:56",
|
||||
"date_lastview": "2017-01-01 12:34:56",
|
||||
"size": 123456789,
|
||||
"views": 1,
|
||||
"bandwidth_used": 123456789,
|
||||
"mime_type": "text/demo",
|
||||
"description": "A file to demonstrate the viewer page",
|
||||
"mime_image": "/res/img/mime/text.png",
|
||||
"thumbnail": "/res/img/mime/text.png",
|
||||
"abuse_type": "",
|
||||
"show_ads": true,
|
||||
},
|
||||
}
|
||||
err := wc.templates.Get().ExecuteTemplate(w, "file_viewer_svelte", templateData)
|
||||
if err != nil && !isNetError(err) {
|
||||
log.Error("Error rendering demo file: %s", err)
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"fornaxian.tech/log"
|
||||
"fornaxian.tech/util"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
@@ -35,7 +36,7 @@ func (wc *WebController) serveDirectory(w http.ResponseWriter, r *http.Request,
|
||||
td.Title = fmt.Sprintf("%s ~ pixeldrain", node.Path[node.BaseIndex].Name)
|
||||
td.Other = node
|
||||
err = wc.templates.Get().ExecuteTemplate(w, "filesystem", td)
|
||||
if err != nil && !isNetError(err) {
|
||||
if err != nil && !util.IsNetError(err) {
|
||||
log.Error("Error executing template filesystem: %s", err)
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
@@ -15,6 +14,7 @@ import (
|
||||
|
||||
"fornaxian.tech/log"
|
||||
"fornaxian.tech/pixeldrain_api_client/pixelapi"
|
||||
"fornaxian.tech/util"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
blackfriday "github.com/russross/blackfriday/v2"
|
||||
)
|
||||
@@ -246,7 +246,7 @@ func (wc *WebController) serveTemplate(tpl string, opts handlerOpts) httprouter.
|
||||
return
|
||||
}
|
||||
err := wc.templates.Get().ExecuteTemplate(w, tpl, td)
|
||||
if err != nil && !isNetError(err) {
|
||||
if err != nil && !util.IsNetError(err) {
|
||||
log.Error("Error executing template '%s': %s", tpl, err)
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ func (wc *WebController) serveMarkdown(tpl string, opts handlerOpts) httprouter.
|
||||
// Execute the raw markdown template and save the result in a buffer
|
||||
var tplBuf bytes.Buffer
|
||||
err = wc.templates.Get().ExecuteTemplate(&tplBuf, tpl, tpld)
|
||||
if err != nil && !isNetError(err) {
|
||||
if err != nil && !util.IsNetError(err) {
|
||||
log.Error("Error executing template '%s': %s", tpl, err)
|
||||
return
|
||||
}
|
||||
@@ -309,7 +309,7 @@ func (wc *WebController) serveMarkdown(tpl string, opts handlerOpts) httprouter.
|
||||
|
||||
// Execute the wrapper template
|
||||
err = wc.templates.Get().ExecuteTemplate(w, "markdown_wrapper", tpld)
|
||||
if err != nil && !isNetError(err) {
|
||||
if err != nil && !util.IsNetError(err) {
|
||||
log.Error("Error executing template '%s': %s", tpl, err)
|
||||
}
|
||||
}
|
||||
@@ -384,7 +384,7 @@ func (wc *WebController) serveForm(
|
||||
}
|
||||
|
||||
err := wc.templates.Get().ExecuteTemplate(w, "form_page", td)
|
||||
if err != nil && !isNetError(err) {
|
||||
if err != nil && !util.IsNetError(err) {
|
||||
log.Error("Error executing form page: %s", err)
|
||||
}
|
||||
}
|
||||
@@ -422,11 +422,3 @@ func (wc *WebController) captchaKey() string {
|
||||
|
||||
return wc.captchaSiteKey
|
||||
}
|
||||
|
||||
func isNetError(err error) bool {
|
||||
if _, ok := err.(*net.OpError); ok {
|
||||
return true
|
||||
}
|
||||
return strings.HasSuffix(err.Error(), "connection reset by peer") ||
|
||||
strings.HasSuffix(err.Error(), "broken pipe")
|
||||
}
|
||||
|
Reference in New Issue
Block a user