website/main.go

65 lines
1.7 KiB
Go
Raw Normal View History

/*
2024-03-19 20:16:26 +00:00
* website | MatterLinux Official Website
* MatterLinux 2023-2024 (https://matterlinux.xyz)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2024-03-19 20:16:26 +00:00
*/
2023-12-09 16:25:38 +00:00
package main
import (
2024-03-19 20:16:26 +00:00
"log"
2024-01-18 17:01:30 +00:00
"git.matterlinux.xyz/Matter/website/lib"
"git.matterlinux.xyz/Matter/website/routes"
2023-12-09 16:25:38 +00:00
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
)
func main(){
2024-03-19 20:16:26 +00:00
log.SetFlags(log.Lshortfile | log.Ltime)
2023-12-09 16:25:38 +00:00
engine := html.New("./templates", ".html")
app := fiber.New(fiber.Config{
2024-01-17 17:16:24 +00:00
DisableStartupMessage: true,
2023-12-09 16:25:38 +00:00
Views: engine,
})
app.Static("/", "./public")
app.Static("/assets", "./content/assets")
2023-12-09 16:25:38 +00:00
app.Get("/", routes.IndexRoute)
2024-01-18 17:01:30 +00:00
app.Get("/download", routes.DownloadRoute)
2023-12-09 16:25:38 +00:00
app.Get("/news", routes.NewsRoute)
app.Get("/news/:id", routes.PostRoute)
app.Get("/wiki", routes.WikiMainRoute)
app.Get("/wiki/:id", routes.WikiRoute)
2024-05-05 18:22:45 +00:00
app.Get("/hub", routes.ConfigsRoute)
2024-05-05 19:16:02 +00:00
app.Get("/hub/:name", routes.ConfigRoute)
2024-05-05 18:22:45 +00:00
2023-12-22 21:22:23 +00:00
app.Get("*", func(c *fiber.Ctx) error {
return lib.RenderError(c, 404)
2023-12-22 21:22:23 +00:00
})
2023-12-09 16:25:38 +00:00
2024-03-19 20:16:26 +00:00
log.Println("Starting MatterLinux Website on port 9878")
err := app.Listen(":9878")
if err != nil {
log.Fatalf("Error starting server: %s", err)
}
2023-12-09 16:25:38 +00:00
}