MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / ShowPageHead

Function ShowPageHead

daemon/HTTPServer.cpp:177–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175 }
176
177 static void ShowPageHead (std::stringstream& s)
178 {
179 std::string webroot; i2p::config::GetOption("http.webroot", webroot);
180 std::string theme; i2p::config::GetOption("http.theme", theme);
181
182 const auto isThemeRegex = std::regex("^(white|black|light)");
183 if (!std::regex_search(theme, isThemeRegex))
184 {
185 LoadExtCSS(theme);
186 }
187 else
188 {
189 LoadExtCSS();
190 }
191
192 // Page language
193 std::string currLang = i2p::client::context.GetLanguage ()->GetLanguage(); // get current used language
194 auto it = i2p::i18n::languages.find(currLang);
195 // fallback to default English, if language is not supported
196 if (it == i2p::i18n::languages.end()) {
197 it = i2p::i18n::languages.find("english");
198 }
199 std::string langCode = it->second.ShortCode;
200
201 // Right to Left language option
202 bool rtl = i2p::client::context.GetLanguage ()->GetRTL();
203
204 s <<
205 "<!DOCTYPE html>\r\n"
206 "<html lang=\"" << langCode << "\"" << (rtl ? " dir=\"rtl\"" : "") << ">\r\n"
207 "<head>\r\n" /* TODO: Find something to parse html/template system. This is horrible. */
208 " <meta charset=\"UTF-8\">\r\n"
209 " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n"
210 " <link rel=\"shortcut icon\" href=\"" << itoopieFavicon << "\">\r\n"
211 " <title>" << tr(/* tr: Webconsole page title */ "Purple I2P Webconsole") << "</title>\r\n";
212 GetStyles(s);
213 if (theme == "black")
214 {
215 s <<
216 "<style>:root {\r\n"
217 "--main-bg-color: #242424;\r\n"
218 "--main-text-color: #17ab5c;\r\n"
219 "--main-link-color: #bf64b7;\r\n"
220 "--main-link-hover-color: #000000;\r\n"
221 "}\r\n</style>";
222
223 }
224 s <<
225 "</head>\r\n"
226 "<body>\r\n"
227 "<div class=\"header\">" << tr("<b>i2pd</b> webconsole") << "</div>\r\n"
228 "<div class=\"wrapper\">\r\n"
229 "<div class=\"menu\">\r\n"
230 " <a href=\"" << webroot << "\">" << tr("Main page") << "</a><br><br>\r\n"
231 " <a href=\"" << webroot << "?page=" << HTTP_PAGE_COMMANDS << "\">" << tr("Router commands") << "</a><br>\r\n"
232 " <a href=\"" << webroot << "?page=" << HTTP_PAGE_LOCAL_DESTINATIONS << "\">" << tr("Local Destinations") << "</a><br>\r\n";
233 if (i2p::context.IsFloodfill ())
234 s << " <a href=\"" << webroot << "?page=" << HTTP_PAGE_LEASESETS << "\">" << tr("LeaseSets") << "</a><br>\r\n";

Callers 1

HandleRequestMethod · 0.85

Calls 10

GetOptionFunction · 0.85
LoadExtCSSFunction · 0.85
trFunction · 0.85
GetStylesFunction · 0.85
GetRTLMethod · 0.80
AcceptsTunnelsMethod · 0.80
CountTransitTunnelsMethod · 0.80
GetSAMBridgeMethod · 0.80
GetLanguageMethod · 0.45
IsFloodfillMethod · 0.45

Tested by

no test coverage detected