Fix/implement .story
This commit is contained in:
parent
9847beeff5
commit
c77f8285d4
11
display.go
11
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)
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block head %}
|
||||
{% if extra.extension == "story" %}
|
||||
<link href="/static/css/highlight/story.css" rel="stylesheet" type="text/css">
|
||||
{% else %}
|
||||
<link href="/static/css/highlight/tomorrow.css" rel="stylesheet" type="text/css">
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block innercontentmore %} class="scrollable"{% endblock %}
|
||||
{% block mainmore %} {% if extra.extension == "story" %} class="storycontent"{% endif %} {% endblock %}
|
||||
|
||||
{% block infoleft %}
|
||||
<div id="editform">
|
||||
|
@ -41,7 +36,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div id="normal-content" class="normal {% if extra.lang_hl != "story" %}fixed{% endif %}">
|
||||
<div id="normal-content" class="normal fixed">
|
||||
<pre id="normal-code"><code id="codeb" class="{{ extra.lang_hl }}">{{ extra.contents }}</code></pre>
|
||||
<textarea id="editor" class="editor">{{ extra.contents }}</textarea>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue