-
Notifications
You must be signed in to change notification settings - Fork 3
/
render_home.cpp
82 lines (71 loc) · 2.86 KB
/
render_home.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "weblegends.h"
#include "helpers.h"
#include "df/world.h"
#include "df/world_data.h"
REQUIRE_GLOBAL(world);
void WebLegends::render_home(Layout & l)
{
CoreSuspender suspend;
if (!world->world_data)
{
return;
}
void simple_header(Layout &, df::world_data *);
simple_header(l, world->world_data);
auto & s = l.content;
s << "<img src=\"region.png\" width=\"100\" height=\"100\" class=\"map\">";
s << "<table class=\"home-links\">";
s << "<tr><th><a href=\"eras-0\">Eras</a></th><td>" << format_number(world->history.eras.size()) << "</td></tr>";
s << "<tr><th><a href=\"eventcols-0\">Event Collections</a></th><td>" << format_number(world->history.event_collections.all.size()) << "</td></tr>";
s << "<tr><th><a href=\"figs-0\">Historical Figures</a></th><td>" << format_number(world->history.figures.size()) << "</td></tr>";
s << "<tr><th><a href=\"sites-0\">Sites</a></th><td>" << format_number(world->world_data->sites.size()) << "</td></tr>";
s << "<tr><th><a href=\"items-0\">Artifacts</a></th><td>" << format_number(world->artifacts.all.size()) << "</td></tr>";
s << "<tr><th><a href=\"regions-0\">Regions</a></th><td>" << format_number(world->world_data->regions.size()) << "</td></tr>";
s << "<tr><th><a href=\"layers-0\">Underground Regions</a></th><td>" << format_number(world->world_data->underground_regions.size()) << "</td></tr>";
s << "<tr><th><a href=\"ents-0\">Civilizations and other entities</a></th><td>" << format_number(world->entities.all.size()) << "</td></tr>";
auto handlers = get_handlers_v0();
if (handlers != nullptr)
{
for (auto & h : *handlers)
{
if (!h.second.first.empty())
{
s << "<tr><th><a href=\"" << html_escape(h.first) << "\">" << html_escape(h.second.first) << "</a></th><td></td></tr>";
}
}
}
s << "</table>";
}
void WebLegends::render_sidebar(Layout & l)
{
CoreSuspender suspend;
if (!world->world_data)
{
return;
}
l.add_sidebar_link("eras-0", "Eras");
l.add_sidebar_link("eventcols-0", "Event Collections");
l.add_sidebar_link("figs-0", "Historical Figures");
l.add_sidebar_link("sites-0", "Sites");
l.add_sidebar_link("items-0", "Artifacts");
l.add_sidebar_link("regions-0", "Regions");
l.add_sidebar_link("layers-0", "Underground Regions");
l.add_sidebar_link("ents-0", "Civilizations");
auto handlers = get_handlers_v0();
if (handlers != nullptr)
{
bool first = true;
for (auto & h : *handlers)
{
if (!h.second.first.empty())
{
if (first)
{
l.add_sidebar_section("Plugins");
first = false;
}
l.add_sidebar_link(h.first, h.second.first);
}
}
}
}