Author: Adam Evyčędo <git@apiote.xyz>
fixes and initial style
.gitignore | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 roadmap.go | 107 +++++++++++++++++++++++++++++++++++++++------- task.html | 26 ----------- templates/task.html | 50 +++++++++++++++++++++
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..7d53220418a862b306cf06ab8f9b1aa4d771e983 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +roadmap diff --git a/bimba/0.ogdl b/bimba/0.ogdl deleted file mode 100644 index 8551cfb1a98a59a0d46e647fd36e07a10fa7a195..0000000000000000000000000000000000000000 --- a/bimba/0.ogdl +++ /dev/null @@ -1,7 +0,0 @@ -"improve presenting looping lines" - description "looping or one-direction lines in LineActivity have wierd artifacts" - priority 5 - status todo - tags - ui - ext-lib diff --git a/bimba/1.ogdl b/bimba/1.ogdl deleted file mode 100644 index d681595979161e6907948b5b4dd08211ad4a5de4..0000000000000000000000000000000000000000 --- a/bimba/1.ogdl +++ /dev/null @@ -1,7 +0,0 @@ -"scale markers with map" - description "currently, markers on map are scaled on refresh. They should be scaled with map scaling" - priority 10 - status todo - tags - ui - ext-lib diff --git a/bimba/10/0.ogdl b/bimba/10/0.ogdl deleted file mode 100644 index 56ee03569488c3b68e9fcebfaaab976f328ee881..0000000000000000000000000000000000000000 --- a/bimba/10/0.ogdl +++ /dev/null @@ -1,4 +0,0 @@ -"show geocoded places" - description "use e.g. Nominatim but also offline geocoding to search places on the map" - priority 0 - status todo diff --git a/bimba/10.ogdl b/bimba/10.ogdl deleted file mode 100644 index 6a44bc9c89e41525f0ce2c302dcbcd20097c8dc2..0000000000000000000000000000000000000000 --- a/bimba/10.ogdl +++ /dev/null @@ -1,6 +0,0 @@ -"improve map" - description "improve usability, moving and finding on the map" - priority 4 - status todo - tags - usability diff --git a/bimba/2.ogdl b/bimba/2.ogdl deleted file mode 100644 index c95462902f1c91a62653b05f68ff3b0daec7e737..0000000000000000000000000000000000000000 --- a/bimba/2.ogdl +++ /dev/null @@ -1,9 +0,0 @@ -"order requests" - description "requests to TRAFFIC server should contain a token that would be return with a response. Responses could be ordered and earlier responses could be dismissed if newer has already come. Such tokens could also be used for request tracing in logs" - priority 2 - status todo - milestone D+ - tags - traffic - usability - monitoring diff --git a/bimba/3/0.ogdl b/bimba/3/0.ogdl deleted file mode 100644 index a3ff71dd123125ab8f5fb804c0fad236d4eda441..0000000000000000000000000000000000000000 --- a/bimba/3/0.ogdl +++ /dev/null @@ -1,6 +0,0 @@ -"read caching info from headers" - description "read `Cache-Control` and `ETag` headers, and send `If-None-Match`" - priority 0 - status todo - tags - api diff --git a/bimba/3/1.ogdl b/bimba/3/1.ogdl deleted file mode 100644 index e2ed9ea7395cf039f0e65e4f7beaccfc1c95798a..0000000000000000000000000000000000000000 --- a/bimba/3/1.ogdl +++ /dev/null @@ -1,7 +0,0 @@ -"store cache" - description "store responses in cache" - priority 1 - status todo - tags - storage - cache diff --git a/bimba/3/2.ogdl b/bimba/3/2.ogdl deleted file mode 100644 index c8d401a1c5571d832453b3d314ddb37cde7e54df..0000000000000000000000000000000000000000 --- a/bimba/3/2.ogdl +++ /dev/null @@ -1,6 +0,0 @@ -"use cache in front" - description "show cached responses and adapt progress bar" - priority 3 - status todo - tags - front diff --git a/bimba/3.ogdl b/bimba/3.ogdl deleted file mode 100644 index 0b7fd933b2fef167ae0aa27d769bedb691eda1d6..0000000000000000000000000000000000000000 --- a/bimba/3.ogdl +++ /dev/null @@ -1,9 +0,0 @@ -"improve caching" - description "RT responses from providers and responses from server to clients should be cached and cacheable" - priority 2 - status todo - milestone D+ - tags - traffic - usability - performance diff --git a/bimba/4/0.ogdl b/bimba/4/0.ogdl deleted file mode 100644 index 8e8ff632feb4edc822942a4df64fa56e5f7080ef..0000000000000000000000000000000000000000 --- a/bimba/4/0.ogdl +++ /dev/null @@ -1,5 +0,0 @@ -"read timetable from storage" - priority 0 - status todo - tags - storage diff --git a/bimba/4/1.ogdl b/bimba/4/1.ogdl deleted file mode 100644 index 63952ff40db23953048b22e16392e38c870c65a3..0000000000000000000000000000000000000000 --- a/bimba/4/1.ogdl +++ /dev/null @@ -1,5 +0,0 @@ -"implement offline responses" - priority 1 - status todo - tags - api diff --git a/bimba/4/2.ogdl b/bimba/4/2.ogdl deleted file mode 100644 index c110573e81dd220193157efdfaa9a01eb8b8b6df..0000000000000000000000000000000000000000 --- a/bimba/4/2.ogdl +++ /dev/null @@ -1,7 +0,0 @@ -"autoupdate offline timetable" - description "add setting to feed chooser and autoupdate timetable" - priority 2 - status todo - tags - settings - feeds diff --git a/bimba/4.ogdl b/bimba/4.ogdl deleted file mode 100644 index 5d1813fd9688a826b75826f38a2b3caa1099c6d7..0000000000000000000000000000000000000000 --- a/bimba/4.ogdl +++ /dev/null @@ -1,7 +0,0 @@ -"add offline timetable support" - description "download timetable and use it offline" - priority 5 - status todo - tags - traffic - offline diff --git a/bimba/5/0.ogdl b/bimba/5/0.ogdl deleted file mode 100644 index 65f70d01aa41698dff2736d558c82727d9dcb9a3..0000000000000000000000000000000000000000 --- a/bimba/5/0.ogdl +++ /dev/null @@ -1,4 +0,0 @@ -"favourite stops" - description "save and show easily stop favourites" - priority 0 - status done diff --git a/bimba/5/1.ogdl b/bimba/5/1.ogdl deleted file mode 100644 index 0cc4dc4aed77af453e9943395874c0b07fd6fe19..0000000000000000000000000000000000000000 --- a/bimba/5/1.ogdl +++ /dev/null @@ -1,4 +0,0 @@ -"join favourite stops" - description "edit, join, separate stop favourites" - priority 0 - status todo diff --git a/bimba/5/2.ogdl b/bimba/5/2.ogdl deleted file mode 100644 index 1df4d57b540bbb7d56ebb0bd6c444ab111d5d1cb..0000000000000000000000000000000000000000 --- a/bimba/5/2.ogdl +++ /dev/null @@ -1,4 +0,0 @@ -"favourite lines" - description "save favourite lines" - priority 0 - status todo diff --git a/bimba/5/3.ogdl b/bimba/5/3.ogdl deleted file mode 100644 index ad1d2762f1756c3950966a4136f20e9c69dca622..0000000000000000000000000000000000000000 --- a/bimba/5/3.ogdl +++ /dev/null @@ -1,4 +0,0 @@ -"show favourite lines" - description "add some screen where one could select favourite lines" - priority 1 - status todo diff --git a/bimba/5/4.ogdl b/bimba/5/4.ogdl deleted file mode 100644 index 186630ec2449796263cd653bc871c7bbe3d6ad13..0000000000000000000000000000000000000000 --- a/bimba/5/4.ogdl +++ /dev/null @@ -1,4 +0,0 @@ -"show favourite lines in change options" - description "favourite lines in change options should be more visible" - priority 3 - status todo diff --git a/bimba/5/5.ogdl b/bimba/5/5.ogdl deleted file mode 100644 index a5b0204e8b78300ac36285edf93a335517ce4c3d..0000000000000000000000000000000000000000 --- a/bimba/5/5.ogdl +++ /dev/null @@ -1,4 +0,0 @@ -"implement search history" - description "save and show search history and most-searched" - priority 0 - status todo diff --git a/bimba/5/6.ogdl b/bimba/5/6.ogdl deleted file mode 100644 index 61a4d49010265142fa8652e62736c81851c44fa1..0000000000000000000000000000000000000000 --- a/bimba/5/6.ogdl +++ /dev/null @@ -1,4 +0,0 @@ -"save favourites in account" - description "use ampelmännchen to save and sync favourites" - priority 10 - status todo diff --git a/bimba/5.ogdl b/bimba/5.ogdl deleted file mode 100644 index c27877a3b094635b5a4955f3af8213d734d96190..0000000000000000000000000000000000000000 --- a/bimba/5.ogdl +++ /dev/null @@ -1,7 +0,0 @@ -"add favourites" - description "show favourite things easily" - priority 6 - status todo - tags - usability - feature diff --git a/bimba/6.ogdl b/bimba/6.ogdl deleted file mode 100644 index 6619ab5ee3572813072bf3479adf236971980576..0000000000000000000000000000000000000000 --- a/bimba/6.ogdl +++ /dev/null @@ -1,8 +0,0 @@ -"show shapes on map" - description "show shape when selecting a vehicle, show shape from search line" - priority 10 - milestone E - status todo - tags - map - shapes diff --git a/bimba/7.ogdl b/bimba/7.ogdl deleted file mode 100644 index e502651dfa285e5d88d94168b81cb502575d1b19..0000000000000000000000000000000000000000 --- a/bimba/7.ogdl +++ /dev/null @@ -1,8 +0,0 @@ -"show trip times from stop" - description "show trip time from selected stop to following ones" - priority 10 - milestone E - status todo - tags - departure - trip diff --git a/bimba/8.ogdl b/bimba/8.ogdl deleted file mode 100644 index a4c37785b99130253acc60b9ee13d8c97cf30829..0000000000000000000000000000000000000000 --- a/bimba/8.ogdl +++ /dev/null @@ -1,7 +0,0 @@ -"show inexact times" - description "indicate if departure and arrival is inexact (stop_times/timepoint == 1 in GTFS)" - priority 10 - milestone E - status todo - tags - departure diff --git a/bimba/9.ogdl b/bimba/9.ogdl deleted file mode 100644 index 3e06c5eab3e18ab364ed7a5cab045a79dad4453b..0000000000000000000000000000000000000000 --- a/bimba/9.ogdl +++ /dev/null @@ -1,6 +0,0 @@ -"separate departure and arrival time" - description "show separate arrival and departure time. Currently for Transitous, later for TRAFFIC. Both or one may be present in single event" - priority 2 - status todo - tags - departure diff --git a/bimba.ogdl b/bimba.ogdl deleted file mode 100644 index dd111e830467ce52dfc18974350279d02ad9b1bb..0000000000000000000000000000000000000000 --- a/bimba.ogdl +++ /dev/null @@ -1,7 +0,0 @@ -Bimba - description "Bimba Android app" - statuses - todo - doing - testing - done diff --git a/projects/bimba/0.ogdl b/projects/bimba/0.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..8551cfb1a98a59a0d46e647fd36e07a10fa7a195 --- /dev/null +++ b/projects/bimba/0.ogdl @@ -0,0 +1,7 @@ +"improve presenting looping lines" + description "looping or one-direction lines in LineActivity have wierd artifacts" + priority 5 + status todo + tags + ui + ext-lib diff --git a/projects/bimba/1.ogdl b/projects/bimba/1.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..d681595979161e6907948b5b4dd08211ad4a5de4 --- /dev/null +++ b/projects/bimba/1.ogdl @@ -0,0 +1,7 @@ +"scale markers with map" + description "currently, markers on map are scaled on refresh. They should be scaled with map scaling" + priority 10 + status todo + tags + ui + ext-lib diff --git a/projects/bimba/10/0.ogdl b/projects/bimba/10/0.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..56ee03569488c3b68e9fcebfaaab976f328ee881 --- /dev/null +++ b/projects/bimba/10/0.ogdl @@ -0,0 +1,4 @@ +"show geocoded places" + description "use e.g. Nominatim but also offline geocoding to search places on the map" + priority 0 + status todo diff --git a/projects/bimba/10.ogdl b/projects/bimba/10.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..6a44bc9c89e41525f0ce2c302dcbcd20097c8dc2 --- /dev/null +++ b/projects/bimba/10.ogdl @@ -0,0 +1,6 @@ +"improve map" + description "improve usability, moving and finding on the map" + priority 4 + status todo + tags + usability diff --git a/projects/bimba/2.ogdl b/projects/bimba/2.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..c95462902f1c91a62653b05f68ff3b0daec7e737 --- /dev/null +++ b/projects/bimba/2.ogdl @@ -0,0 +1,9 @@ +"order requests" + description "requests to TRAFFIC server should contain a token that would be return with a response. Responses could be ordered and earlier responses could be dismissed if newer has already come. Such tokens could also be used for request tracing in logs" + priority 2 + status todo + milestone D+ + tags + traffic + usability + monitoring diff --git a/projects/bimba/3/0.ogdl b/projects/bimba/3/0.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..a3ff71dd123125ab8f5fb804c0fad236d4eda441 --- /dev/null +++ b/projects/bimba/3/0.ogdl @@ -0,0 +1,6 @@ +"read caching info from headers" + description "read `Cache-Control` and `ETag` headers, and send `If-None-Match`" + priority 0 + status todo + tags + api diff --git a/projects/bimba/3/1.ogdl b/projects/bimba/3/1.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..e2ed9ea7395cf039f0e65e4f7beaccfc1c95798a --- /dev/null +++ b/projects/bimba/3/1.ogdl @@ -0,0 +1,7 @@ +"store cache" + description "store responses in cache" + priority 1 + status todo + tags + storage + cache diff --git a/projects/bimba/3/2.ogdl b/projects/bimba/3/2.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..c8d401a1c5571d832453b3d314ddb37cde7e54df --- /dev/null +++ b/projects/bimba/3/2.ogdl @@ -0,0 +1,6 @@ +"use cache in front" + description "show cached responses and adapt progress bar" + priority 3 + status todo + tags + front diff --git a/projects/bimba/3.ogdl b/projects/bimba/3.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..0b7fd933b2fef167ae0aa27d769bedb691eda1d6 --- /dev/null +++ b/projects/bimba/3.ogdl @@ -0,0 +1,9 @@ +"improve caching" + description "RT responses from providers and responses from server to clients should be cached and cacheable" + priority 2 + status todo + milestone D+ + tags + traffic + usability + performance diff --git a/projects/bimba/4/0.ogdl b/projects/bimba/4/0.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..8e8ff632feb4edc822942a4df64fa56e5f7080ef --- /dev/null +++ b/projects/bimba/4/0.ogdl @@ -0,0 +1,5 @@ +"read timetable from storage" + priority 0 + status todo + tags + storage diff --git a/projects/bimba/4/1.ogdl b/projects/bimba/4/1.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..63952ff40db23953048b22e16392e38c870c65a3 --- /dev/null +++ b/projects/bimba/4/1.ogdl @@ -0,0 +1,5 @@ +"implement offline responses" + priority 1 + status todo + tags + api diff --git a/projects/bimba/4/2.ogdl b/projects/bimba/4/2.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..c110573e81dd220193157efdfaa9a01eb8b8b6df --- /dev/null +++ b/projects/bimba/4/2.ogdl @@ -0,0 +1,7 @@ +"autoupdate offline timetable" + description "add setting to feed chooser and autoupdate timetable" + priority 2 + status todo + tags + settings + feeds diff --git a/projects/bimba/4.ogdl b/projects/bimba/4.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..5d1813fd9688a826b75826f38a2b3caa1099c6d7 --- /dev/null +++ b/projects/bimba/4.ogdl @@ -0,0 +1,7 @@ +"add offline timetable support" + description "download timetable and use it offline" + priority 5 + status todo + tags + traffic + offline diff --git a/projects/bimba/5/0.ogdl b/projects/bimba/5/0.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..65f70d01aa41698dff2736d558c82727d9dcb9a3 --- /dev/null +++ b/projects/bimba/5/0.ogdl @@ -0,0 +1,4 @@ +"favourite stops" + description "save and show easily stop favourites" + priority 0 + status done diff --git a/projects/bimba/5/1.ogdl b/projects/bimba/5/1.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..0cc4dc4aed77af453e9943395874c0b07fd6fe19 --- /dev/null +++ b/projects/bimba/5/1.ogdl @@ -0,0 +1,4 @@ +"join favourite stops" + description "edit, join, separate stop favourites" + priority 0 + status todo diff --git a/projects/bimba/5/2.ogdl b/projects/bimba/5/2.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..1df4d57b540bbb7d56ebb0bd6c444ab111d5d1cb --- /dev/null +++ b/projects/bimba/5/2.ogdl @@ -0,0 +1,4 @@ +"favourite lines" + description "save favourite lines" + priority 0 + status todo diff --git a/projects/bimba/5/3.ogdl b/projects/bimba/5/3.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..ad1d2762f1756c3950966a4136f20e9c69dca622 --- /dev/null +++ b/projects/bimba/5/3.ogdl @@ -0,0 +1,4 @@ +"show favourite lines" + description "add some screen where one could select favourite lines" + priority 1 + status todo diff --git a/projects/bimba/5/4.ogdl b/projects/bimba/5/4.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..186630ec2449796263cd653bc871c7bbe3d6ad13 --- /dev/null +++ b/projects/bimba/5/4.ogdl @@ -0,0 +1,4 @@ +"show favourite lines in change options" + description "favourite lines in change options should be more visible" + priority 3 + status todo diff --git a/projects/bimba/5/5.ogdl b/projects/bimba/5/5.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..a5b0204e8b78300ac36285edf93a335517ce4c3d --- /dev/null +++ b/projects/bimba/5/5.ogdl @@ -0,0 +1,4 @@ +"implement search history" + description "save and show search history and most-searched" + priority 0 + status todo diff --git a/projects/bimba/5/6.ogdl b/projects/bimba/5/6.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..61a4d49010265142fa8652e62736c81851c44fa1 --- /dev/null +++ b/projects/bimba/5/6.ogdl @@ -0,0 +1,4 @@ +"save favourites in account" + description "use ampelmännchen to save and sync favourites" + priority 10 + status todo diff --git a/projects/bimba/5.ogdl b/projects/bimba/5.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..c27877a3b094635b5a4955f3af8213d734d96190 --- /dev/null +++ b/projects/bimba/5.ogdl @@ -0,0 +1,7 @@ +"add favourites" + description "show favourite things easily" + priority 6 + status todo + tags + usability + feature diff --git a/projects/bimba/6.ogdl b/projects/bimba/6.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..6619ab5ee3572813072bf3479adf236971980576 --- /dev/null +++ b/projects/bimba/6.ogdl @@ -0,0 +1,8 @@ +"show shapes on map" + description "show shape when selecting a vehicle, show shape from search line" + priority 10 + milestone E + status todo + tags + map + shapes diff --git a/projects/bimba/7.ogdl b/projects/bimba/7.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..e502651dfa285e5d88d94168b81cb502575d1b19 --- /dev/null +++ b/projects/bimba/7.ogdl @@ -0,0 +1,8 @@ +"show trip times from stop" + description "show trip time from selected stop to following ones" + priority 10 + milestone E + status todo + tags + departure + trip diff --git a/projects/bimba/8.ogdl b/projects/bimba/8.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..a4c37785b99130253acc60b9ee13d8c97cf30829 --- /dev/null +++ b/projects/bimba/8.ogdl @@ -0,0 +1,7 @@ +"show inexact times" + description "indicate if departure and arrival is inexact (stop_times/timepoint == 1 in GTFS)" + priority 10 + milestone E + status todo + tags + departure diff --git a/projects/bimba/9.ogdl b/projects/bimba/9.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..3e06c5eab3e18ab364ed7a5cab045a79dad4453b --- /dev/null +++ b/projects/bimba/9.ogdl @@ -0,0 +1,6 @@ +"separate departure and arrival time" + description "show separate arrival and departure time. Currently for Transitous, later for TRAFFIC. Both or one may be present in single event" + priority 2 + status todo + tags + departure diff --git a/projects/bimba.ogdl b/projects/bimba.ogdl new file mode 100644 index 0000000000000000000000000000000000000000..dd111e830467ce52dfc18974350279d02ad9b1bb --- /dev/null +++ b/projects/bimba.ogdl @@ -0,0 +1,7 @@ +Bimba + description "Bimba Android app" + statuses + todo + doing + testing + done diff --git a/roadmap.go b/roadmap.go index a353f2c59d4eefc016f8a1705fa29dca4d428b6c..67654bcadeb1cf8027447a521707887fd95e8ebe 100644 --- a/roadmap.go +++ b/roadmap.go @@ -1,24 +1,43 @@ package main import ( + "embed" "errors" "fmt" - "html" + "html/template" "io/fs" "log" "net/http" "os" "path/filepath" + "slices" "strings" "github.com/rveen/ogdl" ) + +//go:embed templates +var templatesFs embed.FS type Task struct { - Path string - Summary string + Path string + Summary string + Status string + Assignee string + Tags string + Statuses []string + Description string + Priority int64 + Milestone string + + Subtasks map[string][]Task +} - Subtasks []Task +func (t Task) SubtasksMap(status string) []Task { + slices.SortFunc(t.Subtasks[status], func(a, b Task) int { + return int(a.Priority) - int(b.Priority) + }) + return t.Subtasks[status] } func main() { @@ -35,31 +54,46 @@ router(base) } func router(base string) { + http.HandleFunc("/favicon.ico", func(rw http.ResponseWriter, r *http.Request) { + rw.WriteHeader(404) + }) http.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) { - body := renderTasks(base, filepath.Clean(r.URL.Path)) - rw.Write([]byte(body)) + status := renderTasks(base, filepath.Clean(r.URL.Path), rw) + if status != 200 { + rw.WriteHeader(status) + } }) http.ListenAndServe(":8080", nil) } -func renderTasks(base, path string) string { +func renderTasks(base, path string, rw http.ResponseWriter) int { if path == "/" { t, err := root(base) if err != nil { log.Printf("while getting task %s: %v", path, err) - return "" // TODO render error + return 500 // TODO get status from error + } + tmpl, err := template.ParseFS(templatesFs, "templates/root.html") // TODO create template + if err != nil { + log.Printf("while parsing template: %v", err) + return 500 } - log.Println(t) - return "" // TODO render task + tmpl.Execute(rw, t) + return 200 } else { t, err := task(base, path) if err != nil { log.Printf("while getting task %s: %v", path, err) - return "" // TODO render error + return 500 // TODO get status from error + } + tmpl, err := template.ParseFS(templatesFs, "templates/task.html") + if err != nil { + log.Printf("while parsing template: %v", err) + return 500 } - fmt.Println(t) - return "" // TODO render task + tmpl.Execute(rw, t) + return 200 } } @@ -84,10 +118,27 @@ return tasks, nil } func task(base, path string) (Task, error) { + middleTasks := strings.Split(path, "/")[1:] + middleTasks = middleTasks[:len(middleTasks)-1] + statuses := []string{} + middlePath := "" + for _, name := range middleTasks { + middlePath = middlePath + "/" + name + t, err := readTask(base, middlePath+".ogdl") + if err != nil { + return Task{}, fmt.Errorf("while reading middle task %s: %v", path, err) + } + if len(t.Statuses) > 0 { + statuses = t.Statuses + } + } task, err := readTask(base, path+".ogdl") if err != nil { return Task{}, fmt.Errorf("while reading task %s: %v", path, err) } + if len(task.Statuses) == 0 { + task.Statuses = statuses + } dirEntries, err := os.ReadDir(filepath.Join(base, path)) if err != nil { if errors.Is(err, fs.ErrNotExist) { @@ -95,13 +146,16 @@ return task, nil } return Task{}, fmt.Errorf("while reading dir: %v", err) } + task.Subtasks = map[string][]Task{} for _, dirEntry := range dirEntries { if !dirEntry.IsDir() { subtask, err := readTask(base, filepath.Join(path, dirEntry.Name())) if err != nil { return Task{}, fmt.Errorf("while reading subtask %s: %v", path, err) } - task.Subtasks = append(task.Subtasks, subtask) + subtasks := task.Subtasks[subtask.Status] + subtasks = append(subtasks, subtask) + task.Subtasks[subtask.Status] = subtasks } } return task, nil @@ -112,8 +166,29 @@ g := ogdl.FromFile(filepath.Join(base, path)) if g == nil { return Task{}, fmt.Errorf("no such task: %s", path) } + summary := g.String() + g = g.Out[0] + tags := strings.Join(getArray(g.Get("tags")), ", ") return Task{ - Path: strings.ReplaceAll(path, ".ogdl", ""), - Summary: g.String(), + Path: strings.ReplaceAll(path, ".ogdl", ""), + Summary: summary, + Status: g.Get("status").String(), + Statuses: getArray(g.Get("statuses")), // TODO inherit + Assignee: g.Get("assignee").String(), + Description: g.Get("description").String(), + Tags: tags, + Priority: g.Get("priority").Int64(), + Milestone: g.Get("milestone").String(), }, nil } + +func getArray(g *ogdl.Graph) []string { + if g.Len() < 1 { + return []string{} + } + array := make([]string, g.Len()) + for i, o := range g.Out { + array[i] = o.ThisString() + } + return array +} diff --git a/task.html b/task.html deleted file mode 100644 index e96ae0d0422a9aa7828da615ace7cbe2fe966cb7..0000000000000000000000000000000000000000 --- a/task.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Roadmap {.Path}</title> - </head> - <body> - <nav>{{ .Path }}</path> - <h1>{{ .Summary }}</h1> - <p>{{ .Status }}</p> <!-- assignee --> - <p>#{{ .Tags }}</p> - <p>{{ .Description }}</p> - <hr/> - <div> <!-- flex --> - {{ range .Statuses }} - <div> <!-- inline --> - <div>{{ . }}</div> - {{ range .Subtasks.{{.}} }} <!-- func ret: map[status][]Task, tasks sorted by priority --> - <div> - <a href="{{ .Path }}">{{ .Path }}</a> - <p>{{ .Summary }}</p> - <!-- what else: tags, assignee --> - </div> - </div> - </div> - </body> -</html> diff --git a/templates/task.html b/templates/task.html new file mode 100644 index 0000000000000000000000000000000000000000..4da597eebd315e7f69c3b56b9147850441ded63c --- /dev/null +++ b/templates/task.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<html> + <head> + <title>Roadmap {{ .Path }}</title> + <style> + body { + margin: 1rem; + } + #subtasks { + display: flex; + justify-content: space-between; + } + .subtaskHeader { + } + .subtask { + border: solid 2px; + margin-top: 1rem; + padding: .5rem; + } + </style> + </head> + <body> + <nav>{{ .Path }}</nav> + <h1>{{ .Summary }}</h1> + <p>{{ .Status }}</p> + {{ if .Assignee }}<p>assigned to {{ .Assignee }}</p>{{ end }} + {{ if .Milestone }}<p>milestone: {{ .Milestone }}</p>{{ end }} + {{ if .Tags }}<p>#{{ .Tags }}</p>{{ end }} + <p>{{ .Description }}</p> + {{ if .Subtasks }} + <hr/> + <div id="subtasks"> + {{ range .Statuses }} + <div> + <div class="subtaskHeader">{{ . }}</div> + {{ range $.SubtasksMap . }} + <div class="subtask"> + <a href="{{ .Path }}">{{ .Path }}</a> + <p>{{ .Summary }}</p> + {{ if .Tags }}<p>#{{ .Tags }}</p>{{ end }} + {{ if .Assignee }}<p>assigned to {{ .Assignee }}</p>{{ end }} + {{ if .Milestone }}<p>milestone: {{ .Milestone }}</p>{{ end }} + </div> + {{ end }} + </div> + {{ end }} + </div> + {{ end }} + </body> +</html>