Initial Commit
This commit is contained in:
21
resources/templates/cards/collection.html
Normal file
21
resources/templates/cards/collection.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="card-header">
|
||||
<p class="card-header-title">{{.Title}}</p>
|
||||
{{if ne .Icon ""}}
|
||||
<div class="card-header-icon subtitle">
|
||||
{{template "icon" .Icon}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="card-content">
|
||||
{{ range $name, $info := .Data }}
|
||||
{{$data := dict "target" ""}}
|
||||
{{- if eq $info.target "sameTab" -}}
|
||||
{{- $_ := set $data "target" "_self" -}}
|
||||
{{- else if eq $info.target "newTab" -}}
|
||||
{{- $_ := set $data "target" "_blank" -}}
|
||||
{{- else -}}
|
||||
{{- $_ := set $data "target" "_self" -}}
|
||||
{{- end -}}
|
||||
<a href="{{$info.url}}" class="button is-fullwidth has-text-left is-justify-content-start" target="{{$data.target}}" style="margin-bottom: 0.5rem; background-color: #f5f5f5">{{$name}}</a>
|
||||
{{end}}
|
||||
</div>
|
18
resources/templates/cards/simple.html
Normal file
18
resources/templates/cards/simple.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<div class="card-header">
|
||||
<a class="card-header-title" href="{{.URL}}">
|
||||
{{if ne .Icon ""}}
|
||||
{{template "icon" .Icon}}
|
||||
{{end}}
|
||||
{{.Title}}
|
||||
</a>
|
||||
</div>
|
||||
{{if ne .Description ""}}
|
||||
<div class="card-content">
|
||||
<p>{{.Description}}</p>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if ne .URL ""}}
|
||||
<div class="card-footer" style="margin-top: auto">
|
||||
<a class="card-footer-item has-text-info" href="{{.URL}}">{{.URL}}</a>
|
||||
</div>
|
||||
{{end}}
|
39
resources/templates/cards/status.html
Normal file
39
resources/templates/cards/status.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<div class="card-header">
|
||||
<a class="card-header-title" href="{{.URL}}">
|
||||
{{if ne .Icon ""}}
|
||||
{{template "icon" .Icon}}
|
||||
{{end}}
|
||||
{{.Title}}
|
||||
</a>
|
||||
<div class="card-header-icon">
|
||||
<div class="tags has-addons">
|
||||
<p class="tag">Status</p>
|
||||
<p class="tag is-warning" id="{{.Title}}Status">Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{if ne .Description ""}}
|
||||
<div class="card-content">
|
||||
<p>{{.Description}}</p>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="card-footer" style="margin-top: auto">
|
||||
<a class="card-footer-item has-text-info" href="{{.URL}}">{{.URL}}</a>
|
||||
</div>
|
||||
<script>
|
||||
var request = new XMLHttpRequest()
|
||||
request.open('GET', "/status/{{b64enc .URL}}", true)
|
||||
request.onload = function () {
|
||||
var data = JSON.parse(this.response)
|
||||
if (data.down === true || parseInt(data.code) > 500 && parseInt(data.code) < 600 ) {
|
||||
document.getElementById('{{.Title}}Status').classList.remove("is-warning")
|
||||
document.getElementById('{{.Title}}Status').classList.add("is-danger")
|
||||
document.getElementById('{{.Title}}Status').innerHTML = "Offline"
|
||||
} else {
|
||||
document.getElementById('{{.Title}}Status').classList.remove("is-warning")
|
||||
document.getElementById('{{.Title}}Status').classList.add("is-success")
|
||||
document.getElementById('{{.Title}}Status').innerHTML = "Online"
|
||||
}
|
||||
}
|
||||
request.send()
|
||||
</script>
|
43
resources/templates/cards/weather.html
Normal file
43
resources/templates/cards/weather.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<div class="card-header">
|
||||
<p class="card-header-title">{{.Title}}</p>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<p id="weatherLoadingText">Loading...</p>
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-half">
|
||||
<object type="image/svg+xml" id="weatherStateImg" style="width:45px; height: 45px"></object>
|
||||
</div>
|
||||
<div class="column is-half">
|
||||
<p id="weatherTempText" class="has-text-right subtitle"></p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="subtitle is-marginless" id="weatherStateText"></p>
|
||||
<p id="weatherMinText"></p>
|
||||
<p id="weatherMaxText"></p>
|
||||
<p id="weatherWindSpeedText"></p>
|
||||
<p id="weatherHumidityText"></p>
|
||||
<p id="weatherVisibilityText"></p>
|
||||
<p id="weatherPredictabilityText"></p>
|
||||
</div>
|
||||
<div class="card-footer" style="margin-top: auto">
|
||||
<span class="card-footer-item">Data from <a href="https://www.metaweather.com" class="has-text-info">Metaweather</a></span>
|
||||
</div>
|
||||
<script>
|
||||
var request = new XMLHttpRequest()
|
||||
request.open('GET', "{{proxy (printf `https://www.metaweather.com/api/location/%s/` .Data.woeid) }}", true)
|
||||
const round = function (flt){return Number.parseFloat(flt).toPrecision(3)}
|
||||
request.onload = function () {
|
||||
const data = JSON.parse(this.response)
|
||||
document.getElementById('weatherLoadingText').classList.add("is-hidden")
|
||||
document.getElementById('weatherStateText').innerText = data["consolidated_weather"][0]["weather_state_name"]
|
||||
document.getElementById('weatherTempText').innerHTML = round(data["consolidated_weather"][0]["the_temp"]*1.8+32) + " °F"
|
||||
document.getElementById('weatherStateImg').data = "/proxy/" + btoa("https://www.metaweather.com/static/img/weather/" + data["consolidated_weather"][0]["weather_state_abbr"] + ".svg")
|
||||
document.getElementById('weatherMinText').innerHTML = "Min: " + round(data["consolidated_weather"][0]["min_temp"]*1.8+32) + " °F"
|
||||
document.getElementById('weatherMaxText').innerHTML = "Max: " + round(data["consolidated_weather"][0]["max_temp"]*1.8+32) + " °F"
|
||||
document.getElementById('weatherWindSpeedText').innerText = "Wind Speed: " + round(data["consolidated_weather"][0]["wind_speed"]) + "mph"
|
||||
document.getElementById('weatherHumidityText').innerText = "Humidity: " + data["consolidated_weather"][0]["humidity"] + "%"
|
||||
document.getElementById('weatherVisibilityText').innerText = "Visibility: " + round(data["consolidated_weather"][0]["visibility"]) + "mi"
|
||||
document.getElementById('weatherPredictabilityText').innerText = "Predictability: " + data["consolidated_weather"][0]["predictability"] + "%"
|
||||
}
|
||||
request.send()
|
||||
</script>
|
Reference in New Issue
Block a user