TSV and excel instructions
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
This commit is contained in:
parent
1477f9bc55
commit
1aa4572f0e
|
@ -680,10 +680,17 @@ func CSVHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
topNSongs := calculateTopNSongs(channelData.VideoCache, 10)
|
topNSongs := calculateTopNSongs(channelData.VideoCache, 10)
|
||||||
topNSingers := calculateTopNSingers(channelData.VideoCache, 10)
|
topNSingers := calculateTopNSingers(channelData.VideoCache, 10)
|
||||||
var td = TemplateData{channelData.Name, channelData.Command, channelData.ExtraStrings, channelData.JoinTime, channelData.JoinTime.Format(irc.UTCFormat), false, channelData.HasLeft, AugmentSingsVideoStructSliceForCSV(channelData.VideoCache), topNSongs, topNSingers}
|
var td = TemplateData{channelData.Name, channelData.Command, channelData.ExtraStrings, channelData.JoinTime, channelData.JoinTime.Format(irc.UTCFormat), false, channelData.HasLeft, AugmentSingsVideoStructSliceForCSV(channelData.VideoCache), topNSongs, topNSingers}
|
||||||
response.Header().Add("Content-Disposition", "attachment; filename=\"duets.csv\"")
|
if request.URL.Path[0:4] == "/csv" {
|
||||||
response.Header().Add("Content-type", "text/csv")
|
response.Header().Add("Content-Disposition", "attachment; filename=\"duets.csv\"")
|
||||||
tmpl := template.Must(template.ParseFiles("web/data.csv"))
|
response.Header().Add("Content-type", "text/csv")
|
||||||
tmpl.Execute(response, td)
|
tmpl := template.Must(template.ParseFiles("web/data.csv"))
|
||||||
|
tmpl.Execute(response, td)
|
||||||
|
} else {
|
||||||
|
response.Header().Add("Content-Disposition", "attachment; filename=\"duets.tsv\"")
|
||||||
|
response.Header().Add("Content-type", "text/tab-separated-values")
|
||||||
|
tmpl := template.Must(template.ParseFiles("web/data.tsv"))
|
||||||
|
tmpl.Execute(response, td)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleHTTP(passedIrcBot *irc.KardBot) {
|
func HandleHTTP(passedIrcBot *irc.KardBot) {
|
||||||
|
@ -698,6 +705,7 @@ func HandleHTTP(passedIrcBot *irc.KardBot) {
|
||||||
r.HandleFunc("/cover.css", CSSHandler)
|
r.HandleFunc("/cover.css", CSSHandler)
|
||||||
r.HandleFunc("/admin/{channel}/{key}", AdminHandler)
|
r.HandleFunc("/admin/{channel}/{key}", AdminHandler)
|
||||||
r.HandleFunc("/csv/{channel}/{key}", CSVHandler)
|
r.HandleFunc("/csv/{channel}/{key}", CSVHandler)
|
||||||
|
r.HandleFunc("/tsv/{channel}/{key}", CSVHandler)
|
||||||
//r.HandleFunc("/twitchadmin", TwitchAdminHandler)
|
//r.HandleFunc("/twitchadmin", TwitchAdminHandler)
|
||||||
//r.HandleFunc("/twitchtobackend", TwitchBackendHandler)
|
//r.HandleFunc("/twitchtobackend", TwitchBackendHandler)
|
||||||
r.Path("/twitchtobackend").Queries("access_token", "{access_token}", "scope", "{scope}", "token_type", "{token_type}").HandlerFunc(TwitchBackendHandler)
|
r.Path("/twitchtobackend").Queries("access_token", "{access_token}", "scope", "{scope}", "token_type", "{token_type}").HandlerFunc(TwitchBackendHandler)
|
||||||
|
|
|
@ -69,6 +69,12 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
#csvpanel td {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
#csvpanel th {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
@ -148,7 +154,16 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div style="width: 100%; overflow-y: scroll; display: none;" id="csvpanel" class="controlpanel">
|
<div style="width: 100%; overflow-y: scroll; display: none;" id="csvpanel" class="controlpanel">
|
||||||
<h2>Click <a href="/csv/{{.Channel}}/{{.ChannelKey}}">here</a> to download the data as a CSV</h2>
|
<h3>Download your data as :</h3>
|
||||||
|
<center>
|
||||||
|
<table border="2">
|
||||||
|
<tr><th>CSV</th><th>TSV</th></tr>
|
||||||
|
<tr><td><a href="/csv/{{.Channel}}/{{.ChannelKey}}">here</a></td><td><a href="/tsv/{{.Channel}}/{{.ChannelKey}}">here</a></td></tr>
|
||||||
|
</table>
|
||||||
|
</center>
|
||||||
|
<h3>Excel is not very good at handling CSV format it seems...</h3>
|
||||||
|
<p>It is important to "Import Data" not "Open" the csv in many cases (8 year old discussion of this behaviour here) - from that post the instructions are : </p>
|
||||||
|
<blockquote>In Excel, DATA tab, in the Get External Data subsection, click "From Text" and import your CSV in the Wizard.</blockquote>
|
||||||
</div>
|
</div>
|
||||||
<div style="width: 100%; overflow-y: scroll; display: none;" id="botpanel" class="controlpanel">
|
<div style="width: 100%; overflow-y: scroll; display: none;" id="botpanel" class="controlpanel">
|
||||||
<h2>The bot isn't really ready yet... it just has the old Karaokards facility at the moment. I woudn't bother inviting it yet.</h2>
|
<h2>The bot isn't really ready yet... it just has the old Karaokards facility at the moment. I woudn't bother inviting it yet.</h2>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Published,Who,What,Last sang this song,Last dueted with performer
|
Published,Who,What,Last sang this song,Last dueted with performer
|
||||||
{{ range .SongData -}}
|
{{ range .SongData -}}
|
||||||
{{- .NiceDate }},{{ .SongTitle }},{{ .OtherSinger }},{{ .NiceLastSungSong }},{{ .NiceLastSungSinger }}
|
{{- .NiceDate }},"{{ .SongTitle }}",{{ .OtherSinger }},{{ .NiceLastSungSong }},{{ .NiceLastSungSinger }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Can't render this file because it has a wrong number of fields in line 2.
|
|
@ -0,0 +1,4 @@
|
||||||
|
Published Who What Last sang this song Last dueted with performer
|
||||||
|
{{ range .SongData -}}
|
||||||
|
{{- .NiceDate }} "{{ .SongTitle }}" {{ .OtherSinger }} {{ .NiceLastSungSong }} {{ .NiceLastSungSinger }}
|
||||||
|
{{ end }}
|
Can't render this file because it has a wrong number of fields in line 2.
|
Loading…
Reference in New Issue