web/marketing: static asset path (#2872)
* use relative path instead of absolute path * add template func baseURL * add a method * update storj-sim * add comment
This commit is contained in:
parent
a6721ba92f
commit
10a896bf73
@ -276,6 +276,7 @@ func newNetwork(flags *Flags) (*Processes, error) {
|
||||
"--console.static-dir", filepath.Join(storjRoot, "web/satellite/"),
|
||||
// TODO: remove console.auth-token after vanguard release
|
||||
"--console.auth-token", consoleAuthToken,
|
||||
"--marketing.base-url", "",
|
||||
"--marketing.address", net.JoinHostPort(host, port(satellitePeer, i, privateHTTP)),
|
||||
"--marketing.static-dir", filepath.Join(storjRoot, "web/marketing/"),
|
||||
"--server.address", process.Address,
|
||||
|
@ -24,6 +24,7 @@ var Error = errs.Class("satellite marketing error")
|
||||
|
||||
// Config contains configuration for marketingweb server
|
||||
type Config struct {
|
||||
BaseURL string `help:"base url for marketing Admin GUI" default:""`
|
||||
Address string `help:"server address of the marketing Admin GUI" default:"127.0.0.1:8090"`
|
||||
StaticDir string `help:"path to static resources" default:""`
|
||||
}
|
||||
@ -130,24 +131,31 @@ func (s *Server) parseTemplates() (err error) {
|
||||
filepath.Join(s.templateDir, "err.html"),
|
||||
)
|
||||
|
||||
s.templates.home, err = template.New("landingPage").Funcs(template.FuncMap{
|
||||
"referralLink": rewards.GeneratePartnerLink,
|
||||
s.templates.home, err = template.New("home-page").Funcs(template.FuncMap{
|
||||
"BaseURL": s.GetBaseURL,
|
||||
"ReferralLink": rewards.GeneratePartnerLink,
|
||||
}).ParseFiles(homeFiles...)
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
s.templates.pageNotFound, err = template.New("page-not-found").ParseFiles(pageNotFoundFiles...)
|
||||
s.templates.pageNotFound, err = template.New("page-not-found").Funcs(template.FuncMap{
|
||||
"BaseURL": s.GetBaseURL,
|
||||
}).ParseFiles(pageNotFoundFiles...)
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
s.templates.internalError, err = template.New("internal-server-error").ParseFiles(internalErrorFiles...)
|
||||
s.templates.internalError, err = template.New("internal-server-error").Funcs(template.FuncMap{
|
||||
"BaseURL": s.GetBaseURL,
|
||||
}).ParseFiles(internalErrorFiles...)
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
s.templates.badRequest, err = template.New("bad-request-error").ParseFiles(badRequestFiles...)
|
||||
s.templates.badRequest, err = template.New("bad-request-error").Funcs(template.FuncMap{
|
||||
"BaseURL": s.GetBaseURL,
|
||||
}).ParseFiles(badRequestFiles...)
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
@ -207,6 +215,11 @@ func (s *Server) StopOffer(w http.ResponseWriter, req *http.Request) {
|
||||
http.Redirect(w, req, "/", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// GetBaseURL returns base url from config.
|
||||
func (s *Server) GetBaseURL() string {
|
||||
return s.config.BaseURL
|
||||
}
|
||||
|
||||
// serveNotFound handles 404 errors and defaults to 500 if template parsing fails.
|
||||
func (s *Server) serveNotFound(w http.ResponseWriter, req *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
3
scripts/testdata/satellite-config.yaml.lock
vendored
3
scripts/testdata/satellite-config.yaml.lock
vendored
@ -184,6 +184,9 @@ kademlia.operator.wallet: ""
|
||||
# server address of the marketing Admin GUI
|
||||
# marketing.address: 127.0.0.1:8090
|
||||
|
||||
# base url for marketing Admin GUI
|
||||
# marketing.base-url: ""
|
||||
|
||||
# path to static resources
|
||||
# marketing.static-dir: ""
|
||||
|
||||
|
@ -4,7 +4,7 @@ See LICENSE for copying information. -->
|
||||
{{define "head"}}
|
||||
<title>Referral Admin Portal</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
|
||||
<link rel="stylesheet" type="text/css" href="{{BaseURL}}/static/css/style.css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Poppins&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
|
||||
{{end}}
|
||||
|
@ -33,7 +33,7 @@ See LICENSE for copying information. -->
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
{{range referralLink $currentOffer.Name}}
|
||||
{{range ReferralLink $currentOffer.Name}}
|
||||
<span class="d-block">{{.}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
|
@ -6,9 +6,9 @@ See LICENSE for copying information. -->
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="row d-flex justify-content-between">
|
||||
<img class="mt-3 ml-5" src="/static/img/warning.png" height="30" width="30"/>
|
||||
<img class="mt-3 ml-5" src="{{BaseURL}}/static/img/warning.png" height="30" width="30"/>
|
||||
<p class="mt-3">Replace
|
||||
<strong>{{.FreeCredits.Active.Name}}</strong> with
|
||||
<strong>{{.FreeCredits.Active.Name}}</strong> with
|
||||
<strong>{{.FreeCredits.Default.Name}}</strong> ?
|
||||
</p>
|
||||
<div class="mt-2 mb-2 d-flex">
|
||||
|
@ -6,7 +6,7 @@ See LICENSE for copying information. -->
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="row d-flex justify-content-between">
|
||||
<img class="mt-3 ml-5" src="/static/img/warning.png" height="30" width="30"/>
|
||||
<img class="mt-3 ml-5" src="{{BaseURL}}/static/img/warning.png" height="30" width="30"/>
|
||||
<p class="mt-3">Are you sure you want to discontinue this offer ?</p>
|
||||
<div class="mt-2 mb-2 d-flex">
|
||||
<a href="/">
|
||||
|
@ -6,9 +6,9 @@ See LICENSE for copying information. -->
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="row d-flex justify-content-between">
|
||||
<img class="mt-3 ml-5" src="/static/img/warning.png" height="30" width="30"/>
|
||||
<img class="mt-3 ml-5" src="{{BaseURL}}/static/img/warning.png" height="30" width="30"/>
|
||||
<p class="mt-3">Replace
|
||||
<strong>{{.ReferralOffers.Active.Name}}</strong> with
|
||||
<strong>{{.ReferralOffers.Active.Name}}</strong> with
|
||||
<strong>{{.ReferralOffers.Default.Name}}</strong> ?
|
||||
</p>
|
||||
<div class="mt-2 mb-2 d-flex">
|
||||
|
Loading…
Reference in New Issue
Block a user