diff --git a/api/stripe.pay.go b/api/stripe.pay.go deleted file mode 100644 index 7a4a584..0000000 --- a/api/stripe.pay.go +++ /dev/null @@ -1,26 +0,0 @@ -package api - -import ( - "net/http" - - "atri.dad/lib" - "github.com/labstack/echo/v4" -) - -type PayRequest struct { - SuccessUrl string `json:"successUrl"` - CancelUrl string `json:"cancelUrl"` - PriceId string `json:"priceId"` -} - -func Pay(c echo.Context) error { - payReq := new(PayRequest) - - if err := c.Bind(payReq); err != nil { - return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid request payload"}) - } - - lib.CreateCheckoutSession(c.Response().Writer, c.Request(), payReq.SuccessUrl, payReq.CancelUrl, payReq.PriceId) - - return c.String(http.StatusOK, "Checkout session created") -} diff --git a/go.mod b/go.mod index 49faaa5..3167fa1 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,6 @@ require ( github.com/labstack/echo/v4 v4.12.0 github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/stripe/stripe-go/v76 v76.25.0 github.com/yuin/goldmark v1.7.4 github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc golang.org/x/crypto v0.26.0 // indirect diff --git a/go.sum b/go.sum index cbe212a..bad5fed 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stripe/stripe-go/v76 v76.25.0 h1:kmDoOTvdQSTQssQzWZQQkgbAR2Q8eXdMWbN/ylNalWA= -github.com/stripe/stripe-go/v76 v76.25.0/go.mod h1:rw1MxjlAKKcZ+3FOXgTHgwiOa2ya6CPq6ykpJ0Q6Po4= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= @@ -68,23 +66,17 @@ golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn5 golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.19.0 h1:D9FX4QWkLfkeqaC62SonffIIuYdOk/UE2XKUBgRIBIQ= golang.org/x/image v0.19.0/go.mod h1:y0zrRqlQRWQ5PXaYCOMLTW2fpsxZ8Qh9I/ohnInJEys= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/lib/stripe.go b/lib/stripe.go deleted file mode 100644 index 2f6b83b..0000000 --- a/lib/stripe.go +++ /dev/null @@ -1,40 +0,0 @@ -package lib - -import ( - "net/http" - "os" - - "github.com/joho/godotenv" - "github.com/stripe/stripe-go/v76" - "github.com/stripe/stripe-go/v76/checkout/session" -) - -// init function -func init() { - godotenv.Load(".env") - stripe.Key = os.Getenv("STRIPE_SECRET_KEY") -} - -func CreateCheckoutSession(w http.ResponseWriter, r *http.Request, successUrl string, cancelUrl string, priceId string) { - params := &stripe.CheckoutSessionParams{ - LineItems: []*stripe.CheckoutSessionLineItemParams{ - { - // Provide the exact Price ID (for example, pr_1234) of the product you want to sell - Price: stripe.String(priceId), - Quantity: stripe.Int64(1), - }, - }, - Mode: stripe.String(string(stripe.CheckoutSessionModePayment)), - SuccessURL: stripe.String(successUrl), - CancelURL: stripe.String(cancelUrl), - AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, - } - - s, err := session.New(params) - - if err != nil { - LogError.Printf("session.New: %v", err) - } - - http.Redirect(w, r, s.URL, http.StatusSeeOther) -} diff --git a/main.go b/main.go index 88dcdca..cec4ed3 100755 --- a/main.go +++ b/main.go @@ -45,8 +45,8 @@ func main() { e.GET("/projects", pages.Projects) e.GET("/talks", pages.Talks) e.GET("/testimonials", pages.Testimonials) - e.GET("/blog", pages.Blog) - e.GET("/post/:post", pages.Post) + e.GET("/posts", pages.Posts) + e.GET("/posts/:post", pages.Post) e.GET("/tools", pages.Tools) e.GET("/tools/resize", pages.Resize) e.GET("/tools/ssedemo", pages.SSEDemo) @@ -54,7 +54,6 @@ func main() { // API Routes: apiGroup := e.Group("/api") apiGroup.GET("/ping", api.Ping) - apiGroup.POST("/pay", api.Pay) apiGroup.GET("/rss", api.RSSFeedHandler) apiGroup.GET("/post/copy", api.PostCopy) diff --git a/pages/home.go b/pages/home.go index 93de2df..0a92b73 100644 --- a/pages/home.go +++ b/pages/home.go @@ -114,9 +114,9 @@ func Home(c echo.Context) error { Internal: true, }, { - Name: "Support 🩵", - Href: "https://donate.stripe.com/8wMeVF25c78L0V2288", - Internal: false, + Name: "Posts", + Href: "/posts", + Internal: true, }, } diff --git a/pages/blog.go b/pages/posts.go similarity index 89% rename from pages/blog.go rename to pages/posts.go index fcc0e12..7a6d195 100644 --- a/pages/blog.go +++ b/pages/posts.go @@ -13,11 +13,11 @@ import ( "github.com/labstack/echo/v4" ) -type BlogProps struct { +type PostsProps struct { Posts []lib.CardLink } -func Blog(c echo.Context) error { +func Posts(c echo.Context) error { var posts []lib.CardLink files, err := fs.ReadDir(contentfs.FS, ".") @@ -36,7 +36,7 @@ func Blog(c echo.Context) error { return nil } - frontMatter.Href = "post/" + strings.TrimSuffix(file.Name(), ".md") + frontMatter.Href = "posts/" + strings.TrimSuffix(file.Name(), ".md") frontMatter.Internal = true posts = append(posts, frontMatter) @@ -59,7 +59,7 @@ func Blog(c echo.Context) error { return iDate.Before(jDate) }) - props := BlogProps{ + props := PostsProps{ Posts: posts, } diff --git a/pages/templates/layouts/post.html b/pages/templates/layouts/post.html index 2e69a3f..39bccc2 100644 --- a/pages/templates/layouts/post.html +++ b/pages/templates/layouts/post.html @@ -42,7 +42,7 @@ - + Back diff --git a/pages/templates/blog.html b/pages/templates/posts.html similarity index 100% rename from pages/templates/blog.html rename to pages/templates/posts.html