Shop improvements
This commit is contained in:
parent
aec23d0b6e
commit
16ab79b3a8
8
main.go
8
main.go
@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/pages/artworks"
|
"github.com/animenotifier/notify.moe/pages/artworks"
|
||||||
"github.com/animenotifier/notify.moe/pages/best"
|
"github.com/animenotifier/notify.moe/pages/best"
|
||||||
"github.com/animenotifier/notify.moe/pages/character"
|
"github.com/animenotifier/notify.moe/pages/character"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/charge"
|
||||||
"github.com/animenotifier/notify.moe/pages/dashboard"
|
"github.com/animenotifier/notify.moe/pages/dashboard"
|
||||||
"github.com/animenotifier/notify.moe/pages/editanime"
|
"github.com/animenotifier/notify.moe/pages/editanime"
|
||||||
"github.com/animenotifier/notify.moe/pages/embed"
|
"github.com/animenotifier/notify.moe/pages/embed"
|
||||||
@ -25,6 +26,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/pages/forum"
|
"github.com/animenotifier/notify.moe/pages/forum"
|
||||||
"github.com/animenotifier/notify.moe/pages/forums"
|
"github.com/animenotifier/notify.moe/pages/forums"
|
||||||
"github.com/animenotifier/notify.moe/pages/home"
|
"github.com/animenotifier/notify.moe/pages/home"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/inventory"
|
||||||
"github.com/animenotifier/notify.moe/pages/listimport"
|
"github.com/animenotifier/notify.moe/pages/listimport"
|
||||||
"github.com/animenotifier/notify.moe/pages/listimport/listimportanilist"
|
"github.com/animenotifier/notify.moe/pages/listimport/listimportanilist"
|
||||||
"github.com/animenotifier/notify.moe/pages/listimport/listimportkitsu"
|
"github.com/animenotifier/notify.moe/pages/listimport/listimportkitsu"
|
||||||
@ -95,7 +97,6 @@ func configure(app *aero.Application) *aero.Application {
|
|||||||
app.Ajax("/users/anime/watching", users.AnimeWatching)
|
app.Ajax("/users/anime/watching", users.AnimeWatching)
|
||||||
app.Ajax("/statistics", statistics.Get)
|
app.Ajax("/statistics", statistics.Get)
|
||||||
app.Ajax("/statistics/anime", statistics.Anime)
|
app.Ajax("/statistics/anime", statistics.Anime)
|
||||||
app.Ajax("/shop", shop.Get)
|
|
||||||
app.Ajax("/login", login.Get)
|
app.Ajax("/login", login.Get)
|
||||||
|
|
||||||
// User profiles
|
// User profiles
|
||||||
@ -125,6 +126,11 @@ func configure(app *aero.Application) *aero.Application {
|
|||||||
app.Ajax("/search", search.Get)
|
app.Ajax("/search", search.Get)
|
||||||
app.Ajax("/search/:term", search.Get)
|
app.Ajax("/search/:term", search.Get)
|
||||||
|
|
||||||
|
// Shop
|
||||||
|
app.Ajax("/shop", shop.Get)
|
||||||
|
app.Ajax("/inventory", inventory.Get)
|
||||||
|
app.Ajax("/charge", charge.Get)
|
||||||
|
|
||||||
// Admin
|
// Admin
|
||||||
app.Ajax("/admin", admin.Get)
|
app.Ajax("/admin", admin.Get)
|
||||||
app.Ajax("/admin/anilist", admin.AniList)
|
app.Ajax("/admin/anilist", admin.AniList)
|
||||||
|
21
pages/charge/charge.go
Normal file
21
pages/charge/charge.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package charge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get charge page.
|
||||||
|
func Get(ctx *aero.Context) string {
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.Charge())
|
||||||
|
}
|
3
pages/charge/charge.pixy
Normal file
3
pages/charge/charge.pixy
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
component Charge
|
||||||
|
ShopTabs
|
||||||
|
p Coming soon.
|
29
pages/inventory/inventory.go
Normal file
29
pages/inventory/inventory.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package inventory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get inventory page.
|
||||||
|
func Get(ctx *aero.Context) string {
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
inventory, err := arn.GetInventory(user.ID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusInternalServerError, "Error fetching inventory data", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.Inventory(inventory))
|
||||||
|
}
|
7
pages/inventory/inventory.pixy
Normal file
7
pages/inventory/inventory.pixy
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
component Inventory(inventory *arn.Inventory)
|
||||||
|
ShopTabs
|
||||||
|
.inventory
|
||||||
|
each slot in inventory.Slots
|
||||||
|
.inventory-slot
|
||||||
|
span= slot.ItemID
|
||||||
|
p Coming soon.
|
0
pages/inventory/inventory.scarlet
Normal file
0
pages/inventory/inventory.scarlet
Normal file
@ -1,9 +0,0 @@
|
|||||||
PRO account for 1 anime season (3 months).
|
|
||||||
|
|
||||||
Includes:
|
|
||||||
|
|
||||||
* Avatar highlight on the forums
|
|
||||||
* Customizable cover image for your profile
|
|
||||||
* Custom title for profile and forums
|
|
||||||
* Your suggestions will have a high priority
|
|
||||||
* Access to the VIP channel on Discord
|
|
@ -1,21 +1,15 @@
|
|||||||
package shop
|
package shop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var proAccount = ""
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
data, _ := ioutil.ReadFile("pages/shop/pro-account.md")
|
|
||||||
proAccount = string(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get shop page.
|
// Get shop page.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
@ -24,5 +18,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.Shop(user, proAccount))
|
items := arn.AllItems()
|
||||||
|
|
||||||
|
return ctx.HTML(components.Shop(user, items))
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,26 @@
|
|||||||
component Shop(user *arn.User, proAccountMarkdown string)
|
component Shop(user *arn.User, items []*arn.Item)
|
||||||
h1.page-title Shop
|
h1.page-title Shop
|
||||||
|
|
||||||
.user-balance-bar
|
ShopTabs
|
||||||
Icon("diamond")
|
|
||||||
span.user-balance 0
|
|
||||||
|
|
||||||
.tabs
|
|
||||||
.tab Goods
|
|
||||||
.tab Top-Up
|
|
||||||
|
|
||||||
.widgets.shop-items
|
.widgets.shop-items
|
||||||
ShopItem("PRO Account", "3 months", "900", "star", proAccountMarkdown)
|
each item in items
|
||||||
ShopItem("PRO Account", "6 months", "1700", "star", strings.Replace(strings.Replace(proAccountMarkdown, "3 months", "6 months", 1), "1 anime season", "2 anime seasons", 1))
|
ShopItem(item)
|
||||||
ShopItem("PRO Account", "1 year", "3000", "star", strings.Replace(strings.Replace(proAccountMarkdown, "3 months", "12 months", 1), "1 anime season", "4 anime seasons", 1))
|
|
||||||
ShopItem("PRO Account", "2 years", "5900", "star", strings.Replace(strings.Replace(proAccountMarkdown, "3 months", "24 months", 1), "1 anime season", "8 anime seasons", 1))
|
|
||||||
ShopItem("Anime Support Ticket", "", "100", "ticket", "Support the makers of your favourite anime by using an anime support ticket. Anime Notifier uses 8% of the money to handle the transaction fees while the remaining 92% go directly to the studios involved in the creation of your favourite anime.")
|
|
||||||
|
|
||||||
component ShopItem(name string, duration string, price string, icon string, description string)
|
component ShopTabs
|
||||||
.widget.shop-item
|
.tabs
|
||||||
|
Tab("Shop", "shopping-cart", "/shop")
|
||||||
|
Tab("Inventory", "briefcase", "/inventory")
|
||||||
|
Tab("0", "diamond", "/charge")
|
||||||
|
|
||||||
|
component ShopItem(item *arn.Item)
|
||||||
|
.widget.shop-item.mountable
|
||||||
h3.widget-title.shop-item-name
|
h3.widget-title.shop-item-name
|
||||||
Icon(icon)
|
Icon(item.Icon)
|
||||||
span= name
|
span= item.Name
|
||||||
span.shop-item-duration= " " + duration
|
//- span.shop-item-duration= " " + duration
|
||||||
.shop-item-description!= aero.Markdown(description)
|
.shop-item-description!= aero.Markdown(item.Description)
|
||||||
.buttons.shop-buttons
|
.buttons.shop-buttons
|
||||||
button.shop-button-buy
|
button.shop-button-buy
|
||||||
span.shop-item-price= price
|
span.shop-item-price= item.Price
|
||||||
Icon("diamond")
|
Icon("diamond")
|
@ -26,8 +26,3 @@
|
|||||||
.icon-diamond
|
.icon-diamond
|
||||||
margin-left 0.3rem
|
margin-left 0.3rem
|
||||||
margin-right 0
|
margin-right 0
|
||||||
|
|
||||||
.user-balance-bar
|
|
||||||
text-align center
|
|
||||||
font-size 2.5rem
|
|
||||||
margin-bottom 2rem
|
|
@ -12,18 +12,15 @@ func main() {
|
|||||||
|
|
||||||
// Get a stream of all users
|
// Get a stream of all users
|
||||||
allUsers, err := arn.StreamUsers()
|
allUsers, err := arn.StreamUsers()
|
||||||
|
arn.PanicOnError(err)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate over the stream
|
// Iterate over the stream
|
||||||
for user := range allUsers {
|
for user := range allUsers {
|
||||||
// exists, err := arn.DB.Exists("UserFollows", user.ID)
|
exists, err := arn.DB.Exists("UserFollows", user.ID)
|
||||||
|
|
||||||
// if err != nil || exists {
|
if err != nil || exists {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
|
|
||||||
fmt.Println(user.Nick)
|
fmt.Println(user.Nick)
|
||||||
|
|
||||||
|
36
patches/add-inventories/add-inventories.go
Normal file
36
patches/add-inventories/add-inventories.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/fatih/color"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
color.Yellow("Adding inventories to users who don't have one")
|
||||||
|
|
||||||
|
// Get a stream of all users
|
||||||
|
allUsers, err := arn.StreamUsers()
|
||||||
|
arn.PanicOnError(err)
|
||||||
|
|
||||||
|
// Iterate over the stream
|
||||||
|
for user := range allUsers {
|
||||||
|
exists, err := arn.DB.Exists("Inventory", user.ID)
|
||||||
|
|
||||||
|
if err != nil || exists {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(user.Nick)
|
||||||
|
|
||||||
|
inventory := arn.NewInventory(user.ID)
|
||||||
|
err = arn.DB.Set("Inventory", inventory.UserID, inventory)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
color.Red(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
color.Green("Finished.")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user