From 1c36d0d511fcfb1fdbd3d8bc88467e8b4c1cba86 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 3 Feb 2017 11:59:54 +0000 Subject: [PATCH] close #72 Former-commit-id: 992a763c56045ad7311be17201b172764f079baa --- _embed/public/css/styles.css | 7 ++++++- _embed/templates/single.tmpl | 32 +++++++++++++++++--------------- file/info.go | 5 +++-- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/_embed/public/css/styles.css b/_embed/public/css/styles.css index 784130da..01f2ee86 100644 --- a/_embed/public/css/styles.css +++ b/_embed/public/css/styles.css @@ -72,6 +72,11 @@ i.spin { animation: 1s spin linear infinite; } +.pdf { + width: 100%; + height: calc(100vh - 13em); +} + /* * * * * * * * * * * * * * * * * EDITOR * @@ -1200,4 +1205,4 @@ footer a:hover { -webkit-transform: rotate(-360deg); transform: rotate(-360deg); } -} \ No newline at end of file +} diff --git a/_embed/templates/single.tmpl b/_embed/templates/single.tmpl index 46ac9292..c85ab5a4 100644 --- a/_embed/templates/single.tmpl +++ b/_embed/templates/single.tmpl @@ -1,21 +1,23 @@ {{ define "content" }} {{ with .Data}} -
+
{{ if eq .Type "image" }} -
- {{ else if eq .Type "audio" }} - - {{ else if eq .Type "video" }} - - {{ else if eq .Type "blob" }} -

Download file_download

- {{ else}} -
{{ .StringifyContent }}
+
+ {{ else if eq .Type "audio" }} + + {{ else if eq .Type "video" }} + + {{ else if eq .Extension ".pdf" }} + + {{ else if eq .Type "blob" }} +

Download file_download

+ {{ else}} +
{{ .StringifyContent }}
{{ end }} -
+
{{ end }} {{ end }} diff --git a/file/info.go b/file/info.go index 0bb9ec86..ab74c6a1 100644 --- a/file/info.go +++ b/file/info.go @@ -20,6 +20,7 @@ type Info struct { Name string Size int64 URL string + Extension string ModTime time.Time Mode os.FileMode IsDir bool @@ -55,7 +56,7 @@ func GetInfo(url *url.URL, c *config.Config, u *config.User) (*Info, int, error) i.Mode = info.Mode() i.IsDir = info.IsDir() i.Size = info.Size() - + i.Extension = filepath.Ext(i.Name) return i, 0, nil } @@ -79,7 +80,7 @@ var textExtensions = [...]string{ // RetrieveFileType obtains the mimetype and a simplified internal Type // using the first 512 bytes from the file. func (i *Info) RetrieveFileType() error { - i.Mimetype = mime.TypeByExtension(filepath.Ext(i.Name)) + i.Mimetype = mime.TypeByExtension(i.Extension) if i.Mimetype == "" { err := i.Read()