Ignore:
Timestamp:
Apr 30, 2007, 1:17:36 PM (16 years ago)
Author:
Peter Johansson
Message:

reimplementing some part of print_main_page using Commitment class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/html_utility.cc

    r254 r256  
    2424#include "html_utility.h"
    2525
     26#include "Commitment.h"
    2627#include "Date.h"
    2728#include "HtmlStream.h"
     
    239240
    240241    using namespace std;
    241     map<string, Date> latest_commit_date;
    242     assert(log.author().size()==log.date().size());
    243     typedef vector<string>::const_iterator iter;
    244     iter d=log.date().begin();
    245     for (iter a=log.author().begin();
    246          a!=log.author().end(); ++a, ++d) {
    247       latest_commit_date[*a]=Date(*d);
    248     }
     242    set<string> authors;
     243    authors.insert(log.author().begin(), log.author().end());
    249244    // erase invalid authors
    250     latest_commit_date.erase("");
    251     latest_commit_date.erase("no author");
    252 
    253     // vector of authors & date sorted with respect to date
    254     typedef vector<pair<string, Date> > vector;
    255     vector author_date;
    256     author_date.reserve(latest_commit_date.size());
    257     back_insert_iterator<vector> i(author_date);
    258     copy(latest_commit_date.begin(), latest_commit_date.end(), i);
    259     sort(author_date.begin(), author_date.end(),
    260          pair_value_compare<string,Date>());
    261 
    262     print_general_information(os, log, author_date.size());
    263     print_authors(os, author_date, log, stats);
     245    authors.erase("");
     246    authors.erase("no author");
     247
     248    vector<Commitment> latest_commit;
     249    latest_commit.reserve(authors.size());
     250    for (set<string>::const_iterator i(authors.begin()); i!=authors.end(); ++i)
     251      latest_commit.push_back(log.latest_commit(*i));
     252
     253    print_general_information(os, log, authors.size());
     254    sort(latest_commit.begin(), latest_commit.end(), GreaterRevision());
     255    print_authors(os, latest_commit, stats);
    264256    print_recent_logs(os, log);
    265257    os << "<hr width=100% />";
     
    375367
    376368  void print_authors(std::ostream& os,
    377                      const std::vector<std::pair<std::string,Date> >& auth_date,
    378                      const SVNlog& log, const Stats& stats)
     369                     const std::vector<Commitment>& lc,
     370                     const Stats& stats)
    379371  {
    380372    os << "<div class=\"main\">"
     
    392384    std::string timefmt("%b %d %H:%M:%S %Y");
    393385    using namespace std;
    394     for (vector<pair<string,Date> >::const_reverse_iterator i=auth_date.rbegin();
    395          i!=auth_date.rend(); ++i) {
     386    for (vector<Commitment>::const_iterator i=lc.begin(); i!=lc.end(); ++i) {
    396387      os << "<tr><td>"
    397          << anchor(string(i->first+"/total/index.html"),i->first)
    398          << "</td><td>" << stats.lines(i->first) << " ("
    399          << 100*stats.lines(i->first)/stats.lines() << "%)</td>"
    400          << "<td>" << stats.code(i->first) << " ("
    401          << 100*stats.code(i->first)/stats.code() << "%)</td>"
    402          << "<td>" << stats.comments(i->first) << " ("
    403          << 100*stats.comments(i->first)/stats.comments() << "%)</td>"
    404          << "<td>" << i->second(timefmt) << "</td>"
     388         << anchor(string(i->author()+"/total/index.html"),i->author())
     389         << "</td><td>" << stats.lines(i->author()) << " ("
     390         << 100*stats.lines(i->author())/stats.lines() << "%)</td>"
     391         << "<td>" << stats.code(i->author()) << " ("
     392         << 100*stats.code(i->author())/stats.code() << "%)</td>"
     393         << "<td>" << stats.comments(i->author()) << " ("
     394         << 100*stats.comments(i->author())/stats.comments() << "%)</td>"
     395         << "<td>" << i->date()(timefmt) << "</td>"
    405396         <<"</tr>";
    406397    }
Note: See TracChangeset for help on using the changeset viewer.