Changeset 207


Ignore:
Timestamp:
Sep 11, 2006, 9:08:57 AM (13 years ago)
Author:
Peter Johansson
Message:

refs #41 and #44. Splitted print function in File and Directory to 2 functions. One public and one private. The private print a page for a specific author (or all) and specific code (or total), and the public calls this private function. Also added total number of commits #refs 87. NOTE the change of file structure forced all local paths to be relative from target/projectname rather than target as before.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svndigest.cc

    r201 r207  
    136136  if (!option->revisions())
    137137    GnuplotFE::instance()->set_dates(commit_dates);
    138   GnuplotFE::instance()->command(std::string("cd '")+option->targetdir()+"'");
    139138  chdir(option->targetdir().c_str());
    140139  mkdir(tree.name());
    141   print_css(tree.name()+"/svndigest.css");
     140  chdir(tree.name().c_str());
     141  GnuplotFE::instance()->command(std::string("cd '")+option->targetdir()+"/"
     142                                 +tree.name()+"'");
     143  print_css("svndigest.css");
    142144  print_main_page(tree.name(), commit_dates);
    143   mkdir(tree.name()+"/all");
    144   mkdir(tree.name()+"/all/total");
     145  mkdir("all");
    145146  try {
    146     tree.print(tree.name()+"/all/total", option->verbose());
     147    tree.print(option->verbose());
    147148  }
    148149  catch (const std::runtime_error& x) {
  • trunk/lib/Directory.cc

    r203 r207  
    7171          lstat(fullpath.c_str(),&nodestat);   // C api from sys/stat.h
    7272          if (S_ISDIR(nodestat.st_mode))       // C api from sys/stat.h
    73             daughters_.push_back(new Directory(level_+1,fullpath,
    74                                                local_path()+"/"));
     73            daughters_.push_back(new Directory(level_+1,fullpath,local_path()));
    7574          else
    76             daughters_.push_back(new File(level_,fullpath,local_path()+"/"));
     75            daughters_.push_back(new File(level_,fullpath,local_path()));
    7776          break;
    7877        case SVN::unresolved:
     
    118117
    119118
    120   void Directory::print(const std::string& out_path, const bool verbose) const
    121   {
    122     mkdir(out_path);
    123     std::string output(out_path + "/index.html");
     119  void Directory::print(const bool verbose) const
     120  {
     121    if (ignore())
     122      return;
    124123    if (verbose)
    125124      std::cout << "Printing output for " << path_ << std::endl;
    126     std::ofstream os(output.c_str());
     125    print("all", "total");
     126
     127    // print daughter nodes, i.e., this function is recursive
     128    for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
     129      (*i)->print(verbose);
     130  }
     131
     132
     133  void Directory::print(const std::string& user,
     134                        const std::string& line_type) const
     135  {
     136    std::string outdir = user+"/"+line_type+"/"+local_path_;
     137    if (local_path_=="")
     138      outdir = user+"/"+line_type;
     139
     140    mkdir(outdir);
     141    std::string html_name = outdir+"/index.html";
     142    std::ofstream os(html_name.c_str());
     143    assert(os.good());
    127144    print_header(os, name(), level_+2);
    128145    path_anchor(os);
    129146    os << "<p align=center>\n<img src='"
    130        << file_name(stats_.plot(out_path+"/index.png", local_path()))
     147       << file_name(stats_.plot(outdir+"/index.png", local_path()))
    131148       << "' alt='[plot]' border=0><br>\n";
    132149    os << "<table class=\"listings\">\n";
     
    168185    os << "<td>" << stats_.code() << "</td>\n";
    169186    os << "<td>" << stats_.comments() << "</td>\n";
     187    os << "<td>" << stats_.empty() << "</td>\n";
    170188    os << "<td>" << stats_.last_changed_rev() << "</td>\n";
    171189    os << "<td>" << author() << "</td>\n";
     
    176194    os.close();
    177195
    178     // print daughter nodes, i.e, this function is recursive
    179     for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
    180       (*i)->print(out_path+"/"+(*i)->name(), verbose);
     196
     197
    181198  }
    182199
  • trunk/lib/Directory.h

    r201 r207  
    7777    const Stats& parse(const bool verbose=false);
    7878
    79     void print(const std::string&, const bool verbose=false) const;
     79    void print(const bool verbose=false) const;
    8080
    8181    void print_copyright(const std::vector<std::string>& dates) const;
     
    8686    ///
    8787    Directory(const Directory&);
     88
     89    void print(const std::string& user, const std::string& line_type) const;
     90
    8891
    8992    typedef std::list<Node*> NodeContainer;
  • trunk/lib/File.cc

    r206 r207  
    5757
    5858
    59   void File::print(const std::string& out_path, const bool verbose) const
    60   {
    61     // no output page for binary files
    62     if (ignore())
    63       return;
    64     std::string output(out_path + ".html");
    65     if (verbose)
    66       std::cout << "Printing output for " << path_ << std::endl;
    67     std::ofstream os(output.c_str());
     59  void File::print(const std::string& user, const std::string& line_type) const
     60  {
     61    std::string outpath = user+"/"+line_type+"/"+local_path();
     62    std::string html_name(outpath + ".html");
     63    std::ofstream os(html_name.c_str());
    6864    print_header(os, name(), level_+2);
    6965    path_anchor(os);
    7066    os << "<p align=center>\n<img src='"
    71        << file_name(stats_.plot(out_path+".png",local_path()))
     67       << file_name(stats_.plot(outpath+".png",local_path()))
    7268       << "' alt='[plot]' border=0>\n</p>";
    7369
     
    123119
    124120
     121  void File::print(const bool verbose) const
     122  {
     123    // no output page for binary files
     124    if (ignore())
     125      return;
     126    if (verbose)
     127      std::cout << "Printing output for " << path_ << std::endl;
     128    print("all", "total");
     129  }
     130
     131
     132  void File::print_blame(std::ofstream& os, const std::string line_type) const
     133  {
     134    os << "<table class=\"blame\">\n";
     135
     136    os << "</table>\n";
     137  }
     138
     139
    125140  void File::print_copyright(const std::vector<std::string>& dates) const
    126141  {
  • trunk/lib/File.h

    r201 r207  
    6060
    6161    ///
     62    /// printing all pages related to this file
    6263    ///
     64    void print(const bool verbose=false) const;
     65
    6366    ///
    64     void print(const std::string&, const bool verbose=false) const;
     67    /// print blame output
     68    ///
     69    void print_blame(std::ofstream&, const std::string line_type) const;
    6570
    6671    void print_copyright(const std::vector<std::string>&) const;
     
    8085    File(const File&);
    8186
     87    ///
     88    /// print page for specific user (or all) and specific line_style
     89    /// (or total).
     90    ///
     91    void print(const std::string& user, const std::string& line_type) const;
     92
    8293  };
    8394
  • trunk/lib/Node.cc

    r203 r207  
    2727#include "utility.h"
    2828
     29#include <cassert>
    2930#include <ctime>
    3031#include <fstream>
     
    3435namespace svndigest{
    3536
     37  std::string Node::project_=std::string();
     38
    3639  Node::Node(const u_int level, const std::string& path,
    37              const std::string& output="")
    38     : level_(level), path_(path), stats_(path), svninfo_(path)
     40             const std::string& local_path)
     41    : level_(level), path_(path), stats_(path),
     42      svninfo_(path)
    3943  {
    4044    SVNproperty property(path);
    4145    binary_=property.binary();
    4246    svndigest_ignore_=property.svndigest_ignore();
    43     local_path_ = output+file_name(path_);
     47    if (Node::project_==std::string()) // no root directory in local path
     48      Node::project_ = file_name(path);
     49    else if (local_path.empty())
     50      local_path_ = file_name(path);
     51    else
     52      local_path_ = local_path + "/" + file_name(path);
    4453  }
    4554
     
    5362  void Node::path_anchor(std::ostream& os) const
    5463  {
     64
    5565    os << "<h2 class=\"path\">\n";
    5666    std::vector<std::string> words;
    5767    words.reserve(level_+1);
    5868    std::string word;
     69    words.push_back(Node::project_);
    5970    std::stringstream ss(local_path());
    6071    while(getline(ss,word,'/'))
    61       words.push_back(word);
    62     for (size_t i=0; i<words.size()-1; ++i){
    63       anchor(os,"index.html", words[i], level_-i, "View " + words[i]);
    64       os << "<span class=\"sep\">/</span>\n";
     72      if (!word.empty()) // ignore double slash in path
     73        words.push_back(word);
     74    if (words.size()==1)
     75      anchor(os, "index.html", Node::project_,0, "View " + Node::project_);
     76    else {
     77      for (size_t i=0; i<words.size()-1; ++i){
     78        anchor(os,"index.html", words[i], level_-i, "View " + words[i]);
     79        os << "<span class=\"sep\">/</span>\n";
     80      }
     81      anchor(os,href(), words.back(), level_+2-words.size(),
     82             "View " + words.back());
    6583    }
    66     anchor(os,href(), words.back(), level_+2-words.size(),
    67            "View " + words.back());
    6884    os << "\n</h2>\n";
    6985  }
  • trunk/lib/Node.h

    r203 r207  
    137137    /// Function printing HTML in current working directory
    138138    ///
    139     virtual void print(const std::string&, const bool verbose=false) const=0;
     139    virtual void print(const bool verbose=false) const=0;
    140140
    141141    virtual void print_copyright(const std::vector<std::string>& dates) const=0;
     
    163163    std::string local_path_; // path from root
    164164    std::string path_; // absolute path
     165    static std::string project_;
    165166    Stats stats_;
    166167
  • trunk/lib/Stats.cc

    r202 r207  
    160160  {
    161161    GnuplotFE* gp=GnuplotFE::instance();
    162     gp->command("set term png transparent");
     162    gp->command("set term png");
    163163    gp->command("set output '"+filename+"'");
    164164    gp->command("set title '"+title+"'");
  • trunk/lib/html_utility.cc

    r201 r207  
    188188                       const std::vector<std::string>& commit_dates)
    189189  {
    190     std::string filename=dir+"/index.html";
     190    std::string filename="index.html";
    191191    std::ofstream os(filename.c_str());
    192192    print_header(os, dir, 0);
     
    210210       << "<table><thead><tr><th>Statistics for " << dir
    211211       << "</th></tr><thead>\n"
     212       << "<tr><td>Total number of commits</td><td>"
     213       << commit_dates.size()-1 << "</td></tr>\n"
    212214       << "<tr><td>Commits last year</td><td>" << n365 << "</td></tr>\n"
    213215       << "<tr><td>Commits last month</td><td>" << n30 << "</td></tr>\n"
Note: See TracChangeset for help on using the changeset viewer.