Skip to content

Commit

Permalink
close #72
Browse files Browse the repository at this point in the history
Former-commit-id: 992a763
  • Loading branch information
hacdias committed Feb 3, 2017
1 parent f166697 commit 1c36d0d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
7 changes: 6 additions & 1 deletion _embed/public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ i.spin {
animation: 1s spin linear infinite;
}

.pdf {
width: 100%;
height: calc(100vh - 13em);
}


/* * * * * * * * * * * * * * * *
* EDITOR *
Expand Down Expand Up @@ -1200,4 +1205,4 @@ footer a:hover {
-webkit-transform: rotate(-360deg);
transform: rotate(-360deg);
}
}
}
32 changes: 17 additions & 15 deletions _embed/templates/single.tmpl
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{{ define "content" }}
{{ with .Data}}
<main class="container">
<main class="container">
{{ if eq .Type "image" }}
<center><img src="{{ .URL }}?raw=true"></center>
{{ else if eq .Type "audio" }}
<audio src="{{ .URL }}?raw=true" controls></audio>
{{ else if eq .Type "video" }}
<video src="{{ .URL }}?raw=true" controls>
Sorry, your browser doesn't support embedded videos,
but don't worry, you can <a href="?download=true">download it</a>
and watch it with your favorite video player!
</video>
{{ else if eq .Type "blob" }}
<a href="?download=true"><h2 class="message">Download <i class="material-icons">file_download</i></h2></a>
{{ else}}
<pre>{{ .StringifyContent }}</pre>
<center><img src="{{ .URL }}?raw=true"></center>
{{ else if eq .Type "audio" }}
<audio src="{{ .URL }}?raw=true" controls></audio>
{{ else if eq .Type "video" }}
<video src="{{ .URL }}?raw=true" controls>
Sorry, your browser doesn't support embedded videos,
but don't worry, you can <a href="?download=true">download it</a>
and watch it with your favorite video player!
</video>
{{ else if eq .Extension ".pdf" }}
<object class="pdf" data="{{ .URL }}?raw=true"></object>
{{ else if eq .Type "blob" }}
<a href="?download=true"><h2 class="message">Download <i class="material-icons">file_download</i></h2></a>
{{ else}}
<pre>{{ .StringifyContent }}</pre>
{{ end }}
</main>
</main>
{{ end }}
{{ end }}
5 changes: 3 additions & 2 deletions file/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Info struct {
Name string
Size int64
URL string
Extension string
ModTime time.Time
Mode os.FileMode
IsDir bool
Expand Down Expand Up @@ -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
}

Expand All @@ -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()
Expand Down

0 comments on commit 1c36d0d

Please sign in to comment.