website/main.go

67 lines
1.9 KiB
Go
Raw Permalink Normal View History

/*
2024-08-13 21:32:48 +00:00
* website | MatterLinux website
2024-03-19 20:16:26 +00:00
* 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-01-18 17:01:30 +00:00
"git.matterlinux.xyz/Matter/website/lib"
2024-08-13 21:32:48 +00:00
"git.matterlinux.xyz/Matter/website/log"
2024-01-18 17:01:30 +00:00
"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"
)
2024-08-13 21:32:48 +00:00
func main() {
var err error
engine := html.New("./templates", ".html")
app := fiber.New(fiber.Config{
DisableStartupMessage: true,
Views: engine,
})
app.Static("/", "./public")
app.Static("/assets", "./content/assets")
app.Get("/", routes.GET_Index)
app.Get("/download", routes.GET_Download)
app.Get("/news", routes.GET_News)
2024-08-23 11:11:48 +00:00
app.Get("/news/feed.atom", routes.GET_NewsFeed)
app.Get("/news/feed.rss", routes.GET_NewsFeed)
app.Get("/news/feed.json", routes.GET_NewsFeed)
2024-08-13 21:32:48 +00:00
app.Get("/news/:id", routes.GET_New)
app.Get("/wiki", routes.GET_Wiki)
app.Get("/wiki/:id", routes.GET_WikiPage)
app.Get("/hub", routes.GET_Configs)
app.Get("/hub/:name", routes.GET_Config)
app.Get("*", func(c *fiber.Ctx) error {
return lib.RenderError(c, 404)
})
log.Info("Starting MatterLinux website on port 9878")
if err = app.Listen(":9878"); err != nil {
log.Error("Error starting server: %s", err.Error())
}
2023-12-09 16:25:38 +00:00
}