summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorus_arch2015-06-15 17:07:43 +0200
committerhorus_arch2015-06-15 17:07:43 +0200
commit1276eba6a546b61b8396e838e3043f2e609ce7d4 (patch)
tree555fc6aa9ef45bc43cbde7c2ff1ac02c7c62e7b2
parente205935a4fd7ae56a352d5dd8d1b69f143afb09c (diff)
parentdd4baa267dbdfe279aab5f4122305ac51c0c6a3d (diff)
downloaduhttpd-1276eba6a546b61b8396e838e3043f2e609ce7d4.tar.gz
Merge branch 'master' of git.iamfabulous.de:uhttpd
-rw-r--r--intercept.go5
-rw-r--r--scanner.go11
-rw-r--r--view.go8
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)
diff --git a/scanner.go b/scanner.go
index 6679a80..9b35de3 100644
--- a/scanner.go
+++ b/scanner.go
@@ -6,13 +6,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
}
@@ -28,16 +29,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 {
diff --git a/view.go b/view.go
index cc0dd17..005be2c 100644
--- a/view.go
+++ b/view.go
@@ -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>