images to enrich switch data

This commit is contained in:
Cadey Ratio 2020-01-18 15:18:11 -05:00
parent a7a7bd08bd
commit 2ac8f81c9f
8 changed files with 27 additions and 9 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/hex" "encoding/hex"
"flag" "flag"
"net/http" "net/http"
"strings"
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
@ -80,8 +81,6 @@ var publicRoutes map[string]bool
func init() { func init() {
publicRoutes = map[string]bool{ publicRoutes = map[string]bool{
"/webhooks/": true,
"/static/": true,
"/static/main.js": true, "/static/main.js": true,
"/static/gruvbox.css": true, "/static/gruvbox.css": true,
"/static/favicon.ico": true, "/static/favicon.ico": true,
@ -89,7 +88,6 @@ func init() {
"/debug/requests": true, "/debug/requests": true,
"/debug/events": true, "/debug/events": true,
"/sign-in": true, "/sign-in": true,
"/switch": true,
} }
} }
@ -105,19 +103,27 @@ func (pm PasetoMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var newFooter string var newFooter string
var err error var err error
if r.URL.EscapedPath() == "/.within/botinfo" || r.URL.EscapedPath() == "/" { if r.URL.Path == "/.within/botinfo" || r.URL.Path == "/" {
goto ok
}
if strings.HasPrefix(r.URL.Path, "/webhooks/") {
goto ok
}
if strings.HasPrefix(r.URL.Path, "/static/img") {
goto ok goto ok
} }
for k := range publicRoutes { for k := range publicRoutes {
if r.URL.EscapedPath() == k { if r.URL.Path == k {
goto ok goto ok
} }
} }
err = pm.v2.Verify(tok, pm.pubKey, &newJsonToken, &newFooter) err = pm.v2.Verify(tok, pm.pubKey, &newJsonToken, &newFooter)
if err != nil { if err != nil {
http.Error(w, "Not allowed", http.StatusForbidden) http.Redirect(w, r, "/sign-in", http.StatusTemporaryRedirect)
return return
} }

View File

@ -5,6 +5,8 @@ import Element.Font as Font
import Element.Input as Input import Element.Input as Input
import Generated.Params as Params import Generated.Params as Params
import Global import Global
import Html
import Html.Attributes
import Http import Http
import Iso8601 import Iso8601
import Json.Decode import Json.Decode
@ -170,7 +172,17 @@ view model =
in in
column column
[] []
[ el [ Font.size 30 ] (text data.who) [ row []
[ html
(Html.img
[ Html.Attributes.src ("/static/img/" ++ String.toLower data.who ++ ".png")
, Html.Attributes.width 64
, Html.Attributes.height 64
]
[]
)
, el [ Font.size 30 ] (text data.who)
]
, text ("started at " ++ startTime) , text ("started at " ++ startTime)
] ]
@ -188,7 +200,7 @@ view model =
Input.button [] { onPress = Just NextPage, label = text "Next" } Input.button [] { onPress = Just NextPage, label = text "Next" }
tableButtons = tableButtons =
row [] [ prevButton, nextButton ] row [] [ prevButton, text "-", nextButton ]
switchDataTable = switchDataTable =
case model.frontData of case model.frontData of
@ -215,7 +227,7 @@ view model =
, mouseOver [ alpha 0.5 ] , mouseOver [ alpha 0.5 ]
] ]
{ label = text (String.slice 0 10 switch.id) { label = text (String.slice 0 10 switch.id)
, url = "/switch/" ++ switch.id , url = "/switch/id/" ++ switch.id
} }
} }
, { header = text "Who" , { header = text "Who"

BIN
static/img/ashe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
static/img/cadey.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
static/img/jessie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
static/img/mai.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
static/img/nicole.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
static/img/sephie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB