Add website_address config option
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
type PixelWebConfig struct {
|
||||
APIURLExternal string `toml:"api_url_external"`
|
||||
APIURLInternal string `toml:"api_url_internal"`
|
||||
WebsiteAddress string `toml:"website_address"`
|
||||
SessionCookieDomain string `toml:"session_cookie_domain"`
|
||||
ResourceDir string `toml:"resource_dir"`
|
||||
DebugMode bool `toml:"debug_mode"`
|
||||
@@ -26,6 +27,7 @@ const DefaultConfig = `# Pixeldrain Web UI server configuration
|
||||
|
||||
api_url_external = "/api" # Used in the web browser
|
||||
api_url_internal = "http://127.0.0.1:8080" # Used for internal API requests to the pixeldrain server, not visible to users
|
||||
website_address = "https://pixeldrain.com"
|
||||
session_cookie_domain = ".pixeldrain.com"
|
||||
resource_dir = "res"
|
||||
debug_mode = false
|
||||
@@ -62,6 +64,7 @@ func Init(r *httprouter.Router, prefix string, setLogLevel bool) {
|
||||
webconf.ResourceDir,
|
||||
webconf.APIURLInternal,
|
||||
webconf.APIURLExternal,
|
||||
webconf.WebsiteAddress,
|
||||
webconf.SessionCookieDomain,
|
||||
webconf.MaintenanceMode,
|
||||
webconf.DebugMode,
|
||||
|
@@ -16,7 +16,7 @@
|
||||
<hr />
|
||||
<a href="/about">About</a>
|
||||
<a href="/apps">Apps</a>
|
||||
<a href="/appearance">Appearance</a>
|
||||
<a href="/appearance">Theme</a>
|
||||
<a href="/api">API</a>
|
||||
<a href="/acknowledgements">Acknowledgements</a>
|
||||
<a href="/server_status">Server Status</a>
|
||||
|
@@ -383,7 +383,7 @@
|
||||
</p>
|
||||
<p>
|
||||
When you choose for Premium you will also get all the benefits
|
||||
of the Pro subscription. A base rate of €1 per month will be
|
||||
of the Pro subscription. A base rate of €2 per month will be
|
||||
billed regardless of your usage.
|
||||
</p>
|
||||
</div></div>
|
||||
|
@@ -58,12 +58,12 @@ func adType() int {
|
||||
return pdpro3
|
||||
case 6:
|
||||
return pdpro4
|
||||
case 7, 8, 9, 10, 11, 12, 13, 14:
|
||||
case 7, 8:
|
||||
return adMaven
|
||||
case 9, 10, 11, 12, 13, 14:
|
||||
return propellerAds
|
||||
default:
|
||||
panic(fmt.Errorf(
|
||||
"random number generator returned unrecognised number: %d", i),
|
||||
)
|
||||
panic(fmt.Errorf("random number generator returned unrecognised number: %d", i))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
||||
return
|
||||
}
|
||||
|
||||
templateData.OGData = metadataFromFile(finfo[0].FileInfo)
|
||||
templateData.OGData = wc.metadataFromFile(finfo[0].FileInfo)
|
||||
|
||||
var vd = viewerData{
|
||||
CaptchaKey: wc.captchaKey(),
|
||||
@@ -198,7 +198,7 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
|
||||
templateData.Title = fmt.Sprintf("%s ~ pixeldrain", list.Title)
|
||||
templateData.OGData = metadataFromList(list)
|
||||
templateData.OGData = wc.metadataFromList(list)
|
||||
templateData.Other = viewerData{
|
||||
Type: "list",
|
||||
CaptchaKey: wc.captchaSiteKey,
|
||||
|
@@ -21,67 +21,67 @@ func (og *ogData) addOG(k, v string) { og.OGRules = append(og.OGRules, ogPr
|
||||
func (og *ogData) addTwitter(k, v string) { og.TwitterRules = append(og.TwitterRules, ogProp{k, v}) }
|
||||
func (og *ogData) addLink(k, v string) { og.LinkRules = append(og.LinkRules, ogProp{k, v}) }
|
||||
|
||||
func metadataFromFile(f apitype.FileInfo) (og ogData) {
|
||||
func (wc *WebController) metadataFromFile(f apitype.FileInfo) (og ogData) {
|
||||
og.addOG("og:title", f.Name)
|
||||
og.addOG("og:site_name", "pixeldrain")
|
||||
og.addOG("og:description", "View '"+f.Name+"' on pixeldrain")
|
||||
og.addOG("description", "View '"+f.Name+"' on pixeldrain")
|
||||
og.addOG("og:url", "/u/"+f.ID)
|
||||
og.addOG("og:url", wc.websiteAddress+"/u/"+f.ID)
|
||||
og.addTwitter("twitter:title", f.Name)
|
||||
og.addTwitter("twitter:site", "@Fornax96")
|
||||
og.addTwitter("twitter:domain", "pixeldrain.com")
|
||||
|
||||
if strings.HasPrefix(f.MimeType, "image") {
|
||||
og.addOG("og:type", "article")
|
||||
og.addOG("og:image", "/api/file/"+f.ID)
|
||||
og.addOG("og:image:url", "/api/file/"+f.ID)
|
||||
og.addOG("og:image:secure_url", "/api/file/"+f.ID)
|
||||
og.addOG("og:image", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addOG("og:image:url", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addOG("og:image:secure_url", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addOG("og:image:type", f.MimeType)
|
||||
|
||||
og.addTwitter("twitter:card", "summary_large_image")
|
||||
og.addTwitter("twitter:image", "/api/file/"+f.ID)
|
||||
og.addLink("image_src", "/api/file/"+f.ID)
|
||||
og.addTwitter("twitter:image", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addLink("image_src", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
} else if strings.HasPrefix(f.MimeType, "video") {
|
||||
og.addOG("og:type", "video.other")
|
||||
og.addOG("og:image", "/api/file/"+f.ID+"/thumbnail")
|
||||
og.addOG("og:video", "/api/file/"+f.ID)
|
||||
og.addOG("og:video:url", "/api/file/"+f.ID)
|
||||
og.addOG("og:video:secure_url", "/api/file/"+f.ID)
|
||||
og.addOG("og:image", wc.websiteAddress+"/api/file/"+f.ID+"/thumbnail")
|
||||
og.addOG("og:video", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addOG("og:video:url", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addOG("og:video:secure_url", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addOG("og:video:type", f.MimeType)
|
||||
|
||||
og.addTwitter("twitter:card", "player")
|
||||
og.addTwitter("twitter:image", "/api/file/"+f.ID+"/thumbnail")
|
||||
og.addTwitter("twitter:player", "/api/file/"+f.ID)
|
||||
og.addTwitter("twitter:player:stream", "/api/file/"+f.ID)
|
||||
og.addTwitter("twitter:image", wc.websiteAddress+"/api/file/"+f.ID+"/thumbnail")
|
||||
og.addTwitter("twitter:player", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addTwitter("twitter:player:stream", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addTwitter("twitter:player:stream:content_type", f.MimeType)
|
||||
og.addLink("image_src", "/api/file/"+f.ID+"/thumbnail")
|
||||
og.addLink("image_src", wc.websiteAddress+"/api/file/"+f.ID+"/thumbnail")
|
||||
} else if strings.HasPrefix(f.MimeType, "audio") {
|
||||
og.addOG("og:type", "music.song")
|
||||
og.addOG("og:audio", "/api/file/"+f.ID)
|
||||
og.addOG("og:audio:secure_url", "/api/file/"+f.ID)
|
||||
og.addOG("og:audio", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addOG("og:audio:secure_url", wc.websiteAddress+"/api/file/"+f.ID)
|
||||
og.addOG("og:audio:type", f.MimeType)
|
||||
og.addLink("image_src", "/api/file/"+f.ID+"/thumbnail")
|
||||
og.addLink("image_src", wc.websiteAddress+"/api/file/"+f.ID+"/thumbnail")
|
||||
} else {
|
||||
og.addOG("og:type", "website")
|
||||
og.addLink("image_src", "/api/file/"+f.ID+"/thumbnail")
|
||||
og.addLink("image_src", wc.websiteAddress+"/api/file/"+f.ID+"/thumbnail")
|
||||
}
|
||||
return og
|
||||
}
|
||||
func metadataFromList(l apitype.ListInfo) (og ogData) {
|
||||
func (wc *WebController) metadataFromList(l apitype.ListInfo) (og ogData) {
|
||||
og.addOG("og:type", "website")
|
||||
og.addOG("og:title", l.Title)
|
||||
og.addOG("og:site_name", "pixeldrain")
|
||||
og.addOG("og:description", "View '"+l.Title+"' on pixeldrain")
|
||||
og.addOG("description", "View '"+l.Title+"' on pixeldrain")
|
||||
og.addOG("og:url", "/l/"+l.ID)
|
||||
og.addOG("og:url", wc.websiteAddress+"/l/"+l.ID)
|
||||
og.addTwitter("twitter:title", l.Title)
|
||||
og.addTwitter("twitter:site", "@Fornax96")
|
||||
og.addTwitter("twitter:domain", "pixeldrain.com")
|
||||
if l.FileCount > 0 {
|
||||
og.addOG("og:image", "/api/file/"+l.Files[0].ID+"/thumbnail")
|
||||
og.addOG("og:image:url", "/api/file/"+l.Files[0].ID+"/thumbnail")
|
||||
og.addTwitter("twitter:image", "/api/file/"+l.Files[0].ID+"/thumbnail")
|
||||
og.addLink("image_src", "/api/file/"+l.Files[0].ID+"/thumbnail")
|
||||
og.addOG("og:image", wc.websiteAddress+"/api/file/"+l.Files[0].ID+"/thumbnail")
|
||||
og.addOG("og:image:url", wc.websiteAddress+"/api/file/"+l.Files[0].ID+"/thumbnail")
|
||||
og.addTwitter("twitter:image", wc.websiteAddress+"/api/file/"+l.Files[0].ID+"/thumbnail")
|
||||
og.addLink("image_src", wc.websiteAddress+"/api/file/"+l.Files[0].ID+"/thumbnail")
|
||||
}
|
||||
return og
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ type WebController struct {
|
||||
|
||||
apiURLInternal string
|
||||
apiURLExternal string
|
||||
websiteAddress string
|
||||
|
||||
sessionCookieDomain string
|
||||
|
||||
@@ -50,6 +51,7 @@ func New(
|
||||
resourceDir string,
|
||||
apiURLInternal string,
|
||||
apiURLExternal string,
|
||||
websiteAddress string,
|
||||
sessionCookieDomain string,
|
||||
maintenanceMode bool,
|
||||
debugMode bool,
|
||||
@@ -59,6 +61,7 @@ func New(
|
||||
resourceDir: resourceDir,
|
||||
apiURLInternal: apiURLInternal,
|
||||
apiURLExternal: apiURLExternal,
|
||||
websiteAddress: websiteAddress,
|
||||
sessionCookieDomain: sessionCookieDomain,
|
||||
httpClient: &http.Client{Timeout: time.Minute * 10},
|
||||
api: apiclient.New(apiURLInternal),
|
||||
|
Reference in New Issue
Block a user