parent
a77f28fbcf
commit
683b7a5f2d
|
|
@ -12,6 +12,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *Server) Routes() error {
|
||||
|
|
@ -27,6 +28,10 @@ func (s *Server) Routes() error {
|
|||
path: "/mytinytodo_lang.php",
|
||||
handler: s.gzip(s.lang),
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("/themes/%s%s", router.Wildcard, router.Wildcard),
|
||||
handler: s.gzip(s.handleDeviceCSS),
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("%s%s", router.Wildcard, router.Wildcard),
|
||||
handler: s.gzip(s.phpProxy),
|
||||
|
|
@ -119,3 +124,14 @@ func (s *Server) gzip(h http.HandlerFunc) http.HandlerFunc {
|
|||
h(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleDeviceCSS(w http.ResponseWriter, r *http.Request) {
|
||||
if _, ok := r.URL.Query()["pda"]; ok || strings.Contains(r.Header.Get("User-Agent"), "Android") || strings.Contains(r.Header.Get("User-Agent"), "Mobile") {
|
||||
if path.Base(r.URL.Path) == "print.css" {
|
||||
r.URL.Path = path.Join(path.Dir(r.URL.Path), "pda.css")
|
||||
http.Redirect(w, r, r.URL.String(), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
}
|
||||
s.static(w, r)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue