Browse Source

Use bundled images instead of old webroot files

pull/2032/head
Gabe Kangas 3 years ago
parent
commit
18a184eeb7
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
  1. 4
      activitypub/outbox/outbox.go
  2. 2
      config/constants.go
  3. 63
      controllers/emoji.go
  4. 59
      controllers/images.go
  5. 84
      controllers/index.go
  6. 16
      controllers/logo.go
  7. 12
      controllers/web.go
  8. 7
      core/core.go
  9. 10
      core/data/config.go
  10. 8
      core/transcoder/thumbnailGenerator.go
  11. 23
      router/middleware/caching.go
  12. 21
      router/router.go
  13. BIN
      static/img/emoji/Reaper-gg.png
  14. BIN
      static/img/emoji/Reaper-hi.png
  15. BIN
      static/img/emoji/Reaper-hype.png
  16. BIN
      static/img/emoji/Reaper-lol.png
  17. BIN
      static/img/emoji/Reaper-love.png
  18. BIN
      static/img/emoji/Reaper-rage.png
  19. BIN
      static/img/emoji/Reaper-rip.png
  20. BIN
      static/img/emoji/Reaper-wtf.png
  21. BIN
      static/img/emoji/ac-box.png
  22. BIN
      static/img/emoji/ac-construction.png
  23. BIN
      static/img/emoji/ac-fossil.png
  24. BIN
      static/img/emoji/ac-item-leaf.png
  25. BIN
      static/img/emoji/ac-kkslider.png
  26. BIN
      static/img/emoji/ac-moneytree.png
  27. BIN
      static/img/emoji/ac-mosquito.png
  28. BIN
      static/img/emoji/ac-shirt.png
  29. BIN
      static/img/emoji/ac-song.png
  30. BIN
      static/img/emoji/ac-tree.png
  31. BIN
      static/img/emoji/ac-turnip.png
  32. BIN
      static/img/emoji/ac-weeds.png
  33. BIN
      static/img/emoji/alert.gif
  34. BIN
      static/img/emoji/bananadance.gif
  35. BIN
      static/img/emoji/bb8.png
  36. BIN
      static/img/emoji/beerparrot.gif
  37. BIN
      static/img/emoji/bells.png
  38. BIN
      static/img/emoji/birthdaypartyparrot.gif
  39. BIN
      static/img/emoji/blacklightsaber.png
  40. BIN
      static/img/emoji/bluelightsaber.png
  41. BIN
      static/img/emoji/bluntparrot.gif
  42. BIN
      static/img/emoji/bobaparrot.gif
  43. BIN
      static/img/emoji/cakeparrot.gif
  44. BIN
      static/img/emoji/chewbacca.png
  45. BIN
      static/img/emoji/chillparrot.gif
  46. BIN
      static/img/emoji/christmasparrot.gif
  47. BIN
      static/img/emoji/coffeeparrot.gif
  48. BIN
      static/img/emoji/confusedparrot.gif
  49. BIN
      static/img/emoji/copparrot.gif
  50. BIN
      static/img/emoji/coronavirus.png
  51. BIN
      static/img/emoji/covid19parrot.gif
  52. BIN
      static/img/emoji/cryptoparrot.gif
  53. BIN
      static/img/emoji/dabparrot.gif
  54. BIN
      static/img/emoji/dadparrot.gif
  55. BIN
      static/img/emoji/daftpunkparrot.gif
  56. BIN
      static/img/emoji/darkbeerparrot.gif
  57. BIN
      static/img/emoji/darkmodeparrot.gif
  58. BIN
      static/img/emoji/darth_vader.png
  59. BIN
      static/img/emoji/dealwithitparrot.gif
  60. BIN
      static/img/emoji/death_star.png
  61. BIN
      static/img/emoji/discoparrot.gif
  62. BIN
      static/img/emoji/division-gg.png
  63. BIN
      static/img/emoji/division-hi.png
  64. BIN
      static/img/emoji/division-hype.png
  65. BIN
      static/img/emoji/division-lol.png
  66. BIN
      static/img/emoji/division-omg.png
  67. BIN
      static/img/emoji/division-rage.png
  68. BIN
      static/img/emoji/division-rip.png
  69. BIN
      static/img/emoji/division-wtf.png
  70. BIN
      static/img/emoji/docparrot.gif
  71. BIN
      static/img/emoji/donutparrot.gif
  72. BIN
      static/img/emoji/doom_mad.gif
  73. BIN
      static/img/emoji/empire.png
  74. BIN
      static/img/emoji/everythingsfineparrot.gif
  75. BIN
      static/img/emoji/evilparrot.gif
  76. BIN
      static/img/emoji/explodyparrot.gif
  77. BIN
      static/img/emoji/fixparrot.gif
  78. BIN
      static/img/emoji/flyingmoneyparrot.gif
  79. BIN
      static/img/emoji/footballparrot.gif
  80. BIN
      static/img/emoji/gabe1.png
  81. BIN
      static/img/emoji/gabe2.png
  82. BIN
      static/img/emoji/gentlemanparrot.gif
  83. BIN
      static/img/emoji/githubparrot.gif
  84. BIN
      static/img/emoji/goomba.gif
  85. BIN
      static/img/emoji/gothparrot.gif
  86. BIN
      static/img/emoji/hamburgerparrot.gif
  87. BIN
      static/img/emoji/harrypotterparrot.gif
  88. BIN
      static/img/emoji/headbangingparrot.gif
  89. BIN
      static/img/emoji/headingparrot.gif
  90. BIN
      static/img/emoji/headsetparrot.gif
  91. BIN
      static/img/emoji/hmmparrot.gif
  92. BIN
      static/img/emoji/hypnoparrot.gif
  93. BIN
      static/img/emoji/icecreamparrot.gif
  94. BIN
      static/img/emoji/illuminatiparrot.gif
  95. BIN
      static/img/emoji/jediparrot.gif
  96. BIN
      static/img/emoji/keanu_thanks.gif
  97. BIN
      static/img/emoji/laptop_parrot.gif
  98. BIN
      static/img/emoji/loveparrot.gif
  99. BIN
      static/img/emoji/mandalorian.png
  100. BIN
      static/img/emoji/margaritaparrot.gif
  101. Some files were not shown because too many files have changed in this diff Show More

