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))
|
sizeHuman := humanize.Bytes(uint64(metadata.Size))
|
||||||
extra := make(map[string]string)
|
extra := make(map[string]string)
|
||||||
|
lines := []string{}
|
||||||
|
|
||||||
file, _ := os.Open(filePath)
|
file, _ := os.Open(filePath)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
@ -86,6 +87,15 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||||||
tpl = Templates["display/bin.html"]
|
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" {
|
} else if extension == "md" {
|
||||||
if metadata.Size < maxDisplayFileSizeBytes {
|
if metadata.Size < maxDisplayFileSizeBytes {
|
||||||
bytes, err := ioutil.ReadFile(filePath)
|
bytes, err := ioutil.ReadFile(filePath)
|
||||||
@ -110,6 +120,7 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||||||
"size": sizeHuman,
|
"size": sizeHuman,
|
||||||
"expiry": expiryHuman,
|
"expiry": expiryHuman,
|
||||||
"extra": extra,
|
"extra": extra,
|
||||||
|
"lines": lines,
|
||||||
"files": metadata.ArchiveFiles,
|
"files": metadata.ArchiveFiles,
|
||||||
}, w)
|
}, 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;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.storygreen {
|
||||||
|
color: #789922;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storyred {
|
||||||
|
color: #800000;
|
||||||
|
}
|
||||||
|
|
||||||
/* Content display {{{ */
|
/* Content display {{{ */
|
||||||
.display-audio,
|
.display-audio,
|
||||||
.display-file {
|
.display-file {
|
||||||
@ -300,7 +308,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.storycontent {
|
.storycontent {
|
||||||
background-color: #f0e0d6;
|
background-color: #f0e0d6 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#editform,
|
#editform,
|
||||||
|
@ -55,6 +55,7 @@ func populateTemplatesMap(tSet *pongo2.TemplateSet, tMap map[string]*pongo2.Temp
|
|||||||
"display/video.html",
|
"display/video.html",
|
||||||
"display/pdf.html",
|
"display/pdf.html",
|
||||||
"display/bin.html",
|
"display/bin.html",
|
||||||
|
"display/story.html",
|
||||||
"display/md.html",
|
"display/md.html",
|
||||||
"display/file.html",
|
"display/file.html",
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block head %}
|
{% 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">
|
<link href="/static/css/highlight/tomorrow.css" rel="stylesheet" type="text/css">
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block innercontentmore %} class="scrollable"{% endblock %}
|
{% block innercontentmore %} class="scrollable"{% endblock %}
|
||||||
{% block mainmore %} {% if extra.extension == "story" %} class="storycontent"{% endif %} {% endblock %}
|
|
||||||
|
|
||||||
{% block infoleft %}
|
{% block infoleft %}
|
||||||
<div id="editform">
|
<div id="editform">
|
||||||
@ -41,7 +36,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% 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>
|
<pre id="normal-code"><code id="codeb" class="{{ extra.lang_hl }}">{{ extra.contents }}</code></pre>
|
||||||
<textarea id="editor" class="editor">{{ extra.contents }}</textarea>
|
<textarea id="editor" class="editor">{{ extra.contents }}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user