Allow videos in posts, simplify post image view
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
|
||||
struct PostVideo: HtmlProducer {
|
||||
|
||||
let videos: [FileResource]
|
||||
|
||||
func populate(_ result: inout String) {
|
||||
result += "<video autoplay loop muted>"
|
||||
result += "Video not supported."
|
||||
for video in videos {
|
||||
result += "<source src='\(video.absoluteUrl)' type='\(video.type.htmlType!)'>"
|
||||
}
|
||||
result += "</video>"
|
||||
}
|
||||
}
|
@ -14,7 +14,14 @@ struct FeedEntry {
|
||||
|
||||
var content: String {
|
||||
var result = "<article><div class='card\(cardLinkClassText)'>"
|
||||
ImageGallery(id: data.entryId, images: data.images).populate(&result)
|
||||
switch data.media {
|
||||
case .images(let images):
|
||||
ImageGallery(id: data.entryId, images: images).populate(&result)
|
||||
case .video(let videos):
|
||||
PostVideo(videos: videos).populate(&result)
|
||||
case .none:
|
||||
break
|
||||
}
|
||||
|
||||
if let url = data.link?.url {
|
||||
result += "<div class='card-content' onclick=\"window.location.href='\(url)'\">"
|
||||
|
@ -13,16 +13,16 @@ struct FeedEntryData {
|
||||
|
||||
let text: [String]
|
||||
|
||||
let images: [ImageSet]
|
||||
let media: Media?
|
||||
|
||||
init(entryId: String, title: String?, textAboveTitle: String, link: Link?, tags: [Tag], text: [String], images: [ImageSet]) {
|
||||
init(entryId: String, title: String?, textAboveTitle: String, link: Link?, tags: [Tag], text: [String], media: Media?) {
|
||||
self.entryId = entryId
|
||||
self.title = title
|
||||
self.textAboveTitle = textAboveTitle
|
||||
self.link = link
|
||||
self.tags = tags
|
||||
self.text = text
|
||||
self.images = images
|
||||
self.media = media
|
||||
}
|
||||
|
||||
struct Link {
|
||||
@ -40,4 +40,16 @@ struct FeedEntryData {
|
||||
let url: String
|
||||
|
||||
}
|
||||
|
||||
enum Media {
|
||||
case images([ImageSet])
|
||||
case video([FileResource])
|
||||
}
|
||||
|
||||
var requiresSwiper: Bool {
|
||||
if case .images(let images) = media, images.count > 1 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user