1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-02 23:26:23 -07:00

Merge branch 'master' into pre2021-migration-update

This commit is contained in:
Eggbertx 2024-12-31 16:30:53 -08:00
commit 2e91aeb0a4
7 changed files with 214 additions and 5 deletions

View file

@ -39,7 +39,7 @@ release_files = (
"README.md", "README.md",
) )
GOCHAN_VERSION = "4.0.1" GOCHAN_VERSION = "4.0.2"
DATABASE_VERSION = "4" # stored in DBNAME.DBPREFIXdatabase_version DATABASE_VERSION = "4" # stored in DBNAME.DBPREFIXdatabase_version
PATH_NOTHING = -1 PATH_NOTHING = -1

View file

@ -1,6 +1,6 @@
{ {
"name": "gochan.js", "name": "gochan.js",
"version": "4.0.1", "version": "4.0.2",
"description": "", "description": "",
"main": "./ts/main.ts", "main": "./ts/main.ts",
"private": true, "private": true,

View file

@ -7,6 +7,6 @@
<h1>404: File not found</h1> <h1>404: File not found</h1>
<img src="/error/lol 404.gif" alt="lol 404"> <img src="/error/lol 404.gif" alt="lol 404">
<p>The requested file could not be found on this server.</p> <p>The requested file could not be found on this server.</p>
<hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v4.0.1 <hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v4.0.2
</body> </body>
</html> </html>

View file

@ -7,6 +7,6 @@
<h1>Error 500: Internal Server error</h1> <h1>Error 500: Internal Server error</h1>
<img src="/error/server500.gif" alt="server burning"> <img src="/error/server500.gif" alt="server burning">
<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 they get around to it, whenever that is. Hopefully soon.</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 they get around to it, whenever that is. Hopefully soon.</p>
<hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v4.0.1 <hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v4.0.2
</body> </body>
</html> </html>

View file

@ -7,6 +7,6 @@
<h1>Error 502: Bad gateway</h1> <h1>Error 502: Bad gateway</h1>
<img src="/error/server500.gif" alt="server burning"> <img src="/error/server500.gif" alt="server burning">
<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 they get around to it, whenever that is. Hopefully soon.</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 they get around to it, whenever that is. Hopefully soon.</p>
<hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v4.0.1 <hr/>Site powered by <a href="https://github.com/gochan-org/gochan" target="_blank">Gochan</a> v4.0.2
</body> </body>
</html> </html>

View file

@ -70,6 +70,18 @@ var (
AnonymousName: "Anonymous Coward", AnonymousName: "Anonymous Coward",
} }
simpleBoard2 = &gcsql.Board{
ID: 2,
SectionID: 2,
URI: "sup",
Dir: "sup",
Title: "Gochan Support board",
Subtitle: "Board for helping out gochan users/admins",
Description: "Board for helping out gochan users/admins",
DefaultStyle: "yotsuba.css",
AnonymousName: "Anonymous Coward",
}
banPageCases = []templateTestCase{ banPageCases = []templateTestCase{
{ {
desc: "appealable permaban", desc: "appealable permaban",
@ -251,6 +263,195 @@ var (
expectedOutput: `const styles=[];const defaultStyle="\&#34;a\\a\&#34;";const webroot="";const serverTZ=0;const fileTypes=[];`, expectedOutput: `const styles=[];const defaultStyle="\&#34;a\\a\&#34;";const webroot="";const serverTZ=0;const fileTypes=[];`,
}, },
} }
baseFooterCases = []templateTestCase{
{
desc: "base footer test",
data: map[string]any{
"boardConfig": simpleBoardConfig,
"board": simpleBoard1,
"numPages": 1,
"sections": []gcsql.Section{
{ID: 1},
},
},
expectedOutput: footer,
},
{
desc: "base footer test",
data: map[string]any{
"boardConfig": simpleBoardConfig,
"board": simpleBoard2,
"numPages": 3,
"sections": []gcsql.Section{
{ID: 1},
},
},
expectedOutput: footer,
},
}
baseHeaderCases = []templateTestCase{
{
desc: "Header Test /test/",
data: map[string]any{
"boardConfig": simpleBoardConfig,
"board": simpleBoard1,
"numPages": 1,
"sections": []gcsql.Section{
{ID: 1},
},
},
expectedOutput: headBeginning +
`<title>/test/-Testing board</title>` +
`<link rel="stylesheet"href="/css/global.css"/>` +
`<link id="theme"rel="stylesheet"href="/css/pipes.css"/>` +
`<link rel="shortcut icon"href="/favicon.png">` +
`<script type="text/javascript"src="/js/consts.js"></script>` +
`<script type="text/javascript"src="/js/gochan.js"></script>` +
`</head><body><div id="topbar"><div class="topbar-section">` +
`<a href="/"class="topbar-item">home</a></div>` +
`<div class="topbar-section"><a href="/test/"class="topbar-item"title="Testing board">/test/</a>` +
`<a href="/test2/" class="topbar-item" title="Testing board#2">/test2/</a></div></div>` +
`<div id="content">`,
},
{
desc: "Header Test /sup/",
data: map[string]any{
"boardConfig": simpleBoardConfig,
"board": simpleBoard2,
"numPages": 1,
"sections": []gcsql.Section{
{ID: 1},
},
},
expectedOutput: headBeginning +
`<title>/sup/-Gochan Support board</title>` +
`<link rel="stylesheet"href="/css/global.css"/>` +
`<link id="theme"rel="stylesheet"href="/css/pipes.css"/>` +
`<link rel="shortcut icon"href="/favicon.png">` +
`<script type="text/javascript"src="/js/consts.js"></script>` +
`<script type="text/javascript"src="/js/gochan.js"></script>` +
`</head><body><div id="topbar"><div class="topbar-section">` +
`<a href="/"class="topbar-item">home</a></div>` +
`<div class="topbar-section"><a href="/test/"class="topbar-item"title="Testing board">/test/</a>` +
`<a href="/test2/" class="topbar-item" title="Testing board#2">/test2/</a></div></div>` +
`<div id="content">`,
},
{
desc: "Perma Ban Header Test",
data: map[string]any{
"ban": &gcsql.IPBan{
RangeStart: "192.168.56.0",
RangeEnd: "192.168.56.255",
IPBanBase: gcsql.IPBanBase{
IsActive: true,
Permanent: true,
StaffID: 1,
Message: "ban message goes here",
},
},
"ip": "192.168.56.1",
"siteConfig": testingSiteConfig,
"systemCritical": config.SystemCriticalConfig{
WebRoot: "/",
},
"boardConfig": config.BoardConfig{
DefaultStyle: "pipes.css",
},
},
expectedOutput: `<!DOCTYPE html><html lang="en"><head>` +
`<meta charset="UTF-8"><meta name="viewport"content="width=device-width, initial-scale=1.0">` +
`<title>YOU'RE PERMABANNED,&nbsp;IDIOT!</title><link rel="stylesheet"href="/css/global.css"/>` +
`<link id="theme"rel="stylesheet"href="/css/pipes.css"/><link rel="shortcut icon"href="/favicon.png">` +
`<script type="text/javascript"src="/js/consts.js"></script><script type="text/javascript"src="/js/gochan.js"></script>` +
`</head><body><div id="topbar"><div class="topbar-section"><a href="/"class="topbar-item">home</a></div></div><div id="content">`,
},
{
desc: "Appealable Perma Ban Header Test",
data: map[string]any{
"ban": &gcsql.IPBan{
RangeStart: "192.168.56.0",
RangeEnd: "192.168.56.255",
IPBanBase: gcsql.IPBanBase{
Permanent: true,
CanAppeal: true,
StaffID: 1,
Message: "ban message goes here",
},
},
"ip": "192.168.56.1",
"siteConfig": testingSiteConfig,
"systemCritical": config.SystemCriticalConfig{
WebRoot: "/",
},
"boardConfig": config.BoardConfig{
DefaultStyle: "pipes.css",
},
},
expectedOutput: `<!DOCTYPE html><html lang="en"><head>` +
`<meta charset="UTF-8"><meta name="viewport"content="width=device-width, initial-scale=1.0">` +
`<title>YOU ARE BANNED:(</title><link rel="stylesheet"href="/css/global.css"/>` +
`<link id="theme"rel="stylesheet"href="/css/pipes.css"/><link rel="shortcut icon"href="/favicon.png">` +
`<script type="text/javascript"src="/js/consts.js"></script><script type="text/javascript"src="/js/gochan.js"></script>` +
`</head><body><div id="topbar"><div class="topbar-section"><a href="/"class="topbar-item">home</a></div></div><div id="content">`,
},
{
desc: "Appealable Temp Ban Header Test",
data: map[string]any{
"ban": &gcsql.IPBan{
RangeStart: "192.168.56.0",
RangeEnd: "192.168.56.255",
IPBanBase: gcsql.IPBanBase{
CanAppeal: true,
StaffID: 1,
Message: "ban message goes here",
},
},
"ip": "192.168.56.1",
"siteConfig": testingSiteConfig,
"systemCritical": config.SystemCriticalConfig{
WebRoot: "/",
},
"boardConfig": config.BoardConfig{
DefaultStyle: "pipes.css",
},
},
expectedOutput: `<!DOCTYPE html><html lang="en">` +
`<head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, initial-scale=1.0">` +
`<title>YOU ARE BANNED:(</title><link rel="stylesheet"href="/css/global.css"/>` +
`<link id="theme"rel="stylesheet"href="/css/pipes.css"/><link rel="shortcut icon"href="/favicon.png">` +
`<script type="text/javascript"src="/js/consts.js"></script><script type="text/javascript"src="/js/gochan.js"></script>` +
`</head><body><div id="topbar"><div class="topbar-section"><a href="/"class="topbar-item">home</a></div></div><div id="content">`,
},
{
desc: "Unappealable Temp Ban Header Test",
data: map[string]any{
"ban": &gcsql.IPBan{
RangeStart: "192.168.56.0",
RangeEnd: "192.168.56.255",
IPBanBase: gcsql.IPBanBase{
StaffID: 1,
Message: "ban message goes here",
},
},
"ip": "192.168.56.1",
"siteConfig": testingSiteConfig,
"systemCritical": config.SystemCriticalConfig{
WebRoot: "/",
},
"boardConfig": config.BoardConfig{
DefaultStyle: "pipes.css",
},
},
expectedOutput: `<!DOCTYPE html><html lang="en"><head>` +
`<meta charset="UTF-8"><meta name="viewport"content="width=device-width, initial-scale=1.0">` +
`<title>YOU ARE BANNED:(</title><link rel="stylesheet"href="/css/global.css"/>` +
`<link id="theme"rel="stylesheet"href="/css/pipes.css"/><link rel="shortcut icon"href="/favicon.png">` +
`<script type="text/javascript"src="/js/consts.js"></script><script type="text/javascript"src="/js/gochan.js"></script>` +
`</head><body><div id="topbar"><div class="topbar-section"><a href="/"class="topbar-item">home</a></div></div><div id="content">`,
},
}
) )
const ( const (

View file

@ -108,3 +108,11 @@ func TestTemplateBase(t *testing.T) {
initTemplatesMock(t, mock) initTemplatesMock(t, mock)
} }
func TestBaseFooter(t *testing.T) {
runTemplateTestCases(t, gctemplates.PageFooter, baseFooterCases)
}
func TestBaseHeader(t *testing.T) {
runTemplateTestCases(t, gctemplates.PageHeader, baseHeaderCases)
}