mirror of
https://github.com/thebaer/tildes.git
synced 2018-07-20 07:15:21 +00:00
Add jackpot to scoreboard
This commit is contained in:
parent
6c054301c2
commit
0143aa244e
@ -12,6 +12,8 @@
|
|||||||
<h1>{{.Title}}</h1>
|
<h1>{{.Title}}</h1>
|
||||||
<p>Last Updated: <time datetime="{{.Updated}}">{{.UpdatedForHumans}}</time></p>
|
<p>Last Updated: <time datetime="{{.Updated}}">{{.UpdatedForHumans}}</time></p>
|
||||||
|
|
||||||
|
<p style="font-size: 1.2em">Current jackpot: <strong>{{.Jackpot}}</strong></p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
|
@ -10,11 +10,13 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"io/ioutil"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
scoresPath = "/home/krowbar/Code/irc/tildescores.txt"
|
scoresPath = "/home/krowbar/Code/irc/tildescores.txt"
|
||||||
|
jackpotPath = "/home/krowbar/Code/irc/tildejackpot.txt"
|
||||||
addictionData = "/home/karlen/bin/tilderoyale"
|
addictionData = "/home/karlen/bin/tilderoyale"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,6 +35,7 @@ func main() {
|
|||||||
|
|
||||||
if *isTestPtr {
|
if *isTestPtr {
|
||||||
scoresPath = "/home/bear/tildescores.txt"
|
scoresPath = "/home/bear/tildescores.txt"
|
||||||
|
jackpotPath = "/home/bear/tildejackpot.txt"
|
||||||
addictionData = "/home/bear/addicted.sh"
|
addictionData = "/home/bear/addicted.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +47,7 @@ func main() {
|
|||||||
scoresData = checkScoreDelta(scoresData, updatesData)
|
scoresData = checkScoreDelta(scoresData, updatesData)
|
||||||
scoresTable := buildScoresTable(scoresData, headers)
|
scoresTable := buildScoresTable(scoresData, headers)
|
||||||
|
|
||||||
generate("tilde collectors", sortScore(scoresTable), *outPtr)
|
generate("tilde collectors", getFile(jackpotPath), sortScore(scoresTable), *outPtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Table struct {
|
type Table struct {
|
||||||
@ -292,18 +295,29 @@ func readData(path string, delimiter string) *[]Row {
|
|||||||
return &rows
|
return &rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getFile(path string) string {
|
||||||
|
f, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(f)
|
||||||
|
}
|
||||||
|
|
||||||
type Page struct {
|
type Page struct {
|
||||||
Title string
|
Title string
|
||||||
Table Table
|
Table Table
|
||||||
Updated string
|
Updated string
|
||||||
UpdatedForHumans string
|
UpdatedForHumans string
|
||||||
|
Jackpot int
|
||||||
}
|
}
|
||||||
|
|
||||||
func add(x, y int) int {
|
func add(x, y int) int {
|
||||||
return x + y
|
return x + y
|
||||||
}
|
}
|
||||||
|
|
||||||
func generate(title string, table *Table, outputFile string) {
|
func generate(title, jackpot string, table *Table, outputFile string) {
|
||||||
fmt.Println("Generating page.")
|
fmt.Println("Generating page.")
|
||||||
|
|
||||||
f, err := os.Create(os.Getenv("HOME") + "/public_html/" + outputFile + ".html")
|
f, err := os.Create(os.Getenv("HOME") + "/public_html/" + outputFile + ".html")
|
||||||
@ -328,8 +342,15 @@ func generate(title string, table *Table, outputFile string) {
|
|||||||
updatedReadable := curTime.Format(time.RFC1123)
|
updatedReadable := curTime.Format(time.RFC1123)
|
||||||
updated := curTime.Format(time.RFC3339)
|
updated := curTime.Format(time.RFC3339)
|
||||||
|
|
||||||
|
// Jackpot parsing
|
||||||
|
jp, err := strconv.Atoi(jackpot)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
jp = -1
|
||||||
|
}
|
||||||
|
|
||||||
// Generate the page
|
// Generate the page
|
||||||
page := &Page{Title: title, Table: *table, UpdatedForHumans: updatedReadable, Updated: updated}
|
page := &Page{Title: title, Table: *table, UpdatedForHumans: updatedReadable, Updated: updated, Jackpot: jp}
|
||||||
template.ExecuteTemplate(w, "table", page)
|
template.ExecuteTemplate(w, "table", page)
|
||||||
w.Flush()
|
w.Flush()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user