Skip to content

Commit f54b516

Browse files
committed
Fix Feather external plumage/muscles thumbnails
The relative path to the css and js doesn't work inside the grover/puppeteer environment. Fix it similar to how we fix it for TiddlyWiki external core thumbnails.
1 parent 0523b3b commit f54b516

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

rails/app/models/concerns/with_thumbnail.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ def update_thumbnail_now
7070

7171
# Similar to inject_external_core_url_prefix but probably uses less memory
7272
use_html = file_download.
73-
sub(/(<script src=")(tiddlywikicore-[\d.]+.js")/, "\\1#{core_url_prefix}/\\2")
73+
# For tw5x
74+
sub(/(<script src=")(tiddlywikicore-[\d.]+.js")/, "\\1#{core_url_prefix}/\\2").
75+
# For featherx
76+
sub(/(<script id="?a"? src="?)(FeatherWiki-(muscles|bones)_\w+\.js)/, "\\1#{core_url_prefix}/\\2").
77+
sub(/(<link id="?s"? href="?)(FeatherWiki-plumage_\w+\.css)/, "\\1#{core_url_prefix}/\\2")
7478

7579
grover = Grover.new(use_html, **grover_opts)
7680

@@ -103,12 +107,16 @@ def thumbnail_attach(png)
103107
#
104108
def grover_opts
105109
case tw_kind
106-
when 'feather'
110+
when 'feather', 'featherx'
107111
{
108112
style_tag_options: [
109113
# Hide Feather Wiki "can't save to server" notification
110114
{ content: 'html > body > div.notis { display:none; }' }
111-
]
115+
],
116+
# Wait for JS to render the page before taking the screenshot
117+
# (The page renders quickly so we maybe don't need this, but it
118+
# should do no harm either way.)
119+
wait_for_selector: 'main',
112120
}
113121

114122
else

0 commit comments

Comments
 (0)