git-svn-id: svn://losandesgames.com/alfheim-website@53 15359d88-9307-4e75-a9c1-e5686e5897df

This commit is contained in:
vfs committed 2025-10-04 08:59:53 +00:00
1 parent eb222d8677
commit 65e87129a6
10 files changed
+114 -128

No files matched your search

+15 -15
View File
@@ -16,13 +16,13 @@ import (
"strings"
"unicode/utf8"
"github.com/stripe/stripe-go/v78"
"github.com/stripe/stripe-go/v78/billingportal/session"
"github.com/stripe/stripe-go/v78/customer"
"github.com/stripe/stripe-go/v78/customersession"
"github.com/stripe/stripe-go/v78/price"
"github.com/stripe/stripe-go/v78/subscription"
"github.com/stripe/stripe-go/v78/webhook"
"github.com/stripe/stripe-go/v83"
"github.com/stripe/stripe-go/v83/billingportal/session"
"github.com/stripe/stripe-go/v83/customer"
"github.com/stripe/stripe-go/v83/customersession"
"github.com/stripe/stripe-go/v83/price"
"github.com/stripe/stripe-go/v83/subscription"
"github.com/stripe/stripe-go/v83/webhook"
"alfheimgame.com/alfheim/pkg/models"
)
@@ -84,7 +84,7 @@ func home(w http.ResponseWriter, r *http.Request) {
active_subscription := subscriptions.HasActiveSubscription(id)
text, err := template.ParseFiles("ui/base.html", "ui/index.html")
text, err := template.ParseFiles("ui/html/base.html", "ui/html/index.html")
if err != nil {
http.Error(w, "Internal Server Error", 500)
log.Println(err)
@@ -108,7 +108,7 @@ func home(w http.ResponseWriter, r *http.Request) {
}
func login(w http.ResponseWriter, r *http.Request) {
text, err := template.ParseFiles("ui/base.html", "ui/login.html")
text, err := template.ParseFiles("ui/html/base.html", "ui/html/login.html")
if err != nil {
http.Error(w, "Internal Server Error", 500)
log.Fatal(err)
@@ -174,7 +174,7 @@ func login(w http.ResponseWriter, r *http.Request) {
}
func logout(w http.ResponseWriter, r *http.Request) {
text, err := template.ParseFiles("ui/base.html", "ui/logout.html")
text, err := template.ParseFiles("ui/html/base.html", "ui/html/logout.html")
if err != nil {
http.Error(w, "Internal Server Error", 500)
log.Println(err)
@@ -209,7 +209,7 @@ func logout(w http.ResponseWriter, r *http.Request) {
}
func register(w http.ResponseWriter, r *http.Request) {
text, err := template.ParseFiles("ui/base.html", "ui/register.html")
text, err := template.ParseFiles("ui/html/base.html", "ui/html/register.html")
if err != nil {
http.Error(w, "Internal Server Error", 500)
log.Println(err)
@@ -291,7 +291,7 @@ func account(w http.ResponseWriter, r *http.Request) {
//log.Println(id, account)
text, err := template.ParseFiles("ui/base.html", "ui/account.html")
text, err := template.ParseFiles("ui/html/base.html", "ui/html/account.html")
if err != nil {
http.Error(w, "Internal Server Error", 500)
log.Println(err)
@@ -363,7 +363,7 @@ func subscribe(w http.ResponseWriter, r *http.Request) {
},
}
text, err := template.New("base.html").Funcs(fm).ParseFiles("ui/base.html", "ui/subscribe.html")
text, err := template.New("base.html").Funcs(fm).ParseFiles("ui/html/base.html", "ui/html/subscribe.html")
if err != nil {
http.Error(w, "Internal Server Error", 500)
log.Println(err)
@@ -399,7 +399,7 @@ func subscribeStripe(w http.ResponseWriter, r *http.Request) {
log.Println(err)
}
text, err := template.ParseFiles("ui/base.html", "ui/subscribe_stripe.html")
text, err := template.ParseFiles("ui/html/base.html", "ui/html/subscribe_stripe.html")
if err != nil {
http.Error(w, "Internal Server Error", 500)
log.Println(err)
@@ -421,7 +421,7 @@ func manageBilling(w http.ResponseWriter, r *http.Request) {
params := &stripe.BillingPortalSessionParams{
Customer: stripe.String(account.StripeID),
ReturnURL: stripe.String("http://localhost:8080/account"),
ReturnURL: stripe.String("https://alfheimgame.com/account"),
}
result, err := session.New(params)
+10 -8
View File
@@ -5,17 +5,18 @@
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"database/sql"
"regexp"
"github.com/jackc/pgx/v5"
"github.com/gorilla/sessions"
_ "github.com/lib/pq"
"github.com/stripe/stripe-go/v78"
"github.com/stripe/stripe-go/v83"
"alfheimgame.com/alfheim/pkg/models/postgresql"
)
@@ -53,11 +54,12 @@ func main() {
store.MaxAge(0)
db, err := sql.Open("postgres", "postgres://elves_database:iK2SoVbDhdCki5n3LxGyP6zKpLspt4@80.240.25.87/elves_database")
db, err := pgx.Connect(context.Background(), "postgres://alfheim:iK2SoVbDhdCki5n3LxGyP6zKpLspt4@losandesgames.com/alfheim")
if err != nil {
log.Fatal(err)
}
defer db.Close()
defer db.Close(context.Background())
users = &postgresql.AccountModel{DB: db}
subscriptions = &postgresql.SubscriptionModel{DB: db}
@@ -73,7 +75,7 @@ func main() {
//accounts := make([]*Account, 0)
//for rows.Next() {
// acc := new(Account)
// err := rows.Scan(&acc.id, &acc.Username, &acc.password, &acc.Color)
// err := rows.Scan(&acc.id, &acc.Username, &acc.password, &acc.Colour)
// if err != nil {
// log.Fatal(err)
// }
@@ -88,7 +90,7 @@ func main() {
// log.Println(acc)
//}
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("ui/static"))))
mux.HandleFunc("/favicon.ico", favicon)