diff --git a/client/css/post-main-view.styl b/client/css/post-main-view.styl index 1183cce2..61d30ca0 100644 --- a/client/css/post-main-view.styl +++ b/client/css/post-main-view.styl @@ -45,6 +45,8 @@ .post-content margin: 0 + background-size: cover + background-repeat: no-repeat .after-mobile-controls width: 100% diff --git a/client/html/index.htm b/client/html/index.htm index 2f0f4e40..58cef992 100644 --- a/client/html/index.htm +++ b/client/html/index.htm @@ -28,5 +28,6 @@
+ diff --git a/client/html/post_content.tpl b/client/html/post_content.tpl index fd5b094c..aaecdf24 100644 --- a/client/html/post_content.tpl +++ b/client/html/post_content.tpl @@ -1,4 +1,4 @@ -
+
'> <% if (['image', 'animation'].includes(ctx.post.type)) { %> @@ -6,8 +6,9 @@ <% } else if (ctx.post.type === 'flash') { %> - + +
Your browser does not support Flash.
<% } else if (ctx.post.type === 'video') { %> diff --git a/client/js/main.js b/client/js/main.js index c5bdc537..aaa41ee2 100644 --- a/client/js/main.js +++ b/client/js/main.js @@ -42,6 +42,17 @@ const pools = require("./pools.js"); const api = require("./api.js"); const settings = require("./models/settings.js"); +const rgb2hex = (rgb) => `#${rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/).slice(1).map(n => parseInt(n, 10).toString(16).padStart(2, '0')).join('')}` + +window.RufflePlayer = window.RufflePlayer || {}; +window.RufflePlayer.config = { + "polyfills": true, + "autoplay": "off", + "warnOnUnsupportedContent": false, + "showSwfDownload": true, + "splashScreen": false, +}; + Promise.resolve() .then(() => api.fetchConfig()) .then( @@ -99,6 +110,8 @@ Promise.resolve() if (settings.get().darkTheme) { document.body.classList.add("darktheme"); } + + window.RufflePlayer.config.autoplay = settings.get().autoplayVideos ? "auto" : "off" }) .then(() => api.loginFromCookies()) .then( diff --git a/client/js/views/settings_view.js b/client/js/views/settings_view.js index b7f69d55..0a4e34dc 100644 --- a/client/js/views/settings_view.js +++ b/client/js/views/settings_view.js @@ -30,6 +30,7 @@ class SettingsView extends events.EventTarget { _evtSubmit(e) { e.preventDefault(); + window.RufflePlayer.config.autoplay = this._find("autoplay-videos").checked ? "auto" : "off" this.dispatchEvent( new CustomEvent("submit", { detail: { diff --git a/server/szurubooru/func/images.py b/server/szurubooru/func/images.py index e135d182..602f3bd0 100644 --- a/server/szurubooru/func/images.py +++ b/server/szurubooru/func/images.py @@ -28,6 +28,9 @@ class Image: def __init__(self, content: bytes) -> None: self.content = content self._reload_info() + if self.info["format"]["format_name"] == "swf": + self.content = self.swf_to_png() + self._reload_info() @property def width(self) -> int: @@ -60,10 +63,7 @@ class Image: "png", "-", ] - if ( - "duration" in self.info["format"] - and self.info["format"]["format_name"] != "swf" - ): + if "duration" in self.info["format"]: duration = float(self.info["format"]["duration"]) if duration > 3: cli = [ @@ -76,6 +76,19 @@ class Image: self.content = content self._reload_info() + def swf_to_png(self) -> bytes: + return self._execute( + [ + "--silent", + "-g", + "gl", + "--", + "{path}", + "-", + ], + program="exporter", + ) + def to_png(self) -> bytes: return self._execute( [ @@ -315,7 +328,7 @@ class Image: ) assert "format" in self.info assert "streams" in self.info - if len(self.info["streams"]) < 1: + if len(self.info["streams"]) < 1 and self.info["format"]["format_name"] != "swf": logger.warning("The video contains no video streams.") raise errors.ProcessingError( "The video contains no video streams."