diff --git a/README.md b/README.md index ac5b9c2..48fa055 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,40 @@ -# counters -Days Since Last Useless House Service was Mode: 0 -```mermaid -erDiagram - - RESET { - string username - string description - time timestamp - } - COUNTER { - string id - string createdBy - string title - string description - RESET lastReset - list[RESET] history - } +# Counters ![Static Badge](https://img.shields.io/badge/weather-%23b16ded?style=flat&logo=github&logoColor=black&labelColor=0%2C0%2C0&link=https%3A%2F%2Fgithub.com%2FweatherGod3218%2F) +## Day's Since Last Useless House Service was Made: 0 -``` +A simple interface for logging and displaying time since a certain event has occured, allowing for CSHer's to track how long its been since a prior event. Heavily inspired off the "Days since last..." meme format. + +This project uses Golang, [Gin](https://fastapi.tiangolo.com/), HTML/CSS, and Javascript. -__TODO__ +This project ALSO uses a modified version of bootstrap 5! Check it out [here!](https://github.com/ComputerScienceHouse/csh-material-bootstrap/tree/bootstrap-5) -[] Load History +## Installing +1. Clone and cd into the repo: git clone https://github.com/WeatherGod3218/counters +>> (OPTIONAL): Make another branch if your working on a large thing! -[] Allow adding a reset +## Setup +1. Make sure you have docker installed +>> (OPTIONAL): You can use docker compose as well!! +2. Copy the .env.template file, rename it to .env and place it in the root folder +3. Ask an RTP for counters secrets, add them to the .env accordingly -[] Implement csh-auth +## Run -[] Make Sections Smaller in Width +Counters is containerized through a docker file. +1. Build the docker file +``` + docker build -t Counters . +``` +2. Run the newly built docker on port 8000 +``` + docker run -p 8080:80 Counters +``` + +## Docker Compose + +Counters also has support for Docker Compose, a extended version of docker that simplifies the steps. + +(This is a really cool thing! If you use docker often, check it out!) +``` + docker compose up +``` diff --git a/api.go b/api.go index 64f6a81..cb23620 100644 --- a/api.go +++ b/api.go @@ -61,7 +61,7 @@ func GetResetPage(c *gin.Context) { }) } -func GetCounterId(c *gin.Context) { +func LoadCounter(c *gin.Context) { idToUse := c.Param("id") counter, cError := database.GetCounterFromId(c, idToUse) @@ -89,6 +89,7 @@ func ResetCounter(c *gin.Context) { resetTime := translateTime(c.PostForm("reset-time")) reset := &database.Reset{ + Id: bson.NewObjectID(), Reporter: tempName, Instigator: c.PostForm("reset-user"), Description: c.PostForm("reset-description"), @@ -109,6 +110,7 @@ func CreateCounter(c *gin.Context) { resetTime := translateTime(c.PostForm("reset-time")) reset := &database.Reset{ + Id: bson.NewObjectID(), Reporter: tempName, Instigator: c.PostForm("reset-user"), Description: c.PostForm("reset-description"), diff --git a/main.go b/main.go index b687b89..03f8cd6 100644 --- a/main.go +++ b/main.go @@ -42,7 +42,7 @@ func main() { router.Use(auth.CookieMiddleware()) router.GET("/", GetHomePage) - router.GET("counters/:id", GetCounterId) + router.GET("counters/:id", LoadCounter) router.GET("/create", GetCreatePage) router.POST("/create", CreateCounter) diff --git a/templates/counter.tmpl b/templates/counter.tmpl index 74ce1ae..6a2fc03 100644 --- a/templates/counter.tmpl +++ b/templates/counter.tmpl @@ -11,29 +11,29 @@
-