Skip to content

Commit

Permalink
Render and sanitize chat messages server-side. (owncast#237)
Browse files Browse the repository at this point in the history
* Render and sanitize chat messages server-side. Closes owncast#235

* Render content.md server-side and return it in the client config

* Remove showdown from web project

* Update api spec

* Move example user content file
  • Loading branch information
gabek authored Oct 13, 2020
1 parent 9eab6d7 commit d7c3991
Show file tree
Hide file tree
Showing 23 changed files with 408 additions and 5,441 deletions.
192 changes: 7 additions & 185 deletions build/javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions build/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"@videojs/themes": "^1.0.0",
"htm": "^3.0.4",
"preact": "^10.5.3",
"showdown": "^1.9.1",
"tailwindcss": "^1.8.10",
"video.js": "^7.9.6"
},
Expand All @@ -27,7 +26,6 @@
"@justinribeiro/lite-youtube",
"htm",
"preact",
"showdown",
"tailwindcss/dist/tailwind.min.css"
]
},
Expand Down
34 changes: 16 additions & 18 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ type config struct {

// InstanceDetails defines the user-visible information about this particular instance.
type InstanceDetails struct {
Name string `yaml:"name" json:"name"`
Title string `yaml:"title" json:"title"`
Summary string `yaml:"summary" json:"summary"`
Logo logo `yaml:"logo" json:"logo"`
Tags []string `yaml:"tags" json:"tags"`
SocialHandles []socialHandle `yaml:"socialHandles" json:"socialHandles"`
ExtraInfoFile string `yaml:"extraUserInfoFileName" json:"extraUserInfoFileName"`
Version string `json:"version"`
NSFW bool `yaml:"nsfw" json:"nsfw"`
Name string `yaml:"name" json:"name"`
Title string `yaml:"title" json:"title"`
Summary string `yaml:"summary" json:"summary"`
Logo logo `yaml:"logo" json:"logo"`
Tags []string `yaml:"tags" json:"tags"`
SocialHandles []socialHandle `yaml:"socialHandles" json:"socialHandles"`
Version string `json:"version"`
NSFW bool `yaml:"nsfw" json:"nsfw"`
ExtraUserContent string `json:"extraUserContent"`
}

type logo struct {
Expand Down Expand Up @@ -118,6 +118,13 @@ func (c *config) load(filePath string) error {

c.VideoSettings.HighestQualityStreamIndex = findHighestQuality(c.VideoSettings.StreamQualities)

// Add custom page content to the instance details.
customContentMarkdownData, err := ioutil.ReadFile(ExtraInfoFile)
if err == nil {
customContentMarkdownString := string(customContentMarkdownData)
c.InstanceDetails.ExtraUserContent = utils.RenderSimpleMarkdown(customContentMarkdownString)
}

return nil
}

Expand Down Expand Up @@ -224,14 +231,5 @@ func Load(filePath string, versionInfo string) error {

Config.VersionInfo = versionInfo

// Defaults

// This is relative to the webroot, not the project root.
// Has to be set here instead of pulled from a getter
// since it's serialized to JSON.
if Config.InstanceDetails.ExtraInfoFile == "" {
Config.InstanceDetails.ExtraInfoFile = _default.InstanceDetails.ExtraInfoFile
}

return Config.verifySettings()
}
1 change: 1 addition & 0 deletions config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const (
WebRoot = "webroot"
PrivateHLSStoragePath = "hls"
GeoIPDatabasePath = "data/GeoLite2-City.mmdb"
ExtraInfoFile = "data/content.md"
)

var (
Expand Down
1 change: 0 additions & 1 deletion config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ func getDefaults() config {
defaults.VideoSettings.ChunkLengthInSeconds = 4
defaults.Files.MaxNumberInPlaylist = 5
defaults.VideoSettings.OfflineContent = "static/offline.m4v"
defaults.InstanceDetails.ExtraInfoFile = "/static/content.md"
defaults.YP.Enabled = false
defaults.YP.YPServiceURL = "https://yp.owncast.online"

Expand Down
Loading

0 comments on commit d7c3991

Please sign in to comment.