src/html.cpp

changeset 44
de22ded6d50a
parent 42
e0f3d41ae44b
equal deleted inserted replaced
43:f58fd8461e10 44:de22ded6d50a
132 } else { 132 } else {
133 puts(" </div>\n </body>\n</html>"); 133 puts(" </div>\n </body>\n</html>");
134 } 134 }
135 } 135 }
136 136
137 void html::h1(const std::string& heading) { 137 void html::heading_repo(const std::string& repo) {
138 indent(); 138 indent();
139 printf("<h1>%s</h1>\n", encode(heading).c_str()); 139 printf("<h1>%s</h1>\n", encode(repo).c_str());
140 } 140 }
141 141
142 void html::h2(const std::string& heading) { 142 void html::heading_author(const std::string& author, unsigned int total_commits) {
143 indent(); 143 indent();
144 printf("<h2>%s</h2>\n", encode(heading).c_str()); 144 printf("<h2 title=\"Total commits: %u\">%s</h2>\n",
145 } 145 total_commits,
146 146 encode(author).c_str());
147 void html::table_begin(year y) { 147 }
148
149 void html::table_begin(year y, const std::array<unsigned int, 12> &commits_per_month) {
148 static constexpr const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 150 static constexpr const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
149 // compute the column spans, first 151 // compute the column spans, first
150 unsigned colspans[12] = {}; 152 unsigned colspans[12] = {};
151 { 153 {
152 unsigned total_cols = 0; 154 unsigned total_cols = 0;
167 puts("<tr>"); 169 puts("<tr>");
168 indent(1); 170 indent(1);
169 puts("<th></th>"); 171 puts("<th></th>");
170 for (unsigned i = 0 ; i < 12 ; i++) { 172 for (unsigned i = 0 ; i < 12 ; i++) {
171 indent(); 173 indent();
172 printf("<th scope=\"col\" colspan=\"%d\">%s</th>\n", colspans[i], months[i]); 174 printf("<th scope=\"col\" title=\"Total commits: %u\" colspan=\"%d\">%s</th>\n",
175 commits_per_month[i], colspans[i], months[i]);
173 } 176 }
174 indent(-1); 177 indent(-1);
175 puts("</tr>"); 178 puts("</tr>");
176 } 179 }
177 180

mercurial