diff options
author | Aki <please@ignore.pl> | 2021-05-08 00:43:14 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-05-08 00:43:14 +0200 |
commit | 0c6f300f90bf576ffd67df7331fc57b55c5484d3 (patch) | |
tree | a89c3aed3c17fc0104c0e51be794a1f2eb95eef6 | |
parent | a446a7ddf00a700079960e73a9b82f46d22c6ce4 (diff) | |
download | field-0c6f300f90bf576ffd67df7331fc57b55c5484d3.zip field-0c6f300f90bf576ffd67df7331fc57b55c5484d3.tar.gz field-0c6f300f90bf576ffd67df7331fc57b55c5484d3.tar.bz2 |
Added start and end dates to recent items
-rw-r--r-- | models.go | 3 | ||||
-rw-r--r-- | page.css | 25 | ||||
-rw-r--r-- | recent.tmpl | 11 | ||||
-rw-r--r-- | storage.go | 18 |
4 files changed, 39 insertions, 18 deletions
@@ -14,6 +14,8 @@ type Team []uint32 type Battle struct { Id string `json:"-"` LastModified time.Time `json:"-"` + StartTime time.Time `json:"started_at"` + EndTime time.Time `json:"ended_at"` Teams [2]Team `json:"teams"` Killmails []Killmail `json:"killmails"` Name string `json:"name"` @@ -28,6 +30,7 @@ type EsiKillmail struct { Z float64 `json:"z"` } `json:"position"` } `json:"victim"` + Time time.Time `json:"killmail_time"` } type EsiUniverseSystem struct { @@ -59,24 +59,25 @@ footer { padding: 1em; } -.recent-item .id { - color: #555; - font-size: 80% +.recent-item { + padding: 0.2em; + border-bottom: 1px solid #242529; } -.recent-item > header { - text-align: inherit; +.recent-item:hover { + background: #1e1f23; } -.recent-item > header > .last-modified { - float: right; +.recent-item > .details { + color: #555; + font-size: 80%; } -.recent-item { - padding: 0.2em; - border-bottom: 1px solid #242529; +.left-right { + display: flex; + justify-content: space-between; } -.recent-item:hover { - background: #1e1f23; +.left-right > * { + display: block; } diff --git a/recent.tmpl b/recent.tmpl index 6d20a8c..8311636 100644 --- a/recent.tmpl +++ b/recent.tmpl @@ -14,11 +14,14 @@ <h2>Recent</h2> {{range .}} <div class="recent-item"> - <header> + <div class="header left-right"> <a href="/view/{{.Id}}">{{.Name}}</a> - <span class="last-modified">{{.LastModified.Format "January 02, 2006 15:04 UTC"}}</span> - </header> - <span class="id">{{.Id}}</span> + <span>{{.StartTime.Format "January 02, 2006 15:04 UTC"}}</span> + </div> + <div class="details left-right"> + <span class="id">{{.Id}}</span> + <span>Last updated on {{.StartTime.Format "January 02, 2006 15:04 UTC"}}</span> + </div> </div> {{end}} <h2>About</h2> @@ -78,12 +78,26 @@ func (s *Storage) AddBattle(battle *Battle) error { if err != nil { return err } - battle.Name = fmt.Sprintf("Battle in %s", system.Name) + battle.Name = fmt.Sprintf("Fight in %s", system.Name) + battle.StartTime = details.Time + battle.EndTime = details.Time + for _, km := range battle.Killmails[1:] { + details, err := GetKillmail(km.Id, km.Hash) + if err != nil { + return err + } + if battle.StartTime.After(details.Time) { + battle.StartTime = details.Time + } + if battle.EndTime.Before(details.Time) { + battle.EndTime = details.Time + } + } + data, err := json.Marshal(battle) if err != nil { return err } - return ioutil.WriteFile(s.Path+"/battles/"+battle.Id, data, 0644) } |