17#define izzi_TABLES_H 1
24using std::ostringstream;
28std::chrono::year_month_day
31 string ddate = dstamp.substr(0, 10);
34 std::chrono::year_month_day ymd;
35 std::istringstream iss(ddate);
36 iss >> std::chrono::parse(
"%F", ymd);
39 string m(
"date_stamp_to_year_month_day: failed to parse (");
43 throw std::runtime_error(
m);
48 int y = std::stoi(ddate.substr(0, 4));
49 int m = std::stoi(ddate.substr(5, 2));
50 int d = std::stoi(ddate.substr(8, 2));
53 std::chrono::year_month_day ymd {
55 std::chrono::month(
static_cast<unsigned int>(
m)),
56 std::chrono::day(
static_cast<unsigned int>(d))
69 string ds_long = std::format(
"{:%B %d, %Y}", ymd);
75 html_element =
"<time datetime=";
76 html_element += k::quote;
78 html_element += k::quote;
79 html_element += k::space;
80 html_element +=
"aria-label=";
81 html_element += k::quote;
82 html_element += ds_long;
83 html_element += k::quote;
85 html_element += k::space;
87 html_element += k::space;
88 html_element +=
"</time>";
100 std::ostringstream oss;
103 constexpr const char* dtlstart = R
"_delimiter_(
108 <div class="table-container">
110 const string dtlend = R
"_delimiter_(</div></details>)_delimiter_";
112 oss << std::format(dtlstart, htitle) << k::newline;
114 oss << dtlend << k::newline;
128 std::ifstream ifs(minimetricf);
147 const string thead_start(
"<thead>");
148 const string thead_end(
"</thead>");
149 auto startpos = html.find(thead_start);
150 auto endpos = html.find(thead_end);
152 const string theadnu = R
"_delimiter_(
155 <th scope="col" rowspan="2" width="25%">metric</th>
156 <th scope="col" colspan="2" width="25%">firefox</th>
157 <th scope="col" colspan="2" width="25%">chrome</th>
158 <th scope="col" rowspan="2" width="25%">difference</th>
161 <th scope="col">median</th>
162 <th scope="col">rsd</th>
163 <th scope="col">median</th>
164 <th scope="col">rsd</th>
169 if (startpos != string::npos && endpos != string::npos)
171 auto length = endpos + thead_end.size() - startpos;
172 html.replace(startpos, length, theadnu);
175 std::cout <<
"cannot find table heads to swap" << std::endl;
184 string_view uri2, string_view link2)
190 constexpr const char* tdblank = R
"_delimiter_(<th style="padding: 5px;"><a href="{}"> {} </a></th>)_delimiter_";
204 string_view img2src, string_view img2alt)
210 constexpr const char* tdblank = R
"_delimiter_(<th style="padding: 5px;"><img src="{{}}" alt="{{}}" width="50%"></th>)_delimiter_";
225 const string tblstart = R
"_delimiter_(<table style="border-collapse: collapse; width: 100%;">)_delimiter_";
226 const string tblend =
"</table>";
238 const string metricf = gtitlelc +
"-image-table.html";
239 std::ofstream ofs(metricf);
245const string cap =
"<caption>";
246const string capH3 = R
"_delimiter_(<caption style="font-size: 1.17em; font-weight: bold; margin: 1em 0; text-align: left;">)_delimiter_";
274 const string metricf = gtitlelc +
"-meta-collection-table.html";
275 std::ofstream ofs(metricf);
278 const string thead = R
"_delimiter_(
281 <th scope="col" rowspan="2" width="25%">duration</th>
282 <th scope="col" rowspan="2" width="25%">btiha size</th>
283 <th scope="col" colspan="2" width="25%">downloaders</th>
284 <th scope="col" colspan="2" width="25%">uploaders</th>
287 <th scope="col">total</th>
288 <th scope="col">per btiha</th>
289 <th scope="col">total</th>
290 <th scope="col">per btiha</th>
295 ofs.imbue(std::locale(""));
296 ofs << std::fixed << std::setprecision(0);
302 string tts(gtitlelc);
303 std::ranges::replace(tts, k::hyphen, k::space);
333 const uint weeksn,
const string sdates)
336 oss.imbue(std::locale(
""));
337 oss << std::fixed << std::setprecision(0);
constexpr char newline('\n')
std::chrono::year_month_day date_stamp_to_year_month_day(const string dstamp)
Arithmetic on date stamps and date hour stamps. Return time_point associated with that iso-date strin...
string serialize_image_row_2c_4f(string_view img1src, string_view img1alt, string_view img2src, string_view img2alt)
Image row in table.
string serialize_row_6c_8f(const string moname, const uint btihasz, const uint dl, const uint ul, const uint weeksn, const string sdates)
Serialize row of media object information.
string serialize_link_row_2c_4f(string_view uri1, string_view link1, string_view uri2, string_view link2)
Link row in table.
void serialize_2_image_table(const string >itlelc)
Serialize borderless image table.
const string cap
Caption element, both without styling and as H3 element in markdown.
string iso_datestamp_string_to_html_time(const string ds)
Converts ISO datestamp to HTML time element with accessible-readable long form with month names,...
string simplify_pandas_table(const string minimetricf)
Cleanup Pandas HTML table export. Pandas html table export from properly constructed json is excellen...
void serialize_meta_collection_table(const string >itlelc, const string sdur, const uint btihasz, const uint dl, const uint ul)
Serialize information about the analysis passes as an html table. Flatten all objects into one total ...
string detail_summary_table(const string &tbl, const string &htitle)
Wrap table in HTML details element, containing an H3 media object.