From 019efc8c621bcab3e306e7abcb1d094d78f232e9 Mon Sep 17 00:00:00 2001 From: Azareal Date: Mon, 8 Jun 2020 22:19:32 +1000 Subject: [PATCH] add support for niconico videos tweak tempra simple text attach padding --- common/parser.go | 7 +++++++ routes/common.go | 5 +++-- themes/tempra_simple/public/main.css | 8 +------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/common/parser.go b/common/parser.go index 9b2caba6..5c8bf4fe 100644 --- a/common/parser.go +++ b/common/parser.go @@ -1078,6 +1078,13 @@ func parseMediaString(data string, settings *ParseSettings) (media MediaEmbed, o media.Body = "" 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 = "" + return media, true + } } if lastFrag := pathFrags[len(pathFrags)-1]; lastFrag != "" { diff --git a/routes/common.go b/routes/common.go index 69afba34..d4ea91db 100644 --- a/routes/common.go +++ b/routes/common.go @@ -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") } } diff --git a/themes/tempra_simple/public/main.css b/themes/tempra_simple/public/main.css index e44603eb..71adfe5b 100644 --- a/themes/tempra_simple/public/main.css +++ b/themes/tempra_simple/public/main.css @@ -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%;