mirror of
https://github.com/rls-moe/nyx
synced 2024-11-14 22:12:24 +00:00
63 lines
12 KiB
Go
63 lines
12 KiB
Go
|
package board
|
||
|
|
||
|
import (
|
||
|
"github.com/GeertJohan/go.rice/embedded"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
|
||
|
// define files
|
||
|
file2 := &embedded.EmbeddedFile{
|
||
|
Filename: `board.html`,
|
||
|
FileModTime: time.Unix(1489412682, 0),
|
||
|
Content: string("<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>{{.Config.Site.Title}} - /{{.Board.ShortName}}/</title>\n <link rel=\"stylesheet\" href=\"/@/style.css\">\n <link rel=\"stylesheet\" href=\"/@/custom.css\">\n</head>\n<body>\n<div class=\"banner logo\">\n <div class=\"site title\"><h1><span class=\"reflink\"><a href=\"/{{.Board.ShortName}}/board.html\">/{{.Board.ShortName}}/</a></span></h1></div>\n <div class=\"site description\"><h2>{{.Board.LongName}}</h2></div>\n</div>\n{{ $boardlink := .Board.ShortName }}\n{{ if .Session }}\n{{ if eq (.Session.CAttr \"mode\") \"admin\" }}\nLogged in as Admin\n{{ end }}\n{{ if eq (.Session.CAttr \"mode\") \"mod\" }}\nLogged in as Mod for {{ .Session.CAttr \"board\" }}\n{{ end }}\n{{ end }}\n<hr />\n{{ template \"thread/post\" . }}\n<div class=\"postlists\">\n {{ $board := .Board }}\n {{ $csrf := .CSRFToken }}\n {{ $session := .Session }}\n {{range .Threads}}\n {{ template \"thread/postlists\" dict \"Thread\" . \"Board\" $board \"CSRFToken\" $csrf \"Session\" $session }}\n {{end}}\n</div>\n</body>\n</html>"),
|
||
|
}
|
||
|
file3 := &embedded.EmbeddedFile{
|
||
|
Filename: `dir.html`,
|
||
|
FileModTime: time.Unix(1489315156, 0),
|
||
|
Content: string("<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>{{.Config.Site.Title}} Boards</title>\n <link rel=\"stylesheet\" href=\"/@/style.css\">\n <link rel=\"stylesheet\" href=\"/@/custom.css\">\n</head>\n<body>\n <div class=\"banner logo\">\n <div class=\"site title\"><h1>{{.Config.Site.Title}}</h1></div>\n <div class=\"site description\"><h2>{{.Config.Site.Description}}</h2></div>\n </div>\n <div class=\"boardlist\">\n <div class=\"boardtitle\">\n <h3>Boards</h3>\n </div>\n <div class=\"boardlist\">\n <ul>\n {{range .Boards}}\n <li>\n <a class=\"boardlink\" href=\"/{{ .ShortName}}/board.html\">{{.ShortName}}: {{.LongName}}</a>\n </li>\n {{end}}\n </ul>\n </div>\n </div>\n</body>\n</html>"),
|
||
|
}
|
||
|
file4 := &embedded.EmbeddedFile{
|
||
|
Filename: `thread.html`,
|
||
|
FileModTime: time.Unix(1489412660, 0),
|
||
|
Content: string("<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>{{.Config.Site.Title}} - /{{.Board.ShortName}}/</title>\n <link rel=\"stylesheet\" href=\"/@/style.css\">\n <link rel=\"stylesheet\" href=\"/@/custom.css\">\n</head>\n<body>\n<div class=\"banner logo\">\n <div class=\"site title\"><h1><span class=\"reflink\"><a href=\"/{{.Board.ShortName}}/board.html\">/{{.Board.ShortName}}/</a></span></h1></div>\n <div class=\"site description\"><h2>{{.Board.LongName}}</h2></div>\n <div class=\"site thread\"><h3>{{.Thread.ID}}</h3></div>\n</div>\n{{ $boardlink := .Board.ShortName }}\n<hr />\n{{ template \"thread/post\" . }}\n{{ template \"thread/postlists\" . }}\n</body>\n</html>"),
|
||
|
}
|
||
|
file5 := &embedded.EmbeddedFile{
|
||
|
Filename: `thread.tmpl.html`,
|
||
|
FileModTime: time.Unix(1489566591, 0),
|
||
|
Content: string("{{ define \"thread/post\" }}\n<div class=\"postarea\">\n {{ if .Thread }}\n <form id=\"postform\"\n action=\"/{{.Board.ShortName}}/{{.Thread.ID}}/reply.sh\"\n method=\"POST\"\n enctype=\"multipart/form-data\">\n {{ else }}\n <form id=\"postform\"\n action=\"/{{.Board.ShortName}}/new_thread.sh\"\n method=\"POST\"\n enctype=\"multipart/form-data\">\n {{ end }}\n <table>\n <tbody>\n {{ if .PreviousError }}\n <tr>\n <td class=\"postblock\">\n Error\n </td>\n <td>\n {{.PreviousError}}\n </td>\n </tr>\n {{ end }}\n <tr>\n <td class=\"postblock\">\n TripCode\n </td>\n <td>\n <input type=\"text\" name=\"tripcode\" size=48 placeholder=\"Anonymous\"/>\n <input\n type=\"hidden\"\n name=\"csrf_token\"\n value=\"{{ .CSRFToken }}\" />\n </td>\n </tr>\n <tr>\n <td class=\"postblock\">\n Comment\n </td>\n <td>\n <textarea\n name=\"text\"\n placeholder=\"your comment\"\n rows=\"4\"\n cols=\"48\"\n minlength=\"5\"\n required\n ></textarea>\n </td>\n </tr>\n <tr>\n <td class=\"postblock\">\n Image File\n </td>\n <td>\n <input type=\"file\" name=\"image\" />\n </td>\n </tr>\n {{ if ne .Config.Captcha.Mode \"disabled\" }}\n <tr>\n <td class=\"postblock\">\n Captcha\n </td>\n <td>\n {{ $captchaId := makeCaptcha }}\n <img id=\"image\" src=\"/captcha/{{$captchaId}}.png\" alt=\"Captcha Image\"/>\n <audio id=audio controls style=\"display:none\" src=\"/captcha/{{$captchaId}}.wav\" preload=none>\n You browser doesn't support audio.\n <a href=\"/captcha/download/{{$captchaId}}.wav\">Download file</a> to play it in the external player.\n </audio>\n <br>\n <input type=\"text\" name=\"captchaSolution\" size=48 />\n <input type=\"hidden\"\n name=\"captchaId\"\n value=\"{{$captchaId}}\"/>\n </td>\n </tr>\n {{ end }}\n {{ if (isModSession .Session) }}\n <tr>\n <td class=\"postblock\">\n Mod Post\n </td>\n <td>\n <label>\n <input type=\"checkbox\" name=\"modpost\"/>Mark as Mod Post\n </label>\n {{ if (isAdminSession .Session) }}\n <label>\n <input type=\"checkbox\" name=\"adminpost\"/>Mark as Admin Post\n </label>\n {{ end }}\n </td>\n </tr>\n {{ end }}\n <tr>\n <td class=\"postblock\">\n\n </td>\n <td>\n <input type=\"submit\" value=\"Post\" />\n </td>\n </tr>\n {{ if .Board.Metadata.rules }}\n <tr>\n <td class=\"postblock\">\n Rules\n </td>\n <td class=\"rules\">\n {{ renderText .Board.Metadata.rules }}\n
|
||
|
}
|
||
|
|
||
|
// define dirs
|
||
|
dir1 := &embedded.EmbeddedDir{
|
||
|
Filename: ``,
|
||
|
DirModTime: time.Unix(1489566591, 0),
|
||
|
ChildFiles: []*embedded.EmbeddedFile{
|
||
|
file2, // board.html
|
||
|
file3, // dir.html
|
||
|
file4, // thread.html
|
||
|
file5, // thread.tmpl.html
|
||
|
|
||
|
},
|
||
|
}
|
||
|
|
||
|
// link ChildDirs
|
||
|
dir1.ChildDirs = []*embedded.EmbeddedDir{}
|
||
|
|
||
|
// register embeddedBox
|
||
|
embedded.RegisterEmbeddedBox(`res/`, &embedded.EmbeddedBox{
|
||
|
Name: `res/`,
|
||
|
Time: time.Unix(1489566591, 0),
|
||
|
Dirs: map[string]*embedded.EmbeddedDir{
|
||
|
"": dir1,
|
||
|
},
|
||
|
Files: map[string]*embedded.EmbeddedFile{
|
||
|
"board.html": file2,
|
||
|
"dir.html": file3,
|
||
|
"thread.html": file4,
|
||
|
"thread.tmpl.html": file5,
|
||
|
},
|
||
|
})
|
||
|
}
|