Fixed file serving, Added favicon

This commit is contained in:
Patrick Hatsune 2024-07-10 01:24:22 -07:00
parent 10244e156c
commit 11f868c5d1
Signed by: keyemail
GPG key ID: 6FD1A0FDB0D914C2
8 changed files with 22 additions and 14 deletions

11
main.go
View file

@ -15,6 +15,11 @@ var data = &Index {
Title: "MBot",
}
func fileHandler(file string, path string) {
fs := http.FileServer(http.Dir("./" + file))
http.Handle("/" + path + "/", http.StripPrefix("/" + path + "/", fs))
}
func aboutHandler(w http.ResponseWriter, req *http.Request) {
templates := template.Must(template.ParseFiles(
"src/index.tmpl",
@ -50,8 +55,10 @@ func main() {
log.Fatal("Template file does not exist:\n", err)
}
fs := http.FileServer(http.Dir("./src/"))
http.Handle("/src/", http.StripPrefix("/src/", fs))
fileHandler("src/assets", "assets");
fileHandler("src/styles", "styles");
fileHandler("src/scripts", "scripts");
fileHandler("src/fonts", "fonts");
port := ":3939"

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
src/assets/main/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View file

@ -6,13 +6,14 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>{{ .Title }}</title>
<link rel="stylesheet" href="/src/styles/main.css">
<link rel="icon" type="image/x-icon" href="assets/main/favicon.ico">
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
{{ template "navbar" . }}
{{ template "body" . }}
{{ template "footer" . }}
<script src="/src/scripts/main.js"></script>
<script src="scripts/main.js"></script>
</body>
</html>
{{ end }}

View file

@ -1,6 +1,6 @@
<head>
{{ define "head" }}
<link rel="stylesheet" href="/src/styles/about.css">
<link rel="stylesheet" href="styles/about.css">
{{ end }}
</head>
<body>

View file

@ -1,6 +1,6 @@
<head>
{{ define "head" }}
<link rel="stylesheet" href="/src/styles/home.css">
<link rel="stylesheet" href="styles/home.css">
{{ end }}
</head>
<body>
@ -12,7 +12,7 @@
<p>MBot is a new Discord bot that allows you do powerful moderation, play music with your friends, and is built to do way more in the future! This project is currentaly in alpha and MBot is very limited, please wait paintely for new updates comming your way! 😎</p>
</div>
<div id="header-wrapped-profile">
<img src="/src/assets/home/bot-profile-compressed.png" alt="Bot Profile"/>
<img src="assets/home/bot-profile-compressed.png" alt="Bot Profile"/>
</div>
</div>
</header>
@ -23,14 +23,14 @@
<h2>Powerful Moderation!</h2>
<p>Moderate your server with ban or kick commands this will get rid of any naughty people that break your server rules! You can also manage messages using the clear command this will get rid of a big chunk of messages that you may not want on your server.</p>
</div>
<img src="/src/assets/home/bot-moderation.png" alt="Bot Moderation">
<img src="assets/home/bot-moderation.png" alt="Bot Moderation">
</li>
<li class="row-reverse">
<div>
<h2>Music!</h2>
<p>Play music from YouTube with our bot for free! Control your music how youd like by skipping, pausing, or stopping the queue entirely, to play what you want on your server! You may also look at what the queue is storing for your server.</p>
</div>
<img src="/src/assets/home/bot-music.png" alt="Bot Music">
<img src="assets/home/bot-music.png" alt="Bot Music">
</li>
<li>
<div class="shift-center">

View file

@ -7,7 +7,7 @@ header {
margin-bottom: 0;
width: calc(100% + 2 * var(--pad));
height: 600px;
background: #103161 no-repeat center / cover url(/src/assets/home/header-background.svg);
background: #103161 no-repeat center / cover url(../assets/home/header-background.svg);
#header-wrapped-content {
display: flex;
@ -87,7 +87,7 @@ header {
justify-content: center;
width: 100%;
height: 350px;
background: #1e7ebf no-repeat center / cover url(/src/assets/home/invite-banner.svg);
background: #1e7ebf no-repeat center / cover url(../assets/home/invite-banner.svg);
border-radius: 20px;
text-align: center;

View file

@ -1,18 +1,18 @@
@font-face {
font-family: Poppins;
src: url(/src/fonts/poppins/Poppins-Medium.ttf);
src: url(../fonts/poppins/Poppins-Medium.ttf);
font-weight: 400;
}
@font-face {
font-family: Poppins;
src: url(/src/fonts/poppins/Poppins-Light.ttf);
src: url(../fonts/poppins/Poppins-Light.ttf);
font-weight: 200;
}
@font-face {
font-family: Poppins;
src: url(/src/fonts/poppins/Poppins-Bold.ttf);
src: url(../fonts/poppins/Poppins-Bold.ttf);
font-weight: 800;
}