mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-20 09:26:23 -07:00
moved template interface injections to template.go so actual HTML starts on line 1
This commit is contained in:
parent
6bc4c963e4
commit
06af1f8172
3 changed files with 10 additions and 9 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
)
|
||||
|
@ -70,6 +71,11 @@ var funcMap = template.FuncMap{
|
|||
}
|
||||
return parsed.Format("Mon, January 02, 2006 15:04 PM")
|
||||
},
|
||||
"imageToThumbnailPath": func(img string) string {
|
||||
index := strings.LastIndex(img, ".")
|
||||
return img[0:index]+"t"+img[index:len(img)]
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -123,7 +129,7 @@ func initTemplates() {
|
|||
fmt.Println("Failed loading template \""+config.TemplateDir+"/img_thread.html\": " + tmpl_err.Error())
|
||||
os.Exit(2)
|
||||
}
|
||||
img_thread_tmpl_str = string(img_thread_tmpl_bytes)
|
||||
img_thread_tmpl_str = "{{$config := getInterface .Data 0}}{{$post_arr := getInterface .Data 1}}{{$board_arr := getInterface .Data 2}}{{$section_arr := getInterface .Data 3}}{{$op := getInterface $post_arr 0}}{{$boardid := subtract $op.BoardID 1}}{{$board := getInterface $board_arr.Data $boardid}}" + string(img_thread_tmpl_bytes)
|
||||
img_thread_tmpl,tmpl_err = template.New("img_thread_tmpl").Funcs(funcMap).Parse(img_thread_tmpl_str)
|
||||
if tmpl_err != nil {
|
||||
fmt.Println("Failed loading template \""+config.TemplateDir+"/img_thread.html: \"" + tmpl_err.Error())
|
||||
|
@ -146,7 +152,7 @@ func initTemplates() {
|
|||
fmt.Println(err.Error())
|
||||
os.Exit(2)
|
||||
}
|
||||
front_page_tmpl_str = string(front_page_tmpl_bytes)
|
||||
front_page_tmpl_str = "{{$config := getInterface .Data 0}}{{$page_arr := getInterface .Data 1}}{{$board_arr := getInterface .Data 2}}{{$section_arr := getInterface .Data 3}}" + string(front_page_tmpl_bytes)
|
||||
front_page_tmpl,tmpl_err = template.New("front_page_tmpl").Funcs(funcMap).Parse(front_page_tmpl_str)
|
||||
if tmpl_err != nil {
|
||||
fmt.Println("Failed loading template \""+config.TemplateDir+"/front.html\": "+tmpl_err.Error())
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{{$config := getInterface .Data 0}}{{$page_arr := getInterface .Data 1}}{{$board_arr := getInterface .Data 2}}{{$section_arr := getInterface .Data 3}}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -109,14 +108,14 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="recent-posts">
|
||||
<h2>Recent Posts</h2>
|
||||
<span class="section-header">Recent Posts</span>
|
||||
<div class="section-block">
|
||||
<div class="section-title-block">
|
||||
<span class="section-title"><a href="/test/">/test/</a></span> - <b>Poster Mc</b>!Tripcode
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<img src="135693079632s.png" />
|
||||
TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT...<br /><i>(Comment truncated, click <a href="/test/">here</a> to continue reading)</i>
|
||||
TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT TOOT...<br /><i>(Post truncated, click <a href="/test/">here</a> to continue reading)</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{{$config := getInterface .Data 0}}{{$post_arr := getInterface .Data 1}}{{$board_arr := getInterface .Data 2}}{{$section_arr := getInterface .Data 3}}
|
||||
<!DOCTYPE html>
|
||||
{{$op := getInterface $post_arr 0}}
|
||||
{{$boardid := subtract $op.BoardID 1}}
|
||||
{{$board := getInterface $board_arr.Data $boardid}}
|
||||
<html>
|
||||
<head>
|
||||
<title>{{$board.Title}}</title>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue