mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2020-11-18 19:53:40 -08:00
REFERENCING CURRENT HOSTING
This commit is contained in:
parent
1ffd3d0c49
commit
d2c8b85b15
@ -160,11 +160,16 @@ func (s *Server) previewHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
qrCode := base64.StdEncoding.EncodeToString(png)
|
qrCode := base64.StdEncoding.EncodeToString(png)
|
||||||
|
|
||||||
|
hostname := getURL(r).Host
|
||||||
|
webAddress := resolveWebAddress(r)
|
||||||
|
|
||||||
data := struct {
|
data := struct {
|
||||||
ContentType string
|
ContentType string
|
||||||
Content html_template.HTML
|
Content html_template.HTML
|
||||||
Filename string
|
Filename string
|
||||||
Url string
|
Url string
|
||||||
|
Hostname string
|
||||||
|
WebAddress string
|
||||||
ContentLength uint64
|
ContentLength uint64
|
||||||
GAKey string
|
GAKey string
|
||||||
UserVoiceKey string
|
UserVoiceKey string
|
||||||
@ -174,6 +179,8 @@ func (s *Server) previewHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
content,
|
content,
|
||||||
filename,
|
filename,
|
||||||
resolvedUrl,
|
resolvedUrl,
|
||||||
|
hostname,
|
||||||
|
webAddress,
|
||||||
contentLength,
|
contentLength,
|
||||||
s.gaKey,
|
s.gaKey,
|
||||||
s.userVoiceKey,
|
s.userVoiceKey,
|
||||||
@ -193,13 +200,27 @@ func (s *Server) previewHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (s *Server) viewHandler(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) viewHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// vars := mux.Vars(r)
|
// vars := mux.Vars(r)
|
||||||
|
|
||||||
|
hostname := getURL(r).Host
|
||||||
|
webAddress := resolveWebAddress(r)
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
Hostname string
|
||||||
|
WebAddress string
|
||||||
|
GAKey string
|
||||||
|
}{
|
||||||
|
hostname,
|
||||||
|
webAddress,
|
||||||
|
s.gaKey,
|
||||||
|
}
|
||||||
|
|
||||||
if acceptsHTML(r.Header) {
|
if acceptsHTML(r.Header) {
|
||||||
if err := htmlTemplates.ExecuteTemplate(w, "index.html", nil); err != nil {
|
if err := htmlTemplates.ExecuteTemplate(w, "index.html", data); err != nil {
|
||||||
|
s.logger.Println(err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := textTemplates.ExecuteTemplate(w, "index.txt", nil); err != nil {
|
if err := textTemplates.ExecuteTemplate(w, "index.txt", data); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -464,8 +485,14 @@ func resolveUrl(r *http.Request, u *url.URL, absolutePath bool) string {
|
|||||||
return getURL(r).ResolveReference(u).String()
|
return getURL(r).ResolveReference(u).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resolveWebAddress(r *http.Request) string {
|
||||||
|
url := getURL(r)
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s://%s", url.ResolveReference(url).Scheme, url.ResolveReference(url).Host)
|
||||||
|
}
|
||||||
|
|
||||||
func getURL(r *http.Request) *url.URL {
|
func getURL(r *http.Request) *url.URL {
|
||||||
u := *r.URL
|
u, _ := url.Parse(r.URL.String())
|
||||||
|
|
||||||
if r.TLS != nil {
|
if r.TLS != nil {
|
||||||
u.Scheme = "https"
|
u.Scheme = "https"
|
||||||
@ -488,7 +515,7 @@ func getURL(r *http.Request) *url.URL {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Lock(token, filename string) error {
|
func (s *Server) Lock(token, filename string) error {
|
||||||
|
1495
vendor/github.com/dutchcoders/transfer.sh-web/bindata_gen.go
generated
vendored
1495
vendor/github.com/dutchcoders/transfer.sh-web/bindata_gen.go
generated
vendored
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user