Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 33 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
4 changes: 3 additions & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 15 additions & 15 deletions templates/counter.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@
</form>
<br/>
<div>
<ul class="list-group list-unstyled text-wrap text-break">
<ul class="list-group list-unstyled text-wrap text-break w-75 mx-auto">
{{ range $i, $reset := .History }}
<li class = "p-4">
<div class="list-group-item p-3">
<li class = "p-2">
<div class="list-group-item p-2">
<div class="container">
<div class="row">
{{/* <div class="row">
<div class="col-12">
<h3 class="text-center my-2 fs-3">{{ $reset.Description }}</h3>
</div>
</div>

</div> */}}
<div class="row">
<div class="col">
<div class="p-2">
<span class="fs-5">{{ $reset.Description }}</span>
<br/>
<span class="days-since fw-bold display-1" data-timestamp="{{ $reset.Timestamp }}"> </span>
<br/>
<span class="description"><i>reported by: {{ $reset.Reporter }} caused by {{ $reset.Instigator }})</i></span>
</div>
<div class="col d-flex flex-column justify-content-center">
<div class="text-center my-auto">
<span class="fs-5">{{ $reset.Description }}</span>
<br/>
<span class="description"><i>reported by: {{ $reset.Reporter }}</i></span>
</div>
</div>
<div class="col">
<div class="p-2 border bg-light">Box 2</div>
<div class="text-center my-auto">
<span class="days-since fw-bold display-3" data-timestamp="{{ $reset.Timestamp }}"> </span>
<span class="description d-block">Day(s) Ago</span>
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h2 class="text-center w-100 mb-3">
<input class="form-control" type="text" placeholder= "Find Counters">
<br/>
<div>
<ul class="list-group list-unstyled text-wrap text-break">
<ul class="list-group list-unstyled text-wrap text-break w-75 mx-auto">
{{ range $i, $counter := .Counters }}
<li class="p-1">
<a class="text-center list-group-item list-group-item-action p-3" href="/counters/{{ $counter.IDHex }}">
Expand Down
Loading