4
activitypub/outbox/outbox.go

@ -77,8 +77,8 @@ func SendLive() error { @@ -77,8 +77,8 @@ func SendLive() error {
if err == nil {
var imageToAttach string
var mediaType string
previewGif := filepath.Join(config.WebRoot, "preview.gif")
thumbnailJpg := filepath.Join(config.WebRoot, "thumbnail.jpg")
previewGif := filepath.Join(config.TempDir, "preview.gif")
thumbnailJpg := filepath.Join(config.TempDir, "thumbnail.jpg")
uniquenessString := shortid.MustGenerate()
if utils.DoesFileExists(previewGif) {
imageToAttach = "preview.gif"

2
config/constants.go

@ -5,8 +5,6 @@ import "path/filepath" @@ -5,8 +5,6 @@ import "path/filepath"
const (
// StaticVersionNumber is the version of Owncast that is used when it's not overwritten via build-time settings.
StaticVersionNumber = "0.0.12" // Shown when you build from develop
// WebRoot is the web server root directory.
WebRoot = "webroot"
// FfmpegSuggestedVersion is the version of ffmpeg we suggest.
FfmpegSuggestedVersion = "v4.1.5" // Requires the v
// DataDirectory is the directory we save data to.

63
controllers/emoji.go

@ -2,59 +2,60 @@ package controllers @@ -2,59 +2,60 @@ package controllers
import (
"encoding/json"
"io/fs"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/static"
"github.com/owncast/owncast/utils"
log "github.com/sirupsen/logrus"
)
var (
emojiCache = make([]models.CustomEmoji, 0)
emojiCacheTimestamp time.Time
)
// getCustomEmojiList returns a list of custom emoji either from the cache or from the emoji directory.
func getCustomEmojiList() []models.CustomEmoji {
fullPath := filepath.Join(config.WebRoot, config.EmojiDir)
emojiDirInfo, err := os.Stat(fullPath)
bundledEmoji := static.GetEmoji()
emojiResponse := make([]models.CustomEmoji, 0)
files, err := fs.Glob(bundledEmoji, "*")
if err != nil {
log.Errorln(err)
}
if emojiDirInfo.ModTime() != emojiCacheTimestamp {
log.Traceln("Emoji cache invalid")
emojiCache = make([]models.CustomEmoji, 0)
return emojiResponse
}
if len(emojiCache) == 0 {
files, err := os.ReadDir(fullPath)
if err != nil {
log.Errorln(err)
return emojiCache
}
for _, f := range files {
name := strings.TrimSuffix(f.Name(), path.Ext(f.Name()))
emojiPath := filepath.Join(config.EmojiDir, f.Name())
singleEmoji := models.CustomEmoji{Name: name, URL: emojiPath}
emojiCache = append(emojiCache, singleEmoji)
}
emojiCacheTimestamp = emojiDirInfo.ModTime()
for _, name := range files {
emojiPath := filepath.Join(config.EmojiDir, name)
singleEmoji := models.CustomEmoji{Name: name, URL: emojiPath}
emojiResponse = append(emojiResponse, singleEmoji)
}
return emojiCache
return emojiResponse
}
// GetCustomEmoji returns a list of custom emoji via the API.
func GetCustomEmoji(w http.ResponseWriter, r *http.Request) {
// GetCustomEmojiList returns a list of custom emoji via the API.
func GetCustomEmojiList(w http.ResponseWriter, r *http.Request) {
emojiList := getCustomEmojiList()
if err := json.NewEncoder(w).Encode(emojiList); err != nil {
InternalErrorHandler(w, err)
}
}
// GetCustomEmojiImage returns a single emoji image.
func GetCustomEmojiImage(w http.ResponseWriter, r *http.Request) {
bundledEmoji := static.GetEmoji()
path := strings.TrimPrefix(r.URL.Path, "/img/emoji/")
b, err := fs.ReadFile(bundledEmoji, path)
if err != nil {
log.Errorln(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
contentType := "image/jpeg"
cacheTime := utils.GetCacheDurationSecondsForPath(path)
writeBytesAsImage(b, contentType, w, cacheTime)
}

59
controllers/images.go

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
package controllers
import (
"net/http"
"path/filepath"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/utils"
)
// GetThumbnail will return the thumbnail image as a response.
func GetThumbnail(w http.ResponseWriter, r *http.Request) {
imageFilename := "thumbnail.jpg"
imagePath := filepath.Join(config.TempDir, imageFilename)
var imageBytes []byte
var err error
if utils.DoesFileExists(imagePath) {
imageBytes, err = getImage(imagePath)
} else {
GetLogo(w, r)
return
}
if err != nil {
GetLogo(w, r)
return
}
contentType := "image/jpeg"
cacheTime := utils.GetCacheDurationSecondsForPath(imagePath)
writeBytesAsImage(imageBytes, contentType, w, cacheTime)
}
// GetPreview will return the preview gif as a response.
func GetPreview(w http.ResponseWriter, r *http.Request) {
imageFilename := "preview.gif"
imagePath := filepath.Join(config.TempDir, imageFilename)
var imageBytes []byte
var err error
if utils.DoesFileExists(imagePath) {
imageBytes, err = getImage(imagePath)
} else {
GetLogo(w, r)
return
}
if err != nil {
GetLogo(w, r)
return
}
contentType := "image/jpeg"
cacheTime := utils.GetCacheDurationSecondsForPath(imagePath)
writeBytesAsImage(imageBytes, contentType, w, cacheTime)
}

84
controllers/index.go

@ -1,20 +1,11 @@ @@ -1,20 +1,11 @@
package controllers
import (
"fmt"
"net/http"
"net/url"
"path/filepath"
"strings"
log "github.com/sirupsen/logrus"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/core"
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/router/middleware"
"github.com/owncast/owncast/static"
"github.com/owncast/owncast/utils"
)
@ -35,10 +26,6 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) { @@ -35,10 +26,6 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
middleware.EnableCors(w)
isIndexRequest := r.URL.Path == "/" || filepath.Base(r.URL.Path) == "index.html" || filepath.Base(r.URL.Path) == ""
if isIndexRequest {
handleScraperMetadataPage(w, r)
return
}
if utils.IsUserAgentAPlayer(r.UserAgent()) && isIndexRequest {
http.Redirect(w, r, "/hls/stream.m3u8", http.StatusTemporaryRedirect)
@ -46,10 +33,10 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) { @@ -46,10 +33,10 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
}
// If the ETags match then return a StatusNotModified
if responseCode := middleware.ProcessEtags(w, r); responseCode != 0 {
w.WriteHeader(responseCode)
return
}
// if responseCode := middleware.ProcessEtags(w, r); responseCode != 0 {
// w.WriteHeader(responseCode)
// return
// }
// If this is a directory listing request then return a 404
// info, err := os.Stat(path.Join(config.WebRoot, r.URL.Path))
@ -65,67 +52,4 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) { @@ -65,67 +52,4 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
middleware.SetHeaders(w)
serveWeb(w, r)
// http.ServeFile(w, r, path.Join(config.WebRoot, r.URL.Path))
}
// Return a basic HTML page with server-rendered metadata from the config
// to give to Opengraph clients and web scrapers (bots, web crawlers, etc).
func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
tmpl, err := static.GetWebIndexTemplate()
if err != nil {
log.Errorln(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
scheme := "http"
if siteURL := data.GetServerURL(); siteURL != "" {
if parsed, err := url.Parse(siteURL); err == nil && parsed.Scheme != "" {
scheme = parsed.Scheme
}
}
fullURL, err := url.Parse(fmt.Sprintf("%s://%s%s", scheme, r.Host, r.URL.Path))
if err != nil {
log.Errorln(err)
}
imageURL, err := url.Parse(fmt.Sprintf("%s://%s%s", scheme, r.Host, "/logo/external"))
if err != nil {
log.Errorln(err)
}
status := core.GetStatus()
// If the thumbnail does not exist or we're offline then just use the logo image
var thumbnailURL string
if status.Online && utils.DoesFileExists(filepath.Join(config.WebRoot, "thumbnail.jpg")) {
thumbnail, err := url.Parse(fmt.Sprintf("%s://%s%s", scheme, r.Host, "/thumbnail.jpg"))
if err != nil {
log.Errorln(err)
thumbnailURL = imageURL.String()
} else {
thumbnailURL = thumbnail.String()
}
} else {
thumbnailURL = imageURL.String()
}
tagsString := strings.Join(data.GetServerMetadataTags(), ",")
metadata := MetadataPage{
Name: data.GetServerName(),
RequestedURL: fullURL.String(),
Image: imageURL.String(),
Summary: data.GetServerSummary(),
Thumbnail: thumbnailURL,
TagsString: tagsString,
Tags: data.GetServerMetadataTags(),
SocialHandles: data.GetSocialHandles(),
}
w.Header().Set("Content-Type", "text/html")
if err := tmpl.Execute(w, metadata); err != nil {
log.Errorln(err)
}
}

16
controllers/logo.go

@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/static"
"github.com/owncast/owncast/utils"
log "github.com/sirupsen/logrus"
)
@ -21,7 +22,7 @@ func GetLogo(w http.ResponseWriter, r *http.Request) { @@ -21,7 +22,7 @@ func GetLogo(w http.ResponseWriter, r *http.Request) {
returnDefault(w)
return
}
imagePath := filepath.Join("data", imageFilename)
imagePath := filepath.Join(config.DataDirectory, imageFilename)
imageBytes, err := getImage(imagePath)
if err != nil {
returnDefault(w)
@ -56,7 +57,7 @@ func GetCompatibleLogo(w http.ResponseWriter, r *http.Request) { @@ -56,7 +57,7 @@ func GetCompatibleLogo(w http.ResponseWriter, r *http.Request) {
}
// Otherwise use a fallback logo.png.
imagePath := filepath.Join(config.WebRoot, "img", "logo.png")
imagePath := filepath.Join(config.DataDirectory, "logo.png")
contentType := "image/png"
imageBytes, err := getImage(imagePath)
if err != nil {
@ -74,14 +75,9 @@ func GetCompatibleLogo(w http.ResponseWriter, r *http.Request) { @@ -74,14 +75,9 @@ func GetCompatibleLogo(w http.ResponseWriter, r *http.Request) {
}
func returnDefault(w http.ResponseWriter) {
imagePath := filepath.Join(config.WebRoot, "img", "logo.svg")
imageBytes, err := getImage(imagePath)
if err != nil {
log.Errorln(err)
return
}
cacheTime := utils.GetCacheDurationSecondsForPath(imagePath)
writeBytesAsImage(imageBytes, "image/svg+xml", w, cacheTime)
imageBytes := static.GetLogo()
cacheTime := utils.GetCacheDurationSecondsForPath("logo.png")
writeBytesAsImage(imageBytes, "image/png", w, cacheTime)
}
func writeBytesAsImage(data []byte, contentType string, w http.ResponseWriter, cacheSeconds int) {

12
controllers/web.go

@ -16,13 +16,13 @@ import ( @@ -16,13 +16,13 @@ import (
// serveWeb will serve web assets.
func serveWeb(w http.ResponseWriter, r *http.Request) {
// If the ETags match then return a StatusNotModified
if responseCode := middleware.ProcessEtags(w, r); responseCode != 0 {
w.WriteHeader(responseCode)
return
}
// if responseCode := middleware.ProcessEtags(w, r); responseCode != 0 {
// w.WriteHeader(responseCode)
// return
// }
webFiles := static.GetWeb()
path := "web/" + strings.TrimPrefix(r.URL.Path, "/")
path := strings.TrimPrefix(r.URL.Path, "/")
// Determine if the requested path is a directory.
// If so, append index.html to the request.
@ -48,7 +48,7 @@ func serveWeb(w http.ResponseWriter, r *http.Request) { @@ -48,7 +48,7 @@ func serveWeb(w http.ResponseWriter, r *http.Request) {
// Set a cache control max-age header
middleware.SetCachingHeaders(w, r)
d, err := webFiles.ReadFile(path)
d, err := fs.ReadFile(webFiles, path)
if err != nil {
log.Errorln(err)
w.WriteHeader(http.StatusInternalServerError)

7
core/core.go

@ -112,12 +112,13 @@ func transitionToOfflineVideoStreamContent() { @@ -112,12 +112,13 @@ func transitionToOfflineVideoStreamContent() {
// Copy the logo to be the thumbnail
logo := data.GetLogoPath()
if err = utils.Copy(filepath.Join("data", logo), "webroot/thumbnail.jpg"); err != nil {
dst := filepath.Join(config.TempDir, "thumbnail.jpg")
if err = utils.Copy(filepath.Join("data", logo), dst); err != nil {
log.Warnln(err)
}
// Delete the preview Gif
_ = os.Remove(path.Join(config.WebRoot, "preview.gif"))
_ = os.Remove(path.Join(config.DataDirectory, "preview.gif"))
}
func resetDirectories() {
@ -129,7 +130,7 @@ func resetDirectories() { @@ -129,7 +130,7 @@ func resetDirectories() {
// Remove the previous thumbnail
logo := data.GetLogoPath()
if utils.DoesFileExists(logo) {
err := utils.Copy(path.Join("data", logo), filepath.Join(config.WebRoot, "thumbnail.jpg"))
err := utils.Copy(path.Join("data", logo), filepath.Join(config.DataDirectory, "thumbnail.jpg"))
if err != nil {
log.Warnln(err)
}

10
core/data/config.go

@ -2,6 +2,7 @@ package data @@ -2,6 +2,7 @@ package data
import (
"errors"
"os"
"path/filepath"
"sort"
"strings"
@ -9,6 +10,7 @@ import ( @@ -9,6 +10,7 @@ import (
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/static"
"github.com/owncast/owncast/utils"
log "github.com/sirupsen/logrus"
)
@ -583,12 +585,10 @@ func VerifySettings() error { @@ -583,12 +585,10 @@ func VerifySettings() error {
logoPath := GetLogoPath()
if !utils.DoesFileExists(filepath.Join(config.DataDirectory, logoPath)) {
defaultLogo := filepath.Join(config.WebRoot, "img/logo.svg")
log.Traceln(logoPath, "not found in the data directory. copying a default logo.")
if err := utils.Copy(defaultLogo, filepath.Join(config.DataDirectory, "logo.svg")); err != nil {
log.Errorln("error copying default logo: ", err)
}
if err := SetLogoPath("logo.svg"); err != nil {
logo := static.GetLogo()
os.WriteFile(filepath.Join(config.DataDirectory, "logo.png"), logo, 0o600)
if err := SetLogoPath("logo.png"); err != nil {
log.Errorln("unable to set default logo to logo.svg", err)
}
}

8
core/transcoder/thumbnailGenerator.go

@ -49,8 +49,8 @@ func StartThumbnailGenerator(chunkPath string, variantIndex int) { @@ -49,8 +49,8 @@ func StartThumbnailGenerator(chunkPath string, variantIndex int) {
func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
// JPG takes less time to encode than PNG
outputFile := path.Join(config.WebRoot, "thumbnail.jpg")
previewGifFile := path.Join(config.WebRoot, "preview.gif")
outputFile := path.Join(config.TempDir, "thumbnail.jpg")
previewGifFile := path.Join(config.TempDir, "preview.gif")
framePath := path.Join(segmentPath, strconv.Itoa(variantIndex))
files, err := os.ReadDir(framePath)
@ -87,7 +87,7 @@ func fireThumbnailGenerator(segmentPath string, variantIndex int) error { @@ -87,7 +87,7 @@ func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
mostRecentFile := path.Join(framePath, names[0])
ffmpegPath := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
outputFileTemp := path.Join(config.WebRoot, "tempthumbnail.jpg")
outputFileTemp := path.Join(config.TempDir, "tempthumbnail.jpg")
thumbnailCmdFlags := []string{
ffmpegPath,
@ -117,7 +117,7 @@ func fireThumbnailGenerator(segmentPath string, variantIndex int) error { @@ -117,7 +117,7 @@ func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
func makeAnimatedGifPreview(sourceFile string, outputFile string) {
ffmpegPath := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
outputFileTemp := path.Join(config.WebRoot, "temppreview.gif")
outputFileTemp := path.Join(config.TempDir, "temppreview.gif")
// Filter is pulled from https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
animatedGifFlags := []string{

23
router/middleware/caching.go

@ -2,12 +2,8 @@ package middleware @@ -2,12 +2,8 @@ package middleware
import (
"net/http"
"os"
"path/filepath"
"strconv"
"github.com/amalfra/etag"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/utils"
)
@ -22,25 +18,6 @@ func setCacheSeconds(seconds int, w http.ResponseWriter) { @@ -22,25 +18,6 @@ func setCacheSeconds(seconds int, w http.ResponseWriter) {
w.Header().Set("Cache-Control", "public, max-age="+secondsStr)
}
// ProcessEtags gets and sets ETags for caching purposes.
func ProcessEtags(w http.ResponseWriter, r *http.Request) int {
info, err := os.Stat(filepath.Join(config.WebRoot, r.URL.Path))
if err != nil {
return 0
}
localContentEtag := etag.Generate(info.ModTime().String(), true)
if remoteEtagHeader := r.Header.Get("If-None-Match"); remoteEtagHeader != "" {
if remoteEtagHeader == localContentEtag {
return http.StatusNotModified
}
}
w.Header().Set("Etag", localContentEtag)
return 0
}
// SetCachingHeaders will set the cache control header of a response.
func SetCachingHeaders(w http.ResponseWriter, r *http.Request) {
setCacheSeconds(utils.GetCacheDurationSecondsForPath(r.URL.Path), w)

21
router/router.go

@ -25,15 +25,26 @@ import ( @@ -25,15 +25,26 @@ import (
// Start starts the router for the http, ws, and rtmp.
func Start() error {
// static files
// The admin web app.
http.HandleFunc("/admin", middleware.RequireAdminAuth(controllers.IndexHandler))
// The primary web app.
http.HandleFunc("/", controllers.IndexHandler)
// Return a single emoji image.
http.HandleFunc("/img/emoji/", middleware.RequireAdminAuth(controllers.GetCustomEmojiImage))
// return the logo
http.HandleFunc("/logo", controllers.GetLogo)
// return a logo that's compatible with external social networks
http.HandleFunc("/logo/external", controllers.GetCompatibleLogo)
// status of the system
http.HandleFunc("/api/status", controllers.GetStatus)
// custom emoji supported in the chat
http.HandleFunc("/api/emoji", controllers.GetCustomEmoji)
http.HandleFunc("/api/emoji", controllers.GetCustomEmojiList)
// chat rest api
http.HandleFunc("/api/chat", middleware.RequireUserAccessToken(controllers.GetChatMessages))
@ -59,12 +70,6 @@ func Start() error { @@ -59,12 +70,6 @@ func Start() error {
// list of all social platforms
http.HandleFunc("/api/socialplatforms", controllers.GetAllSocialPlatforms)
// return the logo
http.HandleFunc("/logo", controllers.GetLogo)
// return a logo that's compatible with external social networks
http.HandleFunc("/logo/external", controllers.GetCompatibleLogo)
// return the list of video variants available
http.HandleFunc("/api/video/variants", controllers.GetVideoStreamOutputVariants)

BIN
static/img/emoji/Reaper-gg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
static/img/emoji/Reaper-hi.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
static/img/emoji/Reaper-hype.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
static/img/emoji/Reaper-lol.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
static/img/emoji/Reaper-love.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
static/img/emoji/Reaper-rage.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
static/img/emoji/Reaper-rip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
static/img/emoji/Reaper-wtf.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
static/img/emoji/ac-box.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
static/img/emoji/ac-construction.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
static/img/emoji/ac-fossil.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
static/img/emoji/ac-item-leaf.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
static/img/emoji/ac-kkslider.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
static/img/emoji/ac-moneytree.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
static/img/emoji/ac-mosquito.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
static/img/emoji/ac-shirt.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
static/img/emoji/ac-song.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
static/img/emoji/ac-tree.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
static/img/emoji/ac-turnip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
static/img/emoji/ac-weeds.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
static/img/emoji/alert.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
static/img/emoji/bananadance.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
static/img/emoji/bb8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
static/img/emoji/beerparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/img/emoji/bells.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
static/img/emoji/birthdaypartyparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
static/img/emoji/blacklightsaber.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
static/img/emoji/bluelightsaber.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
static/img/emoji/bluntparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
static/img/emoji/bobaparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
static/img/emoji/cakeparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
static/img/emoji/chewbacca.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
static/img/emoji/chillparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
static/img/emoji/christmasparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/img/emoji/coffeeparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
static/img/emoji/confusedparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
static/img/emoji/copparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
static/img/emoji/coronavirus.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
static/img/emoji/covid19parrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

BIN
static/img/emoji/cryptoparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
static/img/emoji/dabparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
static/img/emoji/dadparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
static/img/emoji/daftpunkparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
static/img/emoji/darkbeerparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
static/img/emoji/darkmodeparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
static/img/emoji/darth_vader.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

BIN
static/img/emoji/dealwithitparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
static/img/emoji/death_star.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

BIN
static/img/emoji/discoparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
static/img/emoji/division-gg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
static/img/emoji/division-hi.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
static/img/emoji/division-hype.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
static/img/emoji/division-lol.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
static/img/emoji/division-omg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
static/img/emoji/division-rage.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
static/img/emoji/division-rip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
static/img/emoji/division-wtf.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
static/img/emoji/docparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/img/emoji/donutparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
static/img/emoji/doom_mad.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
static/img/emoji/empire.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
static/img/emoji/everythingsfineparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
static/img/emoji/evilparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/img/emoji/explodyparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
static/img/emoji/fixparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
static/img/emoji/flyingmoneyparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
static/img/emoji/footballparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
static/img/emoji/gabe1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
static/img/emoji/gabe2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
static/img/emoji/gentlemanparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
static/img/emoji/githubparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
static/img/emoji/goomba.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

BIN
static/img/emoji/gothparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
static/img/emoji/hamburgerparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
static/img/emoji/harrypotterparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
static/img/emoji/headbangingparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
static/img/emoji/headingparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
static/img/emoji/headsetparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
static/img/emoji/hmmparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
static/img/emoji/hypnoparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
static/img/emoji/icecreamparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
static/img/emoji/illuminatiparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

BIN
static/img/emoji/jediparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
static/img/emoji/keanu_thanks.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

BIN
static/img/emoji/laptop_parrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
static/img/emoji/loveparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
static/img/emoji/mandalorian.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
static/img/emoji/margaritaparrot.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save