Changeset 223
- Timestamp:
- Mar 9, 2007, 9:44:35 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/svndigest.cc
r213 r223 3 3 /* 4 4 Copyright (C) 2006 Jari Häkkinen, Peter Johansson 5 Copyright (C) 2007 Peter Johansson 5 6 6 7 This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest … … 143 144 +tree.name()+"'"); 144 145 print_css("svndigest.css"); 145 print_main_page(tree.name(), commit_dates );146 print_main_page(tree.name(), commit_dates, stats); 146 147 mkdir("all"); 147 148 for (std::set<std::string>::const_iterator i = stats.authors().begin(); -
trunk/lib/html_utility.cc
r216 r223 2 2 3 3 /* 4 Copyright (C) 2006 Peter Johansson4 Copyright (C) 2006, 2007 Peter Johansson 5 5 6 6 This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest … … 23 23 24 24 #include "html_utility.h" 25 #include "Stats.h" 25 26 #include "utility.h" 26 27 #include <config.h> // this header file is created by configure … … 97 98 s << "<-- svndigest.css generated by " << PACKAGE_STRING << "\n" 98 99 99 << "Copyright (C) 2006 Peter Johansson\n\n"100 << "Copyright (C) 2006, 2007 Peter Johansson\n\n" 100 101 << "This file is part of svndigest, " 101 102 << "http://lev.thep.lu.se/trac/svndigest\n\n" … … 188 189 s << "\n"; 189 190 s << "div.main {\n"; 190 s << " text-align: center\n"; 191 s << "}\n"; 191 s << "margin-top: 50px;\n"; 192 s << "margin-left: 50px;\n"; 193 s << " \n"; 194 s << "}\n"; 195 s << "table.main {\n"; 196 s << " text-align: left;\n"; 197 s << " padding: 0 1em .1em 0;\n"; 198 s << "}\n"; 199 s << "table.main th {\n"; 200 s << " text-align: left;\n"; 201 s << " padding: 0 1em 0.5em 0;\n"; 202 s << " font-size: 150%;\n"; 203 s << " font-wheight: bold;\n"; 204 s << "}\n"; 205 s << "table.main td {\n"; 206 s << " padding: 0 1em .1em 0;\n"; 207 s << "}\n"; 208 209 210 211 192 212 s << "table.listings {\n"; 193 213 s << " clear: both;\n"; … … 242 262 243 263 void print_main_page(const std::string& dir, 244 const std::vector<std::string>& commit_dates) 264 const std::vector<std::string>& commit_dates, 265 const Stats& stats) 245 266 { 246 267 std::string filename="index.html"; 247 268 std::ofstream os(filename.c_str()); 248 269 print_header(os, dir, 0, "main", "index.html"); 249 time_t now; 250 time (&now); 251 u_int n7=0; 252 u_int n30=0; 253 u_int n365=0; 254 for (size_t i=1; i<commit_dates.size(); ++i){ 255 double diff = difftime(now,str2time(commit_dates[i])); 256 if (diff<365*24*3600){ 257 n365++; 258 if (diff<30*24*3600){ 259 n30++; 260 if (diff<7*24*3600) 261 n7++; 262 } 270 time_t first = str2time(commit_dates[0]); 271 time_t last = str2time(commit_dates.back()); 272 273 u_int years = 0; 274 u_int months = 0; 275 u_int days = 0; 276 // No support in std for diffing two tm structs 277 time_t now = time(NULL); 278 tm* timeinfo = gmtime(&now); 279 while (difftime(now,first)>0){ 280 --timeinfo->tm_year; 281 now = mktime(timeinfo); 282 ++years; 283 } 284 --years; 285 ++timeinfo->tm_year; 286 now = mktime(timeinfo); 287 288 while (difftime(now,first)>0){ 289 if (timeinfo->tm_mon>0) 290 --timeinfo->tm_mon; 291 else{ 292 timeinfo->tm_mon=11; 293 --timeinfo->tm_year; 263 294 } 295 now = mktime(timeinfo); 296 ++months; 264 297 } 298 --months; 299 ++timeinfo->tm_mon; 300 if (timeinfo->tm_mon>11){ 301 timeinfo->tm_mon=0; 302 ++timeinfo->tm_year; 303 } 304 now = mktime(timeinfo); 305 306 days = (now - first)/60/60/24; 307 308 now = time(NULL); 265 309 os << "<div class=\"main\">\n" 266 << "<table><thead><tr><th>Statistics for " << dir 310 << "<table class=\"main\"><thead><tr><th colspan=\"2\">" 311 << "General Information" 267 312 << "</th></tr><thead>\n" 268 << "<tr><td>Total number of commits</td><td>" 269 << commit_dates.size()-1 << "</td></tr>\n" 270 << "<tr><td>Commits last year</td><td>" << n365 << "</td></tr>\n" 271 << "<tr><td>Commits last month</td><td>" << n30 << "</td></tr>\n" 272 << "<tr><td>Commits last week</td><td>" << n7 << "</td></tr>\n" 313 << "<tr><td>First Revision:</td><td>" 314 << asctime(gmtime(&first)) << "</td></tr>\n" 315 << "<tr><td>Latest Revision:</td><td>" 316 << asctime(gmtime(&last)) << "</td></tr>\n" 317 << "<tr><td>Report Generated:</td><td>" 318 << asctime(gmtime(&now)) << "</td></tr>\n" 319 << "<tr><td>Repository Age:</td><td>"; 320 if (years){ 321 os << years << " year"; 322 if (years>1) 323 os << "s"; 324 os << " "; 325 } 326 if (months){ 327 os << months << " month"; 328 if (months>1) 329 os << "s"; 330 os << " "; 331 } 332 if (months || years) 333 os << "and "; 334 os << days << " day"; 335 if (days>1) 336 os << "s"; 337 338 os << "</td></tr>\n" 339 << "<tr><td>Number of Authors:</td><td>" << stats.authors().size() 340 << "</td></tr>\n" 341 << "<tr><td>Revisions:</td><td>" << commit_dates.size()-1 342 << "</td></tr>\n" 273 343 << "</table></div>\n"; 344 os << "<hr width=100% />"; 274 345 275 346 … … 281 352 void print_footer(std::ostream& os) 282 353 { 354 283 355 time_t rawtime; 284 356 struct tm * timeinfo; -
trunk/lib/html_utility.h
r211 r223 34 34 namespace svndigest{ 35 35 36 class Stats; 36 37 /// 37 38 /// @brief send anchor to stream @a os … … 60 61 /// @brief print main page 61 62 /// 62 void print_main_page(const std::string&, const std::vector<std::string>&); 63 void print_main_page(const std::string&, const std::vector<std::string>&, 64 const Stats&); 63 65 64 66 ///
Note: See TracChangeset
for help on using the changeset viewer.