Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: go mod download

- name: Build Linux binary
run: GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o moon .
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o moon .

- name: Copy files to server
uses: appleboy/scp-action@v0.1.7
Expand Down
8 changes: 4 additions & 4 deletions calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ <h1 class="header-title">📅 Moon Rise and Set Calendar</h1>
{{ range .Rows }}
<tr>
<td>{{.Date}}</td>
<td>{{.Moon.Rise}}</td>
<td>{{.Moon.Set}}</td>
<td>{{.Sun.Rise}}</td>
<td>{{.Sun.Set}}</td>
<td>{{if .Moon.AlwaysAbove}}Always above{{else if .Moon.AlwaysBelow}}Always below{{else}}{{.Moon.Rise}}{{end}}</td>
<td>{{if .Moon.AlwaysAbove}}Always above{{else if .Moon.AlwaysBelow}}Always below{{else}}{{.Moon.Set}}{{end}}</td>
<td>{{if .Sun.AlwaysAbove}}Always above{{else if .Sun.AlwaysBelow}}Always below{{else}}{{.Sun.Rise}}{{end}}</td>
<td>{{if .Sun.AlwaysAbove}}Always above{{else if .Sun.AlwaysBelow}}Always below{{else}}{{.Sun.Set}}{{end}}</td>
</tr>
{{ end }}
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module moon

go 1.21
go 1.24.7

require github.com/exploded/riseset v1.0.0
require github.com/exploded/riseset v1.0.1-0.20260220080739-24891d86367a
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/exploded/riseset v1.0.0 h1:qdXzKgiEieF8hJSvmONRYcX4QalBMkFnUf1xuW6YIxM=
github.com/exploded/riseset v1.0.0/go.mod h1:VjRq5iJAosiDcmN6cIemg4Koh/g/MirLmI9djQoiuYs=
github.com/exploded/riseset v1.0.1-0.20260220080739-24891d86367a h1:9zXloV9qOl/7d9DUghsbK2l0w1xM0ebmEjMWk8KCS4Y=
github.com/exploded/riseset v1.0.1-0.20260220080739-24891d86367a/go.mod h1:iSOrtnvmvgDPXhfjH+isdiLP0aTLSlIExl2z6Tulizg=
14 changes: 10 additions & 4 deletions moon.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,18 @@ func makeHTTPServer() *http.Server {

func main() {
var flgProduction bool
var httpPort string = ":8181"
if os.Getenv("PROD") == "True" {
flgProduction = true
} else {
flgProduction = false
}

httpPort := os.Getenv("PORT")
if httpPort == "" {
httpPort = "8484"
}
httpPort = ":" + httpPort

log.Printf("Production: %v", flgProduction)
log.Printf("HTTP Port: %s", httpPort)

Expand Down Expand Up @@ -214,8 +220,8 @@ func calendar(w http.ResponseWriter, r *http.Request) {
for i := 0; i < 10; i++ {
newdate = newdate.AddDate(0, 0, 1)
arow.Date = newdate.Format("02-01-2006")
arow.Moon = riseset.Riseset(1, newdate, Lon, Lat, Zon)
arow.Sun = riseset.Riseset(2, newdate, Lon, Lat, Zon)
arow.Moon = riseset.Riseset(riseset.Moon, newdate, Lon, Lat, Zon)
arow.Sun = riseset.Riseset(riseset.Sun, newdate, Lon, Lat, Zon)
Passme.Rows = append(Passme.Rows, arow)
}

Expand Down Expand Up @@ -299,7 +305,7 @@ func gettimes(w http.ResponseWriter, r *http.Request) {
var newdate time.Time
zondur = time.Hour * time.Duration(zon)
newdate = time.Now().Add(zondur)
mydata = riseset.Riseset(1, newdate, lon, lat, zon)
mydata = riseset.Riseset(riseset.Moon, newdate, lon, lat, zon)
}
json.NewEncoder(w).Encode(mydata)
}
Expand Down
14 changes: 11 additions & 3 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,20 @@ const getTimes = function () {

$.getJSON(`gettimes?lon=${mylon}&lat=${mylat}&zon=${zon}`)
.done((json) => {
if (json.Rise && json.Set) {
if (json.Rise === "error" || json.Set === "error") {
showErrorMessage('Unable to calculate moon times for this location.');
} else if (json.AlwaysAbove) {
updateInputField("Rise", "Always above horizon");
updateInputField("Set", "Always above horizon");
clearErrorMessage();
} else if (json.AlwaysBelow) {
updateInputField("Rise", "Always below horizon");
updateInputField("Set", "Always below horizon");
clearErrorMessage();
} else if (json.Rise && json.Set) {
updateInputField("Rise", json.Rise);
updateInputField("Set", json.Set);
clearErrorMessage();
} else if (json.Rise === "error" || json.Set === "error") {
showErrorMessage('Unable to calculate moon times for this location.');
}
})
.fail((jqXHR, textStatus, errorThrown) => {
Expand Down