diff --git a/display.go b/display.go index b60f9bc..a449108 100644 --- a/display.go +++ b/display.go @@ -41,6 +41,7 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) { } sizeHuman := humanize.Bytes(uint64(metadata.Size)) extra := make(map[string]string) + lines := []string{} file, _ := os.Open(filePath) defer file.Close() @@ -86,6 +87,15 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) { tpl = Templates["display/bin.html"] } } + } else if extension == "story" { + if metadata.Size < maxDisplayFileSizeBytes { + bytes, err := ioutil.ReadFile(filePath) + if err == nil { + extra["contents"] = string(bytes) + lines = strings.Split(extra["contents"], "\n") + tpl = Templates["display/story.html"] + } + } } else if extension == "md" { if metadata.Size < maxDisplayFileSizeBytes { bytes, err := ioutil.ReadFile(filePath) @@ -110,6 +120,7 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) { "size": sizeHuman, "expiry": expiryHuman, "extra": extra, + "lines": lines, "files": metadata.ArchiveFiles, }, w) diff --git a/static/css/highlight/story.css b/static/css/highlight/story.css deleted file mode 100644 index e8d935a..0000000 --- a/static/css/highlight/story.css +++ /dev/null @@ -1,13 +0,0 @@ -.hljs { - display: block; - background: #f0e0d6; - color: #800000; - padding: 0.5em; - - font-family: arial,helvetica,sans-serif; - font-size: 13px; -} - -.hljs-comment { - color: #789922; -} diff --git a/static/css/linx.css b/static/css/linx.css index 39336a5..b4b4e28 100644 --- a/static/css/linx.css +++ b/static/css/linx.css @@ -275,6 +275,14 @@ body { overflow: auto; } +.storygreen { + color: #789922; +} + +.storyred { + color: #800000; +} + /* Content display {{{ */ .display-audio, .display-file { @@ -300,7 +308,7 @@ body { } .storycontent { - background-color: #f0e0d6; + background-color: #f0e0d6 !important; } #editform, diff --git a/templates.go b/templates.go index d8cd7bf..aa4652a 100644 --- a/templates.go +++ b/templates.go @@ -55,6 +55,7 @@ func populateTemplatesMap(tSet *pongo2.TemplateSet, tMap map[string]*pongo2.Temp "display/video.html", "display/pdf.html", "display/bin.html", + "display/story.html", "display/md.html", "display/file.html", } diff --git a/templates/display/bin.html b/templates/display/bin.html index 9c6382e..a3b85fd 100644 --- a/templates/display/bin.html +++ b/templates/display/bin.html @@ -1,15 +1,10 @@ {% extends "base.html" %} {% block head %} - {% if extra.extension == "story" %} - - {% else %} - {% endif %} {% endblock %} {% block innercontentmore %} class="scrollable"{% endblock %} -{% block mainmore %} {% if extra.extension == "story" %} class="storycontent"{% endif %} {% endblock %} {% block infoleft %}
{{ extra.contents }}