Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Merge of emoji + autolink + embed + etc (#108)
Gabe Kangasb9a6d504afe9
diff --git a/controllers/emoji.go b/controllers/emoji.gonew file mode 100644index 0000000000..3c2f64af10--- /dev/null+++ b/controllers/emoji.go@@ -0,0 +1,42 @@+package controllers++import (+ "encoding/json"+ "io/ioutil"+ "net/http"+ "path"+ "path/filepath"+ "strings"++ "github.com/gabek/owncast/models"+ log "github.com/sirupsen/logrus"+)++// Make this path configurable if somebody has a valid reason+// to need it to be. The config is getting a bit bloated.+const emojiPath = "/img/emoji" // Relative to webroot++//GetCustomEmoji returns a list of custom emoji via the API+func GetCustomEmoji(w http.ResponseWriter, r *http.Request) {+ emojiList := make([]models.CustomEmoji, 0)++ fullPath := filepath.Join("webroot", emojiPath)+ files, err := ioutil.ReadDir(fullPath)+ if err != nil {+ log.Errorln(err)+ // Throw HTTP 500+ return+ }++ // Memoize this result somewhere? Right now it iterates through the+ // filesystem every time the API is hit. Should you need to restart+ // the server to add emoji?+ for _, f := range files {+ name := strings.TrimSuffix(f.Name(), path.Ext(f.Name()))+ path := filepath.Join(emojiPath, f.Name())+ singleEmoji := models.CustomEmoji{name, path}+ emojiList = append(emojiList, singleEmoji)+ }++ json.NewEncoder(w).Encode(emojiList)+}diff --git a/models/emoji.go b/models/emoji.gonew file mode 100644index 0000000000..e63e7725d6--- /dev/null+++ b/models/emoji.go@@ -0,0 +1,7 @@+package models++//CustomEmoji represents an image that can be used in chat as a custom emoji+type CustomEmoji struct {+ Name string `json:"name"`+ Emoji string `json:"emoji"`+}diff --git a/router/router.go b/router/router.goindex 9cdc6f4e28..13633552f7 100644--- a/router/router.go+++ b/router/router.go@@ -23,6 +23,9 @@ func Start() error {// status of the systemhttp.HandleFunc("/status", controllers.GetStatus)+ // custom emoji supported in the chat+ http.HandleFunc("/emoji", controllers.GetCustomEmoji)+if !config.Config.DisableWebFeatures {// websocket chat servergo chat.Start()diff --git a/webroot/img/emoji/Reaper-gg.png b/webroot/img/emoji/Reaper-gg.pngnew file mode 100644index 0000000000..e07b557fe5Binary files /dev/null and b/webroot/img/emoji/Reaper-gg.png differdiff --git a/webroot/img/emoji/Reaper-hi.png b/webroot/img/emoji/Reaper-hi.pngnew file mode 100644index 0000000000..9ef837752dBinary files /dev/null and b/webroot/img/emoji/Reaper-hi.png differdiff --git a/webroot/img/emoji/Reaper-hype.png b/webroot/img/emoji/Reaper-hype.pngnew file mode 100644index 0000000000..1a14e337d4Binary files /dev/null and b/webroot/img/emoji/Reaper-hype.png differdiff --git a/webroot/img/emoji/Reaper-lol.png b/webroot/img/emoji/Reaper-lol.pngnew file mode 100644index 0000000000..453bf0c236Binary files /dev/null and b/webroot/img/emoji/Reaper-lol.png differdiff --git a/webroot/img/emoji/Reaper-love.png b/webroot/img/emoji/Reaper-love.pngnew file mode 100644index 0000000000..63ad349c8eBinary files /dev/null and b/webroot/img/emoji/Reaper-love.png differdiff --git a/webroot/img/emoji/Reaper-rage.png b/webroot/img/emoji/Reaper-rage.pngnew file mode 100644index 0000000000..b05520018bBinary files /dev/null and b/webroot/img/emoji/Reaper-rage.png differdiff --git a/webroot/img/emoji/Reaper-rip.png b/webroot/img/emoji/Reaper-rip.pngnew file mode 100644index 0000000000..2e8cd2540fBinary files /dev/null and b/webroot/img/emoji/Reaper-rip.png differdiff --git a/webroot/img/emoji/Reaper-wtf.png b/webroot/img/emoji/Reaper-wtf.pngnew file mode 100644index 0000000000..bb58e68e57Binary files /dev/null and b/webroot/img/emoji/Reaper-wtf.png differdiff --git a/webroot/img/emoji/ac-box.png b/webroot/img/emoji/ac-box.pngnew file mode 100644index 0000000000..368cc4bef8Binary files /dev/null and b/webroot/img/emoji/ac-box.png differdiff --git a/webroot/img/emoji/ac-construction.png b/webroot/img/emoji/ac-construction.pngnew file mode 100644index 0000000000..8a683b440dBinary files /dev/null and b/webroot/img/emoji/ac-construction.png differdiff --git a/webroot/img/emoji/ac-fossil.png b/webroot/img/emoji/ac-fossil.pngnew file mode 100644index 0000000000..96b22540aeBinary files /dev/null and b/webroot/img/emoji/ac-fossil.png differdiff --git a/webroot/img/emoji/ac-item-leaf.png b/webroot/img/emoji/ac-item-leaf.pngnew file mode 100644index 0000000000..27c5be89ffBinary files /dev/null and b/webroot/img/emoji/ac-item-leaf.png differdiff --git a/webroot/img/emoji/ac-kkslider.png b/webroot/img/emoji/ac-kkslider.pngnew file mode 100644index 0000000000..c4b86a2ffbBinary files /dev/null and b/webroot/img/emoji/ac-kkslider.png differdiff --git a/webroot/img/emoji/ac-moneytree.png b/webroot/img/emoji/ac-moneytree.pngnew file mode 100644index 0000000000..6dd27dfd05Binary files /dev/null and b/webroot/img/emoji/ac-moneytree.png differdiff --git a/webroot/img/emoji/ac-mosquito.png b/webroot/img/emoji/ac-mosquito.pngnew file mode 100644index 0000000000..22538769edBinary files /dev/null and b/webroot/img/emoji/ac-mosquito.png differdiff --git a/webroot/img/emoji/ac-shirt.png b/webroot/img/emoji/ac-shirt.pngnew file mode 100644index 0000000000..166cbf88feBinary files /dev/null and b/webroot/img/emoji/ac-shirt.png differdiff --git a/webroot/img/emoji/ac-song.png b/webroot/img/emoji/ac-song.pngnew file mode 100644index 0000000000..73eb177af3Binary files /dev/null and b/webroot/img/emoji/ac-song.png differdiff --git a/webroot/img/emoji/ac-tree.png b/webroot/img/emoji/ac-tree.pngnew file mode 100644index 0000000000..2cb0f496ffBinary files /dev/null and b/webroot/img/emoji/ac-tree.png differdiff --git a/webroot/img/emoji/ac-turnip.png b/webroot/img/emoji/ac-turnip.pngnew file mode 100644index 0000000000..f0c2f7f704Binary files /dev/null and b/webroot/img/emoji/ac-turnip.png differdiff --git a/webroot/img/emoji/ac-weeds.png b/webroot/img/emoji/ac-weeds.pngnew file mode 100644index 0000000000..58a6db19c7Binary files /dev/null and b/webroot/img/emoji/ac-weeds.png differdiff --git a/webroot/img/emoji/alert.gif b/webroot/img/emoji/alert.gifnew file mode 100644index 0000000000..82b7840a25Binary files /dev/null and b/webroot/img/emoji/alert.gif differdiff --git a/webroot/img/emoji/bananadance.gif b/webroot/img/emoji/bananadance.gifnew file mode 100644index 0000000000..aac532b003Binary files /dev/null and b/webroot/img/emoji/bananadance.gif differdiff --git a/webroot/img/emoji/bb8.png b/webroot/img/emoji/bb8.pngnew file mode 100644index 0000000000..9e05109aeaBinary files /dev/null and b/webroot/img/emoji/bb8.png differdiff --git a/webroot/img/emoji/beerparrot.gif b/webroot/img/emoji/beerparrot.gifnew file mode 100644index 0000000000..d2a6d25fa0Binary files /dev/null and b/webroot/img/emoji/beerparrot.gif differdiff --git a/webroot/img/emoji/bells.png b/webroot/img/emoji/bells.pngnew file mode 100644index 0000000000..9b55f45f5fBinary files /dev/null and b/webroot/img/emoji/bells.png differdiff --git a/webroot/img/emoji/birthdaypartyparrot.gif b/webroot/img/emoji/birthdaypartyparrot.gifnew file mode 100644index 0000000000..827c908918Binary files /dev/null and b/webroot/img/emoji/birthdaypartyparrot.gif differdiff --git a/webroot/img/emoji/blacklightsaber.png b/webroot/img/emoji/blacklightsaber.pngnew file mode 100644index 0000000000..db8d68dbc8Binary files /dev/null and b/webroot/img/emoji/blacklightsaber.png differdiff --git a/webroot/img/emoji/bluelightsaber.png b/webroot/img/emoji/bluelightsaber.pngnew file mode 100644index 0000000000..77b8fd35e3Binary files /dev/null and b/webroot/img/emoji/bluelightsaber.png differdiff --git a/webroot/img/emoji/bluntparrot.gif b/webroot/img/emoji/bluntparrot.gifnew file mode 100644index 0000000000..4f7e59e4d1Binary files /dev/null and b/webroot/img/emoji/bluntparrot.gif differdiff --git a/webroot/img/emoji/bobaparrot.gif b/webroot/img/emoji/bobaparrot.gifnew file mode 100644index 0000000000..171f5ddc05Binary files /dev/null and b/webroot/img/emoji/bobaparrot.gif differdiff --git a/webroot/img/emoji/cakeparrot.gif b/webroot/img/emoji/cakeparrot.gifnew file mode 100644index 0000000000..dd3f200be1Binary files /dev/null and b/webroot/img/emoji/cakeparrot.gif differdiff --git a/webroot/img/emoji/chewbacca.png b/webroot/img/emoji/chewbacca.pngnew file mode 100644index 0000000000..956f735c47Binary files /dev/null and b/webroot/img/emoji/chewbacca.png differdiff --git a/webroot/img/emoji/chillparrot.gif b/webroot/img/emoji/chillparrot.gifnew file mode 100644index 0000000000..6fbe4c2f1eBinary files /dev/null and b/webroot/img/emoji/chillparrot.gif differdiff --git a/webroot/img/emoji/christmasparrot.gif b/webroot/img/emoji/christmasparrot.gifnew file mode 100644index 0000000000..6ab963589dBinary files /dev/null and b/webroot/img/emoji/christmasparrot.gif differdiff --git a/webroot/img/emoji/coffeeparrot.gif b/webroot/img/emoji/coffeeparrot.gifnew file mode 100644index 0000000000..33a9597276Binary files /dev/null and b/webroot/img/emoji/coffeeparrot.gif differdiff --git a/webroot/img/emoji/confusedparrot.gif b/webroot/img/emoji/confusedparrot.gifnew file mode 100644index 0000000000..e641f43937Binary files /dev/null and b/webroot/img/emoji/confusedparrot.gif differdiff --git a/webroot/img/emoji/copparrot.gif b/webroot/img/emoji/copparrot.gifnew file mode 100644index 0000000000..31904cc9d5Binary files /dev/null and b/webroot/img/emoji/copparrot.gif differdiff --git a/webroot/img/emoji/coronavirus.png b/webroot/img/emoji/coronavirus.pngnew file mode 100644index 0000000000..9865ba318bBinary files /dev/null and b/webroot/img/emoji/coronavirus.png differdiff --git a/webroot/img/emoji/covid19parrot.gif b/webroot/img/emoji/covid19parrot.gifnew file mode 100644index 0000000000..ca9f0a99daBinary files /dev/null and b/webroot/img/emoji/covid19parrot.gif differdiff --git a/webroot/img/emoji/cryptoparrot.gif b/webroot/img/emoji/cryptoparrot.gifnew file mode 100644index 0000000000..81d00917c3Binary files /dev/null and b/webroot/img/emoji/cryptoparrot.gif differdiff --git a/webroot/img/emoji/dabparrot.gif b/webroot/img/emoji/dabparrot.gifnew file mode 100644index 0000000000..d7d0981de2Binary files /dev/null and b/webroot/img/emoji/dabparrot.gif differdiff --git a/webroot/img/emoji/dadparrot.gif b/webroot/img/emoji/dadparrot.gifnew file mode 100644index 0000000000..9f129d90ecBinary files /dev/null and b/webroot/img/emoji/dadparrot.gif differdiff --git a/webroot/img/emoji/daftpunkparrot.gif b/webroot/img/emoji/daftpunkparrot.gifnew file mode 100644index 0000000000..9d1adef742Binary files /dev/null and b/webroot/img/emoji/daftpunkparrot.gif differdiff --git a/webroot/img/emoji/darkbeerparrot.gif b/webroot/img/emoji/darkbeerparrot.gifnew file mode 100644index 0000000000..8562d7b7a0Binary files /dev/null and b/webroot/img/emoji/darkbeerparrot.gif differdiff --git a/webroot/img/emoji/darkmodeparrot.gif b/webroot/img/emoji/darkmodeparrot.gifnew file mode 100644index 0000000000..78b7f83ab0Binary files /dev/null and b/webroot/img/emoji/darkmodeparrot.gif differdiff --git a/webroot/img/emoji/darth_vader.png b/webroot/img/emoji/darth_vader.pngnew file mode 100644index 0000000000..040363bc68Binary files /dev/null and b/webroot/img/emoji/darth_vader.png differdiff --git a/webroot/img/emoji/dealwithitparrot.gif b/webroot/img/emoji/dealwithitparrot.gifnew file mode 100644index 0000000000..f5f149ed3cBinary files /dev/null and b/webroot/img/emoji/dealwithitparrot.gif differdiff --git a/webroot/img/emoji/death_star.png b/webroot/img/emoji/death_star.pngnew file mode 100644index 0000000000..a587ec8b1dBinary files /dev/null and b/webroot/img/emoji/death_star.png differdiff --git a/webroot/img/emoji/discoparrot.gif b/webroot/img/emoji/discoparrot.gifnew file mode 100644index 0000000000..752f843796Binary files /dev/null and b/webroot/img/emoji/discoparrot.gif differdiff --git a/webroot/img/emoji/division-gg.png b/webroot/img/emoji/division-gg.pngnew file mode 100644index 0000000000..58c2cadaf9Binary files /dev/null and b/webroot/img/emoji/division-gg.png differdiff --git a/webroot/img/emoji/division-hi.png b/webroot/img/emoji/division-hi.pngnew file mode 100644index 0000000000..b9c6d626a2Binary files /dev/null and b/webroot/img/emoji/division-hi.png differdiff --git a/webroot/img/emoji/division-hype.png b/webroot/img/emoji/division-hype.pngnew file mode 100644index 0000000000..4639b6660bBinary files /dev/null and b/webroot/img/emoji/division-hype.png differdiff --git a/webroot/img/emoji/division-lol.png b/webroot/img/emoji/division-lol.pngnew file mode 100644index 0000000000..c15f358c67Binary files /dev/null and b/webroot/img/emoji/division-lol.png differdiff --git a/webroot/img/emoji/division-omg.png b/webroot/img/emoji/division-omg.pngnew file mode 100644index 0000000000..4e3b6d2a53Binary files /dev/null and b/webroot/img/emoji/division-omg.png differdiff --git a/webroot/img/emoji/division-rage.png b/webroot/img/emoji/division-rage.pngnew file mode 100644index 0000000000..2f89c4621fBinary files /dev/null and b/webroot/img/emoji/division-rage.png differdiff --git a/webroot/img/emoji/division-rip.png b/webroot/img/emoji/division-rip.pngnew file mode 100644index 0000000000..0ba84c2efcBinary files /dev/null and b/webroot/img/emoji/division-rip.png differdiff --git a/webroot/img/emoji/division-wtf.png b/webroot/img/emoji/division-wtf.pngnew file mode 100644index 0000000000..6d1e07900bBinary files /dev/null and b/webroot/img/emoji/division-wtf.png differdiff --git a/webroot/img/emoji/docparrot.gif b/webroot/img/emoji/docparrot.gifnew file mode 100644index 0000000000..04aedd160dBinary files /dev/null and b/webroot/img/emoji/docparrot.gif differdiff --git a/webroot/img/emoji/donutparrot.gif b/webroot/img/emoji/donutparrot.gifnew file mode 100644index 0000000000..3905bf7b43Binary files /dev/null and b/webroot/img/emoji/donutparrot.gif differdiff --git a/webroot/img/emoji/doom_mad.gif b/webroot/img/emoji/doom_mad.gifnew file mode 100644index 0000000000..e699fe8d7bBinary files /dev/null and b/webroot/img/emoji/doom_mad.gif differdiff --git a/webroot/img/emoji/empire.png b/webroot/img/emoji/empire.pngnew file mode 100644index 0000000000..bae0017bb9Binary files /dev/null and b/webroot/img/emoji/empire.png differdiff --git a/webroot/img/emoji/everythingsfineparrot.gif b/webroot/img/emoji/everythingsfineparrot.gifnew file mode 100644index 0000000000..e25bd7166dBinary files /dev/null and b/webroot/img/emoji/everythingsfineparrot.gif differdiff --git a/webroot/img/emoji/evilparrot.gif b/webroot/img/emoji/evilparrot.gifnew file mode 100644index 0000000000..b1767a3bdeBinary files /dev/null and b/webroot/img/emoji/evilparrot.gif differdiff --git a/webroot/img/emoji/explodyparrot.gif b/webroot/img/emoji/explodyparrot.gifnew file mode 100644index 0000000000..54358e1fffBinary files /dev/null and b/webroot/img/emoji/explodyparrot.gif differdiff --git a/webroot/img/emoji/fixparrot.gif b/webroot/img/emoji/fixparrot.gifnew file mode 100644index 0000000000..72c4b63b40Binary files /dev/null and b/webroot/img/emoji/fixparrot.gif differdiff --git a/webroot/img/emoji/flyingmoneyparrot.gif b/webroot/img/emoji/flyingmoneyparrot.gifnew file mode 100644index 0000000000..fd4146aa8fBinary files /dev/null and b/webroot/img/emoji/flyingmoneyparrot.gif differdiff --git a/webroot/img/emoji/footballparrot.gif b/webroot/img/emoji/footballparrot.gifnew file mode 100644index 0000000000..dd40808349Binary files /dev/null and b/webroot/img/emoji/footballparrot.gif differdiff --git a/webroot/img/emoji/gabe1.png b/webroot/img/emoji/gabe1.pngnew file mode 100644index 0000000000..3cf942f9fdBinary files /dev/null and b/webroot/img/emoji/gabe1.png differdiff --git a/webroot/img/emoji/gabe2.png b/webroot/img/emoji/gabe2.pngnew file mode 100644index 0000000000..987d91cf32Binary files /dev/null and b/webroot/img/emoji/gabe2.png differdiff --git a/webroot/img/emoji/gentlemanparrot.gif b/webroot/img/emoji/gentlemanparrot.gifnew file mode 100644index 0000000000..2996b37d5dBinary files /dev/null and b/webroot/img/emoji/gentlemanparrot.gif differdiff --git a/webroot/img/emoji/githubparrot.gif b/webroot/img/emoji/githubparrot.gifnew file mode 100644index 0000000000..0423502541Binary files /dev/null and b/webroot/img/emoji/githubparrot.gif differdiff --git a/webroot/img/emoji/goomba.gif b/webroot/img/emoji/goomba.gifnew file mode 100644index 0000000000..c6bb719e7eBinary files /dev/null and b/webroot/img/emoji/goomba.gif differdiff --git a/webroot/img/emoji/gothparrot.gif b/webroot/img/emoji/gothparrot.gifnew file mode 100644index 0000000000..eca455ec96Binary files /dev/null and b/webroot/img/emoji/gothparrot.gif differdiff --git a/webroot/img/emoji/hamburgerparrot.gif b/webroot/img/emoji/hamburgerparrot.gifnew file mode 100644index 0000000000..56ba9ec340Binary files /dev/null and b/webroot/img/emoji/hamburgerparrot.gif differdiff --git a/webroot/img/emoji/harrypotterparrot.gif b/webroot/img/emoji/harrypotterparrot.gifnew file mode 100644index 0000000000..f5c43c9f9aBinary files /dev/null and b/webroot/img/emoji/harrypotterparrot.gif differdiff --git a/webroot/img/emoji/headbangingparrot.gif b/webroot/img/emoji/headbangingparrot.gifnew file mode 100644index 0000000000..dcc8df9903Binary files /dev/null and b/webroot/img/emoji/headbangingparrot.gif differdiff --git a/webroot/img/emoji/headingparrot.gif b/webroot/img/emoji/headingparrot.gifnew file mode 100644index 0000000000..a6ee2da694Binary files /dev/null and b/webroot/img/emoji/headingparrot.gif differdiff --git a/webroot/img/emoji/headsetparrot.gif b/webroot/img/emoji/headsetparrot.gifnew file mode 100644index 0000000000..49687070baBinary files /dev/null and b/webroot/img/emoji/headsetparrot.gif differdiff --git a/webroot/img/emoji/hmmparrot.gif b/webroot/img/emoji/hmmparrot.gifnew file mode 100644index 0000000000..d3d5ffe9e0Binary files /dev/null and b/webroot/img/emoji/hmmparrot.gif differdiff --git a/webroot/img/emoji/hypnoparrot.gif b/webroot/img/emoji/hypnoparrot.gifnew file mode 100644index 0000000000..2ccb8fed78Binary files /dev/null and b/webroot/img/emoji/hypnoparrot.gif differdiff --git a/webroot/img/emoji/icecreamparrot.gif b/webroot/img/emoji/icecreamparrot.gifnew file mode 100644index 0000000000..3903121b7cBinary files /dev/null and b/webroot/img/emoji/icecreamparrot.gif differdiff --git a/webroot/img/emoji/illuminatiparrot.gif b/webroot/img/emoji/illuminatiparrot.gifnew file mode 100644index 0000000000..991eb31092Binary files /dev/null and b/webroot/img/emoji/illuminatiparrot.gif differdiff --git a/webroot/img/emoji/jediparrot.gif b/webroot/img/emoji/jediparrot.gifnew file mode 100644index 0000000000..c0be461247Binary files /dev/null and b/webroot/img/emoji/jediparrot.gif differdiff --git a/webroot/img/emoji/keanu_thanks.gif b/webroot/img/emoji/keanu_thanks.gifnew file mode 100644index 0000000000..989b9b7592Binary files /dev/null and b/webroot/img/emoji/keanu_thanks.gif differdiff --git a/webroot/img/emoji/laptop_parrot.gif b/webroot/img/emoji/laptop_parrot.gifnew file mode 100644index 0000000000..1831293241Binary files /dev/null and b/webroot/img/emoji/laptop_parrot.gif differdiff --git a/webroot/img/emoji/loveparrot.gif b/webroot/img/emoji/loveparrot.gifnew file mode 100644index 0000000000..b1dbc41b1dBinary files /dev/null and b/webroot/img/emoji/loveparrot.gif differdiff --git a/webroot/img/emoji/mandalorian.png b/webroot/img/emoji/mandalorian.pngnew file mode 100644index 0000000000..30ac1bea4dBinary files /dev/null and b/webroot/img/emoji/mandalorian.png differdiff --git a/webroot/img/emoji/margaritaparrot.gif b/webroot/img/emoji/margaritaparrot.gifnew file mode 100644index 0000000000..1d6ce4c909Binary files /dev/null and b/webroot/img/emoji/margaritaparrot.gif differdiff --git a/webroot/img/emoji/mario.gif b/webroot/img/emoji/mario.gifnew file mode 100644index 0000000000..87f1133331Binary files /dev/null and b/webroot/img/emoji/mario.gif differdiff --git a/webroot/img/emoji/matrixparrot.gif b/webroot/img/emoji/matrixparrot.gifnew file mode 100644index 0000000000..a7a68a0046Binary files /dev/null and b/webroot/img/emoji/matrixparrot.gif differdiff --git a/webroot/img/emoji/meldparrot.gif b/webroot/img/emoji/meldparrot.gifnew file mode 100644index 0000000000..dd91bbd290Binary files /dev/null and b/webroot/img/emoji/meldparrot.gif differdiff --git a/webroot/img/emoji/metalparrot.gif b/webroot/img/emoji/metalparrot.gifnew file mode 100644index 0000000000..c4209b01c6Binary files /dev/null and b/webroot/img/emoji/metalparrot.gif differdiff --git a/webroot/img/emoji/michaeljacksonparrot.gif b/webroot/img/emoji/michaeljacksonparrot.gifnew file mode 100644index 0000000000..4217ca4e1cBinary files /dev/null and b/webroot/img/emoji/michaeljacksonparrot.gif differdiff --git a/webroot/img/emoji/moonparrot.gif b/webroot/img/emoji/moonparrot.gifnew file mode 100644index 0000000000..ab8241d38dBinary files /dev/null and b/webroot/img/emoji/moonparrot.gif differdiff --git a/webroot/img/emoji/moonwalkingparrot.gif b/webroot/img/emoji/moonwalkingparrot.gifnew file mode 100644index 0000000000..52c5dcf433Binary files /dev/null and b/webroot/img/emoji/moonwalkingparrot.gif differdiff --git a/webroot/img/emoji/mustacheparrot.gif b/webroot/img/emoji/mustacheparrot.gifnew file mode 100644index 0000000000..39b43f231fBinary files /dev/null and b/webroot/img/emoji/mustacheparrot.gif differdiff --git a/webroot/img/emoji/nicolas_cage_party.gif b/webroot/img/emoji/nicolas_cage_party.gifnew file mode 100644index 0000000000..4f523c1382Binary files /dev/null and b/webroot/img/emoji/nicolas_cage_party.gif differdiff --git a/webroot/img/emoji/nodeparrot.gif b/webroot/img/emoji/nodeparrot.gifnew file mode 100644index 0000000000..0a05f59243Binary files /dev/null and b/webroot/img/emoji/nodeparrot.gif differdiff --git a/webroot/img/emoji/norwegianblueparrot.gif b/webroot/img/emoji/norwegianblueparrot.gifnew file mode 100644index 0000000000..0aa9583ec8Binary files /dev/null and b/webroot/img/emoji/norwegianblueparrot.gif differdiff --git a/webroot/img/emoji/opensourceparrot.gif b/webroot/img/emoji/opensourceparrot.gifnew file mode 100644index 0000000000..3904b389eeBinary files /dev/null and b/webroot/img/emoji/opensourceparrot.gif differdiff --git a/webroot/img/emoji/originalparrot.gif b/webroot/img/emoji/originalparrot.gifnew file mode 100644index 0000000000..907b554b8fBinary files /dev/null and b/webroot/img/emoji/originalparrot.gif differdiff --git a/webroot/img/emoji/owncast.png b/webroot/img/emoji/owncast.pngnew file mode 100644index 0000000000..10be70a89fBinary files /dev/null and b/webroot/img/emoji/owncast.png differdiff --git a/webroot/img/emoji/palpatine.png b/webroot/img/emoji/palpatine.pngnew file mode 100644index 0000000000..2053ec3e74Binary files /dev/null and b/webroot/img/emoji/palpatine.png differdiff --git a/webroot/img/emoji/papalparrot.gif b/webroot/img/emoji/papalparrot.gifnew file mode 100644index 0000000000..6fb981ccabBinary files /dev/null and b/webroot/img/emoji/papalparrot.gif differdiff --git a/webroot/img/emoji/parrot.gif b/webroot/img/emoji/parrot.gifnew file mode 100644index 0000000000..458ad859deBinary files /dev/null and b/webroot/img/emoji/parrot.gif differdiff --git a/webroot/img/emoji/parrotnotfound.gif b/webroot/img/emoji/parrotnotfound.gifnew file mode 100644index 0000000000..2a9bfc16c0Binary files /dev/null and b/webroot/img/emoji/parrotnotfound.gif differdiff --git a/webroot/img/emoji/partyparrot.gif b/webroot/img/emoji/partyparrot.gifnew file mode 100644index 0000000000..3cecb68608Binary files /dev/null and b/webroot/img/emoji/partyparrot.gif differdiff --git a/webroot/img/emoji/phparrot.gif b/webroot/img/emoji/phparrot.gifnew file mode 100644index 0000000000..449e172384Binary files /dev/null and b/webroot/img/emoji/phparrot.gif differdiff --git a/webroot/img/emoji/pirateparrot.gif b/webroot/img/emoji/pirateparrot.gifnew file mode 100644index 0000000000..76fdda4630Binary files /dev/null and b/webroot/img/emoji/pirateparrot.gif differdiff --git a/webroot/img/emoji/pizzaparrot.gif b/webroot/img/emoji/pizzaparrot.gifnew file mode 100644index 0000000000..ce9e21ace3Binary files /dev/null and b/webroot/img/emoji/pizzaparrot.gif differdiff --git a/webroot/img/emoji/pokeparrot.gif b/webroot/img/emoji/pokeparrot.gifnew file mode 100644index 0000000000..1159e2a5eaBinary files /dev/null and b/webroot/img/emoji/pokeparrot.gif differdiff --git a/webroot/img/emoji/popcornparrot.gif b/webroot/img/emoji/popcornparrot.gifnew file mode 100644index 0000000000..e67329eca7Binary files /dev/null and b/webroot/img/emoji/popcornparrot.gif differdiff --git a/webroot/img/emoji/porg.png b/webroot/img/emoji/porg.pngnew file mode 100644index 0000000000..aaedcfdf4dBinary files /dev/null and b/webroot/img/emoji/porg.png differdiff --git a/webroot/img/emoji/portalparrot.gif b/webroot/img/emoji/portalparrot.gifnew file mode 100644index 0000000000..5971fbd2abBinary files /dev/null and b/webroot/img/emoji/portalparrot.gif differdiff --git a/webroot/img/emoji/pumpkinparrot.gif b/webroot/img/emoji/pumpkinparrot.gifnew file mode 100644index 0000000000..6f9c9b2d00Binary files /dev/null and b/webroot/img/emoji/pumpkinparrot.gif differdiff --git a/webroot/img/emoji/quadparrot.gif b/webroot/img/emoji/quadparrot.gifnew file mode 100644index 0000000000..0449973a5cBinary files /dev/null and b/webroot/img/emoji/quadparrot.gif differdiff --git a/webroot/img/emoji/r2d2.png b/webroot/img/emoji/r2d2.pngnew file mode 100644index 0000000000..8f1ad871caBinary files /dev/null and b/webroot/img/emoji/r2d2.png differdiff --git a/webroot/img/emoji/redenvelopeparrot.gif b/webroot/img/emoji/redenvelopeparrot.gifnew file mode 100644index 0000000000..75dc001aceBinary files /dev/null and b/webroot/img/emoji/redenvelopeparrot.gif differdiff --git a/webroot/img/emoji/ripparrot.gif b/webroot/img/emoji/ripparrot.gifnew file mode 100644index 0000000000..99ae288450Binary files /dev/null and b/webroot/img/emoji/ripparrot.gif differdiff --git a/webroot/img/emoji/rotatingparrot.gif b/webroot/img/emoji/rotatingparrot.gifnew file mode 100644index 0000000000..1ec84cf4a9Binary files /dev/null and b/webroot/img/emoji/rotatingparrot.gif differdiff --git a/webroot/img/emoji/ryangoslingparrot.gif b/webroot/img/emoji/ryangoslingparrot.gifnew file mode 100644index 0000000000..2b84749ee3Binary files /dev/null and b/webroot/img/emoji/ryangoslingparrot.gif differdiff --git a/webroot/img/emoji/rythmicalparrot.gif b/webroot/img/emoji/rythmicalparrot.gifnew file mode 100644index 0000000000..33241619d9Binary files /dev/null and b/webroot/img/emoji/rythmicalparrot.gif differdiff --git a/webroot/img/emoji/sadparrot.gif b/webroot/img/emoji/sadparrot.gifnew file mode 100644index 0000000000..0ca87e56b7Binary files /dev/null and b/webroot/img/emoji/sadparrot.gif differdiff --git a/webroot/img/emoji/schnitzelparrot.gif b/webroot/img/emoji/schnitzelparrot.gifnew file mode 100644index 0000000000..cb7d816484Binary files /dev/null and b/webroot/img/emoji/schnitzelparrot.gif differdiff --git a/webroot/img/emoji/scienceparrot.gif b/webroot/img/emoji/scienceparrot.gifnew file mode 100644index 0000000000..f7c8a69524Binary files /dev/null and b/webroot/img/emoji/scienceparrot.gif differdiff --git a/webroot/img/emoji/shipitparrot.gif b/webroot/img/emoji/shipitparrot.gifnew file mode 100644index 0000000000..072227de8aBinary files /dev/null and b/webroot/img/emoji/shipitparrot.gif differdiff --git a/webroot/img/emoji/shufflepartyparrot.gif b/webroot/img/emoji/shufflepartyparrot.gifnew file mode 100644index 0000000000..159986a86cBinary files /dev/null and b/webroot/img/emoji/shufflepartyparrot.gif differdiff --git a/webroot/img/emoji/sintparrot.gif b/webroot/img/emoji/sintparrot.gifnew file mode 100644index 0000000000..8138e54301Binary files /dev/null and b/webroot/img/emoji/sintparrot.gif differdiff --git a/webroot/img/emoji/sithparrot.gif b/webroot/img/emoji/sithparrot.gifnew file mode 100644index 0000000000..1f349cb8a5Binary files /dev/null and b/webroot/img/emoji/sithparrot.gif differdiff --git a/webroot/img/emoji/skiparrot.gif b/webroot/img/emoji/skiparrot.gifnew file mode 100644index 0000000000..668014e558Binary files /dev/null and b/webroot/img/emoji/skiparrot.gif differdiff --git a/webroot/img/emoji/sleepingparrot.gif b/webroot/img/emoji/sleepingparrot.gifnew file mode 100644index 0000000000..882baf2908Binary files /dev/null and b/webroot/img/emoji/sleepingparrot.gif differdiff --git a/webroot/img/emoji/sonic.gif b/webroot/img/emoji/sonic.gifnew file mode 100644index 0000000000..fb918e88feBinary files /dev/null and b/webroot/img/emoji/sonic.gif differdiff --git a/webroot/img/emoji/spyparrot.gif b/webroot/img/emoji/spyparrot.gifnew file mode 100644index 0000000000..d3fa88dd39Binary files /dev/null and b/webroot/img/emoji/spyparrot.gif differdiff --git a/webroot/img/emoji/stalkerparrot.gif b/webroot/img/emoji/stalkerparrot.gifnew file mode 100644index 0000000000..349d6494bcBinary files /dev/null and b/webroot/img/emoji/stalkerparrot.gif differdiff --git a/webroot/img/emoji/starwars.png b/webroot/img/emoji/starwars.pngnew file mode 100644index 0000000000..ddbede4384Binary files /dev/null and b/webroot/img/emoji/starwars.png differdiff --git a/webroot/img/emoji/stayhomeparrot.gif b/webroot/img/emoji/stayhomeparrot.gifnew file mode 100644index 0000000000..fc08828281Binary files /dev/null and b/webroot/img/emoji/stayhomeparrot.gif differdiff --git a/webroot/img/emoji/storm_trooper.gif b/webroot/img/emoji/storm_trooper.gifnew file mode 100644index 0000000000..3f5af01a7cBinary files /dev/null and b/webroot/img/emoji/storm_trooper.gif differdiff --git a/webroot/img/emoji/stormtrooper.png b/webroot/img/emoji/stormtrooper.pngnew file mode 100644index 0000000000..1dec38b092Binary files /dev/null and b/webroot/img/emoji/stormtrooper.png differdiff --git a/webroot/img/emoji/sushiparrot.gif b/webroot/img/emoji/sushiparrot.gifnew file mode 100644index 0000000000..a22122c473Binary files /dev/null and b/webroot/img/emoji/sushiparrot.gif differdiff --git a/webroot/img/emoji/tacoparrot.gif b/webroot/img/emoji/tacoparrot.gifnew file mode 100644index 0000000000..dcef11dc1aBinary files /dev/null and b/webroot/img/emoji/tacoparrot.gif differdiff --git a/webroot/img/emoji/tennisparrot.gif b/webroot/img/emoji/tennisparrot.gifnew file mode 100644index 0000000000..fe6f9be699Binary files /dev/null and b/webroot/img/emoji/tennisparrot.gif differdiff --git a/webroot/img/emoji/thanks.png b/webroot/img/emoji/thanks.pngnew file mode 100644index 0000000000..2a9d0ce29bBinary files /dev/null and b/webroot/img/emoji/thanks.png differdiff --git a/webroot/img/emoji/thumbsupparrot.gif b/webroot/img/emoji/thumbsupparrot.gifnew file mode 100644index 0000000000..9c6e45f660Binary files /dev/null and b/webroot/img/emoji/thumbsupparrot.gif differdiff --git a/webroot/img/emoji/tiedyeparrot.gif b/webroot/img/emoji/tiedyeparrot.gifnew file mode 100644index 0000000000..24ab309844Binary files /dev/null and b/webroot/img/emoji/tiedyeparrot.gif differdiff --git a/webroot/img/emoji/tpparrot.gif b/webroot/img/emoji/tpparrot.gifnew file mode 100644index 0000000000..7456ff262cBinary files /dev/null and b/webroot/img/emoji/tpparrot.gif differdiff --git a/webroot/img/emoji/transparront.gif b/webroot/img/emoji/transparront.gifnew file mode 100644index 0000000000..1efb20346dBinary files /dev/null and b/webroot/img/emoji/transparront.gif differdiff --git a/webroot/img/emoji/twinsparrot.gif b/webroot/img/emoji/twinsparrot.gifnew file mode 100644index 0000000000..ba25a64d9dBinary files /dev/null and b/webroot/img/emoji/twinsparrot.gif differdiff --git a/webroot/img/emoji/upvoteparrot.gif b/webroot/img/emoji/upvoteparrot.gifnew file mode 100644index 0000000000..5d2137a818Binary files /dev/null and b/webroot/img/emoji/upvoteparrot.gif differdiff --git a/webroot/img/emoji/vikingparrot.gif b/webroot/img/emoji/vikingparrot.gifnew file mode 100644index 0000000000..5d6fcb690bBinary files /dev/null and b/webroot/img/emoji/vikingparrot.gif differdiff --git a/webroot/img/emoji/wesmart.png b/webroot/img/emoji/wesmart.pngnew file mode 100644index 0000000000..eb9f865f49Binary files /dev/null and b/webroot/img/emoji/wesmart.png differdiff --git a/webroot/img/emoji/wfhparrot.gif b/webroot/img/emoji/wfhparrot.gifnew file mode 100644index 0000000000..69029c408fBinary files /dev/null and b/webroot/img/emoji/wfhparrot.gif differdiff --git a/webroot/img/emoji/wineparrot.gif b/webroot/img/emoji/wineparrot.gifnew file mode 100644index 0000000000..19b57d6f02Binary files /dev/null and b/webroot/img/emoji/wineparrot.gif differdiff --git a/webroot/img/emoji/yoda.gif b/webroot/img/emoji/yoda.gifnew file mode 100644index 0000000000..117958c7f0Binary files /dev/null and b/webroot/img/emoji/yoda.gif differdiff --git a/webroot/index.html b/webroot/index.htmlindex b9e112ee80..b4fb2b46bc 100644--- a/webroot/index.html+++ b/webroot/index.html@@ -28,7 +28,6 @@<link href="https://unpkg.com/@videojs/themes@1/dist/fantasy/index.css" rel="stylesheet" /><script src="//unpkg.com/[email protected]/dist/video.js"></script><script src="//unpkg.com/showdown/dist/showdown.min.js"></script>- <script src="vendor/autolink.js"></script><link href="./styles/layout.css" rel="stylesheet" /></head>@@ -156,14 +155,11 @@<form id="message-form" class="flex"><input type="hidden" name="inputAuthor" id="self-message-author" />-- <textarea- disabled- id="message-body-form"- placeholder="Message"- class="appearance-none block w-full bg-gray-200 text-gray-700 border border-black-500 rounded py-2 px-2 my-2 focus:bg-white"- ></textarea>-+ <div id="message-body-form" contenteditable="true" placeholder=""+ class="appearance-none block w-full bg-gray-200 text-gray-700 border border-black-500 rounded py-2 px-2 my-2 focus:bg-white"+ ></div>+ <div id="emoji-button">😏</div>+<div id="message-form-actions" class="flex"><span id="message-form-warning" class="text-red-600 text-xs"></span><button@@ -219,5 +215,7 @@</p></div></noscript>++ <script type='module' src="/js/emoji.js"></script></body>-</html>\ No newline at end of file+</html>diff --git a/webroot/js/app.js b/webroot/js/app.jsindex e4582adf91..1c5a8d9b5f 100644--- a/webroot/js/app.js+++ b/webroot/js/app.js@@ -8,12 +8,9 @@ const MESSAGE_ONLINE = 'Stream is online';const TEMP_IMAGE = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';-const LOCAL_TEST = window.location.href.indexOf('localhost:') >= 0;--const URL_PREFIX = LOCAL_TEST ? 'http://localhost:8080' : '';-const URL_CONFIG = `${URL_PREFIX}/config`;-const URL_STATUS = `${URL_PREFIX}/status`;-const URL_CHAT_HISTORY = `${URL_PREFIX}/chat`;+const URL_CONFIG = `/config`;+const URL_STATUS = `/status`;+const URL_CHAT_HISTORY = `/chat`;const TIMER_STATUS_UPDATE = 5000; // msconst TIMER_DISABLE_CHAT_AFTER_OFFLINE = 5 * 60 * 1000; // 5 mins@@ -120,7 +117,7 @@ class Owncast {window.document.title = data.title;- this.getExtraUserContent(`${URL_PREFIX}${data.extraUserInfoFileName}`);+ this.getExtraUserContent(`${data.extraUserInfoFileName}`);this.configData = data;}diff --git a/webroot/js/emoji.js b/webroot/js/emoji.jsnew file mode 100644index 0000000000..33ef36b48d--- /dev/null+++ b/webroot/js/emoji.js@@ -0,0 +1,41 @@+import { EmojiButton } from 'https://cdn.skypack.dev/@joeattardi/emoji-button'++fetch('/emoji')+ .then(response => {+ if (!response.ok) {+ throw new Error(`Network response was not ok ${response.ok}`);+ }+ return response.json();+ })+ .then(json => {+ setupEmojiPickerWithCustomEmoji(json);+ })+ .catch(error => {+ this.handleNetworkingError(`Emoji Fetch: ${error}`);+ });++function setupEmojiPickerWithCustomEmoji(customEmoji) {+ const picker = new EmojiButton({+ zIndex: 100,+ theme: 'dark',+ custom: customEmoji,+ initialCategory: 'custom',+ showPreview: false,+ position: {+ top: '50%',+ right: '100'+ }+ });+ const trigger = document.querySelector('#emoji-button');++ trigger.addEventListener('click', () => picker.togglePicker(picker));+ picker.on('emoji', emoji => {+ if (emoji.url) {+ const url = location.protocol + "//" + location.host + "/" + emoji.url;+ const name = url.split('\\').pop().split('/').pop();+ document.querySelector('#message-body-form').innerHTML += "<img class=\"emoji\" alt=\"" + name + "\" src=\"" + url + "\"/>";+ } else {+ document.querySelector('#message-body-form').innerHTML += emoji.emoji;+ }+ });+}diff --git a/webroot/js/message.js b/webroot/js/message.jsindex e000c992cc..f3ca460b0a 100644--- a/webroot/js/message.js+++ b/webroot/js/message.js@@ -19,7 +19,7 @@ class Message {formatText() {showdown.setFlavor('github');- var markdownToHTML = new showdown.Converter({+ let formattedText = new showdown.Converter({emoji: true,openLinksInNewWindow: true,tables: false,@@ -28,16 +28,73 @@ class Message {strikethrough: true,ghMentions: false,}).makeHtml(this.body);- const linked = autoLink(markdownToHTML, {- embed: true,- removeHTTP: true,- linkAttr: {- target: '_blank'++ formattedText = this.linkify(formattedText, this.body);+ formattedText = this.highlightUsername(formattedText);++ return addNewlines(formattedText);+ }++ // TODO: Move this into a util function once we can organize code+ // and split things up.+ linkify(text, rawText) {+ const urls = getURLs(stripTags(rawText));+ if (urls) {+ urls.forEach(function (url) {+ let linkURL = url;++ // Add http prefix if none exist in the URL so it actually+ // will work in an anchor tag.+ if (linkURL.indexOf('http') === -1) {+ linkURL = 'http://' + linkURL;+ }++ // Remove the protocol prefix in the display URLs just to make+ // things look a little nicer.+ const displayURL = url.replace(/(^\w+:|^)\/\//, '');+ const link = `<a href="${linkURL}" target="_blank">${displayURL}</a>`;+ text = text.replace(url, link);++ if (getYoutubeIdFromURL(url)) {+ if (this.isTextJustURLs(text, [url, displayURL])) {+ text = '';+ } else {+ text += '<br/>';+ }++ const youtubeID = getYoutubeIdFromURL(url);+ text += getYoutubeEmbedFromID(youtubeID);+ } else if (url.indexOf('instagram.com/p/') > -1) {+ if (this.isTextJustURLs(text, [url, displayURL])) {+ text = '';+ } else {+ text += `<br/>`;+ }+ text += getInstagramEmbedFromURL(url);+ } else if (isImage(url)) {+ if (this.isTextJustURLs(text, [url, displayURL])) {+ text = '';+ } else {+ text += `<br/>`;+ }+ text += getImageForURL(url);+ }+ }.bind(this));+ }+ return text;+ }++ isTextJustURLs(text, urls) {+ for (var i = 0; i < urls.length; i++) {+ const url = urls[i];+ if (stripTags(text) === url) {+ return true;}- });- const highlighted = this.highlightUsername(linked);- return addNewlines(highlighted);+ }++ return false;}+userColor() {return messageBubbleColorForString(this.author);}@@ -73,7 +130,7 @@ class MessagingInterface {this.tagMessageFormWarning = document.getElementById('message-form-warning');this.inputMessageAuthor = document.getElementById('self-message-author');- this.inputChangeUserName = document.getElementById('username-change-input');+ this.inputChangeUserName = document.getElementById('username-change-input');this.btnUpdateUserName = document.getElementById('button-update-username');this.btnCancelUpdateUsername = document.getElementById('button-cancel-change');@@ -204,8 +261,8 @@ class MessagingInterface {}tryToComplete() {- const rawValue = this.formMessageInput.value;- const position = this.formMessageInput.selectionStart;+ const rawValue = this.formMessageInput.innerHTML;+ const position = getCaretPosition(this.formMessageInput);const at = rawValue.lastIndexOf('@', position - 1);if (at === -1) {@@ -231,9 +288,9 @@ class MessagingInterface {if (possibilities.length > 0) {this.suggestion = possibilities[this.completionIndex];- this.formMessageInput.value = rawValue.substring(0, at + 1) + this.suggestion + ' ' + rawValue.substring(position);- this.formMessageInput.selectionStart = at + this.suggestion.length + 2;- this.formMessageInput.selectionEnd = this.formMessageInput.selectionStart;+ // TODO: Fix the space not working. I'm guessing because the DOM ignores spaces and it requires a nbsp or something?+ this.formMessageInput.innerHTML = rawValue.substring(0, at + 1) + this.suggestion + ' ' + rawValue.substring(position);+ setCaretPosition(this.formMessageInput, at + this.suggestion.length + 2);}return true;@@ -241,7 +298,7 @@ class MessagingInterface {handleMessageInputKeydown(event) {var okCodes = [37,38,39,40,16,91,18,46,8];- var value = this.formMessageInput.value.trim();+ var value = this.formMessageInput.innerHTML.trim();var numCharsLeft = this.maxMessageLength - value.length;if (event.keyCode === 13) { // enterif (!this.prepNewLine) {@@ -260,7 +317,7 @@ class MessagingInterface {event.preventDefault();// value could have been changed, update variables- value = this.formMessageInput.value.trim();+ value = this.formMessageInput.innerHTML.trim();numCharsLeft = this.maxMessageLength - value.length;}}@@ -287,7 +344,7 @@ class MessagingInterface {}handleSubmitChatButton(event) {- var value = this.formMessageInput.value.trim();+ var value = this.formMessageInput.innerHTML.trim();if (value) {this.submitChat(value);event.preventDefault();@@ -310,7 +367,7 @@ class MessagingInterface {this.send(message);// clear out things.- this.formMessageInput.value = '';+ this.formMessageInput.innerHTML = '';this.tagMessageFormWarning.innerText = '';const hasSentFirstChatMessage = getLocalStorage(KEY_CHAT_FIRST_MESSAGE_SENT);@@ -322,20 +379,25 @@ class MessagingInterface {disableChat() {if (this.formMessageInput) {- this.formMessageInput.disabled = true;- this.formMessageInput.placeholder = CHAT_PLACEHOLDER_OFFLINE;+ this.formMessageInput.contentEditable = false;+ this.formMessageInput.innerHTML = '';+ this.formMessageInput.setAttribute("placeholder", CHAT_PLACEHOLDER_OFFLINE);}}+enableChat() {if (this.formMessageInput) {- this.formMessageInput.disabled = false;+ this.formMessageInput.contentEditable = true;this.setChatPlaceholderText();}}setChatPlaceholderText() {+ // NOTE: This is a fake placeholder that is being styled via CSS.+ // You can't just set the .placeholder property because it's not a form element.const hasSentFirstChatMessage = getLocalStorage(KEY_CHAT_FIRST_MESSAGE_SENT);- this.formMessageInput.placeholder = hasSentFirstChatMessage ? CHAT_PLACEHOLDER_TEXT : CHAT_INITIAL_PLACEHOLDER_TEXT+ const placeholderText = hasSentFirstChatMessage ? CHAT_PLACEHOLDER_TEXT : CHAT_INITIAL_PLACEHOLDER_TEXT;+ this.formMessageInput.setAttribute("placeholder", placeholderText);}// handle Vue.js message display@@ -373,4 +435,88 @@ class MessagingInterface {}}-export { Message, MessagingInterface }\ No newline at end of file+export { Message, MessagingInterface }++function stripTags(str) {+ return str.replace(/<\/?[^>]+(>|$)/g, "");+}++function getURLs(str) {+ var exp = /((\w+:\/\/\S+)|(\w+[\.:]\w+\S+))[^\s,\.]/ig;+ return str.match(exp);+}++function getYoutubeIdFromURL(url) {+ try {+ var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;+ var match = url.match(regExp);++ if (match && match[2].length == 11) {+ return match[2];+ } else {+ return null;+ }+ } catch (e) {+ console.log(e);+ return null;+ }+}++function getYoutubeEmbedFromID(id) {+ return `<iframe class="chat-embed" src="//www.youtube.com/embed/${id}" frameborder="0" allowfullscreen></iframe>`;+}++function getInstagramEmbedFromURL(url) {+ const urlObject = new URL(url.replace(/\/$/, ""));+ urlObject.pathname += "/embed";+ return `<iframe class="chat-embed instagram-embed" height="150px" src="${urlObject.href}" frameborder="0" allowfullscreen></iframe>`;+}++function isImage(url) {+ const re = /\.(jpe?g|png|gif)$/;+ const isImage = re.test(url);+ return isImage;+}++function getImageForURL(url) {+ return `<a target="_blank" href="${url}"><img class="embedded-image" src="${url}" width="100%" height="150px"/></a>`;+}+++// Taken from https://stackoverflow.com/questions/3972014/get-contenteditable-caret-index-position+function getCaretPosition(editableDiv) {+ var caretPos = 0,+ sel, range;+ if (window.getSelection) {+ sel = window.getSelection();+ if (sel.rangeCount) {+ range = sel.getRangeAt(0);+ if (range.commonAncestorContainer.parentNode == editableDiv) {+ caretPos = range.endOffset;+ }+ }+ } else if (document.selection && document.selection.createRange) {+ range = document.selection.createRange();+ if (range.parentElement() == editableDiv) {+ var tempEl = document.createElement("span");+ editableDiv.insertBefore(tempEl, editableDiv.firstChild);+ var tempRange = range.duplicate();+ tempRange.moveToElementText(tempEl);+ tempRange.setEndPoint("EndToEnd", range);+ caretPos = tempRange.text.length;+ }+ }+ return caretPos;+}++// Pieced together from parts of https://stackoverflow.com/questions/6249095/how-to-set-caretcursor-position-in-contenteditable-element-div+function setCaretPosition(editableDiv, position) {+ var range = document.createRange();+ var sel = window.getSelection();+ range.selectNode(editableDiv);+ range.setStart(editableDiv.childNodes[0], position);+ range.collapse(true);++ sel.removeAllRanges();+ sel.addRange(range);+}\ No newline at end of filediff --git a/webroot/js/player.js b/webroot/js/player.jsindex 890bc28338..986e3566d2 100644--- a/webroot/js/player.js+++ b/webroot/js/player.js@@ -1,9 +1,8 @@// https://docs.videojs.com/playerconst VIDEO_ID = 'video';-const LOCAL_TEST = window.location.href.indexOf('localhost:') >= 0;-const URL_PREFIX = LOCAL_TEST ? 'http://localhost:8080' : '';-const URL_STREAM = `${URL_PREFIX}/hls/stream.m3u8`;+// TODO: This directory is customizable in the config. So we should expose this via the config API.+const URL_STREAM = `/hls/stream.m3u8`;// Video setupconst VIDEO_SRC = {diff --git a/webroot/js/utils.js b/webroot/js/utils.jsindex ba09ca479d..d04c17117e 100644--- a/webroot/js/utils.js+++ b/webroot/js/utils.js@@ -1,9 +1,12 @@-const LOCAL_TEST = window.location.href.indexOf('localhost:') >= 0;-const URL_PREFIX = LOCAL_TEST ? 'http://localhost:8080' : '';--const POSTER_DEFAULT = `${URL_PREFIX}/img/logo.png`;-const POSTER_THUMB = `${URL_PREFIX}/thumbnail.jpg`;+const URL_STATUS = `/status`;+const URL_CHAT_HISTORY = `/chat`;+// TODO: This directory is customizable in the config. So we should expose this via the config API.+const URL_STREAM = `/hls/stream.m3u8`;+const URL_WEBSOCKET = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/entry`;++const POSTER_DEFAULT = `/img/logo.png`;+const POSTER_THUMB = `/thumbnail.jpg`;const URL_OWNCAST = 'https://github.com/gabek/owncast'; // used in footerdiff --git a/webroot/js/websocket.js b/webroot/js/websocket.jsindex bc4efd1d91..6c628d6e56 100644--- a/webroot/js/websocket.js+++ b/webroot/js/websocket.js@@ -1,9 +1,6 @@import SOCKET_MESSAGE_TYPES from './chat/socketMessageTypes.js';-const LOCAL_TEST = window.location.href.indexOf('localhost:') >= 0;-const URL_WEBSOCKET = LOCAL_TEST- ? 'wss://goth.land/entry'- : `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/entry`;+const URL_WEBSOCKET = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/entry`;const TIMER_WEBSOCKET_RECONNECT = 5000; // msdiff --git a/webroot/styles/layout.css b/webroot/styles/layout.cssindex 81de24302a..b179dfef15 100644--- a/webroot/styles/layout.css+++ b/webroot/styles/layout.css@@ -376,10 +376,21 @@ h2 {}#message-body-form {font-size: 1em;+ height: 60px;}#message-body-form:disabled{opacity: .5;}+#message-body-form img {+ display: inline;+ padding-left: 5px;+ padding-right: 5px;+}++#message-body-form .emoji {+ width: 40px;+}+#message-form-actions {flex-direction: row;justify-content: space-between;@@ -387,6 +398,15 @@ h2 {width: 100%;}+.message-text img {+ display: inline;+ padding-left: 5px;+ padding-right: 5px;+}++.message-text .emoji {+ width: 60px;+}/* ************************************************8 */@@ -618,18 +638,86 @@ h2 {border-radius: 15px;}+.message-text .instagram-embed {+ height: 314px;+}++.message-text code {+ background-color:darkslategrey;+ padding: 3px;+}+/* Emoji picker */+#emoji-button {+ position: relative;+ top: -65px;+ right: 10px;+ cursor: pointer;+}++.message-text .embedded-image {+ width: 100%;+ height: 170px;+ border-radius: 15px;+}++.message-text code {+ background-color:darkslategrey;+ padding: 3px;+}++/* Emoji picker */+#emoji-button {+ position: relative;+ top: -65px;+ right: 10px;+ cursor: pointer;+}.message-text .embedded-image {width: 100%;height: 170px;border-radius: 15px;}+.message-text code {+ background-color:darkslategrey;+ padding: 3px;+}.message-text .highlighted {color: orange;- font-weight: bold;+ font-weight: 400;+ font-size: 14px;+}.message-text code {background-color:darkslategrey;padding: 3px;-}\ No newline at end of file+}++/*+The chat input has a fake placeholder that is styled below.+It pulls the placeholder text from the div's placeholder attribute.+But really it's just the innerHTML content.+*/++/* If the div is empty then show the placeholder */+#message-body-form:empty:before{+ content: attr(placeholder);+ pointer-events: none;+ display: block; /* For Firefox */++ /* Style the div's placeholder text color */+ color: rgba(0, 0, 0, 0.5);+}++/* When chat is enabled (contenteditable=true) */+#message-body-form[contenteditable=true]:before {+ opacity: 1.0;+}+++/* When chat is disabled (contenteditable=false) chat input div should appear disabled. */+#message-body-form[contenteditable=false] {+ opacity: 0.6;+}+diff --git a/webroot/vendor/autolink.js b/webroot/vendor/autolink.jsdeleted file mode 100644index 4bbfba2841..0000000000--- a/webroot/vendor/autolink.js+++ /dev/null@@ -1,238 +0,0 @@-const re = {- http: /.*?:\/\//g,- url: /(\s|^)((https?|ftp):\/\/)?[\da-z\d:%._\+~#=-]{2,256}\.[a-z]{2,6}\b([\da-z:%_\+.~#?&//=-]*)/gi,- image: /\.(jpe?g|png|gif)$/,- email: /(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gi,- cloudmusic: /http:\/\/music\.163\.com\/#\/song\?id=(\d+)/i,- kickstarter: /(https?:\/\/www\.kickstarter\.com\/projects\/\d+\/[a-zA-Z0-9_-]+)(\?\w+\=\w+)?/i,- youtube: /https?:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)(\?\w+\=\w+)?/i,- vimeo: /https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/[^\/]*\/videos\/|album\/\d+\/video\/|video\/|)(\d+)(?:$|\/|\?)/i,- youku: /https?:\/\/v\.youku\.com\/v_show\/id_([a-zA-Z0-9_\=-]+).html(\?\w+\=\w+)?(\#\w+)?/i-}-/**- * AutoLink constructor function- *- * @param {String} text- * @param {Object} options- * @constructor- */-function AutoLink(string, options = {}) {- this.string = options.safe ? safe_tags_replace(string) : string- this.options = options- this.attrs = ''- this.linkAttr = ''- this.imageAttr = ''- if (this.options.sharedAttr) {- this.attrs = getAttr(this.options.sharedAttr)- }- if (this.options.linkAttr) {- this.linkAttr = getAttr(this.options.linkAttr)- }- if (this.options.imageAttr) {- this.imageAttr = getAttr(this.options.imageAttr)- }-}--AutoLink.prototype = {- constructor: AutoLink,- /**- * call relative functions to parse url/email/image- *- * @returns {String}- */- parse: function() {- var shouldReplaceImage = defaultTrue(this.options.image)- var shouldRelaceEmail = defaultTrue(this.options.email)- var shouldRelaceBr = defaultTrue(this.options.br)-- var result = ''- if (!shouldReplaceImage) {- result = this.string.replace(re.url, this.formatURLMatch.bind(this))- } else {- result = this.string.replace(re.url, this.formatIMGMatch.bind(this))- }- if (shouldRelaceEmail) {- result = this.formatEmailMatch.call(this, result)- }- if (shouldRelaceBr) {- result = result.replace(/\r?\n/g, '<br />')- }- return result- },- /**- * @param {String} match- * @returns {String} Offset 1- */- formatURLMatch: function(match, p1) {- match = prepHTTP(match.trim())- if (this.options.cloudmusic || this.options.embed) {- if (match.indexOf('music.163.com/#/song?id=') > -1) {- return match.replace(- re.cloudmusic,- p1 +- '<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="http://music.163.com/outchain/player?type=2&id=$1&auto=1&height=66"></iframe>'- )- }- }- if (this.options.kickstarter || this.options.embed) {- if (re.kickstarter.test(match)) {- return match.replace(- re.kickstarter,- p1 +- '<iframe width="480" height="360" src="$1/widget/video.html" frameborder="0" scrolling="no"> </iframe>'- )- }- }- if (this.options.vimeo || this.options.embed) {- if (re.vimeo.test(match)) {- return match.replace(- re.vimeo,- p1 +- '<iframe width="500" height="281" src="https://player.vimeo.com/video/$1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'- )- }- }- if (this.options.youtube || this.options.embed) {- if (re.youtube.test(match)) {- return match.replace(- re.youtube,- p1 +- '<iframe width="560" height="315" src="https://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>'- )- }- }- if (this.options.youku || this.options.embed) {- if (re.youku.test(match)) {- return match.replace(- re.youku,- p1 +- '<iframe height=498 width=510 src="http://player.youku.com/embed/$1" frameborder=0 allowfullscreen></iframe>'- )- }- }- var text = this.options.removeHTTP ? removeHTTP(match) : match- return (- p1 +- '<a target="_blank" href="' +- match +- '"' +- this.attrs +- this.linkAttr +- '>' +- text +- '</a>'- )- },- /**- * @param {String} match- * @param {String} Offset 1- */- formatIMGMatch: function(match, p1) {- match = match.trim()- var isIMG = re.image.test(match)- if (isIMG) {- return (- p1 +- '<img src="' +- prepHTTP(match.trim()) +- '"' +- this.attrs +- this.imageAttr +- '/>'- )- }- return this.formatURLMatch(match, p1)- },- /**- * @param {String} text- */- formatEmailMatch: function(text) {- return text.replace(- re.email,- '<a href="mailto:$&"' + this.attrs + this.linkAttr + '>$&</a>'- )- }-}--/**- * return true if undefined- * else return itself- *- * @param {Boolean} val- * @returns {Boolean}- */-function defaultTrue(val) {- return typeof val === 'undefined' ? true : val-}--/**- * parse attrs from object- *- * @param {Object} obj- * @returns {Stirng}- */-function getAttr(obj) {- var attr = ''- for (var key in obj) {- if (key) {- attr += ' ' + key + '="' + obj[key] + '"'- }- }- return attr-}--/**- * @param {String} url- * @returns {String}- */-function prepHTTP(url) {- if (url.substring(0, 4) !== 'http' && url.substring(0, 2) !== '//') {- return 'http://' + url- }- return url-}--/**- * @param {String} url- * @returns {String}- */-function removeHTTP(url) {- return url.replace(re.http, '')-}--var tagsToReplace = {- '&': '&',- '<': '<',- '>': '>'-}--/**- * Replace tag if should be replace- *- * @param {String} tag- * @returns {String}- */-function replaceTag(tag) {- return tagsToReplace[tag] || tag-}--/**- * Make string safe by replacing html tag- *- * @param {String} str- * @returns {String}- */-function safe_tags_replace(str) {- return str.replace(/[&<>]/g, replaceTag)-}--/**- * return an instance of AutoLink- *- * @param {String} string- * @param {Object} options- * @returns {Object}- */-function autoLink(string, options) {- return new AutoLink(string, options).parse()-}