nitc :: CardSummary :: defaultinit
# A card that displays a summary of a list of cards
class CardSummary
super CardList
autoinit(no_title)
redef var id = "summary"
redef var title = "Summary"
# Show the summary title
var no_title: Bool = false is optional, writable
redef fun rendering do
if not no_title then
addn "<h4>Summary</h4>"
end
addn "<div class='summary'>"
addn " <ul class='list-unstyled'>"
var sections = new Array[CardSection]
for card in cards do
if card isa CardSection then
while sections.not_empty and sections.last.level >= card.level do
sections.pop
end
sections.add card
end
var level = if sections.is_empty then 1 else sections.last.level
if not card isa CardSection then level += 1
addn "<li><a href='#{card.id}'><h{level}>{card.title}</h{level}></a></li>"
end
addn " </ul>"
addn "</div>"
end
end
src/doc/static/static_cards.nit:112,1--144,3