add support for niconico videos

tweak tempra simple text attach padding
This commit is contained in:
Azareal 2020-06-08 22:19:32 +10:00
parent cb383240f8
commit 019efc8c62
3 changed files with 11 additions and 9 deletions

View File

@ -1078,6 +1078,13 @@ func parseMediaString(data string, settings *ParseSettings) (media MediaEmbed, o
media.Body = "<iframe class='postIframe'src='https://www.youtube-nocookie.com/embed/" + video[0] + "'frameborder=0 allowfullscreen></iframe>"
return media, true
}
} else if strings.HasPrefix(host, "www.nicovideo.jp") && strings.HasPrefix(path, "/watch/sm") {
vid, err := strconv.ParseInt(strings.TrimPrefix(path, "/watch/sm"), 10, 64)
if err == nil {
media.Type = ERaw
media.Body = "<iframe class='postIframe'src='https://embed.nicovideo.jp/watch/sm"+strconv.FormatInt(vid, 10)+"?jsapi=1&amp;playerId=1'frameborder=0 allowfullscreen></iframe>"
return media, true
}
}
if lastFrag := pathFrags[len(pathFrags)-1]; lastFrag != "" {

View File

@ -134,11 +134,12 @@ func renderTemplate2(tmplName, hookName string, w http.ResponseWriter, r *http.R
}
func FootHeaders(w http.ResponseWriter, h *c.Header) {
// TODO: Only set video domain when there is a video on the page
if !h.LooseCSP {
if c.Config.SslSchema {
w.Header().Set("Content-Security-Policy", "default-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-eval' 'unsafe-inline'; img-src * data: 'unsafe-eval' 'unsafe-inline'; connect-src * 'unsafe-eval' 'unsafe-inline'; frame-src 'self' www.youtube-nocookie.com;upgrade-insecure-requests")
w.Header().Set("Content-Security-Policy", "default-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-eval' 'unsafe-inline'; img-src * data: 'unsafe-eval' 'unsafe-inline'; connect-src * 'unsafe-eval' 'unsafe-inline'; frame-src 'self' www.youtube-nocookie.com embed.nicovideo.jp;upgrade-insecure-requests")
} else {
w.Header().Set("Content-Security-Policy", "default-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-eval' 'unsafe-inline'; img-src * data: 'unsafe-eval' 'unsafe-inline'; connect-src * 'unsafe-eval' 'unsafe-inline'; frame-src 'self' www.youtube-nocookie.com")
w.Header().Set("Content-Security-Policy", "default-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-eval' 'unsafe-inline'; img-src * data: 'unsafe-eval' 'unsafe-inline'; connect-src * 'unsafe-eval' 'unsafe-inline'; frame-src 'self' www.youtube-nocookie.com embed.nicovideo.jp")
}
}

View File

@ -826,16 +826,10 @@ red {
.staff_post .hide_spoil img {
background-color: rgb(240,180,240);
}
.attach_box {
background-color: #5a5555;
background-color: rgb(71,71,76);
border-radius: 3px;
padding: 16px;
}
.attach_box {
border: 1px solid hsl(10, 0%, 80%);
background: white;
padding: 5px;
padding: 12px;
margin: 0px;
display: inline-block;
width: 100%;