mirror of
https://git.sr.ht/~edwardloveall/scribe
synced 2025-12-10 12:41:23 +00:00
Add captions to embedded media
This commit is contained in:
@@ -34,11 +34,19 @@ class EmbeddedConverter
|
||||
EmbeddedContent.new(
|
||||
src: media.iframeSrc,
|
||||
originalWidth: media.iframeWidth,
|
||||
originalHeight: media.iframeHeight
|
||||
originalHeight: media.iframeHeight,
|
||||
caption: caption
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private def caption : FigureCaption?
|
||||
if !paragraph.text.blank?
|
||||
children = [Text.new(paragraph.text || "")] of Child
|
||||
FigureCaption.new(children: children)
|
||||
end
|
||||
end
|
||||
|
||||
private def custom_embed(media : PostResponse::MediaResource) : Embedded
|
||||
if media.href.starts_with?(GIST_HOST_AND_SCHEME)
|
||||
GithubGist.new(href: media.href, gist_store: gist_store)
|
||||
|
||||
@@ -40,6 +40,9 @@ class PageContent < BaseComponent
|
||||
frameborder: "0",
|
||||
allowfullscreen: true,
|
||||
)
|
||||
if caption = child.caption
|
||||
render_child(caption)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -147,8 +147,14 @@ module Nodes
|
||||
MAX_WIDTH = 800
|
||||
|
||||
getter src : String
|
||||
getter caption : FigureCaption?
|
||||
|
||||
def initialize(@src : String, @originalWidth : Int32, @originalHeight : Int32)
|
||||
def initialize(
|
||||
@src : String,
|
||||
@originalWidth : Int32,
|
||||
@originalHeight : Int32,
|
||||
@caption : FigureCaption? = nil
|
||||
)
|
||||
end
|
||||
|
||||
def width
|
||||
@@ -168,7 +174,10 @@ module Nodes
|
||||
end
|
||||
|
||||
def ==(other : EmbeddedContent)
|
||||
other.src == src && other.width == width && other.height == height
|
||||
other.src == src &&
|
||||
other.width == width &&
|
||||
other.height == height &&
|
||||
other.caption == caption
|
||||
end
|
||||
|
||||
def empty?
|
||||
|
||||
Reference in New Issue
Block a user