mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-02 15:06:23 -07:00
Add board config to all templates using the standard header
Also remove commented migration lines in build.py
This commit is contained in:
parent
8719227f3d
commit
7e13a32ec3
9 changed files with 39 additions and 55 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -3,13 +3,13 @@
|
|||
/log/
|
||||
/releases/
|
||||
/vagrant/.vagrant/
|
||||
/vagrant/*.log
|
||||
/html/boards.json
|
||||
/html/index.html
|
||||
/html/test*
|
||||
/html/javascript/consts.js
|
||||
/html/js/consts.js
|
||||
/templates/override
|
||||
**/*.bak
|
||||
*.bak
|
||||
*.log
|
||||
*.swp
|
||||
__debug_bin
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2013-2021, Gochan development group
|
||||
Copyright (c) 2013-2022, Gochan development group
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
25
build.py
25
build.py
|
@ -110,8 +110,6 @@ def set_vars(goos = ""):
|
|||
global exe
|
||||
global gochan_bin
|
||||
global gochan_exe
|
||||
global migration_bin
|
||||
global migration_exe
|
||||
global version
|
||||
|
||||
if goos != "":
|
||||
|
@ -128,14 +126,13 @@ def set_vars(goos = ""):
|
|||
|
||||
gochan_bin = "gochan"
|
||||
gochan_exe = "gochan" + exe
|
||||
migration_bin = "gochan-migration"
|
||||
migration_exe = "gochan-migration" + exe
|
||||
|
||||
version_file = open("version", "r")
|
||||
version = version_file.read().strip()
|
||||
version_file.close()
|
||||
|
||||
def build(debugging = False):
|
||||
"""Build the gochan executable for the current GOOS"""
|
||||
pwd = os.getcwd()
|
||||
trimpath = "-trimpath=" + pwd
|
||||
gcflags = " -gcflags=\"" + trimpath + "{}\""
|
||||
|
@ -158,13 +155,6 @@ def build(debugging = False):
|
|||
exit(1)
|
||||
print("Built gochan successfully\n")
|
||||
|
||||
# print("Note: gochan-migration has been put on indefinite suspention. See README.md")
|
||||
# status = run_cmd(build_cmd + " -o " + migration_exe + " ./cmd/gochan-migration", realtime = True, print_command = True)[1]
|
||||
# if status != 0:
|
||||
# print("Failed building gochan-migration, see command output for details")
|
||||
# exit(1)
|
||||
# print("Build gochan-migration successfully\n")
|
||||
|
||||
def clean():
|
||||
print("Cleaning up")
|
||||
del_files = ["gochan", "gochan.exe", "gochan-migration", "gochan-migration.exe", "releases/", "pkg/gclog/logtest/"]
|
||||
|
@ -188,6 +178,7 @@ def docker(option = "guestdb", attached = False):
|
|||
status = run_cmd(cmd, print_output = True, realtime = True, print_command = True)[1]
|
||||
if status != 0:
|
||||
print("Failed starting a docker container, exited with status code", status)
|
||||
exit(1)
|
||||
|
||||
def install(prefix = "/usr", document_root = "/srv/gochan", js_only = False, css_only = False, templates_only = False):
|
||||
if gcos == "windows" or gcos == "darwin":
|
||||
|
@ -210,7 +201,6 @@ def install(prefix = "/usr", document_root = "/srv/gochan", js_only = False, css
|
|||
done = True
|
||||
if templates_only:
|
||||
print("Installing template files")
|
||||
print(document_root)
|
||||
templates_install_dir = path.join(document_root, "templates")
|
||||
if not path.exists(templates_install_dir):
|
||||
fs_action("mkdir", templates_install_dir)
|
||||
|
@ -223,7 +213,6 @@ def install(prefix = "/usr", document_root = "/srv/gochan", js_only = False, css
|
|||
path.join(document_root, "templates", template))
|
||||
done = True
|
||||
if done:
|
||||
print("done.")
|
||||
return
|
||||
|
||||
fs_action("mkdir", "/etc/gochan")
|
||||
|
@ -238,17 +227,11 @@ def install(prefix = "/usr", document_root = "/srv/gochan", js_only = False, css
|
|||
print("Installing", file, "to", out_path)
|
||||
fs_action("copy", file, out_path)
|
||||
|
||||
|
||||
# print("installing sample-configs/gochan.example.json to /etc/gochan/gochan.example.json")
|
||||
# fs_action("copy")
|
||||
if(path.exists(gochan_exe) == False or path.exists(migration_exe)):
|
||||
if path.exists(gochan_exe) == False:
|
||||
build()
|
||||
print("Installing",gochan_exe,"to",path.join(prefix, "bin", gochan_exe))
|
||||
fs_action("copy", gochan_exe, path.join(prefix, "bin", gochan_exe))
|
||||
print("Note: gochan-migration has been put on indefinite suspention. See README.md")
|
||||
# print("Installing",migration_exe,"to",path.join(prefix, "bin", migration_exe))
|
||||
# fs_action("copy", migration_exe, path.join(prefix, "bin", migration_exe))
|
||||
|
||||
|
||||
print(
|
||||
"gochan successfully installed. If you haven't already, you should copy\n",
|
||||
|
@ -275,6 +258,7 @@ def js(nominify = False, watch = False):
|
|||
status = run_cmd(npm_cmd, True, True, True)[1]
|
||||
if status != 0:
|
||||
print("JS transpiling failed with status", status)
|
||||
exit(status)
|
||||
|
||||
def release(goos):
|
||||
set_vars(goos)
|
||||
|
@ -297,6 +281,7 @@ def sass(minify = False):
|
|||
status = run_cmd(sass_cmd, realtime = True, print_command = True)[1]
|
||||
if status != 0:
|
||||
print("Failed running sass with status", status)
|
||||
exit(status)
|
||||
|
||||
def test():
|
||||
pkgs = os.listdir("pkg")
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
|
@ -5,8 +5,8 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>404: File not found</h1>
|
||||
<img src="/error/lol 404.gif" border="0" alt="">
|
||||
<p>The requested file could not be found on this server. Are you just typing random stuff in the address bar? If you followed a link from this site here, then post <a href="/site">here</a></p>
|
||||
<hr><address>http://gochan.org powered by Gochan v2.12.0</address>
|
||||
<img src="./lol 404.gif" border="0" alt="">
|
||||
<p>The requested file could not be found on this server.</p>
|
||||
<hr><address>http://gochan.org powered by Gochan v3.0.0-beta</address>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>500: Internal Server error</h1>
|
||||
<img src="/error/derpy server.gif" border="0" alt="">
|
||||
<img src="./derpy server.gif" border="0" alt="">
|
||||
<p>The server encountered an error while trying to serve the page, and we apologize for the inconvenience. The <a href="https://en.wikipedia.org/wiki/Idiot">system administrator</a> will try to fix things as soon has he/she/it can.</p>
|
||||
<hr><address>http://gochan.org powered by Gochan v2.12.0</address>
|
||||
<hr><address>http://gochan.org powered by Gochan v3.0.0-beta</address>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -140,11 +140,12 @@ func BuildBoardPages(board *gcsql.Board) error {
|
|||
// Render board page template to the file,
|
||||
// packaging the board/section list, threads, and board info
|
||||
if err = serverutil.MinifyTemplate(gctemplates.BoardPage, map[string]interface{}{
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": threads,
|
||||
"board": board,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": threads,
|
||||
"board": board,
|
||||
"board_config": config.GetBoardConfig(board.Dir),
|
||||
}, boardPageFile, "text/html"); err != nil {
|
||||
return errors.New(gclog.Printf(gclog.LErrorLog,
|
||||
"Failed building /%s/: %s", board.Dir, err.Error()))
|
||||
|
@ -183,11 +184,12 @@ func BuildBoardPages(board *gcsql.Board) error {
|
|||
|
||||
// Render the boardpage template
|
||||
if err = serverutil.MinifyTemplate(gctemplates.BoardPage, map[string]interface{}{
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": pageThreads,
|
||||
"board": board,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": pageThreads,
|
||||
"board": board,
|
||||
"board_config": config.GetBoardConfig(board.Dir),
|
||||
"posts": []interface{}{
|
||||
gcsql.Post{BoardID: board.ID},
|
||||
},
|
||||
|
@ -286,11 +288,12 @@ func BuildCatalog(boardID int) string {
|
|||
}
|
||||
|
||||
if err = serverutil.MinifyTemplate(gctemplates.Catalog, map[string]interface{}{
|
||||
"boards": gcsql.AllBoards,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"board": board,
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": threadInterfaces,
|
||||
"boards": gcsql.AllBoards,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"board": board,
|
||||
"board_config": config.GetBoardConfig(board.Dir),
|
||||
"sections": gcsql.AllSections,
|
||||
"threads": threadInterfaces,
|
||||
}, catalogFile, "text/html"); err != nil {
|
||||
return gclog.Printf(gclog.LErrorLog,
|
||||
"Error building catalog for /%s/: %s", board.Dir, err.Error()) + "<br />"
|
||||
|
|
|
@ -70,7 +70,7 @@ func BuildBoardListJSON() error {
|
|||
defer boardListFile.Close()
|
||||
|
||||
boardsMap := map[string][]gcsql.Board{
|
||||
"boards": []gcsql.Board{},
|
||||
"boards": {},
|
||||
}
|
||||
|
||||
boardCfg := config.GetBoardConfig("")
|
||||
|
|
|
@ -61,11 +61,6 @@ func BuildThreadPages(op *gcsql.Post) error {
|
|||
criticalCfg := config.GetSystemCriticalConfig()
|
||||
os.Remove(path.Join(criticalCfg.DocumentRoot, board.Dir, "res", strconv.Itoa(op.ID)+".html"))
|
||||
|
||||
var repliesInterface []interface{}
|
||||
for _, reply := range replies {
|
||||
repliesInterface = append(repliesInterface, reply)
|
||||
}
|
||||
|
||||
threadPageFilepath := path.Join(criticalCfg.DocumentRoot, board.Dir, "res", strconv.Itoa(op.ID)+".html")
|
||||
threadPageFile, err = os.OpenFile(threadPageFilepath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0777)
|
||||
if err != nil {
|
||||
|
@ -75,12 +70,13 @@ func BuildThreadPages(op *gcsql.Post) error {
|
|||
|
||||
// render thread page
|
||||
if err = serverutil.MinifyTemplate(gctemplates.ThreadPage, map[string]interface{}{
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board": board,
|
||||
"sections": gcsql.AllSections,
|
||||
"posts": replies,
|
||||
"op": op,
|
||||
"webroot": criticalCfg.WebRoot,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board": board,
|
||||
"board_config": config.GetBoardConfig(board.Dir),
|
||||
"sections": gcsql.AllSections,
|
||||
"posts": replies,
|
||||
"op": op,
|
||||
}, threadPageFile, "text/html"); err != nil {
|
||||
return errors.New(gclog.Printf(gclog.LErrorLog,
|
||||
"Failed building /%s/res/%d threadpage: %s", board.Dir, op.ID, err.Error()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue