diff options
| author | Horus3 | 2015-06-15 15:00:21 +0200 |
|---|---|---|
| committer | Horus3 | 2015-06-15 15:00:21 +0200 |
| commit | dd4baa267dbdfe279aab5f4122305ac51c0c6a3d (patch) | |
| tree | 3704ecc1d709e0613d972d778b7b9ee046f96e1c | |
| parent | ffdfbb70cf2af25482b56f08e8cad53104d91e61 (diff) | |
| download | uhttpd-dd4baa267dbdfe279aab5f4122305ac51c0c6a3d.tar.gz | |
Fix css and some bugs.
| -rw-r--r-- | intercept.go | 5 | ||||
| -rw-r--r-- | scanner.go | 11 | ||||
| -rw-r--r-- | view.go | 8 |
3 files changed, 14 insertions, 10 deletions
diff --git a/intercept.go b/intercept.go index 8201f3e..eeea651 100644 --- a/intercept.go +++ b/intercept.go @@ -54,7 +54,10 @@ func (t *TemplateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - err = tmpl.Execute(w, struct{ URL string }{URL: r.URL.Path}) + err = tmpl.Execute(w, struct { + URL string + Favicon template.HTML + }{URL: r.URL.Path, Favicon: getFavicon()}) if err != nil { log.Println(err.Error()) w.WriteHeader(500) @@ -7,13 +7,14 @@ package main */ import "C" import ( + "html/template" "log" "strings" ) type Link struct { - Url string - Text string + Url template.URL + Text template.HTML IsDir bool } @@ -29,16 +30,16 @@ func getToken(input string) []Link { if token == C.TOKEN_URL { // flex reads the href attr - l.Url = C.GoString(C.yylval) + l.Url = template.URL(C.GoString(C.yylval)) - if strings.HasSuffix(l.Url, "/") { + if strings.HasSuffix(C.GoString(C.yylval), "/") { l.IsDir = true } } else if token == C.TOKEN_TEXT { // flex reads the link description - l.Text = C.GoString(C.yylval) + l.Text = template.HTML(C.GoString(C.yylval)) ls = append(ls, l) l = Link{} } else { @@ -7,16 +7,16 @@ func getTemplate() string { <meta charset="utf-8"> <title>{{.URL}}</title> <meta name="viewport" content="width=device-width, initial-scale=1"> - <style>/*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}a{background-color:transparent}a:active,a:hover{outline:0}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}.container{position:relative;width:100%;max-width:960px;margin:0 auto;padding:0 20px;box-sizing:border-box}.column{width:100%;float:left;box-sizing:border-box}@media (min-width:400px){.container{width:85%;padding:0}}@media (min-width:550px){.container{width:80%}.column{margin-left:4%}.column:first-child{margin-left:0}}html{font-size:62.5%}body{font-size:1.5em;line-height:1.6;font-weight:400;font-family:Raleway,HelveticaNeue,"Helvetica Neue",Helvetica,Arial,sans-serif;color:#222}h4{margin-top:0;margin-bottom:2rem;font-weight:300;font-size:2.4rem;line-height:1.35;letter-spacing:-.08rem}@media (min-width:550px){h4{font-size:3rem}}a{color:#1EAEDB}a:hover{color:#0FA0CE}blockquote{margin-bottom:2.5rem}.container:after,.row:after{content:"";display:table;clear:both}.margin-top{margin-top:20px}.dir,.dir:hover{color:#1EAEDB}.dir:hover{text-decoration:none}div.icon{height:32px;width:32px;position:relative;margin:15px;overflow:hidden;display:inline-block}span.icono-folder{color: #1EAEDB}.file,span.icono-caretUp,span.icono-home,span.icono-file{color:#000} -/*git.io/icono*/ .icono-file,.icono-folder,.icono-home,.icono-home:after,.icono-home:before{border:2px solid}.icono-home{width:22px;height:16px;border-top:none;margin:15px 6px 3px}.icono-home:before{width:18px;height:18px;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);position:absolute;left:-2px;top:-7px;border-right-color:transparent;border-bottom-color:transparent}.icono-home:after{width:6px;height:10px;bottom:0;position:absolute;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);border-width:1px;border-bottom:none}.icono-file{width:26px;height:32px;border-radius:0 12px 0 0;margin:1px 4px}.icono-file:before{position:absolute;top:-2px;right:-2px;border-style:solid;width:0;height:0;border-width:5px;border-top-color:transparent;border-right-color:transparent}.icono-folder{width:18px;height:22px;border-left-width:0;border-radius:0 3px 3px 0;margin:8px 2px 4px 14px}.icono-folder:before{position:absolute;width:12px;height:20px;left:-12px;bottom:-2px;border-width:0 0 2px 2px;border-style:solid;border-radius:0 0 0 3px}.icono-folder:after{position:absolute;width:10px;height:5px;left:-12px;top:-7px;border-width:2px 2px 0;border-style:solid;border-radius:3px 3px 0 0}[class*=icono-]{display:inline-block;vertical-align:middle;position:relative;font-style:normal;color:#ddd;text-align:left;text-indent:-9999px;direction:ltr}[class*=icono-]:after,[class*=icono-]:before{content:'';pointer-events:none}[class*=icono-]{box-sizing:border-box}</style> + <style>/*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}a{background-color:transparent}a:active,a:hover{outline:0}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}.container{position:relative;width:100%;max-width:960px;margin:0 auto;padding:0 20px;box-sizing:border-box}.column{width:100%;float:left;box-sizing:border-box}@media (min-width:400px){.container{width:85%;padding:0}}@media (min-width:550px){.container{width:80%}.column{margin-left:4%}.column:first-child{margin-left:0}}html{font-size:62.5%}body{font-size:1.5em;line-height:1.6;font-weight:400;font-family:Raleway,HelveticaNeue,"Helvetica Neue",Helvetica,Arial,sans-serif;color:#222}h4{margin-top:0;margin-bottom:2rem;font-weight:300;font-size:2.4rem;line-height:1.35;letter-spacing:-.08rem}@media (min-width:550px){h4{font-size:3rem}}a{color:#1EAEDB}a:hover{color:#0FA0CE}blockquote{margin-bottom:2.5rem}.container:after,.row:after{content:"";display:table;clear:both}.margin-top{margin-top:20px}.dir,.dir:hover{color:#1EAEDB}.dir:hover{text-decoration:none}span.icono-folder{color: #1EAEDB}.file,span.icono-caretUp,span.icono-home,span.icono-file{color:#000}span.icono-home:hover{color:#1EAEDB} +/*git.io/icono*/ .icono-file,.icono-folder,.icono-home,.icono-home:after,.icono-home:before{border:2px solid}.icono-home{width:22px;height:16px;border-top:none;margin:15px 6px 3px}.icono-home:before{width:18px;height:18px;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);position:absolute;left:-2px;top:-7px;border-right-color:transparent;border-bottom-color:transparent}.icono-home:after{width:6px;height:10px;bottom:0;position:absolute;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);border-width:1px;border-bottom:none}.icono-file{width:26px;height:32px;border-radius:0 12px 0 0;margin:1px 4px}.icono-file:before{position:absolute;top:-2px;right:-2px;border-style:solid;width:0;height:0;border-width:5px;border-top-color:transparent;border-right-color:transparent}.icono-folder{width:18px;height:22px;border-left-width:0;border-radius:0 3px 3px 0;margin:8px 2px 4px 14px}.icono-folder:before{position:absolute;width:12px;height:20px;left:-12px;bottom:-2px;border-width:0 0 2px 2px;border-style:solid;border-radius:0 0 0 3px}.icono-folder:after{position:absolute;width:10px;height:5px;left:-12px;top:-7px;border-width:2px 2px 0;border-style:solid;border-radius:3px 3px 0 0}.icono-caretUp{width:12px;height:20px;margin:7px 11px}.icono-caretUp:after,.icono-caretUp:before{width:14px;height:2px;position:absolute;bottom:0;margin:auto 0;right:2px;box-shadow:inset 0 0 0 32px;-webkit-transform-origin:right;-ms-transform-origin:right;transform-origin:right}.icono-caretUp:before{top:2px;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.icono-caretUp:after{top:0;-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg)}.icono-caretUp{-webkit-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}[class*=icono-]{display:inline-block;vertical-align:middle;position:relative;font-style:normal;color:#ddd;text-align:left;text-indent:-9999px;direction:ltr}[class*=icono-]:after,[class*=icono-]:before{content:'';pointer-events:none}[class*=icono-]{box-sizing:border-box}</style> {{.Favicon}} </head> <body> <div class="container"> <div class="row"> <div class="column margin-top"> - <h4><a href="/" title="Go back to root" class="file"><span class="icono-home"></span> {{.URL}}</a></h4> - {{if .AllowUpload}}<p>To upload please click <a href="/upload" title="Upload">here</a>.</p>{{end}} + <h4><a href="/" title="Go back to root" class="file"><span class="icono-home"></span></a> - {{.URL}}</h4> + {{if .AllowUpload}}<p>To upload please click <a href="/upload" title="Upload" class="dir">here</a>.</p>{{end}} <blockquote> {{if ne .URL "/"}} <a class="dir" href=".."><span class="icono-caretUp"></span> .. (up a dir)</a><br><br> |
