Changeset 235
- Timestamp:
- Apr 21, 2007, 3:39:50 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/svndigest.cc
r234 r235 159 159 +tree.name()+"'"); 160 160 print_css("svndigest.css"); 161 print_main_page(tree.name(), svnlog, stats); 161 SVNlog local_log(option->root()); 162 print_main_page(tree.name(), local_log, stats); 162 163 mkdir("all"); 164 mkdir("images"); 163 165 for (std::set<std::string>::const_iterator i = stats.authors().begin(); 164 166 i!=stats.authors().end(); ++i) { -
trunk/lib/Directory.cc
r234 r235 153 153 154 154 mkdir(outdir); 155 std::string imagedir = "images/"+line_type+"/"+local_path_; 156 if (user=="all") 157 mkdir(imagedir); 158 155 159 std::string html_name = outdir+"/index.html"; 156 160 std::ofstream os(html_name.c_str()); … … 162 166 local_path()+"/index.html"); 163 167 path_anchor(os); 164 os << "<p align=center>\n<img src='" 165 << file_name(stats_.plot(outdir+"/index.png", local_path(),line_type)) 166 << "' alt='[plot]' border=0><br>\n"; 168 os << "<p align=center>\n<img src='"; 169 for (size_t i=0; i<level_; ++i) 170 os << "../"; 171 os << "../../"; 172 if (user=="all") 173 os << stats_.plot(imagedir+"/index.png", local_path(),line_type); 174 else 175 os << imagedir << "/index.png"; 176 os << "' alt='[plot]' border=0><br>\n"; 167 177 os << "<table class=\"listings\">\n"; 168 178 os << "<thead>"; … … 182 192 os << "<tr class=\"light\">\n"; 183 193 os << "<td class=\"directory\" colspan=\"6\">"; 184 anchor(os,"../index.html", "../");194 os << anchor("../index.html", "../"); 185 195 os << "</td>\n</tr>\n"; 186 196 color = "dark"; … … 213 223 os << "</tr>\n"; 214 224 os << "</table>\n"; 215 print_author_summary(os );225 print_author_summary(os, line_type); 216 226 os << "</p>\n"; 217 227 print_footer(os); -
trunk/lib/File.cc
r234 r235 64 64 { 65 65 std::string outpath = user+"/"+line_type+"/"+local_path(); 66 std::string imagefile = "images/"+line_type+"/"+local_path_+".png"; 66 67 std::string html_name(outpath + ".html"); 67 68 std::ofstream os(html_name.c_str()); 68 69 print_header(os, name(), level_+2, user, line_type, local_path()+".html"); 69 70 path_anchor(os); 70 os << "<p align=center>\n<img src='" 71 << file_name(stats_.plot(outpath+".png",local_path(),line_type)) 72 << "' alt='[plot]' border=0>\n</p>"; 73 74 print_author_summary(os); 71 os << "<p align=center>\n<img src='"; 72 for (size_t i=0; i<level_; ++i) 73 os << "../"; 74 os << "../../"; 75 if (user=="all") 76 os << stats_.plot(imagefile, local_path(),line_type); 77 else 78 os << imagefile; 79 os << "' alt='[plot]' border=0>\n</p>"; 80 81 print_author_summary(os, line_type); 75 82 os << "</p>\n"; 76 83 … … 137 144 // else insert user name 138 145 copyright[timeinfo->tm_year].insert(*author); 139 std::cerr << "Warning: no alias found for `" << *author << "`\n"; 146 std::cerr << "svndigest: warning: no copyright alias found for `" 147 << *author << "`\n"; 140 148 // insert alias to avoid multiple warnings. 141 149 alias.insert(name, std::make_pair(*author, *author)); -
trunk/lib/HtmlStream.cc
r234 r235 61 61 { 62 62 char c; 63 while ( ss.good()){63 while (true){ 64 64 ss.get(c); 65 if (!ss.good()) 66 return; 65 67 std::map<char, std::string>::const_iterator i = map_.find(c); 66 68 if (i==map_.end()) -
trunk/lib/Node.cc
r234 r235 74 74 words.push_back(word); 75 75 if (words.size()==1) 76 anchor(os,"index.html", Node::project_,0, "View " + Node::project_);76 os << anchor("index.html", Node::project_,0, "View " + Node::project_); 77 77 else { 78 78 for (size_t i=0; i<words.size()-1; ++i){ 79 anchor(os,"index.html", words[i], level_-i, "View " + words[i]);79 os << anchor("index.html", words[i], level_-i, "View " + words[i]); 80 80 os << "<span class=\"sep\">/</span>\n"; 81 81 } 82 anchor(os,href(), words.back(), level_+2-words.size(),82 os << anchor(href(), words.back(), level_+2-words.size(), 83 83 "View " + words.back()); 84 84 } … … 101 101 os << name(); 102 102 else 103 anchor(os,href(), name());103 os << anchor(href(), name()); 104 104 os << "</td>\n"; 105 105 if (user=="all") { … … 121 121 122 122 123 void Node::print_author_summary(std::ostream& os ) const123 void Node::print_author_summary(std::ostream& os, std::string line_type) const 124 124 { 125 125 os << "<table class=\"listings\">\n"; … … 135 135 os << "<tr class=\"light\">\n"; 136 136 os << "<td class=\"directory\" colspan=\"5\">"; 137 anchor(os, "index.html", "../"); 137 if (!dir()) 138 os << anchor("index.html", "../"); 138 139 os << "</td>\n</tr>\n"; 139 140 … … 142 143 for (std::set<std::string>::const_iterator i=stats_.authors().begin(); 143 144 i!=stats_.authors().end(); ++i){ 144 os << "<tr class=\"" << color << "\"><td>" << *i 145 << "</td><td>" << stats_.lines(*i) 145 os << "<tr class=\"" << color << "\"><td>"; 146 if (dir()) 147 os << anchor(*i+"/"+line_type+"/"+local_path()+"/index.html" 148 ,*i, level_+2, "View statistics for "+*i); 149 else 150 os << anchor(*i+"/"+line_type+"/"+local_path()+".html" 151 ,*i, level_+2, "View statistics for "+*i); 152 os << "</td><td>" << stats_.lines(*i) 146 153 << "</td><td>" << stats_.code(*i) 147 154 << "</td><td>" << stats_.comments(*i) … … 154 161 155 162 os << "<tr class=\"" << color << "\">\n"; 156 os << "<td>Total</td>\n"; 163 os << "<td>"; 164 if (dir()) 165 os << anchor("all/"+line_type+"/"+local_path()+"/index.html" 166 ,"Total", level_+2, "View statistics for all"); 167 else 168 os << anchor("all/"+line_type+"/"+local_path()+".html" 169 ,"Total", level_+2, "View statistics for all"); 170 os << "</td>\n"; 157 171 os << "<td>" << stats_.lines() << "</td>\n"; 158 172 os << "<td>" << stats_.code() << "</td>\n"; -
trunk/lib/Node.h
r234 r235 142 142 virtual void print(const bool verbose=false) const=0; 143 143 144 void print_author_summary(std::ostream& ) const;144 void print_author_summary(std::ostream&, std::string) const; 145 145 146 146 virtual void -
trunk/lib/html_utility.cc
r234 r235 24 24 #include "html_utility.h" 25 25 26 #include "Date.h" 26 27 #include "HtmlStream.h" 27 28 #include "Stats.h" … … 43 44 namespace svndigest{ 44 45 45 void anchor(std::ostream& os, const std::string& href, 46 const std::string& name, u_int level, 47 const std::string& title) 48 { 49 os << "<a title=\"" << title << "\" href=\"" ; 46 std::string anchor(const std::string& href, 47 const std::string& name, u_int level, 48 const std::string& title) 49 { 50 std::stringstream ss; 51 HtmlStream hs(ss); 52 ss << "<a title=\""; 53 hs << title; 54 ss << "\" href=\""; 50 55 for (size_t i=0; i<level; ++i) 51 os << "../"; 52 os << href << "\">" << name << "</a>"; 56 ss << "../"; 57 hs << href; 58 ss << "\">"; 59 hs << name; 60 ss << "</a>"; 61 return ss.str(); 53 62 } 54 63 … … 230 239 231 240 using namespace std; 232 map<string, time_t> latest_commit_date;241 map<string, Date> latest_commit_date; 233 242 assert(log.author().size()==log.date().size()); 234 243 typedef vector<string>::const_iterator iter; … … 236 245 for (iter a=log.author().begin(); 237 246 a!=log.author().end(); ++a, ++d) { 238 latest_commit_date[*a]= str2time(*d);247 latest_commit_date[*a]=Date(*d); 239 248 } 240 249 // erase invalid authors … … 243 252 244 253 // vector of authors & date sorted with respect to date 245 typedef vector<pair<string, time_t> > vector;254 typedef vector<pair<string, Date> > vector; 246 255 vector author_date; 247 256 author_date.reserve(latest_commit_date.size()); … … 249 258 copy(latest_commit_date.begin(), latest_commit_date.end(), i); 250 259 sort(author_date.begin(), author_date.end(), 251 pair_value_compare<string, time_t>());260 pair_value_compare<string,Date>()); 252 261 253 262 print_general_information(os, log, author_date.size()); … … 263 272 size_t nof_authors) 264 273 { 265 time_t first = str2time(log.date()[1]); 266 std::string first_date = asctime(gmtime(&first)); 267 time_t last = str2time(log.date().back()); 268 std::string last_date = asctime(gmtime(&last)); 269 270 u_int years = 0; 271 u_int months = 0; 272 u_int days = 0; 273 // No support in std for diffing two tm structs 274 time_t now = time(NULL); 275 tm* timeinfo = gmtime(&now); 276 std::string now_date = asctime(timeinfo); 277 while (difftime(now,first)>0){ 278 --timeinfo->tm_year; 279 now = mktime(timeinfo); 280 ++years; 281 } 282 --years; 283 ++timeinfo->tm_year; 284 now = mktime(timeinfo); 285 286 while (difftime(now,first)>0){ 287 if (timeinfo->tm_mon>0) 288 --timeinfo->tm_mon; 289 else{ 290 timeinfo->tm_mon=11; 291 --timeinfo->tm_year; 292 } 293 now = mktime(timeinfo); 294 ++months; 295 } 296 --months; 297 ++timeinfo->tm_mon; 298 if (timeinfo->tm_mon>11){ 299 timeinfo->tm_mon=0; 300 ++timeinfo->tm_year; 301 } 302 now = mktime(timeinfo); 303 304 days = (now - first)/60/60/24; 305 306 now = time(NULL); 274 Date begin(log.date()[0]); 275 if (log.date().size()>1) 276 begin = std::min(begin, Date(log.date()[1])); 277 Date end(log.date().back()); 278 Date now; 279 std::string timefmt("%a, %e %b %Y"); 280 307 281 os << "<div class=\"main\">" 308 282 << "<table class=\"main\"><thead><tr><th colspan=\"2\">" … … 310 284 << "</th></tr></thead>\n" 311 285 << "<tr><td>First Revision:</td><td>" 312 << first_date<< "</td></tr>\n"286 << begin(timefmt) << "</td></tr>\n" 313 287 << "<tr><td>Latest Revision:</td><td>" 314 << last_date<< "</td></tr>\n"288 << end(timefmt) << "</td></tr>\n" 315 289 << "<tr><td>Report Generated:</td><td>" 316 << now_date<< "</td></tr>\n"290 << now(timefmt) << "</td></tr>\n" 317 291 << "<tr><td>Repository Age:</td><td>"; 318 if (years){ 319 os << years << " year"; 320 if (years>1) 321 os << "s"; 322 os << " "; 323 } 324 if (months){ 325 os << months << " month"; 326 if (months>1) 327 os << "s"; 328 os << " "; 329 } 330 if (months || years) 331 os << "and "; 332 os << days << " day"; 333 if (days>1) 334 os << "s"; 335 292 os << now.difftime(begin); 336 293 os << "</td></tr>\n" 337 294 << "<tr><td>Number of Authors:</td><td>" << nof_authors 338 295 << "</td></tr>\n" 339 << "<tr><td>Revisions:</td><td>" << log.revision(). size()-1296 << "<tr><td>Revisions:</td><td>" << log.revision().back() 340 297 << "</td></tr>\n" 341 298 << "</table></div>\n"; … … 345 302 void print_footer(std::ostream& os) 346 303 { 347 348 time_t rawtime; 349 struct tm * timeinfo; 350 time ( &rawtime ); 351 timeinfo = gmtime ( &rawtime ); 304 Date date; 352 305 os << "<p align=center><font size=-2>\nGenerated on " 353 << asctime (timeinfo) << " (UTC) by "; 354 anchor(os, "http://lev.thep.lu.se/trac/svndigest/", PACKAGE_STRING, 0, ""); 355 os << "</font>\n</p>\n</div>\n</body>\n</html>\n"; 306 << date("%a %b %d %H:%M:%S %Y") << " (UTC) by " 307 << anchor("http://lev.thep.lu.se/trac/svndigest/", 308 PACKAGE_STRING, 0, "") 309 << "</font>\n</p>\n</div>\n</body>\n</html>\n"; 356 310 } 357 311 … … 380 334 else 381 335 os << "<li>"; 382 anchor(os,"index.html", "Main", level, "Main page");336 os << anchor("index.html", "Main", level, "Main page"); 383 337 os << "</li>"; 384 338 … … 387 341 else 388 342 os << "<li>"; 389 anchor(os,user+"/total/"+path, "Total", level,343 os << anchor(user+"/total/"+path, "Total", level, 390 344 "View statistics of all lines"); 391 345 os << "</li>"; … … 395 349 else 396 350 os << "<li>"; 397 anchor(os,user+"/code/"+path, "Code", level,398 "View statistics of code lines");351 os << anchor(user+"/code/"+path, "Code", level, 352 "View statistics of code lines"); 399 353 os << "</li>"; 400 354 … … 403 357 else 404 358 os << "<li>"; 405 anchor(os,user+"/comments/"+path, "Comment", level,406 "View statistics of comment lines");359 os << anchor(user+"/comments/"+path, "Comment", level, 360 "View statistics of comment lines"); 407 361 os << "</li>"; 408 362 … … 412 366 else 413 367 os << "<li>"; 414 anchor(os,user+"/empty/"+path, "Empty", level,415 "View statistics of empty lines");368 os << anchor(user+"/empty/"+path, "Empty", level, 369 "View statistics of empty lines"); 416 370 os << "</li>" 417 371 << "</ul></div>" … … 421 375 422 376 void print_authors(std::ostream& os, 423 const std::vector<std::pair<std::string, time_t> >& ad,377 const std::vector<std::pair<std::string,Date> >& auth_date, 424 378 const SVNlog& log, const Stats& stats) 425 379 { … … 436 390 <<"</tr>"; 437 391 392 std::string timefmt("%b %d %H:%M:%S %Y"); 438 393 using namespace std; 439 for (vector<pair<string, time_t> >::const_reverse_iterator i=ad.rbegin();440 i!=a d.rend(); ++i) {441 os << "<tr><td>" ;442 anchor(os, string(i->first+"/total/index.html"),i->first);443 os<< "</td><td>" << stats.lines(i->first) << " ("394 for (vector<pair<string,Date> >::const_reverse_iterator i=auth_date.rbegin(); 395 i!=auth_date.rend(); ++i) { 396 os << "<tr><td>" 397 << anchor(string(i->first+"/total/index.html"),i->first) 398 << "</td><td>" << stats.lines(i->first) << " (" 444 399 << 100*stats.lines(i->first)/stats.lines() << "%)</td>" 445 400 << "<td>" << stats.code(i->first) << " (" … … 447 402 << "<td>" << stats.comments(i->first) << " (" 448 403 << 100*stats.comments(i->first)/stats.comments() << "%)</td>" 449 << "<td>" << asctime(gmtime(&i->second)) << "</td>"404 << "<td>" << i->second(timefmt) << "</td>" 450 405 <<"</tr>"; 451 406 } … … 466 421 std::vector<std::string>::const_reverse_iterator d=log.date().rbegin(); 467 422 std::vector<std::string>::const_reverse_iterator m=log.message().rbegin(); 423 std::vector<size_t>::const_reverse_iterator r=log.revision().rbegin(); 468 424 assert(log.author().size()==log.date().size()); 469 425 assert(log.author().size()==log.message().size()); 426 assert(log.author().size()==log.revision().size()); 427 os << "<tr><td>Author</td><td>Date</td><td>Rev</td><td>Message</td></tr>\n"; 470 428 HtmlStream hs(os); 429 std::string timefmt("%b %d %H:%M:%S %Y"); 430 const size_t maxlength = 80; 471 431 for (size_t i=0; i<10 && a!=log.author().rend(); ++i) { 472 os << "<tr><td>" << *a << "</td>"; 473 time_t date = str2time(*d); 474 os << "<td>" << asctime(gmtime(&date)) << "</td>"; 432 os << "<tr><td>" << anchor(*a+"/total/index.html",*a) << "</td>"; 433 Date date(*d); 434 os << "<td>" << date(timefmt) << "</td>"; 435 os << "<td>" << *r << "</td>"; 475 436 os << "<td>"; 476 hs << *m; 437 std::string mess = *m; 438 // replace newlines with space 439 std::replace(mess.begin(), mess.end(), '\n', ' '); 440 mess = htrim(mess); 441 // trunctate message if too long 442 if (mess.size()>maxlength) 443 mess = mess.substr(0,maxlength-3) + "..."; 444 hs << mess; 477 445 os << "</td></tr>"; 478 446 ++a; 479 447 ++d; 480 448 ++m; 449 ++r; 481 450 } 482 451 os << "</table></div>\n"; -
trunk/lib/html_utility.h
r234 r235 35 35 namespace svndigest{ 36 36 37 class Date; 37 38 class Stats; 38 39 class SVNlog; 39 40 40 41 /// 41 /// @brief send anchor to stream @a os42 /// @brief create anchor 42 43 /// 43 44 /// @param href address to link to … … 46 47 /// @param title title of anchor 47 48 /// 48 void anchor(std::ostream& os,const std::string& href,49 const std::string& name, u_int level=0,50 const std::string& title="");49 std::string anchor(const std::string& href, 50 const std::string& name, u_int level=0, 51 const std::string& title=""); 51 52 52 53 /// … … 56 57 57 58 void print_authors(std::ostream& os, 58 const std::vector<std::pair<std::string, time_t> >&,59 const std::vector<std::pair<std::string, Date> >&, 59 60 const SVNlog&, const Stats& stats); 60 61
Note: See TracChangeset
for help on using the changeset viewer.