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/
|
/log/
|
||||||
/releases/
|
/releases/
|
||||||
/vagrant/.vagrant/
|
/vagrant/.vagrant/
|
||||||
/vagrant/*.log
|
|
||||||
/html/boards.json
|
/html/boards.json
|
||||||
/html/index.html
|
/html/index.html
|
||||||
/html/test*
|
/html/test*
|
||||||
/html/javascript/consts.js
|
/html/javascript/consts.js
|
||||||
|
/html/js/consts.js
|
||||||
/templates/override
|
/templates/override
|
||||||
**/*.bak
|
*.bak
|
||||||
*.log
|
*.log
|
||||||
*.swp
|
*.swp
|
||||||
__debug_bin
|
__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.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
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 exe
|
||||||
global gochan_bin
|
global gochan_bin
|
||||||
global gochan_exe
|
global gochan_exe
|
||||||
global migration_bin
|
|
||||||
global migration_exe
|
|
||||||
global version
|
global version
|
||||||
|
|
||||||
if goos != "":
|
if goos != "":
|
||||||
|
@ -128,14 +126,13 @@ def set_vars(goos = ""):
|
||||||
|
|
||||||
gochan_bin = "gochan"
|
gochan_bin = "gochan"
|
||||||
gochan_exe = "gochan" + exe
|
gochan_exe = "gochan" + exe
|
||||||
migration_bin = "gochan-migration"
|
|
||||||
migration_exe = "gochan-migration" + exe
|
|
||||||
|
|
||||||
version_file = open("version", "r")
|
version_file = open("version", "r")
|
||||||
version = version_file.read().strip()
|
version = version_file.read().strip()
|
||||||
version_file.close()
|
version_file.close()
|
||||||
|
|
||||||
def build(debugging = False):
|
def build(debugging = False):
|
||||||
|
"""Build the gochan executable for the current GOOS"""
|
||||||
pwd = os.getcwd()
|
pwd = os.getcwd()
|
||||||
trimpath = "-trimpath=" + pwd
|
trimpath = "-trimpath=" + pwd
|
||||||
gcflags = " -gcflags=\"" + trimpath + "{}\""
|
gcflags = " -gcflags=\"" + trimpath + "{}\""
|
||||||
|
@ -158,13 +155,6 @@ def build(debugging = False):
|
||||||
exit(1)
|
exit(1)
|
||||||
print("Built gochan successfully\n")
|
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():
|
def clean():
|
||||||
print("Cleaning up")
|
print("Cleaning up")
|
||||||
del_files = ["gochan", "gochan.exe", "gochan-migration", "gochan-migration.exe", "releases/", "pkg/gclog/logtest/"]
|
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]
|
status = run_cmd(cmd, print_output = True, realtime = True, print_command = True)[1]
|
||||||
if status != 0:
|
if status != 0:
|
||||||
print("Failed starting a docker container, exited with status code", status)
|
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):
|
def install(prefix = "/usr", document_root = "/srv/gochan", js_only = False, css_only = False, templates_only = False):
|
||||||
if gcos == "windows" or gcos == "darwin":
|
if gcos == "windows" or gcos == "darwin":
|
||||||
|
@ -210,7 +201,6 @@ def install(prefix = "/usr", document_root = "/srv/gochan", js_only = False, css
|
||||||
done = True
|
done = True
|
||||||
if templates_only:
|
if templates_only:
|
||||||
print("Installing template files")
|
print("Installing template files")
|
||||||
print(document_root)
|
|
||||||
templates_install_dir = path.join(document_root, "templates")
|
templates_install_dir = path.join(document_root, "templates")
|
||||||
if not path.exists(templates_install_dir):
|
if not path.exists(templates_install_dir):
|
||||||
fs_action("mkdir", 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))
|
path.join(document_root, "templates", template))
|
||||||
done = True
|
done = True
|
||||||
if done:
|
if done:
|
||||||
print("done.")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
fs_action("mkdir", "/etc/gochan")
|
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)
|
print("Installing", file, "to", out_path)
|
||||||
fs_action("copy", file, out_path)
|
fs_action("copy", file, out_path)
|
||||||
|
|
||||||
|
if path.exists(gochan_exe) == False:
|
||||||
# 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)):
|
|
||||||
build()
|
build()
|
||||||
print("Installing",gochan_exe,"to",path.join(prefix, "bin", gochan_exe))
|
print("Installing",gochan_exe,"to",path.join(prefix, "bin", gochan_exe))
|
||||||
fs_action("copy", gochan_exe, 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("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(
|
print(
|
||||||
"gochan successfully installed. If you haven't already, you should copy\n",
|
"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]
|
status = run_cmd(npm_cmd, True, True, True)[1]
|
||||||
if status != 0:
|
if status != 0:
|
||||||
print("JS transpiling failed with status", status)
|
print("JS transpiling failed with status", status)
|
||||||
|
exit(status)
|
||||||
|
|
||||||
def release(goos):
|
def release(goos):
|
||||||
set_vars(goos)
|
set_vars(goos)
|
||||||
|
@ -297,6 +281,7 @@ def sass(minify = False):
|
||||||
status = run_cmd(sass_cmd, realtime = True, print_command = True)[1]
|
status = run_cmd(sass_cmd, realtime = True, print_command = True)[1]
|
||||||
if status != 0:
|
if status != 0:
|
||||||
print("Failed running sass with status", status)
|
print("Failed running sass with status", status)
|
||||||
|
exit(status)
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
pkgs = os.listdir("pkg")
|
pkgs = os.listdir("pkg")
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
|
@ -5,8 +5,8 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>404: File not found</h1>
|
<h1>404: File not found</h1>
|
||||||
<img src="/error/lol 404.gif" border="0" alt="">
|
<img src="./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>
|
<p>The requested file could not be found on this server.</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>500: Internal Server error</h1>
|
<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>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -140,11 +140,12 @@ func BuildBoardPages(board *gcsql.Board) error {
|
||||||
// Render board page template to the file,
|
// Render board page template to the file,
|
||||||
// packaging the board/section list, threads, and board info
|
// packaging the board/section list, threads, and board info
|
||||||
if err = serverutil.MinifyTemplate(gctemplates.BoardPage, map[string]interface{}{
|
if err = serverutil.MinifyTemplate(gctemplates.BoardPage, map[string]interface{}{
|
||||||
"webroot": criticalCfg.WebRoot,
|
"webroot": criticalCfg.WebRoot,
|
||||||
"boards": gcsql.AllBoards,
|
"boards": gcsql.AllBoards,
|
||||||
"sections": gcsql.AllSections,
|
"sections": gcsql.AllSections,
|
||||||
"threads": threads,
|
"threads": threads,
|
||||||
"board": board,
|
"board": board,
|
||||||
|
"board_config": config.GetBoardConfig(board.Dir),
|
||||||
}, boardPageFile, "text/html"); err != nil {
|
}, boardPageFile, "text/html"); err != nil {
|
||||||
return errors.New(gclog.Printf(gclog.LErrorLog,
|
return errors.New(gclog.Printf(gclog.LErrorLog,
|
||||||
"Failed building /%s/: %s", board.Dir, err.Error()))
|
"Failed building /%s/: %s", board.Dir, err.Error()))
|
||||||
|
@ -183,11 +184,12 @@ func BuildBoardPages(board *gcsql.Board) error {
|
||||||
|
|
||||||
// Render the boardpage template
|
// Render the boardpage template
|
||||||
if err = serverutil.MinifyTemplate(gctemplates.BoardPage, map[string]interface{}{
|
if err = serverutil.MinifyTemplate(gctemplates.BoardPage, map[string]interface{}{
|
||||||
"webroot": criticalCfg.WebRoot,
|
"webroot": criticalCfg.WebRoot,
|
||||||
"boards": gcsql.AllBoards,
|
"boards": gcsql.AllBoards,
|
||||||
"sections": gcsql.AllSections,
|
"sections": gcsql.AllSections,
|
||||||
"threads": pageThreads,
|
"threads": pageThreads,
|
||||||
"board": board,
|
"board": board,
|
||||||
|
"board_config": config.GetBoardConfig(board.Dir),
|
||||||
"posts": []interface{}{
|
"posts": []interface{}{
|
||||||
gcsql.Post{BoardID: board.ID},
|
gcsql.Post{BoardID: board.ID},
|
||||||
},
|
},
|
||||||
|
@ -286,11 +288,12 @@ func BuildCatalog(boardID int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = serverutil.MinifyTemplate(gctemplates.Catalog, map[string]interface{}{
|
if err = serverutil.MinifyTemplate(gctemplates.Catalog, map[string]interface{}{
|
||||||
"boards": gcsql.AllBoards,
|
"boards": gcsql.AllBoards,
|
||||||
"webroot": criticalCfg.WebRoot,
|
"webroot": criticalCfg.WebRoot,
|
||||||
"board": board,
|
"board": board,
|
||||||
"sections": gcsql.AllSections,
|
"board_config": config.GetBoardConfig(board.Dir),
|
||||||
"threads": threadInterfaces,
|
"sections": gcsql.AllSections,
|
||||||
|
"threads": threadInterfaces,
|
||||||
}, catalogFile, "text/html"); err != nil {
|
}, catalogFile, "text/html"); err != nil {
|
||||||
return gclog.Printf(gclog.LErrorLog,
|
return gclog.Printf(gclog.LErrorLog,
|
||||||
"Error building catalog for /%s/: %s", board.Dir, err.Error()) + "<br />"
|
"Error building catalog for /%s/: %s", board.Dir, err.Error()) + "<br />"
|
||||||
|
|
|
@ -70,7 +70,7 @@ func BuildBoardListJSON() error {
|
||||||
defer boardListFile.Close()
|
defer boardListFile.Close()
|
||||||
|
|
||||||
boardsMap := map[string][]gcsql.Board{
|
boardsMap := map[string][]gcsql.Board{
|
||||||
"boards": []gcsql.Board{},
|
"boards": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
boardCfg := config.GetBoardConfig("")
|
boardCfg := config.GetBoardConfig("")
|
||||||
|
|
|
@ -61,11 +61,6 @@ func BuildThreadPages(op *gcsql.Post) error {
|
||||||
criticalCfg := config.GetSystemCriticalConfig()
|
criticalCfg := config.GetSystemCriticalConfig()
|
||||||
os.Remove(path.Join(criticalCfg.DocumentRoot, board.Dir, "res", strconv.Itoa(op.ID)+".html"))
|
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")
|
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)
|
threadPageFile, err = os.OpenFile(threadPageFilepath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -75,12 +70,13 @@ func BuildThreadPages(op *gcsql.Post) error {
|
||||||
|
|
||||||
// render thread page
|
// render thread page
|
||||||
if err = serverutil.MinifyTemplate(gctemplates.ThreadPage, map[string]interface{}{
|
if err = serverutil.MinifyTemplate(gctemplates.ThreadPage, map[string]interface{}{
|
||||||
"webroot": criticalCfg.WebRoot,
|
"webroot": criticalCfg.WebRoot,
|
||||||
"boards": gcsql.AllBoards,
|
"boards": gcsql.AllBoards,
|
||||||
"board": board,
|
"board": board,
|
||||||
"sections": gcsql.AllSections,
|
"board_config": config.GetBoardConfig(board.Dir),
|
||||||
"posts": replies,
|
"sections": gcsql.AllSections,
|
||||||
"op": op,
|
"posts": replies,
|
||||||
|
"op": op,
|
||||||
}, threadPageFile, "text/html"); err != nil {
|
}, threadPageFile, "text/html"); err != nil {
|
||||||
return errors.New(gclog.Printf(gclog.LErrorLog,
|
return errors.New(gclog.Printf(gclog.LErrorLog,
|
||||||
"Failed building /%s/res/%d threadpage: %s", board.Dir, op.ID, err.Error()))
|
"Failed building /%s/res/%d threadpage: %s", board.Dir, op.ID, err.Error()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue