Compare commits

23 Commits

Author SHA1 Message Date
b67eb2d778 add insta task
All checks were successful
Check / tests (push) Successful in 12m44s
2025-10-20 19:38:04 +02:00
511bfb8f73 add poster task
Some checks failed
Check / tests (push) Has been cancelled
2025-10-20 19:34:55 +02:00
b61466549e add mailbox task
All checks were successful
Check / tests (push) Successful in 10m24s
2025-04-01 00:08:09 +02:00
c5fff78c83 tasks update
All checks were successful
Check / tests (push) Successful in 10m4s
2025-01-22 13:20:21 +01:00
9cdab949f4 add Fridge task
All checks were successful
Check / tests (push) Successful in 9m41s
2025-01-06 18:21:41 +01:00
610269a142 Merge pull request 'Actions Runner test' (#1) from runner_test into master
All checks were successful
Check / tests (push) Successful in 8m49s
Reviewed-on: #1
2024-10-23 23:05:17 +02:00
886feef65a fix task::Trash descr again
All checks were successful
Check / tests (push) Successful in 8m48s
Check / tests (pull_request) Successful in 9m3s
2024-10-23 22:42:41 +02:00
e9bd8610fe fix task::Trash description
All checks were successful
Check / tests (push) Successful in 8m57s
Check / tests (pull_request) Successful in 8m55s
2024-10-23 22:19:30 +02:00
8ac550d160 add kvm support via jobset
All checks were successful
Check / tests (push) Successful in 8m53s
2024-10-23 12:47:06 +02:00
895c19269b Revert 1 commits
cd5c0f1 'try fix actions kvm error'
2024-10-23 12:20:09 +02:00
cd5c0f18ea try fix actions kvm error
Some checks failed
Check / tests (push) Failing after 4m28s
https://github.com/nix-community/nixos-generators/issues/83
2024-10-23 12:12:42 +02:00
7ebdc08457 [actions] install sudo
Some checks failed
Check / tests (push) Failing after 4m34s
2024-10-23 03:17:48 +02:00
f7bd5bd5e3 try cachix use-nix-action
Some checks failed
Check / tests (push) Failing after 2m8s
2024-10-23 03:13:28 +02:00
41c0d16428 fix runner branch
Some checks failed
checks / checks-impure (push) Failing after 7m10s
2024-10-23 02:01:47 +02:00
514437473e fix runner target 2024-10-23 01:56:43 +02:00
c6de5b4723 add check runner 2024-10-23 01:54:41 +02:00
a4a9bf571d add Plants task
renam cleanup -> closing
2024-07-15 11:14:33 +02:00
c60fc43f73 add Trash as task 2024-06-25 17:03:00 +02:00
c6ae5019dd add api call 2024-06-17 21:33:03 +02:00
b9f8fe84d9 fix dependencies 2024-06-17 17:38:19 +02:00
94314ae91e update appearance 2024-06-17 17:25:45 +02:00
2c4b6cac19 change db schema to json field 2024-06-17 17:16:15 +02:00
74e2f4e0a2 update gitignore 2023-10-05 19:12:12 +02:00
5 changed files with 151 additions and 148 deletions

View File

@@ -0,0 +1,20 @@
name: "Check"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies for Nix setup action
run: |
apt update -y
apt install sudo -y
- uses: cachix/install-nix-action@v27
- name: enable kvm support
run: |
echo "system-features = nixos-test benchmark big-parallel kvm" >> /etc/nix/nix.conf
echo "Added features to nix conf"
cat /etc/nix/nix.conf
- run: nix flake check

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
*.db *.db
result
main main

View File

@@ -14,86 +14,14 @@
body { body {
background-image: url('https://files.libcom.org/files/images/library/anarchists.jpg'); background-color: #F5F5F5;
background-repeat: no-repeat; font-family: Copperplate;
background-attachment: fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 100vh;
display: flex;
flex-direction: column;
} }
footer{ footer{
margin-top: auto; margin-top: auto;
} }
.h-divider{
margin-left: auto;
margin-right: auto;
height:1px;
width:80%;
border-top:1px solid gray;
}
@media (min-width: 768px) {
.row.equal {
display: flex;
flex-wrap: wrap;
}
}
.inherit_height
{
width:inherit;
height:100%;
}
.rgba-gradient {
background: -webkit-linear-gradient(45deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.7) 100%);
}
.rgba-gradient:hover {
background: -webkit-linear-gradient(45deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.9) 100%);
}
.card {
background-color: rgba(42, 42, 42, 0.2);
}
.md-form label {
color: #ffffff;
}
h6 {
line-height: 1.7;
}
label {
color: #000000;
}
input {
color: #000000;
}
.black-background {background-color:#ffffff;}
.white {color:#ffffff;}
.black {color:#000000;}
.about white {
color: white;
font-size: 14px;
}
.a {
text-decoration:none;
color:red;
}
</style> </style>
</head> </head>
<body> <body>
@@ -104,8 +32,8 @@ input {
<div class="container"> <div class="container">
<div class="row col-md-12"> <div class="row col-md-12">
<div class="col-12 col-md pl-5"> <div class="col-12 col-md pl-5">
<h2 class='text-light'>tasklist</h2> <h2 class='text-dark'>tasklist</h2>
<h5 class='text-light'> <h5 class='text-dark'>
enter your name to make yourself happy enter your name to make yourself happy
</h5> </h5>
</div> </div>
@@ -124,7 +52,7 @@ input {
<social class="white"> <social class="white">
<div class="form-group"> <div class="form-group">
<div class="col-md-12 pt-3"> <div class="col-md-12 pt-3">
<h2>{{.Title}}</h2> <h2>{{.Date}}</h2>
{{ if .Updated }} {{ if .Updated }}
<h3 class="text-success">Updated</h3> <h3 class="text-success">Updated</h3>
{{end}} {{end}}
@@ -136,7 +64,7 @@ input {
<div id="{{.Name}}Help" class="form-text font-italic">{{.Description}}</div> <div id="{{.Name}}Help" class="form-text font-italic">{{.Description}}</div>
</div> </div>
{{end}} {{end}}
<input type="hidden" name="Name" value="{{.Title}}"/> <input type="hidden" name="Name" value="{{.Date}}"/>
<input type="submit" class="btn btn-primary"></input> <input type="submit" class="btn btn-primary"></input>
</form> </form>
</div> </div>

2
go.mod
View File

@@ -2,4 +2,4 @@ module tasklist
go 1.20 go 1.20
require github.com/mattn/go-sqlite3 v1.14.16 // indirect require github.com/mattn/go-sqlite3 v1.14.16

192
main.go
View File

@@ -2,6 +2,7 @@ package main
import ( import (
"database/sql" "database/sql"
"encoding/json"
"flag" "flag"
"fmt" "fmt"
"html/template" "html/template"
@@ -14,46 +15,54 @@ import (
func GetDefaultTasks() []Task { func GetDefaultTasks() []Task {
return []Task{ return []Task{
{
Name: "Title",
Description: ``,
IsOptional: true,
},
{
Name: "Promotion",
Description: `
(make a post on the website to promote openings times and for each film event, posting description and announcement on telegram channel, forwarding it to telegram groups, making a fb event, making a post about fb event on the fb page, sharing the event to fb groups)
`,
IsOptional: false,
},
{ {
Name: "Opening", Name: "Opening",
Description: `(checking toilet if there is toilet paper and fresh towel, refill fridge, sorting deposit bottles, quickly tidy up the place)`, Description: `(checking toilet if there is toilet paper and fresh towel, refill fridge, sorting deposit bottles, quickly tidy up the place)`,
IsOptional: false, IsOptional: false,
}, },
{ {
Name: "Entering", Name: "Closing",
Description: `(checking if there are new books to be entered into the library catalogue, categorizing them, stamping them, putting them into the book shelf)`,
IsOptional: true,
},
{
Name: "PrepareKuefa",
Description: `(includes preparing the cutting boards and knives and all devices needed to prepare food. Including potential visitors in this action, preparing chairs, tables and benches outside of malo for people to eat and chill outside)`,
IsOptional: true,
},
{
Name: "CookingKuefa",
Description: `(choosing a dish/recipe, doing shopping or arranging somebody to do shopping, cooking, serving)`,
IsOptional: true,
},
{
Name: "CleanUp",
Description: `(includes cleaning up, tidying up, rearranging chairs, closing or arranging somebody to lock the front and back doors)`, Description: `(includes cleaning up, tidying up, rearranging chairs, closing or arranging somebody to lock the front and back doors)`,
IsOptional: false, IsOptional: false,
}, },
{ {
Name: "WeeklyToiletAndKitchen", Name: "WeeklyToilet",
Description: `(whiping the floor in kitchen and bathroom, clean toilet, clean sink, check soap and menstruation supplies)`, Description: `(whiping the floor in the bathroom, empty trash, clean toilet, clean sink, check soap and menstruation supplies)`,
IsOptional: false,
},
{
Name: "WeeklyKitchen",
Description: `(whiping the floor in kitchen, clean sink, empty trash, check surfaces)`,
IsOptional: false,
},
{
Name: "Trash",
Description: `(empty the trash and take care the boxes are not ultra disgusting)`,
IsOptional: false,
},
{
Name: "Plants",
Description: `(take care of the plants. they need water, but not too much!)`,
IsOptional: false,
},
{
Name: "Fridge",
Description: `(Check the fridges (kitchen and main room) for nasty stuff and try to remove it.)`,
IsOptional: false,
},
{
Name: "Check Mailbox",
Description: `(Go to mailbox, open it, look if there are letters inside, if yes bring them into malo)`,
IsOptional: false,
},
{
Name: "Poster Check",
Description: `(Check current Posters in the main window, make sure they look nice and are not outdated)`,
IsOptional: false,
},
{
Name: "Weekly Insta Post",
Description: `(Post something on instagram, like a newly printed zine, kuefa or whatever)`,
IsOptional: false, IsOptional: false,
}, },
} }
@@ -65,16 +74,7 @@ func InitDB(db_name string) *sql.DB {
log.Fatal(err) log.Fatal(err)
} }
sqlStmt := "create table if not exists tasklists (name test not null primary key" sqlStmt := "create table if not exists tasklists (name test not null primary key, Data text);"
// promotion text, opening text, entering text, cleanup text, weeklytoilet text);
for _, task := range GetDefaultTasks() {
sqlStmt += ", " + task.Name + " text"
}
sqlStmt += ");"
fmt.Println(sqlStmt)
_, err = db.Exec(sqlStmt) _, err = db.Exec(sqlStmt)
if err != nil { if err != nil {
log.Printf("%q: %s\n", err, sqlStmt) log.Printf("%q: %s\n", err, sqlStmt)
@@ -85,7 +85,7 @@ func InitDB(db_name string) *sql.DB {
} }
func GetTaskNameString(FillString string) string { func GetTaskNameString(FillString string) string {
result := "" result := "Data"
IsFirst := true IsFirst := true
for _, task := range GetDefaultTasks() { for _, task := range GetDefaultTasks() {
if !IsFirst { if !IsFirst {
@@ -98,30 +98,34 @@ func GetTaskNameString(FillString string) string {
return result return result
} }
func CreateTasklist(title string, db *sql.DB) Tasklist { func CreateTasklist(date string, db *sql.DB) Tasklist {
tasks := GetDefaultTasks() stmt, err := db.Prepare("select " + "Data" + " from tasklists where name = ?")
stmt, err := db.Prepare("select " + GetTaskNameString(", ") + " from tasklists where name = ?")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
defer stmt.Close()
var eventtitle, promotion, opening, entering, preparekuefa, cookkuefa, cleanup, weeklytoilet string
err = stmt.QueryRow(title).Scan(&eventtitle, &promotion, &opening, &entering, &preparekuefa, &cookkuefa, &cleanup, &weeklytoilet)
if err == nil { defer stmt.Close()
tasks[0].Value = eventtitle
tasks[1].Value = promotion var data string
tasks[2].Value = opening err = stmt.QueryRow(date).Scan(&data)
tasks[3].Value = entering
tasks[4].Value = preparekuefa tasks := GetDefaultTasks()
tasks[5].Value = cookkuefa if err != nil {
tasks[6].Value = cleanup if err != sql.ErrNoRows {
tasks[7].Value = weeklytoilet fmt.Printf("Error in CreateTasklist during QueryRow, Date %s\n", date)
fmt.Println(err)
}
} else {
tasks = TasksFromJson(data)
if tasks == nil {
fmt.Println("Error in CreateTasklist")
fmt.Println(err)
}
} }
return Tasklist{ return Tasklist{
Title: title, Date: date,
Tasks: tasks, Tasks: tasks,
Updated: false, Updated: false,
} }
@@ -129,19 +133,27 @@ func CreateTasklist(title string, db *sql.DB) Tasklist {
func InsertToDB(tasklist Tasklist, db *sql.DB) { func InsertToDB(tasklist Tasklist, db *sql.DB) {
stmt, err := db.Prepare("select name from tasklists where name = ?") stmt, err := db.Prepare("select name from tasklists where name = ?")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
defer stmt.Close() defer stmt.Close()
var name string var name string
err = stmt.QueryRow(tasklist.Title).Scan(&name) err = stmt.QueryRow(tasklist.Date).Scan(&name)
if err != nil { if err != nil {
db.Exec("insert into tasklists(name, "+GetTaskNameString(", ")+") values(?, ?, ?, ?, ?, ?, ?, ?, ?)", tasklist.Title, tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value, tasklist.Tasks[7].Value) _, err := db.Exec("insert into tasklists(name, "+"Data"+") values(?, ?)", tasklist.Date, TasksToJson(tasklist.Tasks))
if err != nil { if err != nil {
fmt.Println("Error during insert: ", err) fmt.Println("Error during insert: ", err)
} }
} else { } else {
_, err := db.Exec("update tasklists set "+GetTaskNameString(" = ?,")+" = ? where name = ?", tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value, tasklist.Tasks[7].Value, tasklist.Title) _, err := db.Exec("update tasklists set "+"Data"+" = ? where name = ?", TasksToJson(tasklist.Tasks), tasklist.Date)
fmt.Println(TasksToJson(tasklist.Tasks))
if err != nil { if err != nil {
fmt.Println("Error during update: ", err) fmt.Println("Error during update: ", err)
} }
@@ -149,18 +161,43 @@ func InsertToDB(tasklist Tasklist, db *sql.DB) {
} }
type Task struct { type Task struct {
Name string Name string `json:"Name"`
Description string Description string `json:"Description"`
Value string Value string `json:"Value"`
IsOptional bool IsOptional bool `json:"IsOptional"`
} }
type Tasklist struct { type Tasklist struct {
Title string Date string
Tasks []Task Tasks []Task
Updated bool Updated bool
} }
func TasksFromJson(tasks string) []Task {
var result []Task
err := json.Unmarshal([]byte(tasks), &result)
if err != nil {
fmt.Println("Error during TasksFromJson")
fmt.Println(err)
return nil
}
return result
}
func TasksToJson(tasks []Task) string {
result, err := json.Marshal(tasks)
if err != nil {
fmt.Println("Error during TasksToJson")
fmt.Println(err)
return ""
}
return string(result)
}
type Tasklists struct { type Tasklists struct {
Tasklists []Tasklist Tasklists []Tasklist
} }
@@ -170,7 +207,7 @@ type QueryResult struct {
} }
func (n *Tasklist) Print() { func (n *Tasklist) Print() {
fmt.Println(n.Title) fmt.Println(n.Date)
for _, task := range n.Tasks { for _, task := range n.Tasks {
fmt.Println("\t Name: ", task.Name) fmt.Println("\t Name: ", task.Name)
@@ -194,7 +231,7 @@ func GetNextNDaysOfName(n int, name time.Weekday, current time.Time) []time.Time
return result return result
} }
const DB_NAME = "./tasklist.db" const DB_NAME = "./tasklistJson.db"
const FORMS_NAME = "./forms.html" const FORMS_NAME = "./forms.html"
const TASK_DAY = time.Tuesday const TASK_DAY = time.Tuesday
const AMOUNT_DAYS = 4 const AMOUNT_DAYS = 4
@@ -213,6 +250,18 @@ func main() {
} }
tmpl := template.Must(template.ParseFiles(*formsName)) tmpl := template.Must(template.ParseFiles(*formsName))
http.HandleFunc("/api/next", func(w http.ResponseWriter, r *http.Request) {
days := GetNextNDaysOfName(1, TASK_DAY, time.Now())
tasklist_arr := QueryResult{make([]Tasklist, 1)}
for idx, day := range days {
tasklist_arr.Tasklists[idx] = CreateTasklist(day.Format("Jan 2, 2006"), db)
}
fmt.Fprintf(w, TasksToJson(tasklist_arr.Tasklists[0].Tasks))
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
days := GetNextNDaysOfName(AMOUNT_DAYS, TASK_DAY, time.Now()) days := GetNextNDaysOfName(AMOUNT_DAYS, TASK_DAY, time.Now())
tasklist_arr := QueryResult{make([]Tasklist, AMOUNT_DAYS)} tasklist_arr := QueryResult{make([]Tasklist, AMOUNT_DAYS)}
@@ -227,7 +276,7 @@ func main() {
} }
for idx, task := range tasklist_arr.Tasklists { for idx, task := range tasklist_arr.Tasklists {
if task.Title == r.FormValue("Name") { if task.Date == r.FormValue("Name") {
for idx2 := range task.Tasks { for idx2 := range task.Tasks {
task.Tasks[idx2].Value = r.FormValue(task.Tasks[idx2].Name) task.Tasks[idx2].Value = r.FormValue(task.Tasks[idx2].Name)
} }
@@ -236,9 +285,14 @@ func main() {
} }
} }
tmpl.Execute(w, tasklist_arr) err := tmpl.Execute(w, tasklist_arr)
if err != nil {
fmt.Println("Error during tmpl.Execute")
fmt.Println(err)
}
}) })
fmt.Println("Start listening on port 8080")
http.ListenAndServe(":8080", nil) http.ListenAndServe(":8080", nil)
} }