Changeset 201
- Timestamp:
- Sep 9, 2006, 7:36:34 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/svndigest.cc
r198 r201 138 138 GnuplotFE::instance()->command(std::string("cd '")+option->targetdir()+"'"); 139 139 chdir(option->targetdir().c_str()); 140 mkdir(tree.name()); 141 print_css(tree.name()+"/svndigest.css"); 142 print_main_page(tree.name(), commit_dates); 143 mkdir(tree.name()+"/all"); 144 mkdir(tree.name()+"/all/total"); 140 145 try { 141 tree.print( option->verbose());146 tree.print(tree.name()+"/all/total", option->verbose()); 142 147 } 143 148 catch (const std::runtime_error& x) { … … 156 161 if (option->verbose()) 157 162 std::cout << "Finalizing" << std::endl; 158 std::string css(file_name(option->root())+"/svndigest.css");159 std::ofstream os(css.c_str());160 print_css(os);161 os.close();162 163 163 164 delete option; -
trunk/lib/Directory.cc
r199 r201 72 72 if (S_ISDIR(nodestat.st_mode)) // C api from sys/stat.h 73 73 daughters_.push_back(new Directory(level_+1,fullpath, 74 output_name()+"/"));74 local_path()+"/")); 75 75 else 76 daughters_.push_back(new File(level_,fullpath, output_name()+"/"));76 daughters_.push_back(new File(level_,fullpath,local_path()+"/")); 77 77 break; 78 78 case SVN::unresolved: … … 118 118 119 119 120 void Directory::print(const bool verbose) const120 void Directory::print(const std::string& out_path, const bool verbose) const 121 121 { 122 mkdir(out put_name());123 std::string output(out put_name()+ "/index.html");122 mkdir(out_path); 123 std::string output(out_path + "/index.html"); 124 124 if (verbose) 125 125 std::cout << "Printing output for " << path_ << std::endl; 126 126 std::ofstream os(output.c_str()); 127 print_header(os, name(), level_ );127 print_header(os, name(), level_+2); 128 128 path_anchor(os); 129 129 os << "<p align=center>\n<img src='" 130 << file_name(stats_.plot(out put_name()+"/index.png", output_name()))130 << file_name(stats_.plot(out_path+"/index.png", local_path())) 131 131 << "' alt='[plot]' border=0><br>\n"; 132 132 os << "<table class=\"listings\">\n"; … … 176 176 177 177 // print daughter nodes, i.e, this function is recursive 178 std::for_each(daughters_.begin(), daughters_.end(),179 std::bind2nd(std::mem_fun(&Node::print),verbose));178 for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); ++i) 179 (*i)->print(out_path+"/"+(*i)->name(), verbose); 180 180 } 181 181 -
trunk/lib/Directory.h
r198 r201 77 77 const Stats& parse(const bool verbose=false); 78 78 79 void print(const bool verbose=false) const;79 void print(const std::string&, const bool verbose=false) const; 80 80 81 81 void print_copyright(const std::vector<std::string>& dates) const; -
trunk/lib/File.cc
r199 r201 56 56 57 57 58 void File::print(const bool verbose) const58 void File::print(const std::string& out_path, const bool verbose) const 59 59 { 60 60 // no output page for binary files 61 61 if (ignore()) 62 62 return; 63 std::string output(out put_name()+ ".html");63 std::string output(out_path + ".html"); 64 64 if (verbose) 65 65 std::cout << "Printing output for " << path_ << std::endl; 66 66 std::ofstream os(output.c_str()); 67 print_header(os, name(), level_ );67 print_header(os, name(), level_+2); 68 68 path_anchor(os); 69 69 os << "<p align=center>\n<img src='" 70 << file_name(stats_.plot(out put_name()+".png",output_name()))70 << file_name(stats_.plot(out_path+".png",local_path())) 71 71 << "' alt='[plot]' border=0>\n</p>"; 72 72 … … 126 126 if (ignore()) 127 127 return; 128 std::cout << "\nCOPYRIGHT " << output_name() << std::endl;128 std::cout << "\nCOPYRIGHT " << local_path() << std::endl; 129 129 // last rev and 4-chars string for each year 130 130 std::vector<std::pair<size_t,std::string> > years; -
trunk/lib/File.h
r198 r201 62 62 /// 63 63 /// 64 void print(const bool verbose=false) const;64 void print(const std::string&, const bool verbose=false) const; 65 65 66 66 void print_copyright(const std::vector<std::string>&) const; -
trunk/lib/Node.cc
r200 r201 41 41 binary_=property.binary(); 42 42 svndigest_ignore_=property.svndigest_ignore(); 43 output_name_ = output+file_name(path_);43 local_path_ = output+file_name(path_); 44 44 } 45 45 … … 57 57 words.reserve(level_+1); 58 58 std::string word; 59 std::stringstream ss( output_name());59 std::stringstream ss(local_path()); 60 60 while(getline(ss,word,'/')) 61 61 words.push_back(word); -
trunk/lib/Node.h
r200 r201 115 115 /// @return 116 116 /// 117 inline const std::string& output_name(void) const { return output_name_; } 117 inline const std::string& local_path(void) const { return local_path_; } 118 119 /// 120 /// Function returning everything after the last '/' 121 /// 122 /// @return name of node (not full path) 123 /// 124 inline std::string name(void) const { return file_name(path_); } 118 125 119 126 /// … … 130 137 /// Function printing HTML in current working directory 131 138 /// 132 virtual void print(const bool verbose=false) const=0;139 virtual void print(const std::string&, const bool verbose=false) const=0; 133 140 134 141 virtual void print_copyright(const std::vector<std::string>& dates) const=0; … … 149 156 150 157 /// 151 /// Function returning everything after the last '/'152 ///153 /// @return name of node (not full path)154 ///155 inline std::string name(void) const { return file_name(path_); }156 157 ///158 158 /// print path in html format (with anchors) to @a os 159 159 /// … … 161 161 162 162 u_int level_; 163 std::string output_name_; //without suffix164 std::string path_; 163 std::string local_path_; // path from root 164 std::string path_; // absolute path from 165 165 Stats stats_; 166 166 … … 181 181 { 182 182 if (first->dir()==second->dir()) 183 return first-> output_name()<second->output_name();183 return first->name()<second->name(); 184 184 return first->dir(); 185 185 } -
trunk/lib/html_utility.cc
r200 r201 22 22 */ 23 23 24 #include "html_utility.h" 24 25 #include "utility.h" 25 26 #include <config.h> // this header file is created by configure … … 32 33 #include <sys/param.h> 33 34 #include <unistd.h> 35 #include <vector> 34 36 35 37 namespace theplu{ … … 90 92 91 93 92 void print_css(std::ostream& s) 93 { 94 void print_css(const std::string& str) 95 { 96 std::ofstream s(str.c_str()); 94 97 s << "body {\n"; 95 98 s << " background: #fff; \n"; … … 128 131 s << "}\n"; 129 132 s << "\n"; 133 s << "div.main {\n"; 134 s << " text-align: center\n"; 135 s << "}\n"; 130 136 s << "table.listings {\n"; 131 137 s << " clear: both;\n"; … … 175 181 s << "\n"; 176 182 s << "\n"; 183 s.close(); 184 } 185 186 187 void print_main_page(const std::string& dir, 188 const std::vector<std::string>& commit_dates) 189 { 190 std::string filename=dir+"/index.html"; 191 std::ofstream os(filename.c_str()); 192 print_header(os, dir, 0); 193 time_t now; 194 time (&now); 195 u_int n7=0; 196 u_int n30=0; 197 u_int n365=0; 198 for (size_t i=1; i<commit_dates.size(); ++i){ 199 double diff = difftime(now,str2time(commit_dates[i])); 200 if (diff<365*24*3600){ 201 n365++; 202 if (diff<30*24*3600){ 203 n30++; 204 if (diff<7*24*3600) 205 n7++; 206 } 207 } 208 } 209 os << "<div class=\"main\">\n" 210 << "<table><thead><tr><th>Statistics for " << dir 211 << "</th></tr><thead>\n" 212 << "<tr><td>Commits last year</td><td>" << n365 << "</td></tr>\n" 213 << "<tr><td>Commits last month</td><td>" << n30 << "</td></tr>\n" 214 << "<tr><td>Commits last week</td><td>" << n7 << "</td></tr>\n" 215 << "</table></div>\n"; 216 217 218 print_footer(os); 219 os.close(); 177 220 } 178 221 … … 199 242 << " xml:lang=\"en\" lang=\"en\"><head>\n" 200 243 << "<head>\n" 201 << "<title> svndigest " << title << "</title>\n"244 << "<title> " << title << " - svndigest</title>\n" 202 245 << "</head>\n" 203 246 << "<link rel=\"stylesheet\" " … … 212 255 anchor(os, "index.html", "Home", level, "Main page"); 213 256 os << "</li>" 257 << "<li>"; 258 anchor(os, "all/total/index.html", "Browse", level, "Browser"); 259 os << "</li>" 214 260 << "</ul></div>" 215 261 << "<div id=\"main\">\n"; -
trunk/lib/html_utility.h
r200 r201 29 29 #include <iosfwd> 30 30 #include <string> 31 #include <vector> 31 32 32 33 namespace theplu{ … … 52 53 53 54 /// 54 /// @printing cascading style sheet to stream @a s.55 /// @printing cascading style sheet to file name @a str. 55 56 /// 56 void print_css( std::ostream& s);57 void print_css(const std::string& str); 57 58 59 /// 60 /// @brief print main page 61 /// 62 void print_main_page(const std::string&, const std::vector<std::string>&); 63 58 64 /// 59 65 /// @brief print html footer of page -
trunk/lib/utility.cc
r198 r201 31 31 #include <sys/param.h> 32 32 #include <unistd.h> 33 34 #include <iostream> 33 35 34 36 namespace theplu{ … … 84 86 } 85 87 88 time_t str2time(const std::string& str) 89 { 90 // str in format 2006-09-09T10:55:52.132733Z 91 std::stringstream sstream(str); 92 time_t rawtime; 93 struct tm * timeinfo; 94 time ( &rawtime ); 95 timeinfo = gmtime ( &rawtime ); 96 97 u_int year, month, day, hour, minute, second; 98 std::string tmp; 99 getline(sstream,tmp,'-'); 100 year=atoi(tmp.c_str()); 101 timeinfo->tm_year = year - 1900; 102 std::cout << tmp << " " << year << std::endl; 103 104 getline(sstream,tmp,'-'); 105 month=atoi(tmp.c_str()); 106 timeinfo->tm_mon = month - 1; 107 std::cout << tmp << " " << month << std::endl; 108 109 getline(sstream,tmp,'T'); 110 day=atoi(tmp.c_str()); 111 timeinfo->tm_mday = day; 112 std::cout << tmp << " " << day << std::endl; 113 114 getline(sstream,tmp,':'); 115 hour=atoi(tmp.c_str()); 116 timeinfo->tm_hour = hour; 117 std::cout << tmp << " " << hour << std::endl; 118 119 getline(sstream,tmp,':'); 120 minute=atoi(tmp.c_str()); 121 timeinfo->tm_min = minute; 122 std::cout << tmp << " " << minute << std::endl; 123 124 getline(sstream,tmp,'.'); 125 second=atoi(tmp.c_str()); 126 timeinfo->tm_sec = second; 127 std::cout << tmp << " " << second << std::endl; 128 129 return mktime(timeinfo); 130 } 131 132 86 133 }} // end of namespace svndigest and namespace theplu -
trunk/lib/utility.h
r198 r201 94 94 95 95 /// 96 /// 97 /// 98 time_t str2time(const std::string&); 99 100 /// 96 101 /// Calculating sum of two vectors. 97 102 ///
Note: See TracChangeset
for help on using the changeset viewer.