diff --git a/Makefile b/Makefile index 5f846ae..fab402c 100644 --- a/Makefile +++ b/Makefile @@ -7,17 +7,15 @@ build: mkdir bin/static mkdir bin/ui go build -ldflags="-s -X main.version=$(svn_revision)" -o bin/alfheim-website ./cmd/web - cp -r ui bin - cp -r static bin - cp favicon.ico bin + cp -r ui/html bin + cp -r ui/static bin cp Caddyfile bin mkdir bin/linux_amd64 mkdir bin/linux_amd64/static mkdir bin/linux_amd64/ui GOOS=linux GOARCH=amd64 go build -ldflags="-s -X main.version=$(svn_revision)" -o bin/linux_amd64/alfheim-website ./cmd/web - cp -r ui bin/linux_amd64 - cp -r static bin/linux_amd64 - cp favicon.ico bin/linux_amd64 + cp -r ui/html bin/linux_amd64 + cp -r ui/static bin/linux_amd64 cp Caddyfile bin/linux_amd64 run: diff --git a/bin/Caddyfile b/bin/Caddyfile deleted file mode 100644 index d418646..0000000 --- a/bin/Caddyfile +++ /dev/null @@ -1,7 +0,0 @@ -{ - email vicenteferrarismith@gmail.com -} - -alfheimgame.com { - reverse_proxy localhost:4000 -} \ No newline at end of file diff --git a/bin/alfheim-website b/bin/alfheim-website deleted file mode 100755 index 7eec309..0000000 Binary files a/bin/alfheim-website and /dev/null differ diff --git a/bin/linux_amd64/Caddyfile b/bin/linux_amd64/Caddyfile deleted file mode 100644 index d418646..0000000 --- a/bin/linux_amd64/Caddyfile +++ /dev/null @@ -1,7 +0,0 @@ -{ - email vicenteferrarismith@gmail.com -} - -alfheimgame.com { - reverse_proxy localhost:4000 -} \ No newline at end of file diff --git a/bin/linux_amd64/alfheim-website b/bin/linux_amd64/alfheim-website deleted file mode 100755 index 8b873d9..0000000 Binary files a/bin/linux_amd64/alfheim-website and /dev/null differ diff --git a/bin/linux_amd64/favicon.ico b/bin/linux_amd64/favicon.ico deleted file mode 100755 index fd13ee6..0000000 Binary files a/bin/linux_amd64/favicon.ico and /dev/null differ diff --git a/bin/linux_amd64/static/Vollkorn-VariableFont_wght.ttf b/bin/linux_amd64/static/Vollkorn-VariableFont_wght.ttf deleted file mode 100644 index 188fd06..0000000 Binary files a/bin/linux_amd64/static/Vollkorn-VariableFont_wght.ttf and /dev/null differ diff --git a/bin/linux_amd64/static/image.png b/bin/linux_amd64/static/image.png deleted file mode 100644 index 0475eda..0000000 Binary files a/bin/linux_amd64/static/image.png and /dev/null differ diff --git a/bin/linux_amd64/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg b/bin/linux_amd64/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg deleted file mode 100644 index 1163dcb..0000000 --- a/bin/linux_amd64/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/bin/linux_amd64/static/panel-000.png b/bin/linux_amd64/static/panel-000.png deleted file mode 100644 index 82c2a37..0000000 Binary files a/bin/linux_amd64/static/panel-000.png and /dev/null differ diff --git a/bin/linux_amd64/static/style.css b/bin/linux_amd64/static/style.css deleted file mode 100644 index 8044bd1..0000000 --- a/bin/linux_amd64/static/style.css +++ /dev/null @@ -1,202 +0,0 @@ -html { - /*background: no-repeat url(/static/image.png); - background-size: cover; - background-position: center;*/ - height: 100vh; - background-color: black; - box-sizing: border-box; -} - -body { - display: flex; - flex-direction: column; - justify-content: space-between; - background-color: #3475CB; - font-family: "Vollkorn"; - color: white; - margin-top: 0px; - margin-bottom: 0px; - margin-left: auto; - margin-right: auto; - max-width: 900px; - min-height: 100%; -} - -header { - -} - -nav { - padding-left: 8px; - padding-right: 8px; - display: flex; - align-items: center; - justify-content: space-between; -} - -.navbuttons a { - display: inline-block; -} - -.maintitle { - margin: 0px; - font-size: 6rem; - color: white; -} - -@media (max-width: 1080px) { - .maintitle { - font-size: 4rem; - } -} - -.loginbutton { - align-self: center; - display: flex; - border: 12px solid; - border-image-source: url("/static/panel-000.png"); - border-image-slice: 12 fill; - padding-top: 15px; - padding-right: 20px; - padding-bottom: 15px; - padding-left: 20px; - color: black; - /*box-shadow: 10px 10px 5px lightblue;*/ -} - -main { - padding: 8px; - flex: 1; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - min-height: 100%; - max-height: 100%; - margin-left: auto; - margin-right: auto; -} - -p { - text-align: center; - font-size: 1rem; -} - -.account-wrapper { - background: transparent; - border: 2px solid white; - backdrop-filter: blur(20px); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); - border-radius: 15px; - padding: 30px 40px; - font-size: 1.5rem; -} - -.wrapper { - display: inline-block; - background: transparent; - border: 2px solid white; - backdrop-filter: blur(20px); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); - border-radius: 15px; - padding: 30px 40px; - width: 80%; - text-align: center; -} - -.wrapper h1 { - font-size: 1.5rem; - text-align: center; -} - -.wrapper .input-box { - width: 100%; -} - -.input-box input { - box-sizing: border-box; - background: transparent; - width: 100%; - height: 100%; - outline: none; - border: 2px solid rgba(255, 255, 255, .2); - border-radius: 25px; - padding: 10px 45px 10px 20px -} - -.input-box input::placeholder { - color: white; -} - -.wrapper .input-error { - width: 100%; -} - -.error { - color: rgba(240, 0, 0, .8); -} - -.input-error input { - box-sizing: border-box; - background: transparent; - width: 100%; - height: 100%; - outline: none; - border: 2px solid rgba(255, 0, 0, .2); - border-radius: 25px; - padding: 10px 45px 10px 20px -} - -.input-error input::placeholder { - color: red; -} - -.login-btn-wrapper { - display: flex; - justify-content: center; -} - -.wrapper .btn { - width: 100%; - outline: none; - border: none; - border-radius: 20px; -} - -.wrapper .register-link { - display: flex; - justify-content: center; -} - -input { - font-family: inherit; -} - -footer { - /*margin-top: auto;*/ - width: 100%; - background-color: #132123; - color: white; - text-align: center; -} - -a:link { - text-decoration: none; -} - -.wrapper a:link { - text-decoration: none; -} - -.wrapper a:visited { - text-decoration: none; -} - -.wrapper a:hover { - text-decoration: underline; -} - -video { - width: 100%; - height: auto; -} diff --git a/bin/linux_amd64/static/video.mp4 b/bin/linux_amd64/static/video.mp4 deleted file mode 100644 index a9f4427..0000000 Binary files a/bin/linux_amd64/static/video.mp4 and /dev/null differ diff --git a/bin/linux_amd64/ui/account.html b/bin/linux_amd64/ui/account.html deleted file mode 100644 index 6d7f407..0000000 --- a/bin/linux_amd64/ui/account.html +++ /dev/null @@ -1,22 +0,0 @@ -{{define "body"}} -
-
Username: {{.Account.Username}}
-
First name: {{.Account.Firstname}}
-
Last name: {{.Account.Lastname}}
-
Color: {{.Account.Color}}
-
- -
-
- -
- -
- -
-
-{{end}} diff --git a/bin/linux_amd64/ui/base.html b/bin/linux_amd64/ui/base.html deleted file mode 100644 index 42f9e32..0000000 --- a/bin/linux_amd64/ui/base.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - Alfheim - - - - - - - - - - -
- -
- -
- {{template "body" .}} -
- - - - diff --git a/bin/linux_amd64/ui/index.html b/bin/linux_amd64/ui/index.html deleted file mode 100644 index 05fb507..0000000 --- a/bin/linux_amd64/ui/index.html +++ /dev/null @@ -1,9 +0,0 @@ -{{define "body"}} -

Alfheim is a game about humanity: our own will, and our place in the world at large.

-

Alfheim is an MMO where you—the player—administer a medieval settlement of elves. -In an infinite world, and with thousands of other players, you will have to design an efficient command economy, if you wish to be able to compete with your enemies... Or your friends?

-
- -
-Alfheim -{{end}} diff --git a/bin/linux_amd64/ui/login.html b/bin/linux_amd64/ui/login.html deleted file mode 100644 index ed38137..0000000 --- a/bin/linux_amd64/ui/login.html +++ /dev/null @@ -1,39 +0,0 @@ -{{define "body"}} -
-
-

Log in

- - {{with .FormErrors.generic}} - - {{end}} - - {{with .FormErrors.username}} - - {{end}} - -
- -
-
- - {{with .FormErrors.password}} - - {{end}} - -
- -
-
- - -
- Have you forgotten your password? - - -
-
-{{end}} diff --git a/bin/linux_amd64/ui/logout.html b/bin/linux_amd64/ui/logout.html deleted file mode 100644 index 690d0bc..0000000 --- a/bin/linux_amd64/ui/logout.html +++ /dev/null @@ -1,11 +0,0 @@ -{{define "body"}} -
-
-

Log out

- - -
-
-{{end}} diff --git a/bin/linux_amd64/ui/register.html b/bin/linux_amd64/ui/register.html deleted file mode 100644 index 66777f5..0000000 --- a/bin/linux_amd64/ui/register.html +++ /dev/null @@ -1,45 +0,0 @@ -{{define "body"}} -
-
-

Register

- - {{with .FormErrors.username}} - - {{end}} - -
- -
-
- - -
- -
-
- -
- -
-
- -
- -
-
- - {{with .FormErrors.password}} - - {{end}} - -
- -
-
- - -
-
-{{end}} diff --git a/bin/linux_amd64/ui/subscribe.html b/bin/linux_amd64/ui/subscribe.html deleted file mode 100644 index fb1f4a2..0000000 --- a/bin/linux_amd64/ui/subscribe.html +++ /dev/null @@ -1,8 +0,0 @@ -{{define "body"}} -{{range .Prices}} -
- {{$price := divide .UnitAmountDecimal 100}} - {{.Currency}} {{printf "%.2f" $price}} -
-{{end}} -{{end}} diff --git a/bin/linux_amd64/ui/subscribe_stripe.html b/bin/linux_amd64/ui/subscribe_stripe.html deleted file mode 100644 index bbdf87e..0000000 --- a/bin/linux_amd64/ui/subscribe_stripe.html +++ /dev/null @@ -1,5 +0,0 @@ -{{define "body"}} - - - -{{end}} diff --git a/bin/static/Vollkorn-VariableFont_wght.ttf b/bin/static/Vollkorn-VariableFont_wght.ttf deleted file mode 100644 index 188fd06..0000000 Binary files a/bin/static/Vollkorn-VariableFont_wght.ttf and /dev/null differ diff --git a/bin/static/image.png b/bin/static/image.png deleted file mode 100644 index 0475eda..0000000 Binary files a/bin/static/image.png and /dev/null differ diff --git a/bin/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg b/bin/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg deleted file mode 100644 index 1163dcb..0000000 --- a/bin/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/bin/static/panel-000.png b/bin/static/panel-000.png deleted file mode 100644 index 82c2a37..0000000 Binary files a/bin/static/panel-000.png and /dev/null differ diff --git a/bin/static/style.css b/bin/static/style.css deleted file mode 100644 index 8044bd1..0000000 --- a/bin/static/style.css +++ /dev/null @@ -1,202 +0,0 @@ -html { - /*background: no-repeat url(/static/image.png); - background-size: cover; - background-position: center;*/ - height: 100vh; - background-color: black; - box-sizing: border-box; -} - -body { - display: flex; - flex-direction: column; - justify-content: space-between; - background-color: #3475CB; - font-family: "Vollkorn"; - color: white; - margin-top: 0px; - margin-bottom: 0px; - margin-left: auto; - margin-right: auto; - max-width: 900px; - min-height: 100%; -} - -header { - -} - -nav { - padding-left: 8px; - padding-right: 8px; - display: flex; - align-items: center; - justify-content: space-between; -} - -.navbuttons a { - display: inline-block; -} - -.maintitle { - margin: 0px; - font-size: 6rem; - color: white; -} - -@media (max-width: 1080px) { - .maintitle { - font-size: 4rem; - } -} - -.loginbutton { - align-self: center; - display: flex; - border: 12px solid; - border-image-source: url("/static/panel-000.png"); - border-image-slice: 12 fill; - padding-top: 15px; - padding-right: 20px; - padding-bottom: 15px; - padding-left: 20px; - color: black; - /*box-shadow: 10px 10px 5px lightblue;*/ -} - -main { - padding: 8px; - flex: 1; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - min-height: 100%; - max-height: 100%; - margin-left: auto; - margin-right: auto; -} - -p { - text-align: center; - font-size: 1rem; -} - -.account-wrapper { - background: transparent; - border: 2px solid white; - backdrop-filter: blur(20px); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); - border-radius: 15px; - padding: 30px 40px; - font-size: 1.5rem; -} - -.wrapper { - display: inline-block; - background: transparent; - border: 2px solid white; - backdrop-filter: blur(20px); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); - border-radius: 15px; - padding: 30px 40px; - width: 80%; - text-align: center; -} - -.wrapper h1 { - font-size: 1.5rem; - text-align: center; -} - -.wrapper .input-box { - width: 100%; -} - -.input-box input { - box-sizing: border-box; - background: transparent; - width: 100%; - height: 100%; - outline: none; - border: 2px solid rgba(255, 255, 255, .2); - border-radius: 25px; - padding: 10px 45px 10px 20px -} - -.input-box input::placeholder { - color: white; -} - -.wrapper .input-error { - width: 100%; -} - -.error { - color: rgba(240, 0, 0, .8); -} - -.input-error input { - box-sizing: border-box; - background: transparent; - width: 100%; - height: 100%; - outline: none; - border: 2px solid rgba(255, 0, 0, .2); - border-radius: 25px; - padding: 10px 45px 10px 20px -} - -.input-error input::placeholder { - color: red; -} - -.login-btn-wrapper { - display: flex; - justify-content: center; -} - -.wrapper .btn { - width: 100%; - outline: none; - border: none; - border-radius: 20px; -} - -.wrapper .register-link { - display: flex; - justify-content: center; -} - -input { - font-family: inherit; -} - -footer { - /*margin-top: auto;*/ - width: 100%; - background-color: #132123; - color: white; - text-align: center; -} - -a:link { - text-decoration: none; -} - -.wrapper a:link { - text-decoration: none; -} - -.wrapper a:visited { - text-decoration: none; -} - -.wrapper a:hover { - text-decoration: underline; -} - -video { - width: 100%; - height: auto; -} diff --git a/bin/static/video.mp4 b/bin/static/video.mp4 deleted file mode 100644 index a9f4427..0000000 Binary files a/bin/static/video.mp4 and /dev/null differ diff --git a/bin/ui/account.html b/bin/ui/account.html deleted file mode 100644 index 6d7f407..0000000 --- a/bin/ui/account.html +++ /dev/null @@ -1,22 +0,0 @@ -{{define "body"}} -
-
Username: {{.Account.Username}}
-
First name: {{.Account.Firstname}}
-
Last name: {{.Account.Lastname}}
-
Color: {{.Account.Color}}
-
- -
-
- -
- -
- -
-
-{{end}} diff --git a/bin/ui/base.html b/bin/ui/base.html deleted file mode 100644 index 42f9e32..0000000 --- a/bin/ui/base.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - Alfheim - - - - - - - - - - -
- -
- -
- {{template "body" .}} -
- - - - diff --git a/bin/ui/index.html b/bin/ui/index.html deleted file mode 100644 index 05fb507..0000000 --- a/bin/ui/index.html +++ /dev/null @@ -1,9 +0,0 @@ -{{define "body"}} -

Alfheim is a game about humanity: our own will, and our place in the world at large.

-

Alfheim is an MMO where you—the player—administer a medieval settlement of elves. -In an infinite world, and with thousands of other players, you will have to design an efficient command economy, if you wish to be able to compete with your enemies... Or your friends?

-
- -
-Alfheim -{{end}} diff --git a/bin/ui/login.html b/bin/ui/login.html deleted file mode 100644 index ed38137..0000000 --- a/bin/ui/login.html +++ /dev/null @@ -1,39 +0,0 @@ -{{define "body"}} -
-
-

Log in

- - {{with .FormErrors.generic}} - - {{end}} - - {{with .FormErrors.username}} - - {{end}} - -
- -
-
- - {{with .FormErrors.password}} - - {{end}} - -
- -
-
- - -
- Have you forgotten your password? - - -
-
-{{end}} diff --git a/bin/ui/logout.html b/bin/ui/logout.html deleted file mode 100644 index 690d0bc..0000000 --- a/bin/ui/logout.html +++ /dev/null @@ -1,11 +0,0 @@ -{{define "body"}} -
-
-

Log out

- - -
-
-{{end}} diff --git a/bin/ui/register.html b/bin/ui/register.html deleted file mode 100644 index 66777f5..0000000 --- a/bin/ui/register.html +++ /dev/null @@ -1,45 +0,0 @@ -{{define "body"}} -
-
-

Register

- - {{with .FormErrors.username}} - - {{end}} - -
- -
-
- - -
- -
-
- -
- -
-
- -
- -
-
- - {{with .FormErrors.password}} - - {{end}} - -
- -
-
- - -
-
-{{end}} diff --git a/bin/ui/subscribe.html b/bin/ui/subscribe.html deleted file mode 100644 index fb1f4a2..0000000 --- a/bin/ui/subscribe.html +++ /dev/null @@ -1,8 +0,0 @@ -{{define "body"}} -{{range .Prices}} -
- {{$price := divide .UnitAmountDecimal 100}} - {{.Currency}} {{printf "%.2f" $price}} -
-{{end}} -{{end}} diff --git a/bin/ui/subscribe_stripe.html b/bin/ui/subscribe_stripe.html deleted file mode 100644 index bbdf87e..0000000 --- a/bin/ui/subscribe_stripe.html +++ /dev/null @@ -1,5 +0,0 @@ -{{define "body"}} - - - -{{end}} diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index cddadaa..ddfd35b 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -377,7 +377,7 @@ func subscribe(w http.ResponseWriter, r *http.Request) { } } -func subscribe_stripe(w http.ResponseWriter, r *http.Request) { +func subscribeStripe(w http.ResponseWriter, r *http.Request) { id := authenticatedUser(w, r) account, err := users.GetAccount(id) @@ -412,7 +412,7 @@ func subscribe_stripe(w http.ResponseWriter, r *http.Request) { } } -func managebilling(w http.ResponseWriter, r *http.Request) { +func manageBilling(w http.ResponseWriter, r *http.Request) { id := authenticatedUser(w, r) account, err := users.GetAccount(id) if err != nil { @@ -510,11 +510,11 @@ func webhooks(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } -func handle_checkout_session_completed(checkoutsession stripe.CheckoutSession) error { +func handle_checkout_session_completed(checkoutSession stripe.CheckoutSession) error { //toprint, _ := json.MarshalIndent(checkoutSession, "", " ") //log.Println(string(toprint)) - subscription, err := subscription.Get(checkoutsession.Subscription.ID, nil) + subscription, err := subscription.Get(checkoutSession.Subscription.ID, nil) if err != nil { log.Println(err) return err @@ -542,19 +542,19 @@ func handle_checkout_session_completed(checkoutsession stripe.CheckoutSession) e // status = paused //} - subscriptions.Insert(checkoutsession.Customer.ID, subscription.ID, checkoutsession.ID, subscription.Status) + subscriptions.Insert(checkoutSession.Customer.ID, subscription.ID, checkoutSession.ID, subscription.Status) return nil } -func handle_payment_method_attached(paymentmethod stripe.PaymentMethod) error { +func handlePaymentMethodAttached(paymentMethod stripe.PaymentMethod) error { //toprint, _ := json.MarshalIndent(setupintent, "", " ") //log.Println(string(toprint)) // make this the new customer's default payment method params := &stripe.CustomerParams{} - params.DefaultSource = &paymentmethod.ID - /*result*/ _, err := customer.Update(paymentmethod.Customer.ID, params) + params.DefaultSource = &paymentMethod.ID + /*result*/ _, err := customer.Update(paymentMethod.Customer.ID, params) //log.Println(result) if err != nil { log.Println(err) diff --git a/cmd/web/main.go b/cmd/web/main.go index e0ab851..6276c1d 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -98,8 +98,8 @@ func main() { mux.HandleFunc("/register", register) mux.HandleFunc("/account", requireAuthenticatedUser(account)) mux.HandleFunc("/deleteaccount", requireAuthenticatedUser(deleteAccount)) - mux.HandleFunc("/subscribe", requireAuthenticatedUser(subscribe_stripe)) - mux.HandleFunc("/managebilling", requireAuthenticatedUser(managebilling)) + mux.HandleFunc("/subscribe", requireAuthenticatedUser(subscribeStripe)) + mux.HandleFunc("/managebilling", requireAuthenticatedUser(manageBilling)) mux.HandleFunc("/webhook", webhooks) if *production { diff --git a/pkg/models/models.go b/pkg/models/models.go index 3cd6c64..e1ffaf5 100644 --- a/pkg/models/models.go +++ b/pkg/models/models.go @@ -7,7 +7,6 @@ package models import ( "errors" "time" - _ "github.com/lib/pq" ) var ErrNoRecord = errors.New("no matching record found") diff --git a/bin/favicon.ico b/ui/static/favicon.ico similarity index 100% rename from bin/favicon.ico rename to ui/static/favicon.ico