window.open
This commit is contained in:
@@ -2,27 +2,27 @@
|
||||
|
||||
module UI
|
||||
module Windows
|
||||
module_function
|
||||
|
||||
# Split-view wiki browser. Left=titles, right=selected page content
|
||||
# (rendered with markdown-aware formatting).
|
||||
def wiki(app, services:, category:, title:)
|
||||
items = services[:wiki].list(category)
|
||||
BBS::Windows::MasterDetail.open(app,
|
||||
title: " #{title} ",
|
||||
items: items,
|
||||
item_label: ->(p) { p.title },
|
||||
list_width: [32, app.cols / 3].max,
|
||||
empty_message: ' (no pages found)',
|
||||
close_button: false,
|
||||
render_detail: ->(page, width) {
|
||||
text = services[:wiki].content(page.id)
|
||||
BBS::Markdown.to_lines(text, width: width - 1, theme: app.theme)
|
||||
},
|
||||
bottom_meta: ->(page) {
|
||||
"#{page.created_at.to_s[0, 10]} #{services[:wiki].page_url(page.locale, page.path)}"
|
||||
}
|
||||
)
|
||||
class Wiki
|
||||
def self.open(app, services:, category:, title:)
|
||||
items = services[:wiki].list(category)
|
||||
BBS::Windows::MasterDetail.open(app,
|
||||
title: " #{title} ",
|
||||
items: items,
|
||||
item_label: ->(p) { p.title },
|
||||
list_width: [32, app.cols / 3].max,
|
||||
empty_message: ' (no pages found)',
|
||||
close_button: false,
|
||||
render_detail: ->(page, width) {
|
||||
text = services[:wiki].content(page.id)
|
||||
BBS::Markdown.to_lines(text, width: width - 1, theme: app.theme)
|
||||
},
|
||||
bottom_meta: ->(page) {
|
||||
"#{page.created_at.to_s[0, 10]} #{services[:wiki].page_url(page.locale, page.path)}"
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user