Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Directory.cc
r101 r112 43 43 44 44 45 Directory::Directory(const std::string& path, const std::string& output) 46 : Node(path,output) 45 Directory::Directory(const u_int level, const std::string& path, 46 const std::string& output) 47 : Node(level,path,output) 47 48 { 48 49 using namespace std; … … 69 70 lstat(fullpath.c_str(),&nodestat); // C api from sys/stat.h 70 71 if (S_ISDIR(nodestat.st_mode)) // C api from sys/stat.h 71 daughters_.push_back(new Directory(fullpath, output_name()+"/")); 72 daughters_.push_back(new Directory(level_+1,fullpath, 73 output_name()+"/")); 72 74 else 73 daughters_.push_back(new File( fullpath,output_name()+"/"));75 daughters_.push_back(new File(level_,fullpath,output_name()+"/")); 74 76 break; 75 77 case SVN::unresolved: … … 88 90 } 89 91 92 std::string Directory::author(void) const 93 { 94 std::string a; 95 u_int max_rev=0; 96 for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); i++) 97 if ((*i)->last_changed_rev()>max_rev){ 98 max_rev = (*i)->last_changed_rev(); 99 a = (*i)->author(); 100 } 101 return a; 102 } 103 90 104 bool Directory::dir(void) const 91 105 { … … 96 110 { 97 111 return "<a href=\"" + name() + "/index.html\">" + name() + "</a>"; 112 } 113 114 u_int Directory::last_changed_rev(void) const 115 { 116 u_int max_rev=0; 117 for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); i++) 118 if ((*i)->last_changed_rev()>max_rev) 119 max_rev = (*i)->last_changed_rev(); 120 return max_rev; 98 121 } 99 122 … … 120 143 << file_name(stats_.plot(output_name()+"/index.png", output_name())) 121 144 << "' alt='[plot]' border=0><br>\n"; 122 os << "<table>\n"; 123 os << "<tr>\n<td><strong>Node</strong></td>\n"; 124 os << "<td><strong>Count</strong></td>\n</tr>\n"; 125 os << "<tr>\n<td bgcolor=#dddddd>Total</td>\n"; 126 os << "<td align=right bgcolor=#dddddd>" << stats_.rows() 127 << "</td>\n</tr>\n"; 145 os << "<table class=\"listings\">\n"; 146 os << "<thead>"; 147 os << "<tr>\n"; 148 os << "<th>Node</th>\n"; 149 os << "<th>Lines</th>\n"; 150 os << "<th>Code</th>\n"; 151 os << "<th>Comments</th>\n"; 152 os << "<th>Revision</th>\n"; 153 os << "<th>Author</th>\n"; 154 os << "</tr>\n</thead>\n"; 155 os << "<tbody>"; 156 157 bool dark=false; 158 if (level_){ 159 os << "<tr class=\"light\">\n"; 160 os << "<td colspan=\"6\"><a href=\"../index.html\">../</a></td>\n"; 161 os << "</tr>\n"; 162 dark=!dark; 163 } 128 164 129 165 // print html links to daughter nodes 130 bool dark=true;131 166 for (NodeConstIterator d = daughters_.begin(); d!=daughters_.end(); d++){ 132 167 if (dark) 133 os << (*d)->html_tablerow(" #eeeeee");168 os << (*d)->html_tablerow("dark"); 134 169 else 135 os << (*d)->html_tablerow(" #dddddd");170 os << (*d)->html_tablerow("light"); 136 171 dark = !dark; 137 172 } 173 if (dark) 174 os << "<tr class=\"dark\">\n"; 175 else 176 os << "<tr class=\"light\">\n"; 177 os << "<td>Total</td>\n"; 178 os << "<td>" << stats_.rows() << "</td>\n"; 179 os << "<td>---</td>\n"; 180 os << "<td>---</td>\n"; 181 os << "<td>" << stats_.last_changed_rev() << "</td>\n"; 182 os << "<td>" << author() << "</td>\n"; 183 os << "</tr>\n"; 138 184 os << "</table>\n"; 139 185 os << "</p>\n"; -
trunk/lib/Directory.h
r101 r112 52 52 /// traversed. 53 53 /// 54 Directory(const std::string& path, const std::string& output=""); 54 Directory(const u_int level, const std::string& path, 55 const std::string& output=""); 55 56 56 57 /// … … 58 59 /// 59 60 ~Directory(void); 61 62 /// 63 /// @return author of last commitment. 64 /// 65 std::string author(void) const; 60 66 61 67 /// … … 69 75 std::string html_link(void) const; 70 76 77 /// 78 /// 79 /// 80 u_int last_changed_rev(void) const; 81 71 82 const Stats& parse(const bool verbose=false); 72 83 -
trunk/lib/File.h
r100 r112 38 38 /// @brief Default Constructor 39 39 /// 40 File(const std::string& path, const std::string& output="") 41 : Node(path,output), binary_(false), ignore_(false) {} 40 File(const u_int level, const std::string& path, 41 const std::string& output="") 42 : Node(level,path,output), binary_(false), ignore_(false) {} 43 44 /// 45 /// 46 /// 47 std::string author(void) const { return author_; } 42 48 43 49 /// … … 45 51 /// 46 52 std::string html_link(void) const; 53 54 /// 55 /// 56 /// 57 u_int last_changed_rev(void) const { return revision_; } 47 58 48 59 /// … … 71 82 File(const File&); 72 83 73 84 std::string author_; 74 85 bool binary_; 75 86 bool ignore_; -
trunk/lib/Node.cc
r102 r112 34 34 namespace svnstat{ 35 35 36 Node::Node(const std::string& path, const std::string& output="") 37 : path_(path), stats_(path) 36 Node::Node(const u_int level, const std::string& path, 37 const std::string& output="") 38 : level_(level), path_(path), stats_(path) 38 39 { 39 40 output_name_ = output+file_name(path_); … … 45 46 } 46 47 47 std::string Node::html_tablerow(const std::string& c olor) const48 std::string Node::html_tablerow(const std::string& css_class) const 48 49 { 49 50 std::stringstream ss; 50 ss << "<tr>\n<td bgcolor=" << color << ">" << html_link() 51 << "</td>\n<td bgcolor=" << color << " align=right>" 52 << stats_.rows() << "</td>\n</tr>\n"; 51 ss << "<tr class=\"" << css_class << "\">\n" 52 << "<td" << html_link() << "</td>\n" 53 << "<td>" << stats_.rows() << "</td>\n" 54 << "<td>" << "---" << "</td>\n" 55 << "<td>" << "---" << "</td>\n" 56 << "<td>" << stats_.last_changed_rev() << "</td>\n" 57 << "<td>" << author() << "</td>\n" 58 << "</tr>\n"; 53 59 return ss.str(); 54 60 } … … 78 84 << "<title> svnstat " << name() << "</title>\n" 79 85 << "</head>\n" 80 << "<body bgcolor=#ffffff vlink=#000000>\n"; 86 << "<link rel=\"stylesheet\" " 87 << "href=\""; 88 for (u_int i=0; i<level_; ++i) 89 os << "../"; 90 os << "svnstat.css\" type=\"text/css\" />\n"; 81 91 } 82 92 -
trunk/lib/Node.h
r101 r112 53 53 /// @brief Constructor 54 54 /// 55 // Node(void) : path_("JARI_trixar"), stats_("JARI_trixar") { }; 56 57 /// 58 /// @brief Constructor 59 /// 60 Node(const std::string&, const std::string&); 55 Node(const u_int, const std::string&, const std::string&); 61 56 62 57 /// … … 64 59 /// 65 60 virtual inline ~Node(void) {}; 61 62 /// 63 /// 64 /// 65 virtual std::string author(void) const=0; 66 66 67 67 /// … … 79 79 /// 80 80 std::string html_tablerow(const std::string&) const; 81 82 /// 83 /// 84 /// 85 virtual u_int last_changed_rev(void) const=0; 81 86 82 87 /// … … 98 103 99 104 protected: 105 100 106 /// 101 107 /// Function returning everything after the last '/' … … 115 121 void print_header(std::ostream&) const; 116 122 123 u_int level_; 117 124 std::string output_name_; //without suffix 118 125 std::string path_; -
trunk/lib/Stats.cc
r101 r112 51 51 std::stringstream ss; 52 52 ss << (svn_info.count("Revision") ? svn_info["Revision"] : "0"); 53 ss >> latest_revision_; 53 ss >> revision_; 54 ss.clear(); 55 ss << (svn_info.count("Last Changed Rev") ? svn_info["Last Changed Rev"] : "0"); 56 ss >> last_changed_rev_; 54 57 } 55 58 … … 58 61 { 59 62 // sum of all users 60 std::vector<u_int> sum( latest_revision_+1, 0);63 std::vector<u_int> sum(revision_+1, 0); 61 64 sum=std::accumulate(map_.begin(), map_.end(), sum, 62 65 PairValuePlus<std::string,u_int>()); … … 75 78 std::vector<u_int> vec=(map_.find(user))->second; 76 79 77 if (vec.size() < latest_revision_+1)78 vec.insert(vec.end(), latest_revision_+1-vec.size(), 0);80 if (vec.size() < revision_+1) 81 vec.insert(vec.end(), revision_+1-vec.size(), 0); 79 82 80 83 std::vector<u_int> accum(vec.size()); … … 87 90 std::vector<u_int>* vec = &(map_[user]); 88 91 if (vec->size() < rev+1){ 89 vec->reserve( latest_revision_ + 1);92 vec->reserve(revision_ + 1); 90 93 vec->insert(vec->end(), rev - vec->size(),0); 91 94 vec->push_back(1); -
trunk/lib/Stats.h
r101 r112 47 47 48 48 /// 49 /// 50 /// 51 inline u_int last_changed_rev(void) const { return last_changed_rev_; } 52 53 /// 49 54 /// @return true if file is binary 50 55 /// … … 60 65 /// 61 66 inline void reset(void) { map_.clear(); } 67 68 /// 69 /// 70 /// 71 inline u_int revision(void) const { return revision_; } 62 72 63 73 /// … … 93 103 94 104 95 u_int latest_revision_; // Should be the latest revision for whole project 105 u_int revision_; // Should be the latest revision for whole project 106 u_int last_changed_rev_; // Should be the latest revision for file 96 107 97 108 // Peter, if the vector is sparse make it a map -
trunk/lib/utility.cc
r100 r112 80 80 } 81 81 82 82 void print_css(std::ostream& s) 83 { 84 s << "body {\n"; 85 s << " background: #fff; \n"; 86 s << " color: #000; \n"; 87 s << " margin: 10px; \n"; 88 s << " padding: 0; \n"; 89 s << "} \n"; 90 s << "\n"; 91 s << "body, th, td {\n"; 92 s << " font: normal 13px verdana,arial,'Bitstream Vera Sans'," 93 << "helvetica,sans-serif;\n"; 94 s << "}\n"; 95 s << ":link, :visited {\n"; 96 s << " text-decoration: none;\n"; 97 s << " color: #b00;\n"; 98 s << " border-bottom: 1px dotted #bbb;\n"; 99 s << "}\n"; 100 s << "\n"; 101 s << "table.listings {\n"; 102 s << " clear: both;\n"; 103 s << " border-bottom: 1px solid #d7d7d7;\n"; 104 s << " border-collapse: collapse;\n"; 105 s << " border-spacing: 0;\n"; 106 s << " margin-top: 1em;\n"; 107 s << " width: 100%;\n"; 108 s << "}\n"; 109 s << "\n"; 110 s << "table.listings th {\n"; 111 s << " text-align: left;\n"; 112 s << " padding: 0 1em .1em 0;\n"; 113 s << " font-size: 12px\n"; 114 s << "}\n"; 115 s << "table.listings thead { background: #f7f7f0 }\n"; 116 s << "table.listings thead th {\n"; 117 s << " border: 1px solid #d7d7d7;\n"; 118 s << " border-bottom-color: #999;\n"; 119 s << " font-size: 11px;\n"; 120 s << " font-wheight: bold;\n"; 121 s << " padding: 2px .5em;\n"; 122 s << " vertical-align: bottom;\n"; 123 s << "}\n"; 124 s << "\n"; 125 s << "table.listings tbody td a:hover, table.listing tbody th a:hover {\n"; 126 s << " background-color: transparent;\n"; 127 s << "}\n"; 128 s << "\n"; 129 s << "table.listings tbody td, table.listing tbody th {\n"; 130 s << " border: 1px dotted #ddd;\n"; 131 s << " padding: .33em .5em;\n"; 132 s << " vertical-align: top;\n"; 133 s << "}\n"; 134 s << "\n"; 135 s << "table.listings tbody td a:hover, table.listing tbody th a:hover {\n"; 136 s << " background-color: transparent;\n"; 137 s << "}\n"; 138 s << "table.listings tbody tr { border-top: 1px solid #ddd }\n"; 139 s << "table.listings tbody tr.light { background-color: #fcfcfc }\n"; 140 s << "table.listings tbody tr.dark { background-color: #f7f7f7 }\n"; 141 s << "table.listings tbody tr.hover { background: #eed }\n"; 142 s << "\n"; 143 s << "\n"; 144 s << "\n"; 145 } 83 146 84 147 -
trunk/lib/utility.h
r100 r112 26 26 27 27 #include <algorithm> 28 #include <fstream> 28 29 #include <functional> 29 30 #include <map> … … 59 60 std::map<std::string, std::string> info(const std::string&); 60 61 61 // int log(const std::string&); 62 /// 63 /// @printing cascading style sheet to stream @a s. 64 /// 65 void print_css(std::ostream& s); 62 66 63 67 ///
Note: See TracChangeset
for help on using the changeset viewer.