Ignore:
Timestamp:
Nov 12, 2010, 5:01:35 AM (11 years ago)
Author:
Peter Johansson
Message:

closes #457. Lifting out plotting functions in Stats into a new class
StatsPlotter?. In same manner lifting out print functions from
Node/Directory/File? into a new hierarchy
NodePrinter/DirectoryPrinter/FilePrinter?. To accomplish these splits
without to much recoding some friendships are introduced. These new
classes are only needed for svndigest (not svncopyright) and are
therefore placed in a library named libsvndigest together with Graph
class and first_page functions. Remaining functionality, shared
between svncopyright and svndigest, are located in libsvndigest_core
and linked into both binaries.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Directory.cc

    r1289 r1290  
    146146
    147147
    148   std::string Directory::output_path(void) const
    149   {
    150     return output_dir()+"index.html";
    151   }
    152 
    153 
    154   void Directory::print_core(const bool verbose) const
    155   {
    156   }
    157 
    158 
    159   void Directory::print_core(const std::string& stats_type,
    160                              const std::string& user,
    161                              const std::string& line_type,
    162                              const SVNlog& log) const
    163   {
    164 
    165     const Stats& stats = stats_[stats_type];
    166     std::string imagedir = stats_type+"/"+"images/"+line_type;
    167     std::string outdir   = stats_type+"/"+user+"/" +line_type;
    168     if (local_path()!="") {
    169       imagedir += "/"+local_path();
    170       outdir   += "/"+local_path();
    171     }
    172     mkdir_p(outdir);
    173     if (user=="all")
    174       mkdir_p(imagedir);
    175     std::string html_name = outdir+"/index.html";
    176     std::ofstream os(html_name.c_str());
    177     assert(os.good());
    178     if (local_path().empty())
    179       print_header(os, name(), level_+3, user, line_type, "index.html",
    180                    stats_type);
    181     else
    182       print_header(os, name(), level_+3, user, line_type,
    183                    local_path()+"/index.html", stats_type);
    184     path_anchor(os);
    185 
    186     std::stringstream ss;
    187     for (size_t i=0; i<level_; ++i)
    188       ss << "../";
    189     ss << "../../../";
    190     if (user=="all")
    191       ss << stats.plot(imagedir+"/index", line_type);
    192     else
    193       ss << imagedir << "/index";
    194     os << "<p class=\"plot\">\n";
    195     os << image(ss.str());
    196     os << "</p>\n";
    197 
    198     os << "<h3>File Summary";
    199     if (user!="all")
    200       os << " for " << user;
    201     os << "</h3>";     
    202     os << "<table class=\"listings\">\n";
    203     os << "<thead>\n";
    204     os << "<tr>\n";
    205     os << "<th>Node</th>\n";
    206     os << "<th>Lines</th>\n";
    207     os << "<th>Code</th>\n";
    208     os << "<th>Comments</th>\n";
    209     os << "<th>Other</th>\n";
    210     os << "<th>Revision</th>\n";
    211     os << "<th>Author</th>\n";
    212     os << "</tr>\n</thead>\n";
    213     os << "<tbody>\n";
    214 
    215     std::string color("light");
    216     if (level_){
    217       os << "<tr class=\"light\">\n";
    218       os << "<td class=\"directory\" colspan=\"7\">";
    219       os << anchor("../index.html", "../");
    220       os << "</td>\n</tr>\n";
    221       color = "dark";
    222     }
    223 
    224     // print html links to daughter nodes
    225     for (NodeConstIterator d = daughters_.begin(); d!=daughters_.end(); ++d) {
    226       (*d)->html_tablerow(os,stats_type, color, user);
    227       if (color=="dark")
    228         color = "light";
    229       else
    230         color = "dark";
    231     }
    232     os << "<tr class=\"" << color << "\">\n";
    233     os << "<td>Total</td>\n";
    234     if (user=="all"){
    235       os << "<td>" << stats.lines() << "</td>\n";
    236       os << "<td>" << stats.code() << "</td>\n";
    237       os << "<td>" << stats.comments() << "</td>\n";
    238       os << "<td>" << stats.empty() << "</td>\n";
    239     }
    240     else {
    241       os << "<td>" << stats.lines(user);
    242       if (stats.lines(user))
    243         os << " (" << percent(stats.lines(user),stats.lines()) << "%)";
    244       os << "</td>\n";
    245       os << "<td>" << stats.code(user);
    246       if (stats.code(user))
    247         os << " (" << percent(stats.code(user),stats.code()) << "%)";
    248       os << "</td>\n";
    249       os << "<td>" << stats.comments(user);
    250       if (stats.comments(user))
    251         os << " (" << percent(stats.comments(user),stats.comments()) << "%)";
    252       os << "</td>\n";
    253       os << "<td>" << stats.empty(user);
    254       if (stats.empty(user))
    255         os << " (" << percent(stats.empty(user),stats.empty()) << "%)";
    256       os << "</td>\n";
    257     }
    258     os << "<td>" << trac_revision(last_changed_rev()) << "</td>\n";
    259     os << "<td>" << author() << "</td>\n";
    260     os << "</tr>\n";
    261     os << "</tbody>\n";
    262     os << "</table>\n";
    263     print_author_summary(os, stats, line_type, log);
    264     os << "\n";
    265     print_footer(os);
    266     os.close();
    267   }
    268 
    269 
    270148  void Directory::traverse(NodeVisitor& visitor)
    271149  {
Note: See TracChangeset for help on using the changeset viewer.