diff --git a/Dockerfile b/Dockerfile index ef4147d..cfc9157 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,6 @@ WORKDIR /go/src/pastebin COPY . /go/src/pastebin RUN go get -v -d +RUN go get github.com/GeertJohan/go.rice/rice +RUN rice embed-go RUN go install -v diff --git a/server.go b/server.go index 96aa4c1..8fd350b 100644 --- a/server.go +++ b/server.go @@ -3,10 +3,13 @@ package main import ( "encoding/json" "fmt" + "html/template" "io/ioutil" "log" "net/http" "net/url" + "strings" + "time" // Logging "github.com/unrolled/logger" @@ -21,7 +24,6 @@ import ( "github.com/patrickmn/go-cache" "github.com/renstrom/shortuuid" "github.com/timewasted/go-accept-headers" - "go.iondynamics.net/templice" ) // AcceptedTypes ... @@ -63,7 +65,7 @@ type Server struct { bind string config Config store *cache.Cache - templates *templice.Template + templates *Templates router *httprouter.Router // Logger @@ -74,8 +76,13 @@ type Server struct { stats *stats.Stats } -func (s *Server) render(w http.ResponseWriter, tmpl string, data interface{}) { - err := s.templates.ExecuteTemplate(w, tmpl+".html", data) +func (s *Server) render(name string, w http.ResponseWriter, ctx interface{}) { + buf, err := s.templates.Exec(name, ctx) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + + _, err = buf.WriteTo(w) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } @@ -97,7 +104,7 @@ func (s *Server) IndexHandler() httprouter.Handle { switch accepts { case "text/html": - s.render(w, "index", nil) + s.render("index", w, nil) case "text/plain": default: } @@ -109,23 +116,15 @@ func (s *Server) PasteHandler() httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { s.counters.Inc("n_paste") - var blob string - - body, err := ioutil.ReadAll(r.Body) - if err != nil { - http.Error(w, "Internal Error", http.StatusInternalServerError) - return - } - blob = string(body) - - err = r.ParseForm() - if err != nil { - http.Error(w, "Internal Error", http.StatusInternalServerError) - return - } + blob := r.FormValue("blob") if blob == "" { - blob = r.Form.Get("blob") + body, err := ioutil.ReadAll(r.Body) + if err != nil { + http.Error(w, "Internal Error", http.StatusInternalServerError) + return + } + blob = string(body) } if blob == "" { @@ -148,6 +147,33 @@ func (s *Server) PasteHandler() httprouter.Handle { } } +// DownloadHandler ... +func (s *Server) DownloadHandler() httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { + s.counters.Inc("n_download") + + uuid := p.ByName("uuid") + if uuid == "" { + http.Error(w, "Bad Request", http.StatusBadRequest) + return + } + + blob, ok := s.store.Get(uuid) + if !ok { + http.Error(w, "Not Found", http.StatusNotFound) + return + } + + content := strings.NewReader(blob.(string)) + + w.Header().Set("Content-Disposition", "attachment; filename="+uuid) + w.Header().Set("Content-Type", "application/octet-stream") + w.Header().Set("Content-Length", string(content.Size())) + + http.ServeContent(w, r, uuid, time.Now(), content) + } +} + // ViewHandler ... func (s *Server) ViewHandler() httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { @@ -176,7 +202,16 @@ func (s *Server) ViewHandler() httprouter.Handle { switch accepts { case "text/html": - s.render(w, "view", struct{ Blob string }{Blob: blob.(string)}) + s.render( + "view", w, + struct { + Blob string + UUID string + }{ + Blob: blob.(string), + UUID: uuid, + }, + ) case "text/plain": w.Write([]byte(blob.(string))) default: @@ -213,8 +248,14 @@ func (s *Server) initRoutes() { s.router.Handler("GET", "/debug/metrics", exp.ExpHandler(s.counters.r)) s.router.GET("/debug/stats", s.StatsHandler()) + s.router.ServeFiles( + "/css/*filepath", + rice.MustFindBox("static/css").HTTPBox(), + ) + s.router.GET("/", s.IndexHandler()) s.router.POST("/", s.PasteHandler()) + s.router.GET("/download/:uuid", s.DownloadHandler()) s.router.GET("/view/:uuid", s.ViewHandler()) } @@ -225,7 +266,7 @@ func NewServer(bind string, config Config) *Server { config: config, router: httprouter.New(), store: cache.New(cfg.expiry, cfg.expiry*2), - templates: templice.New(rice.MustFindBox("templates")), + templates: NewTemplates("base"), // Logger logger: logger.New(logger.Options{ @@ -239,10 +280,19 @@ func NewServer(bind string, config Config) *Server { stats: stats.New(), } - err := server.templates.Load() - if err != nil { - log.Panicf("error loading templates: %s", err) - } + // Templates + box := rice.MustFindBox("templates") + + indexTemplate := template.New("view") + template.Must(indexTemplate.Parse(box.MustString("index.html"))) + template.Must(indexTemplate.Parse(box.MustString("base.html"))) + + viewTemplate := template.New("view") + template.Must(viewTemplate.Parse(box.MustString("view.html"))) + template.Must(viewTemplate.Parse(box.MustString("base.html"))) + + server.templates.Add("index", indexTemplate) + server.templates.Add("view", viewTemplate) server.initRoutes() diff --git a/static/css/spectre-icons.min.css b/static/css/spectre-icons.min.css new file mode 100644 index 0000000..6c3b6a2 --- /dev/null +++ b/static/css/spectre-icons.min.css @@ -0,0 +1 @@ +/*! Spectre.css Icons | MIT License | github.com/picturepan2/spectre */.icon{box-sizing:border-box;display:inline-block;font-size:inherit;font-style:normal;height:1em;position:relative;text-indent:-999rem;vertical-align:middle;width:1em}.icon::after,.icon::before{display:block;left:50%;position:absolute;top:50%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.icon-arrow-down::before,.icon-arrow-left::before,.icon-arrow-right::before,.icon-arrow-up::before,.icon-back::before,.icon-downward::before,.icon-forward::before,.icon-upward::before{border:.2rem solid currentColor;border-bottom:0;border-right:0;content:"";height:.65em;-webkit-transform:translate(-25%,-50%) rotate(-45deg);-ms-transform:translate(-25%,-50%) rotate(-45deg);transform:translate(-25%,-50%) rotate(-45deg);width:.65em}.icon-arrow-down,.icon-downward{-webkit-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}.icon-arrow-right,.icon-forward{-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.icon-arrow-up,.icon-upward{-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.icon-back::before,.icon-downward::before,.icon-forward::before,.icon-upward::before{-webkit-transform:translate(-50%,-50%) rotate(-45deg);-ms-transform:translate(-50%,-50%) rotate(-45deg);transform:translate(-50%,-50%) rotate(-45deg)}.icon-back::after,.icon-downward::after,.icon-forward::after,.icon-upward::after{background:currentColor;content:"";height:.2rem;left:55%;width:.8em}.icon-caret::before{border-left:.3em solid transparent;border-right:.3em solid transparent;border-top:.3em solid currentColor;content:"";height:0;-webkit-transform:translate(-50%,-25%);-ms-transform:translate(-50%,-25%);transform:translate(-50%,-25%);width:0}.icon-menu::before{background:currentColor;box-shadow:0 -.35em,0 .35em;content:"";height:.2rem;width:100%}.icon-apps::before{background:currentColor;box-shadow:-.35em -.35em,-.35em 0,-.35em .35em,0 -.35em,0 .35em,.35em -.35em,.35em 0,.35em .35em;content:"";height:.3rem;width:.3rem}.icon-resize-horiz::after,.icon-resize-horiz::before,.icon-resize-vert::after,.icon-resize-vert::before{border:.2rem solid currentColor;border-bottom:0;border-right:0;content:"";height:.45em;width:.45em}.icon-resize-horiz::before,.icon-resize-vert::before{-webkit-transform:translate(-50%,-90%) rotate(45deg);-ms-transform:translate(-50%,-90%) rotate(45deg);transform:translate(-50%,-90%) rotate(45deg)}.icon-resize-horiz::after,.icon-resize-vert::after{-webkit-transform:translate(-50%,-10%) rotate(225deg);-ms-transform:translate(-50%,-10%) rotate(225deg);transform:translate(-50%,-10%) rotate(225deg)}.icon-resize-horiz::before{-webkit-transform:translate(-90%,-50%) rotate(-45deg);-ms-transform:translate(-90%,-50%) rotate(-45deg);transform:translate(-90%,-50%) rotate(-45deg)}.icon-resize-horiz::after{-webkit-transform:translate(-10%,-50%) rotate(135deg);-ms-transform:translate(-10%,-50%) rotate(135deg);transform:translate(-10%,-50%) rotate(135deg)}.icon-more-horiz::before,.icon-more-vert::before{background:currentColor;border-radius:50%;box-shadow:-.4em 0,.4em 0;content:"";height:.3rem;width:.3rem}.icon-more-vert::before{box-shadow:0 -.4em,0 .4em}.icon-cross::before,.icon-minus::before,.icon-plus::before{background:currentColor;content:"";height:.2rem;width:100%}.icon-cross::after,.icon-plus::after{background:currentColor;content:"";height:100%;width:.2rem}.icon-cross::before{width:100%}.icon-cross::after{height:100%}.icon-cross::after,.icon-cross::before{-webkit-transform:translate(-50%,-50%) rotate(45deg);-ms-transform:translate(-50%,-50%) rotate(45deg);transform:translate(-50%,-50%) rotate(45deg)}.icon-check::before{border:.2rem solid currentColor;border-right:0;border-top:0;content:"";height:.5em;-webkit-transform:translate(-50%,-75%) rotate(-45deg);-ms-transform:translate(-50%,-75%) rotate(-45deg);transform:translate(-50%,-75%) rotate(-45deg);width:.9em}.icon-stop{border:.2rem solid currentColor;border-radius:50%}.icon-stop::before{background:currentColor;content:"";height:.2rem;-webkit-transform:translate(-50%,-50%) rotate(45deg);-ms-transform:translate(-50%,-50%) rotate(45deg);transform:translate(-50%,-50%) rotate(45deg);width:1em}.icon-shutdown{border:.2rem solid currentColor;border-radius:50%;border-top-color:transparent}.icon-shutdown::before{background:currentColor;content:"";height:.5em;top:.1em;width:.2rem}.icon-refresh::before{border:.2rem solid currentColor;border-radius:50%;border-right-color:transparent;content:"";height:1em;width:1em}.icon-refresh::after{border:.2em solid currentColor;border-left-color:transparent;border-top-color:transparent;content:"";height:0;left:80%;top:20%;width:0}.icon-search::before{border:.2rem solid currentColor;border-radius:50%;content:"";height:.75em;left:5%;top:5%;-webkit-transform:translate(0,0) rotate(45deg);-ms-transform:translate(0,0) rotate(45deg);transform:translate(0,0) rotate(45deg);width:.75em}.icon-search::after{background:currentColor;content:"";height:.2rem;left:80%;top:80%;-webkit-transform:translate(-50%,-50%) rotate(45deg);-ms-transform:translate(-50%,-50%) rotate(45deg);transform:translate(-50%,-50%) rotate(45deg);width:.4em}.icon-edit::before{border:.2rem solid currentColor;content:"";height:.4em;-webkit-transform:translate(-40%,-60%) rotate(-45deg);-ms-transform:translate(-40%,-60%) rotate(-45deg);transform:translate(-40%,-60%) rotate(-45deg);width:.85em}.icon-edit::after{border:.15em solid currentColor;border-right-color:transparent;border-top-color:transparent;content:"";height:0;left:5%;top:95%;-webkit-transform:translate(0,-100%);-ms-transform:translate(0,-100%);transform:translate(0,-100%);width:0}.icon-delete::before{border:.2rem solid currentColor;border-bottom-left-radius:.2rem;border-bottom-right-radius:.2rem;border-top:0;content:"";height:.75em;top:60%;width:.75em}.icon-delete::after{background:currentColor;box-shadow:-.25em .2em,.25em .2em;content:"";height:.2rem;top:.1rem;width:.5em}.icon-share{border:.2rem solid currentColor;border-radius:.2rem;border-right:0;border-top:0}.icon-share::before{border:.2rem solid currentColor;border-left:0;border-top:0;content:"";height:.4em;left:100%;top:.25em;-webkit-transform:translate(-125%,-50%) rotate(-45deg);-ms-transform:translate(-125%,-50%) rotate(-45deg);transform:translate(-125%,-50%) rotate(-45deg);width:.4em}.icon-share::after{border:.2rem solid currentColor;border-bottom:0;border-radius:75% 0;border-right:0;content:"";height:.5em;width:.6em}.icon-flag::before{background:currentColor;content:"";height:1em;left:15%;width:.2rem}.icon-flag::after{border:.2rem solid currentColor;border-bottom-right-radius:.2rem;border-left:0;border-top-right-radius:.2rem;content:"";height:.65em;left:60%;top:35%;width:.8em}.icon-bookmark::before{border:.2rem solid currentColor;border-bottom:0;border-top-left-radius:.2rem;border-top-right-radius:.2rem;content:"";height:.9em;width:.8em}.icon-bookmark::after{border:.2rem solid currentColor;border-bottom:0;border-left:0;border-radius:.2rem;content:"";height:.5em;-webkit-transform:translate(-50%,35%) rotate(-45deg) skew(15deg,15deg);-ms-transform:translate(-50%,35%) rotate(-45deg) skew(15deg,15deg);transform:translate(-50%,35%) rotate(-45deg) skew(15deg,15deg);width:.5em}.icon-download,.icon-upload{border-bottom:.2rem solid currentColor}.icon-download::before,.icon-upload::before{border:.2rem solid currentColor;border-bottom:0;border-right:0;content:"";height:.5em;-webkit-transform:translate(-50%,-60%) rotate(-135deg);-ms-transform:translate(-50%,-60%) rotate(-135deg);transform:translate(-50%,-60%) rotate(-135deg);width:.5em}.icon-download::after,.icon-upload::after{background:currentColor;content:"";height:.6em;top:40%;width:.2rem}.icon-upload::before{-webkit-transform:translate(-50%,-60%) rotate(45deg);-ms-transform:translate(-50%,-60%) rotate(45deg);transform:translate(-50%,-60%) rotate(45deg)}.icon-upload::after{top:50%}.icon-time{border:.2rem solid currentColor;border-radius:50%}.icon-time::before{background:currentColor;content:"";height:.4em;-webkit-transform:translate(-50%,-75%);-ms-transform:translate(-50%,-75%);transform:translate(-50%,-75%);width:.2rem}.icon-time::after{background:currentColor;content:"";height:.3em;-webkit-transform:translate(-50%,-75%) rotate(90deg);-ms-transform:translate(-50%,-75%) rotate(90deg);transform:translate(-50%,-75%) rotate(90deg);-webkit-transform-origin:50% 90%;-ms-transform-origin:50% 90%;transform-origin:50% 90%;width:.2rem}.icon-mail::before{border:.2rem solid currentColor;border-radius:.2rem;content:"";height:.8em;width:1em}.icon-mail::after{border:.2rem solid currentColor;border-right:0;border-top:0;content:"";height:.5em;-webkit-transform:translate(-50%,-90%) rotate(-45deg) skew(10deg,10deg);-ms-transform:translate(-50%,-90%) rotate(-45deg) skew(10deg,10deg);transform:translate(-50%,-90%) rotate(-45deg) skew(10deg,10deg);width:.5em}.icon-people::before{border:.2rem solid currentColor;border-radius:50%;content:"";height:.45em;top:25%;width:.45em}.icon-people::after{border:.2rem solid currentColor;border-radius:50% 50% 0 0;content:"";height:.4em;top:75%;width:.9em}.icon-message{border:.2rem solid currentColor;border-bottom:0;border-radius:.2rem;border-right:0}.icon-message::before{border:.2rem solid currentColor;border-bottom-right-radius:.2rem;border-left:0;border-top:0;content:"";height:.8em;left:65%;top:40%;width:.7em}.icon-message::after{background:currentColor;border-radius:.2rem;content:"";height:.3em;left:10%;top:100%;-webkit-transform:translate(0,-90%) rotate(45deg);-ms-transform:translate(0,-90%) rotate(45deg);transform:translate(0,-90%) rotate(45deg);width:.2rem}.icon-photo{border:.2rem solid currentColor;border-radius:.2rem}.icon-photo::before{border:.2rem solid currentColor;border-radius:50%;content:"";height:.25em;left:35%;top:35%;width:.25em}.icon-photo::after{border:.2rem solid currentColor;border-bottom:0;border-left:0;content:"";height:.5em;left:60%;-webkit-transform:translate(-50%,25%) rotate(-45deg);-ms-transform:translate(-50%,25%) rotate(-45deg);transform:translate(-50%,25%) rotate(-45deg);width:.5em}.icon-link::after,.icon-link::before{border:.2rem solid currentColor;border-radius:5em 0 0 5em;border-right:0;content:"";height:.5em;width:.75em}.icon-link::before{-webkit-transform:translate(-70%,-45%) rotate(-45deg);-ms-transform:translate(-70%,-45%) rotate(-45deg);transform:translate(-70%,-45%) rotate(-45deg)}.icon-link::after{-webkit-transform:translate(-30%,-55%) rotate(135deg);-ms-transform:translate(-30%,-55%) rotate(135deg);transform:translate(-30%,-55%) rotate(135deg)}.icon-location::before{border:.2rem solid currentColor;border-radius:50% 50% 50% 0;content:"";height:.8em;-webkit-transform:translate(-50%,-60%) rotate(-45deg);-ms-transform:translate(-50%,-60%) rotate(-45deg);transform:translate(-50%,-60%) rotate(-45deg);width:.8em}.icon-location::after{border:.2rem solid currentColor;border-radius:50%;content:"";height:.2em;-webkit-transform:translate(-50%,-80%);-ms-transform:translate(-50%,-80%);transform:translate(-50%,-80%);width:.2em}.icon-emoji{border:.2rem solid currentColor;border-radius:50%}.icon-emoji::before{border-radius:50%;box-shadow:-.17em -.15em,.17em -.15em;content:"";height:.1em;width:.1em}.icon-emoji::after{border:.2rem solid currentColor;border-bottom-color:transparent;border-radius:50%;border-right-color:transparent;content:"";height:.5em;-webkit-transform:translate(-50%,-40%) rotate(-135deg);-ms-transform:translate(-50%,-40%) rotate(-135deg);transform:translate(-50%,-40%) rotate(-135deg);width:.5em}.btn .icon,.menu .icon,.toast .icon{vertical-align:-10%} \ No newline at end of file diff --git a/static/css/spectre.min.css b/static/css/spectre.min.css new file mode 100644 index 0000000..5b9550a --- /dev/null +++ b/static/css/spectre.min.css @@ -0,0 +1 @@ +/*! Spectre.css | MIT License | github.com/picturepan2/spectre */html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}hr{box-sizing:content-box;height:0;overflow:visible}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}b,strong{font-weight:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}fieldset{border:0;margin:0;padding:0}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}template{display:none}[hidden]{display:none}*,::after,::before{box-sizing:inherit}html{box-sizing:border-box;font-size:10px;line-height:1.42857143;-webkit-tap-highlight-color:transparent}body{background:#fff;color:#50596c;font-family:-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",sans-serif;font-size:1.4rem;overflow-x:hidden;text-rendering:optimizeLegibility}a{color:#5764c6;outline:0;text-decoration:none}a:focus{box-shadow:0 0 0 .2rem rgba(87,100,198,.15)}a.active,a:active,a:focus,a:hover{color:#3b49af;text-decoration:underline}h1,h2,h3,h4,h5,h6{color:inherit;font-weight:300;line-height:1.2;margin-bottom:1.5rem;margin-top:0}h1{font-size:5rem}h2{font-size:4rem}h3{font-size:3rem}h4{font-size:2.4rem}h5{font-size:2rem}h6{font-size:1.6rem}p{line-height:2.4rem;margin:0 0 1rem}a,ins,u{-webkit-text-decoration-skip:ink edges;text-decoration-skip:ink edges}blockquote{border-left:.2rem solid #f0f1f4;margin-left:0;padding:1rem 2rem}blockquote p:last-child{margin-bottom:0}blockquote cite{color:#acb3c2}ol,ul{margin:2rem 0 2rem 2rem;padding:0}ol ol,ol ul,ul ol,ul ul{margin:1.5rem 0 1.5rem 2rem}ol li,ul li{margin-top:1rem}ul{list-style:disc inside}ul ul{list-style-type:circle}ol{list-style:decimal inside}ol ol{list-style-type:lower-alpha}dl dt{font-weight:700}dl dd{margin:.5rem 0 1.5rem 0}mark{background:#ffe9b3;border-radius:.2rem;color:#50596c;display:inline-block;line-height:1;padding:.3rem .4rem;vertical-align:baseline}kbd{background:#454d5d;border-radius:.2rem;color:#fff;display:inline-block;line-height:1;padding:.3rem .4rem;vertical-align:baseline}abbr[title]{border-bottom:.1rem dotted;cursor:help;text-decoration:none}.cjk,:lang(ja),:lang(ko),:lang(zh){font-family:-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Hiragino Kaku Gothic Pro",Meiryo,"Malgun Gothic","Helvetica Neue",sans-serif}.cjk ins,.cjk u,:lang(ja) ins,:lang(ja) u,:lang(zh) ins,:lang(zh) u{border-bottom:.1rem solid;text-decoration:none}.cjk del+del,.cjk del+s,.cjk ins+ins,.cjk ins+u,.cjk s+del,.cjk s+s,.cjk u+ins,.cjk u+u,:lang(ja) del+del,:lang(ja) del+s,:lang(ja) ins+ins,:lang(ja) ins+u,:lang(ja) s+del,:lang(ja) s+s,:lang(ja) u+ins,:lang(ja) u+u,:lang(zh) del+del,:lang(zh) del+s,:lang(zh) ins+ins,:lang(zh) ins+u,:lang(zh) s+del,:lang(zh) s+s,:lang(zh) u+ins,:lang(zh) u+u{margin-left:.125em}.table{border-collapse:collapse;border-spacing:0;text-align:left;width:100%}.table.table-striped tbody tr:nth-of-type(odd){background:#f8f9fa}.table.table-hover tbody tr:hover{background:#f0f1f4}.table tbody tr.active,.table.table-striped tbody tr.active{background:#f0f1f4}.table td{border-bottom:.1rem solid #f0f1f4;padding:1.5rem 1rem}.table th{border-bottom:.1rem solid #727e96;padding:1.5rem 1rem}.btn{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:#fff;border:.1rem solid #5764c6;border-radius:.2rem;color:#5764c6;cursor:pointer;display:inline-block;font-size:1.4rem;height:3.2rem;line-height:2rem;outline:0;padding:.5rem .8rem;text-align:center;text-decoration:none;transition:all .2s ease;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;white-space:nowrap}.btn:focus{background:#fbfbfe;box-shadow:0 0 0 .2rem rgba(87,100,198,.15);text-decoration:none}.btn:hover{background:#5764c6;border-color:#4c59c2;color:#fff;text-decoration:none}.btn.active,.btn:active{background:#4c59c2;border-color:#3e4cb6;color:#fff;text-decoration:none}.btn.disabled,.btn:disabled,.btn[disabled]{cursor:default;opacity:.5;pointer-events:none}.btn.btn-primary{background:#5764c6;border-color:#4c59c2;color:#fff}.btn.btn-primary:focus,.btn.btn-primary:hover{background:#4452c0;border-color:#3e4cb6;color:#fff}.btn.btn-primary.active,.btn.btn-primary:active{background:#3f4eba;border-color:#3b49af;color:#fff}.btn.btn-primary.loading::after{border-bottom-color:#fff;border-left-color:#fff}.btn.btn-link{background:0 0;border-color:transparent;color:#5764c6}.btn.btn-link.active,.btn.btn-link:active,.btn.btn-link:focus,.btn.btn-link:hover{color:#3b49af}.btn.btn-sm{font-size:1.2rem;height:2.4rem;padding:.1rem .8rem}.btn.btn-lg{font-size:1.6rem;height:4rem;padding:.9rem .8rem}.btn.btn-block{display:block;width:100%}.btn.btn-action{padding-left:0;padding-right:0;width:3.2rem}.btn.btn-action.btn-sm{width:2.4rem}.btn.btn-action.btn-lg{width:4rem}.btn.btn-clear{background:0 0;border:0;color:currentColor;height:1.6rem;line-height:1.6rem;margin-left:.4rem;margin-right:-.2rem;opacity:.45;padding:0 .2rem;text-decoration:none;width:1.6rem}.btn.btn-clear:hover{opacity:.85}.btn.btn-clear::before{content:"\2715"}.btn-group{display:inline-flex;display:-ms-inline-flexbox;display:-webkit-inline-flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.btn-group .btn{-webkit-flex:1 0 auto;-ms-flex:1 0 auto;flex:1 0 auto}.btn-group .btn:first-child:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.btn-group .btn:not(:first-child):not(:last-child){border-radius:0;margin-left:-.1rem}.btn-group .btn:last-child:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0;margin-left:-.1rem}.btn-group .btn.active,.btn-group .btn:active,.btn-group .btn:focus,.btn-group .btn:hover{z-index:1}.btn-group.btn-group-block{display:flex;display:-ms-flexbox;display:-webkit-flex}.btn-group.btn-group-block .btn{-webkit-flex:1 0 0;-ms-flex:1 0 0;flex:1 0 0}.form-group:not(:last-child){margin-bottom:1rem}.form-label{display:block;padding:.6rem 0}.form-label.label-sm{padding:.2rem 0}.form-label.label-lg{padding:1rem 0}.form-input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:#fff;background-image:none;border:.1rem solid #c4c9d3;border-radius:.2rem;color:#50596c;display:block;font-size:1.4rem;height:3.2rem;line-height:2rem;max-width:100%;outline:0;padding:.5rem .8rem;position:relative;transition:all .2s ease;width:100%}.form-input:focus{border-color:#5764c6;box-shadow:0 0 0 .2rem rgba(87,100,198,.15)}.form-input::-webkit-input-placeholder{color:#acb3c2}.form-input::-moz-placeholder{color:#acb3c2}.form-input:-ms-input-placeholder{color:#acb3c2}.form-input::placeholder{color:#acb3c2}.form-input.input-sm{font-size:1.2rem;height:2.4rem;padding:.1rem .8rem}.form-input.input-lg{font-size:1.6rem;height:4rem;padding:.9rem .8rem}.form-input.input-inline{display:inline-block;vertical-align:middle;width:auto}textarea.form-input{height:auto}.form-input[type=file]{height:auto}.form-input-hint{color:#acb3c2;margin-top:.4rem}.has-success .form-input-hint,.is-success+.form-input-hint{color:#32b643}.has-error .form-input-hint,.is-error+.form-input-hint{color:#e85600}.form-select{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:.1rem solid #c4c9d3;border-radius:.2rem;color:inherit;font-size:1.4rem;line-height:2rem;outline:0;padding:.5rem .8rem;vertical-align:middle;width:100%}.form-select[multiple] option{padding:.2rem .4rem}.form-select:not([multiple]){background:#fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23667189' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .75rem center/.8rem 1rem;height:3.2rem;padding-right:2.4rem}.form-select:focus{border-color:#5764c6;box-shadow:0 0 0 .2rem rgba(87,100,198,.15)}.form-select::-ms-expand{display:none}.form-select.select-sm{font-size:1.2rem;height:2.4rem;padding:.1rem 2rem .1rem .6rem}.form-select.select-lg{font-size:1.6rem;height:4rem;padding:.9rem 2.4rem .9rem .8rem}.form-input.is-success,.form-select.is-success,.has-success .form-input,.has-success .form-select{border-color:#32b643}.form-input.is-success:focus,.form-select.is-success:focus,.has-success .form-input:focus,.has-success .form-select:focus{box-shadow:0 0 0 .2rem rgba(50,182,67,.15)}.form-input.is-error,.form-select.is-error,.has-error .form-input,.has-error .form-select{border-color:#e85600}.form-input.is-error:focus,.form-select.is-error:focus,.has-error .form-input:focus,.has-error .form-select:focus{box-shadow:0 0 0 .2rem rgba(232,86,0,.15)}.form-input:not(:placeholder-shown):invalid{border-color:#e85600}.form-input:not(:placeholder-shown):invalid:focus{box-shadow:0 0 0 .2rem rgba(232,86,0,.15)}.form-input:not(:placeholder-shown):invalid+.form-input-hint{color:#e85600}.has-icon-left,.has-icon-right{position:relative}.has-icon-left .form-icon,.has-icon-right .form-icon{margin:0 .8rem;min-width:1.4rem;position:absolute;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%)}.has-icon-left .form-icon{left:0}.has-icon-left .form-input{padding-left:3rem}.has-icon-right .form-icon{right:0}.has-icon-right .form-input{padding-right:3rem}.form-checkbox,.form-radio,.form-switch{display:inline-block;line-height:2rem;position:relative}.form-checkbox input,.form-radio input,.form-switch input{clip:rect(0,0,0,0);height:.1rem;margin:-.1rem;overflow:hidden;position:absolute;width:.1rem}.form-checkbox input:focus+.form-icon,.form-radio input:focus+.form-icon,.form-switch input:focus+.form-icon{border-color:#5764c6;box-shadow:0 0 0 .2rem rgba(87,100,198,.15)}.form-checkbox input:checked+.form-icon,.form-radio input:checked+.form-icon,.form-switch input:checked+.form-icon{background:#5764c6;border-color:#5764c6}.form-checkbox .form-icon,.form-radio .form-icon,.form-switch .form-icon{border:.1rem solid #c4c9d3;cursor:pointer;display:inline-block;position:absolute;transition:all .2s ease}.form-checkbox,.form-radio{padding:.2rem 2rem}.form-checkbox .form-icon,.form-radio .form-icon{background:#fff;height:1.4rem;left:0;top:.5rem;width:1.4rem}.form-checkbox input:active+.form-icon,.form-radio input:active+.form-icon{background:#f0f1f4}.form-checkbox .form-icon{border-radius:.2rem}.form-checkbox input:checked+.form-icon::before{background-clip:padding-box;border:.2rem solid #fff;border-left-width:0;border-top-width:0;content:"";height:1rem;left:50%;margin-left:-.3rem;margin-top:-.6rem;position:absolute;top:50%;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);width:.6rem}.form-checkbox input:indeterminate+.form-icon{background:#5764c6;border-color:#5764c6}.form-checkbox input:indeterminate+.form-icon::before{background:#fff;content:"";height:.2rem;left:50%;margin-left:-.5rem;margin-top:-.1rem;position:absolute;top:50%;width:1rem}.form-radio .form-icon{border-radius:.7rem}.form-radio input:checked+.form-icon::before{background:#fff;border-radius:.2rem;content:"";height:.4rem;left:50%;margin-left:-.2rem;margin-top:-.2rem;position:absolute;top:50%;width:.4rem}.form-switch{padding:.2rem 2rem .2rem 3.6rem}.form-switch .form-icon{background:#e7e9ed;background-clip:padding-box;border-radius:.9rem;height:1.8rem;left:0;top:.3rem;width:3rem}.form-switch .form-icon::before{background:#fff;border-radius:.8rem;content:"";display:block;height:1.6rem;left:0;position:absolute;top:0;transition:all .2s ease;width:1.6rem}.form-switch input:checked+.form-icon::before{left:1.2rem}.form-switch input:active+.form-icon::before{background:#f8f9fa}.input-group{display:flex;display:-ms-flexbox;display:-webkit-flex}.input-group .input-group-addon{background:#f8f9fa;border:.1rem solid #c4c9d3;border-radius:.2rem;line-height:2rem;padding:.5rem .8rem}.input-group .input-group-addon.addon-sm{font-size:1.2rem;padding:.1rem .8rem}.input-group .input-group-addon.addon-lg{font-size:1.6rem;padding:.9rem .8rem}.input-group .input-group-addon,.input-group .input-group-btn{-webkit-flex:1 0 auto;-ms-flex:1 0 auto;flex:1 0 auto}.input-group .form-input:first-child:not(:last-child),.input-group .form-select:first-child:not(:last-child),.input-group .input-group-addon:first-child:not(:last-child),.input-group .input-group-btn:first-child:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.input-group .form-input:not(:first-child):not(:last-child),.input-group .form-select:not(:first-child):not(:last-child),.input-group .input-group-addon:not(:first-child):not(:last-child),.input-group .input-group-btn:not(:first-child):not(:last-child){border-radius:0;margin-left:-.1rem}.input-group .form-input:last-child:not(:first-child),.input-group .form-select:last-child:not(:first-child),.input-group .input-group-addon:last-child:not(:first-child),.input-group .input-group-btn:last-child:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0;margin-left:-.1rem}.input-group .form-input:focus,.input-group .form-select:focus,.input-group .input-group-addon:focus,.input-group .input-group-btn:focus{z-index:1}.input-group .form-select{width:auto}.input-group.input-inline{display:inline-flex;display:-ms-inline-flexbox;display:-webkit-inline-flex}.form-input.disabled,.form-input:disabled,.form-select.disabled,.form-select:disabled{background-color:#f0f1f4;cursor:not-allowed;opacity:.5}.form-input[readonly]{background-color:#f8f9fa}input.disabled+.form-icon,input:disabled+.form-icon{background:#f0f1f4;cursor:not-allowed;opacity:.5}.form-switch input.disabled+.form-icon::before,.form-switch input:disabled+.form-icon::before{background:#fff}.form-horizontal{padding:1rem}.form-horizontal .form-group{display:flex;display:-ms-flexbox;display:-webkit-flex}.form-horizontal .form-checkbox,.form-horizontal .form-radio,.form-horizontal .form-switch{margin:.4rem 0}.label{background:#f8f9fa;border-radius:.2rem;color:#5b657a;display:inline-block;line-height:1;padding:.3rem .4rem;vertical-align:baseline}.label.label-primary{background:#5764c6;color:#fff}.label.label-success{background:#32b643;color:#fff}.label.label-warning{background:#ffb700;color:#fff}.label.label-error{background:#e85600;color:#fff}code{background:#fdf4f4;border-radius:.2rem;color:#e06870;display:inline-block;line-height:1;padding:.3rem .4rem;vertical-align:baseline}.code{border-radius:.2rem;color:#50596c;line-height:2rem;position:relative}.code::before{color:#acb3c2;content:attr(data-lang);font-size:1.2rem;position:absolute;right:1rem;top:.2rem}.code code{background:#f8f9fa;color:inherit;display:block;line-height:inherit;overflow-x:auto;padding:2rem;width:100%}.img-responsive{display:block;height:auto;max-width:100%}.img-fit-cover{object-fit:cover}.img-fit-contain{object-fit:contain}.video-responsive{display:block;overflow:hidden;padding:0;position:relative;width:100%}.video-responsive::before{content:"";display:block;padding-bottom:56.25%}.video-responsive embed,.video-responsive iframe,.video-responsive object{bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%}.video-responsive video{height:auto;max-width:100%;width:100%}.video-responsive-4-3::before{padding-bottom:75%}.video-responsive-1-1::before{padding-bottom:100%}.figure{margin:0 0 1rem 0}.figure .figure-caption{color:#727e96;margin-top:1rem}.container{margin-left:auto;margin-right:auto;padding-left:1rem;padding-right:1rem;width:100%}.container.grid-1280{max-width:130rem}.container.grid-960{max-width:98rem}.container.grid-480{max-width:50rem}.columns{display:flex;display:-ms-flexbox;display:-webkit-flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-left:-1rem;margin-right:-1rem}.columns.col-gapless{margin-left:0;margin-right:0}.columns.col-gapless .column{padding-left:0;padding-right:0}.columns.col-oneline{-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;overflow-x:auto}.column{-webkit-flex:1;-ms-flex:1;flex:1;max-width:100%;padding:1rem}.column.col-1,.column.col-10,.column.col-11,.column.col-12,.column.col-2,.column.col-3,.column.col-4,.column.col-5,.column.col-6,.column.col-7,.column.col-8,.column.col-9{-webkit-flex:none;-ms-flex:none;flex:none}.col-12{width:100%}.col-11{width:91.66666667%}.col-10{width:83.33333333%}.col-9{width:75%}.col-8{width:66.66666667%}.col-7{width:58.33333333%}.col-6{width:50%}.col-5{width:41.66666667%}.col-4{width:33.33333333%}.col-3{width:25%}.col-2{width:16.66666667%}.col-1{width:8.33333333%}@media screen and (max-width:1280px){.col-xl-1,.col-xl-10,.col-xl-11,.col-xl-12,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9{-webkit-flex:none;-ms-flex:none;flex:none}.col-xl-12{width:100%}.col-xl-11{width:91.66666667%}.col-xl-10{width:83.33333333%}.col-xl-9{width:75%}.col-xl-8{width:66.66666667%}.col-xl-7{width:58.33333333%}.col-xl-6{width:50%}.col-xl-5{width:41.66666667%}.col-xl-4{width:33.33333333%}.col-xl-3{width:25%}.col-xl-2{width:16.66666667%}.col-xl-1{width:8.33333333%}}@media screen and (max-width:960px){.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9{-webkit-flex:none;-ms-flex:none;flex:none}.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}}@media screen and (max-width:840px){.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9{-webkit-flex:none;-ms-flex:none;flex:none}.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}}@media screen and (max-width:600px){.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9{-webkit-flex:none;-ms-flex:none;flex:none}.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}}@media screen and (max-width:480px){.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{-webkit-flex:none;-ms-flex:none;flex:none}.col-xs-12{width:100%}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}}.show-lg,.show-md,.show-sm,.show-xl,.show-xs{display:none!important}@media screen and (max-width:480px){.hide-xs{display:none!important}.show-xs{display:block!important}}@media screen and (max-width:600px){.hide-sm{display:none!important}.show-sm{display:block!important}}@media screen and (max-width:840px){.hide-md{display:none!important}.show-md{display:block!important}}@media screen and (max-width:960px){.hide-lg{display:none!important}.show-lg{display:block!important}}@media screen and (max-width:1280px){.hide-xl{display:none!important}.show-xl{display:block!important}}.navbar{-webkit-align-items:stretch;align-items:stretch;display:flex;display:-ms-flexbox;display:-webkit-flex;-ms-flex-align:stretch;-ms-flex-pack:justify;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-justify-content:space-between;justify-content:space-between}.navbar .navbar-section{-webkit-align-items:center;align-items:center;display:flex;display:-ms-flexbox;display:-webkit-flex;-webkit-flex:1 0 0;-ms-flex:1 0 0;flex:1 0 0;-ms-flex-align:center}.navbar .navbar-section:last-child{-ms-flex-pack:end;-webkit-justify-content:flex-end;justify-content:flex-end}.navbar .navbar-center{-webkit-align-items:center;align-items:center;display:flex;display:-ms-flexbox;display:-webkit-flex;-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;-ms-flex-align:center}.navbar .navbar-brand{font-size:1.6rem;font-weight:500;text-decoration:none}.panel{border:.1rem solid #f0f1f4;border-radius:.2rem;display:flex;display:-ms-flexbox;display:-webkit-flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}.panel .panel-footer,.panel .panel-header{-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;padding:1.5rem}.panel .panel-nav{-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto}.panel .panel-body{-webkit-flex:1 1 auto;-ms-flex:1 1 auto;flex:1 1 auto;overflow-y:auto;padding:0 1.5rem}.panel .panel-title{font-size:2rem}.panel .panel-subtitle{color:#bbc1cd}.empty{background:#f8f9fa;border-radius:.2rem;color:#727e96;padding:4rem;text-align:center}.empty .empty-subtitle,.empty .empty-title{margin:1rem auto}.empty .empty-subtitle{color:#bbc1cd}.empty .empty-action{margin-top:1.5rem}.form-autocomplete{position:relative}.form-autocomplete .form-autocomplete-input{-webkit-align-content:flex-start;align-content:flex-start;display:flex;display:-ms-flexbox;display:-webkit-flex;-ms-flex-line-pack:start;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;height:auto;min-height:3.2rem;padding:.1rem 0 0 .1rem}.form-autocomplete .form-autocomplete-input.is-focused{border-color:#5764c6;box-shadow:0 0 0 .2rem rgba(87,100,198,.15)}.form-autocomplete .form-autocomplete-input .form-input{border-color:transparent;box-shadow:none;display:inline-block;-webkit-flex:1 0 auto;-ms-flex:1 0 auto;flex:1 0 auto;height:2.8rem;padding:.3rem .8rem;width:auto}.form-autocomplete mark{font-size:1;padding:.1em 0}.form-autocomplete .menu{left:0;position:absolute;top:100%;width:100%}.avatar{background:#5764c6;border-radius:50%;color:rgba(255,255,255,.85);display:inline-block;font-size:1.4rem;font-weight:300;height:3.2rem;line-height:1;margin:0;position:relative;vertical-align:middle;width:3.2rem}.avatar.avatar-xs{font-size:.8rem;height:1.6rem;width:1.6rem}.avatar.avatar-sm{font-size:1rem;height:2.4rem;width:2.4rem}.avatar.avatar-lg{font-size:2rem;height:4.8rem;width:4.8rem}.avatar.avatar-xl{font-size:2.6rem;height:6.4rem;width:6.4rem}.avatar img{border-radius:50%;height:100%;position:relative;width:100%;z-index:100}.avatar .avatar-icon{background:#fff;bottom:14.64%;height:50%;padding:.2rem;position:absolute;right:14.64%;-webkit-transform:translate(50%,50%);-ms-transform:translate(50%,50%);transform:translate(50%,50%);width:50%}.avatar[data-initial]::before{color:currentColor;content:attr(data-initial);left:50%;position:absolute;top:50%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:1}.badge{position:relative;white-space:nowrap}.badge:not([data-badge])::after,.badge[data-badge]::after{background:#5764c6;background-clip:padding-box;border-radius:1rem;box-shadow:0 0 0 .2rem #fff;color:#fff;content:attr(data-badge);display:inline-block;-webkit-transform:translate(-.2rem,-1rem);-ms-transform:translate(-.2rem,-1rem);transform:translate(-.2rem,-1rem)}.badge[data-badge]::after{font-size:1.2rem;height:1.8rem;line-height:1;min-width:1.8rem;padding:.3rem .5rem;text-align:center;white-space:nowrap}.badge:not([data-badge])::after,.badge[data-badge=""]::after{height:.6rem;min-width:.6rem;padding:0;width:.6rem}.badge.btn::after{position:absolute;right:0;top:0;-webkit-transform:translate(50%,-50%);-ms-transform:translate(50%,-50%);transform:translate(50%,-50%)}.badge.avatar::after{position:absolute;right:14.64%;top:14.64%;-webkit-transform:translate(50%,-50%);-ms-transform:translate(50%,-50%);transform:translate(50%,-50%);z-index:100}.badge.avatar-xs::after{content:"";height:.8rem;min-width:.8rem;padding:0;width:.8rem}.bar{background:#f0f1f4;border-radius:.2rem;display:flex;display:-ms-flexbox;display:-webkit-flex;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;height:1.6rem;width:100%}.bar.bar-sm{height:.4rem}.bar .bar-item{background:#5764c6;color:#fff;display:block;-ms-flex-negative:0;-webkit-flex-shrink:0;flex-shrink:0;font-size:1.2rem;height:100%;line-height:1;padding:.2rem 0;position:relative;text-align:center;width:0}.bar .bar-item:first-child{border-bottom-left-radius:.2rem;border-top-left-radius:.2rem}.bar .bar-item:last-child{border-bottom-right-radius:.2rem;border-top-right-radius:.2rem;-ms-flex-negative:1;-webkit-flex-shrink:1;flex-shrink:1}.bar-slider{height:.2rem;margin:1rem 0;position:relative}.bar-slider .bar-item{left:0;padding:0;position:absolute}.bar-slider .bar-item:not(:last-child):first-child{background:#f0f1f4;z-index:1}.bar-slider .bar-slider-btn{background:#5764c6;border:0;border-radius:50%;height:1.2rem;padding:0;position:absolute;right:0;top:50%;-webkit-transform:translate(50%,-50%);-ms-transform:translate(50%,-50%);transform:translate(50%,-50%);width:1.2rem}.bar-slider .bar-slider-btn:active{box-shadow:0 0 0 .2rem #5764c6}.card{background:#fff;border:.1rem solid #f0f1f4;border-radius:.2rem;display:block}.card .card-body,.card .card-footer,.card .card-header{padding:1.5rem;padding-bottom:0}.card .card-body:last-child,.card .card-footer:last-child,.card .card-header:last-child{padding-bottom:1.5rem}.card .card-image{padding-top:1.5rem}.card .card-image:first-child{padding-top:0}.card .card-image:first-child img{border-top-left-radius:.2rem;border-top-right-radius:.2rem}.card .card-image:last-child img{border-bottom-left-radius:.2rem;border-bottom-right-radius:.2rem}.card .card-title{font-size:2rem}.card .card-subtitle{color:#bbc1cd;font-size:1.2rem}.chip{-webkit-align-items:center;align-items:center;background:#f0f1f4;border-radius:.2rem;color:#727e96;display:-ms-inline-flexbox;display:inline-flex;display:-webkit-inline-flex;-ms-flex-align:center;height:2.8rem;margin:0 .1rem .1rem 0;max-width:100%;padding:.1rem .8rem;text-decoration:none;vertical-align:middle}.chip.active{background:#5764c6;color:#fff}.chip .avatar{margin-left:-.4rem;margin-right:.4rem}.dropdown{display:inline-block;position:relative}.dropdown .menu{-webkit-animation:slide-down .2s ease 1;animation:slide-down .2s ease 1;display:none;left:0;position:absolute;top:100%}.dropdown.dropdown-right .menu{left:auto;right:0}.dropdown .dropdown-toggle:focus+.menu,.dropdown .menu:hover,.dropdown.active .menu{display:block}.dropdown .btn-group .dropdown-toggle:nth-last-child(2){border-bottom-right-radius:.2rem;border-top-right-radius:.2rem}.menu{background:#fff;border-radius:.2rem;box-shadow:0 .1rem .4rem rgba(69,77,93,.3);list-style:none;margin:0;min-width:18rem;padding:1rem;-webkit-transform:translateY(.5rem);-ms-transform:translateY(.5rem);transform:translateY(.5rem);z-index:100}.menu .menu-item{margin-top:0;padding:0 .8rem;text-decoration:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.menu .menu-item>a{border-radius:.2rem;color:inherit;display:block;margin:0 -.8rem;padding:.6rem .8rem;text-decoration:none}.menu .menu-item>a:focus,.menu .menu-item>a:hover{color:#5764c6}.menu .menu-item>a.active,.menu .menu-item>a:active{background:#fbfbfe;color:#5764c6}.menu .menu-badge{float:right;padding:.6rem 0}.menu .menu-badge .btn{margin-top:-.2rem}.modal{-webkit-align-items:center;align-items:center;bottom:0;display:none;-ms-flex-align:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;left:0;opacity:0;overflow:hidden;padding:1rem;position:fixed;right:0;top:0}.modal.active,.modal:target{display:flex;display:-ms-flexbox;display:-webkit-flex;opacity:1;z-index:400}.modal.active .modal-overlay,.modal:target .modal-overlay{background:rgba(69,77,93,.5);bottom:0;cursor:default;display:block;left:0;position:absolute;right:0;top:0}.modal.active .modal-container,.modal:target .modal-container{-webkit-animation:slide-down .2s ease 1;animation:slide-down .2s ease 1;max-width:64rem;z-index:1}.modal.modal-sm .modal-container{max-width:32rem}.modal-container{background:#fff;border-radius:.2rem;box-shadow:0 .4rem 1rem rgba(69,77,93,.3);display:block;padding:0;text-align:left}.modal-container .modal-header{padding:1.5rem}.modal-container .modal-header .modal-title{font-size:1.6rem;margin:0}.modal-container .modal-body{max-height:50vh;overflow-y:auto;padding:1.5rem;position:relative}.modal-container .modal-footer{padding:1.5rem;text-align:right}.breadcrumb,.nav,.pagination,.tab{list-style:none;margin:.5rem 0}.breadcrumb{padding:1.2rem}.breadcrumb .breadcrumb-item{display:inline-block;margin:0}.breadcrumb .breadcrumb-item:last-child{color:#acb3c2}.breadcrumb .breadcrumb-item:not(:first-child)::before{color:#e7e9ed;content:"/";padding:0 .4rem}.tab{-webkit-align-items:center;align-items:center;display:flex;display:-ms-flexbox;display:-webkit-flex;-ms-flex-align:center;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.tab .tab-item{margin-top:0}.tab .tab-item.tab-action{-webkit-flex:1 0 auto;-ms-flex:1 0 auto;flex:1 0 auto;text-align:right}.tab .tab-item a{border-bottom:.2rem solid transparent;color:inherit;display:block;margin-top:0;padding:.6rem 1.2rem .4rem 1.2rem;text-decoration:none}.tab .tab-item a:focus,.tab .tab-item a:hover{color:#5764c6}.tab .tab-item a.active,.tab .tab-item.active a{border-bottom-color:#5764c6;color:#5764c6}.tab.tab-block .tab-item{-webkit-flex:1 0 0;-ms-flex:1 0 0;flex:1 0 0;text-align:center}.tab.tab-block .tab-item .badge[data-badge]::after{position:absolute;right:-.4rem;top:-.4rem;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.tab:not(.tab-block) .badge{padding-right:.2rem}.pagination{display:flex;display:-ms-flexbox;display:-webkit-flex}.pagination .page-item{margin:1rem .1rem}.pagination .page-item span{display:inline-block;padding:.6rem .4rem}.pagination .page-item a{border-radius:.2rem;color:#727e96;display:inline-block;padding:.6rem .8rem;text-decoration:none}.pagination .page-item a:focus,.pagination .page-item a:hover{color:#5764c6}.pagination .page-item a.disabled,.pagination .page-item a[disabled]{cursor:default;opacity:.5;pointer-events:none}.pagination .page-item.active a{background:#5764c6;color:#fff}.pagination .page-item.page-next,.pagination .page-item.page-prev{-webkit-flex:1 0 50%;-ms-flex:1 0 50%;flex:1 0 50%}.pagination .page-item.page-next{text-align:right}.pagination .page-item .page-item-title{margin:0}.pagination .page-item .page-item-subtitle{margin:0;opacity:.5}.nav{display:flex;display:-ms-flexbox;display:-webkit-flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}.nav .nav-item a{color:#727e96;padding:.6rem .8rem;text-decoration:none}.nav .nav-item a:focus,.nav .nav-item a:hover{color:#5764c6}.nav .nav-item.active>a{font-weight:700}.nav .nav-item.active>a:focus,.nav .nav-item.active>a:hover{color:#5764c6}.nav .nav{margin-bottom:1rem;margin-left:2rem}.nav .nav a{color:#acb3c2}.popover{display:inline-block;position:relative}.popover .popover-container{content:attr(data-tooltip);left:50%;opacity:0;padding:1rem;position:absolute;top:0;-webkit-transform:translate(-50%,-50%) scale(0);-ms-transform:translate(-50%,-50%) scale(0);transform:translate(-50%,-50%) scale(0);transition:transform .2s ease,-webkit-transform .2s ease;transition:transform .2s ease;transition:-webkit-transform .2s ease;width:32rem;z-index:400}.popover .popover-container:hover,.popover :focus+.popover-container,.popover:hover .popover-container{display:block;opacity:1;-webkit-transform:translate(-50%,-100%) scale(1);-ms-transform:translate(-50%,-100%) scale(1);transform:translate(-50%,-100%) scale(1)}.popover.popover-right .popover-container{left:100%;top:50%}.popover.popover-right .popover-container:hover,.popover.popover-right :focus+.popover-container,.popover.popover-right:hover .popover-container{-webkit-transform:translate(0,-50%) scale(1);-ms-transform:translate(0,-50%) scale(1);transform:translate(0,-50%) scale(1)}.popover.popover-bottom .popover-container{left:50%;top:100%}.popover.popover-bottom .popover-container:hover,.popover.popover-bottom :focus+.popover-container,.popover.popover-bottom:hover .popover-container{-webkit-transform:translate(-50%,0) scale(1);-ms-transform:translate(-50%,0) scale(1);transform:translate(-50%,0) scale(1)}.popover.popover-left .popover-container{left:0;top:50%}.popover.popover-left .popover-container:hover,.popover.popover-left :focus+.popover-container,.popover.popover-left:hover .popover-container{-webkit-transform:translate(-100%,-50%) scale(1);-ms-transform:translate(-100%,-50%) scale(1);transform:translate(-100%,-50%) scale(1)}.popover .card{border:0;box-shadow:0 .4rem 1rem rgba(69,77,93,.3)}.step{display:flex;display:-ms-flexbox;display:-webkit-flex;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;list-style:none;margin:.5rem 0;width:100%}.step .step-item{-webkit-flex:1 1 0;-ms-flex:1 1 0;flex:1 1 0;margin-top:0;min-height:2rem;position:relative;text-align:center}.step .step-item:not(:first-child)::before{background:#5764c6;content:"";height:.2rem;left:-50%;position:absolute;top:.9rem;width:100%}.step .step-item a{color:#acb3c2;display:inline-block;padding:2rem 1rem 0;text-decoration:none}.step .step-item a::before{background:#5764c6;border:.2rem solid #fff;border-radius:50%;content:"";display:block;height:1.2rem;left:50%;position:absolute;top:.4rem;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);width:1.2rem;z-index:1}.step .step-item.active a::before{background:#fff;border:.2rem solid #5764c6}.step .step-item.active~.step-item::before{background:#f0f1f4}.step .step-item.active~.step-item a::before{background:#e7e9ed}.tile{-webkit-align-content:space-between;align-content:space-between;-webkit-align-items:flex-start;align-items:flex-start;display:flex;display:-ms-flexbox;display:-webkit-flex;-ms-flex-align:start;-ms-flex-line-pack:justify}.tile .tile-action,.tile .tile-icon{-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto}.tile .tile-content{-webkit-flex:1 1 auto;-ms-flex:1 1 auto;flex:1 1 auto}.tile .tile-content:not(:first-child){padding-left:1rem}.tile .tile-content:not(:last-child){padding-right:1rem}.tile .tile-title{line-height:2rem}.tile .tile-subtitle{color:#bbc1cd;line-height:2rem}.tile.tile-centered{-webkit-align-items:center;align-items:center;-ms-flex-align:center}.tile.tile-centered .tile-content{overflow:hidden}.tile.tile-centered .tile-subtitle,.tile.tile-centered .tile-title{margin-bottom:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.toast{background:rgba(69,77,93,.9);border:.1rem solid #454d5d;border-color:#454d5d;border-radius:.2rem;color:#fff;display:block;padding:1rem;width:100%}.toast.toast-primary{background:rgba(87,100,198,.9);border-color:#5764c6}.toast.toast-success{background:rgba(50,182,67,.9);border-color:#32b643}.toast.toast-warning{background:rgba(255,183,0,.9);border-color:#ffb700}.toast.toast-error{background:rgba(232,86,0,.9);border-color:#e85600}.toast a{color:#fff;text-decoration:underline}.toast a.active,.toast a:active,.toast a:focus,.toast a:hover{opacity:.75}.tooltip{position:relative}.tooltip::after{background:rgba(69,77,93,.9);border-radius:.2rem;bottom:100%;color:#fff;content:attr(data-tooltip);display:block;font-size:1.2rem;left:50%;max-width:32rem;opacity:0;overflow:hidden;padding:.4rem .8rem;pointer-events:none;position:absolute;text-overflow:ellipsis;-webkit-transform:translate(-50%,1rem);-ms-transform:translate(-50%,1rem);transform:translate(-50%,1rem);transition:all .2s ease;white-space:nowrap;z-index:200}.tooltip:focus::after,.tooltip:hover::after{opacity:1;-webkit-transform:translate(-50%,-.5rem);-ms-transform:translate(-50%,-.5rem);transform:translate(-50%,-.5rem)}.tooltip.disabled,.tooltip[disabled]{pointer-events:auto}.tooltip.tooltip-right::after{bottom:50%;left:100%;-webkit-transform:translate(-1rem,50%);-ms-transform:translate(-1rem,50%);transform:translate(-1rem,50%)}.tooltip.tooltip-right:focus::after,.tooltip.tooltip-right:hover::after{-webkit-transform:translate(.5rem,50%);-ms-transform:translate(.5rem,50%);transform:translate(.5rem,50%)}.tooltip.tooltip-bottom::after{bottom:auto;top:100%;-webkit-transform:translate(-50%,-1rem);-ms-transform:translate(-50%,-1rem);transform:translate(-50%,-1rem)}.tooltip.tooltip-bottom:focus::after,.tooltip.tooltip-bottom:hover::after{-webkit-transform:translate(-50%,.5rem);-ms-transform:translate(-50%,.5rem);transform:translate(-50%,.5rem)}.tooltip.tooltip-left::after{bottom:50%;left:auto;right:100%;-webkit-transform:translate(1rem,50%);-ms-transform:translate(1rem,50%);transform:translate(1rem,50%)}.tooltip.tooltip-left:focus::after,.tooltip.tooltip-left:hover::after{-webkit-transform:translate(-.5rem,50%);-ms-transform:translate(-.5rem,50%);transform:translate(-.5rem,50%)}@-webkit-keyframes loading{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loading{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes slide-down{0%{opacity:0;-webkit-transform:translateY(-3rem);transform:translateY(-3rem)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes slide-down{0%{opacity:0;-webkit-transform:translateY(-3rem);transform:translateY(-3rem)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}.divider,.divider-vert{display:block;position:relative}.divider-vert[data-content]::after,.divider[data-content]::after{background:#fff;color:#e7e9ed;content:attr(data-content);display:inline-block;font-size:1.2rem;padding:0 .8rem;-webkit-transform:translateY(-1.1rem);-ms-transform:translateY(-1.1rem);transform:translateY(-1.1rem)}.divider{border-top:.1rem solid #f0f1f4;height:.1rem;margin:1rem 0}.divider-vert{display:block;padding:1rem}.divider-vert::before{border-left:.1rem solid #f0f1f4;bottom:1rem;content:"";display:block;left:50%;position:absolute;top:1rem;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%)}.divider-vert[data-content]::after{left:50%;padding:.4rem 0;position:absolute;top:50%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.loading{color:transparent!important;min-height:1.6rem;pointer-events:none;position:relative}.loading::after{-webkit-animation:loading .5s infinite linear;animation:loading .5s infinite linear;border:.2rem solid #5764c6;border-radius:.8rem;border-right-color:transparent;border-top-color:transparent;content:"";display:block;height:1.6rem;left:50%;margin-left:-.8rem;margin-top:-.8rem;position:absolute;top:50%;width:1.6rem;z-index:1}.clearfix::after,.container::after{clear:both;content:"";display:table}.float-left{float:left!important}.float-right{float:right!important}.rel{position:relative}.abs{position:absolute}.fixed{position:fixed}.centered{display:block;float:none;margin-left:auto;margin-right:auto}.mt-10{margin-top:1rem}.mr-10{margin-right:1rem}.mb-10{margin-bottom:1rem}.ml-10{margin-left:1rem}.mt-5{margin-top:.5rem}.mr-5{margin-right:.5rem}.mb-5{margin-bottom:.5rem}.ml-5{margin-left:.5rem}.pt-10{padding-top:1rem}.pr-10{padding-right:1rem}.pb-10{padding-bottom:1rem}.pl-10{padding-left:1rem}.pt-5{padding-top:.5rem}.pr-5{padding-right:.5rem}.pb-5{padding-bottom:.5rem}.pl-5{padding-left:.5rem}.block{display:block}.inline{display:inline}.inline-block{display:inline-block}.flex{display:flex;display:-ms-flexbox;display:-webkit-flex}.inline-flex{display:inline-flex;display:-ms-inline-flexbox;display:-webkit-inline-flex}.hide{display:none!important}.visible{visibility:visible}.invisible{visibility:hidden}.text-hide{background:0 0;border:0;color:transparent;font-size:0;line-height:0;text-shadow:none}.text-assistive{border:0;clip:rect(0,0,0,0);height:.1rem;margin:-.1rem;overflow:hidden;padding:0;position:absolute;width:.1rem}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.text-justify{text-align:justify}.text-lowercase{text-transform:lowercase}.text-uppercase{text-transform:uppercase}.text-capitalize{text-transform:capitalize}.text-normal{font-weight:400}.text-bold{font-weight:700}.text-italic{font-style:italic}.text-large{font-size:1.2em}.text-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-clip{overflow:hidden;text-overflow:clip;white-space:nowrap}.text-break{-webkit-hyphens:auto;-ms-hyphens:auto;hyphens:auto;word-break:break-word;word-wrap:break-word}.hand{cursor:pointer}.shadow-0{box-shadow:0 0 .2rem rgba(69,77,93,.3)}.shadow-1{box-shadow:0 .1rem .4rem rgba(69,77,93,.3)}.shadow-2{box-shadow:0 .2rem .6rem rgba(69,77,93,.3)}.shadow-3{box-shadow:0 .3rem .8rem rgba(69,77,93,.3)}.shadow-4{box-shadow:0 .4rem 1rem rgba(69,77,93,.3)}.rounded{border-radius:.2rem}.circle{border-radius:50%} \ No newline at end of file diff --git a/templates.go b/templates.go new file mode 100644 index 0000000..c2eda07 --- /dev/null +++ b/templates.go @@ -0,0 +1,53 @@ +package main + +import ( + "bytes" + "fmt" + "html/template" + "io" + "log" + "sync" +) + +type TemplateMap map[string]*template.Template + +type Templates struct { + sync.Mutex + + base string + templates TemplateMap +} + +func NewTemplates(base string) *Templates { + return &Templates{ + base: base, + templates: make(TemplateMap), + } +} + +func (t *Templates) Add(name string, template *template.Template) { + t.Lock() + defer t.Unlock() + + t.templates[name] = template +} + +func (t *Templates) Exec(name string, ctx interface{}) (io.WriterTo, error) { + t.Lock() + defer t.Unlock() + + template, ok := t.templates[name] + if !ok { + log.Printf("template %s not found", name) + return nil, fmt.Errorf("no such template: %s", name) + } + + buf := bytes.NewBuffer([]byte{}) + err := template.ExecuteTemplate(buf, t.base, ctx) + if err != nil { + log.Printf("error parsing template %s: %s", name, err) + return nil, err + } + + return buf, nil +} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..0f22351 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,22 @@ +{{define "base"}} + + + + + + + Pastebin + + +
+ + {{template "content" .}} +
+ + +{{end}} diff --git a/templates/index.html b/templates/index.html index 5447c5b..edd424d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,14 +1,17 @@ - - - pastebin - - - -

Enter your text here:

-
- - -
- - - +{{define "content"}} +
+
+
+
+
+ + +
+
+ +
+
+
+
+
+{{end}} diff --git a/templates/view.html b/templates/view.html index 0e8381e..d22cc48 100644 --- a/templates/view.html +++ b/templates/view.html @@ -1,10 +1,30 @@ - - - pastebin - - - -
{{.Blob}}
- - - +{{define "content"}} +
+  {{.Blob}}
+
+
+
+ +
+
+{{end}}