From 5bac14459f512ffee1f321835bb0ce4c6becb15b Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Fri, 22 Sep 2023 02:04:04 +0100 Subject: [PATCH] Add battlenet and domain, improve rendering --- module/discord/main.go | 20 +- .../discord/pages/assets/icon/battlenet.svg | 3 + module/discord/pages/assets/icon/domain.svg | 5 + module/discord/pages/index.go.html | 193 +++++++++--------- 4 files changed, 120 insertions(+), 101 deletions(-) create mode 100644 module/discord/pages/assets/icon/battlenet.svg create mode 100644 module/discord/pages/assets/icon/domain.svg diff --git a/module/discord/main.go b/module/discord/main.go index 88a1ac9..af5d3a1 100644 --- a/module/discord/main.go +++ b/module/discord/main.go @@ -108,27 +108,27 @@ func (m *Module) homepage(rw http.ResponseWriter, _ *http.Request, state *utils. return } - guildIcons := make([]template.HTMLAttr, len(myGuilds)) + guildIcons := make([]string, len(myGuilds)) for i, j := range myGuilds { var a discordgo.Guild a.ID = j.ID a.Icon = j.Icon - guildIcons[i] = template.HTMLAttr(fmt.Sprintf("src=\"%s\"", a.IconURL())) + guildIcons[i] = a.IconURL() } err = tmp.Execute(rw, struct { User *discordgo.User UserAccent string - Avatar template.HTMLAttr - Banner template.HTMLAttr + Avatar string + Banner string Guilds []*discordgo.UserGuild - GuildIcons []template.HTMLAttr + GuildIcons []string Connections []*discordgo.UserConnection }{ User: myUser, UserAccent: fmt.Sprintf("#%06x", myUser.AccentColor), - Avatar: template.HTMLAttr(fmt.Sprintf("src=\"%s\"", myUser.AvatarURL("256"))), - Banner: template.HTMLAttr(fmt.Sprintf("src=\"%s\"", myUser.BannerURL("256"))), + Avatar: myUser.AvatarURL("256"), + Banner: myUser.BannerURL("256"), Guilds: myGuilds, GuildIcons: guildIcons, Connections: myConns, @@ -180,6 +180,8 @@ func (m *Module) loginPage(rw http.ResponseWriter, req *http.Request, state *uti func connectedLinkFunc(a *discordgo.UserConnection) string { switch a.Type { + case "domain": + return "https://" + a.Name case "github": return "https://github.com/" + a.Name case "reddit": @@ -192,10 +194,8 @@ func connectedLinkFunc(a *discordgo.UserConnection) string { return "https://www.twitch.tv/" + a.Name case "twitter": return "https://twitter.com/" + a.Name - case "xbox": - return "javascript:alert('No link to XBox profiles')" case "youtube": return "https://www.youtube.com/channel/" + a.ID } - return "javascript:alert('Unknown profile type')" + return "" } diff --git a/module/discord/pages/assets/icon/battlenet.svg b/module/discord/pages/assets/icon/battlenet.svg new file mode 100644 index 0000000..8176bec --- /dev/null +++ b/module/discord/pages/assets/icon/battlenet.svg @@ -0,0 +1,3 @@ + + + diff --git a/module/discord/pages/assets/icon/domain.svg b/module/discord/pages/assets/icon/domain.svg new file mode 100644 index 0000000..a4a015d --- /dev/null +++ b/module/discord/pages/assets/icon/domain.svg @@ -0,0 +1,5 @@ + + + diff --git a/module/discord/pages/index.go.html b/module/discord/pages/index.go.html index 24cb4bc..26dca93 100644 --- a/module/discord/pages/index.go.html +++ b/module/discord/pages/index.go.html @@ -14,12 +14,21 @@ } .page-content { + + } + + .page-row { display: flex; flex-direction: row; align-items: flex-start; flex-wrap: wrap; } + .page-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); + } + .connected-accounts li a[data-is-revoked=true] { border: 2px solid red; } @@ -41,102 +50,104 @@

Discord | Melon Tools

-
- {{with .User}} -

My User: {{.Username}}#{{.Discriminator}}

-
    -
  • ID: {{.ID}}
  • -
  • Email: {{.Email}}
  • -
  • Username: {{.Username}}
  • -
  • Avatar: User Avatar
  • -
  • Locale: {{.Locale}}
  • -
  • Discriminator: {{.Discriminator}}
  • -
  • Verified: {{.Verified}}
  • -
  • MFA: {{.MFAEnabled}}
  • -
  • Banner: User Banner
  • -
  • Accent Color: {{$.UserAccent}}   -
  • -
  • Bot: {{.Bot}}
  • -
  • Premium: {{.PremiumType}}
  • -
  • System: {{.System}}
  • -
- {{end}} -
-
- {{with .User.PublicFlags}} -

My Flags:

-
    - {{if checkFlag . 1}} -
  • Discord Employee
  • - {{end}} - {{if checkFlag . 2}} -
  • Discord Partner
  • - {{end}} - {{if checkFlag . 4}} -
  • Hype Squad Events
  • - {{end}} - {{if checkFlag . 8}} -
  • Bug Hunter Level 1
  • - {{end}} - {{if checkFlag . 64}} -
  • House Bravery
  • - {{end}} - {{if checkFlag . 128}} -
  • House Brilliance
  • - {{end}} - {{if checkFlag . 256}} -
  • House Balance
  • - {{end}} - {{if checkFlag . 512}} -
  • Early Supporter
  • - {{end}} - {{if checkFlag . 1024}} -
  • Team User
  • - {{end}} - {{if checkFlag . 4096}} -
  • System
  • - {{end}} - {{if checkFlag . 16384}} -
  • Bug Hunter Level 2
  • - {{end}} - {{if checkFlag . 65536}} -
  • Verified Bot
  • - {{end}} - {{if checkFlag . 131072}} -
  • Verified Bot Developer
  • - {{end}} - {{if checkFlag . 262144}} -
  • Discord Certified Moderator
  • - {{end}} - {{if checkFlag . 524288}} -
  • Bot HTTP interactions
  • - {{end}} - {{if checkFlag . 4194304}} -
  • Active Developer
  • - {{end}} -
- {{end}} -
-
-

Connections ({{len .Connections}}):

-
    - {{range .Connections}} -
  • - - - {{.Name}} - -
  • +
    +
    + {{with .User}} +

    My User: {{.Username}}#{{.Discriminator}}

    +
      +
    • ID: {{.ID}}
    • +
    • Email: {{.Email}}
    • +
    • Username: {{.Username}}
    • +
    • Avatar: User Avatar
    • +
    • Locale: {{.Locale}}
    • +
    • Discriminator: {{.Discriminator}}
    • +
    • Verified: {{.Verified}}
    • +
    • MFA: {{.MFAEnabled}}
    • +
    • Banner: User Banner
    • +
    • Accent Color: {{$.UserAccent}}   +
    • +
    • Bot: {{.Bot}}
    • +
    • Premium: {{.PremiumType}}
    • +
    • System: {{.System}}
    • +
    {{end}} -
+
+
+ {{with .User.PublicFlags}} +

My Flags:

+
    + {{if checkFlag . 1}} +
  • Discord Employee
  • + {{end}} + {{if checkFlag . 2}} +
  • Discord Partner
  • + {{end}} + {{if checkFlag . 4}} +
  • Hype Squad Events
  • + {{end}} + {{if checkFlag . 8}} +
  • Bug Hunter Level 1
  • + {{end}} + {{if checkFlag . 64}} +
  • House Bravery
  • + {{end}} + {{if checkFlag . 128}} +
  • House Brilliance
  • + {{end}} + {{if checkFlag . 256}} +
  • House Balance
  • + {{end}} + {{if checkFlag . 512}} +
  • Early Supporter
  • + {{end}} + {{if checkFlag . 1024}} +
  • Team User
  • + {{end}} + {{if checkFlag . 4096}} +
  • System
  • + {{end}} + {{if checkFlag . 16384}} +
  • Bug Hunter Level 2
  • + {{end}} + {{if checkFlag . 65536}} +
  • Verified Bot
  • + {{end}} + {{if checkFlag . 131072}} +
  • Verified Bot Developer
  • + {{end}} + {{if checkFlag . 262144}} +
  • Discord Certified Moderator
  • + {{end}} + {{if checkFlag . 524288}} +
  • Bot HTTP interactions
  • + {{end}} + {{if checkFlag . 4194304}} +
  • Active Developer
  • + {{end}} +
+ {{end}} +
+
+

Connections ({{len .Connections}}):

+ +
-
+

Guilds ({{len .Guilds}}):

-
+
{{range $k, $v := .Guilds}}
-
+
Icon for {{$v.Name}}
{{$v.Name}}
@*{{$v.ID}}