Changeset 274
- Timestamp:
- May 2, 2007, 11:05:55 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Configuration.cc
r264 r274 31 31 #include <string> 32 32 #include <sstream> 33 #include <utility> 33 34 34 35 namespace theplu{ … … 73 74 copyright_alias_[key] = name; 74 75 } 76 else if (section == "trac"){ 77 getline(ss, tmp, '='); 78 std::string key = trim(tmp); 79 getline(ss, tmp); 80 std::string value = trim(tmp); 81 if (key=="trac-ticket") 82 trac_ticket_=value; 83 if (key=="trac-revision") 84 trac_revision_=value; 85 86 } 75 87 } 76 88 } … … 88 100 { 89 101 copyright_alias_.clear(); 102 trac_ticket_ = ""; 103 trac_revision_ = ""; 90 104 } 91 105 … … 106 120 os << i->first << " = " << i->second << " \n"; 107 121 } 122 123 os << "\n" 124 << "### Section for setting trac environment\n" 125 << "[trac]\n" 126 << "# If trac-ticket is set, svndigest will create anchors for\n" 127 << "# ticket to the Trac page.\n" 128 << "trac-ticket = " << conf.trac_ticket() << "\n"; 129 os << "# If trac-revision is set, svndigest will create anchors for\n" 130 << "# revisions to the Trac page.\n" 131 << "trac-revision = " << conf.trac_revision() << "\n"; 132 108 133 return os; 109 134 } -
trunk/lib/Configuration.h
r264 r274 28 28 #include <map> 29 29 #include <string> 30 #include <utility> 30 31 31 32 namespace theplu{ 32 33 namespace svndigest{ 33 34 35 /// 36 /// Configuration class takes care of all setting defined in the 37 /// configuration file. 38 /// 34 39 class Configuration 35 40 { … … 53 58 copyright_alias(void) const { return copyright_alias_; } 54 59 60 /// 61 /// @return root for the trac envrionment, e.g., 62 /// http://lev.thep.lu.se/trac/svndigest/ticket/ 63 /// 64 inline std::string trac_ticket(void) const { return trac_ticket_; } 65 66 /// 67 /// @return root for the trac envrionment, e.g., 68 /// http://lev.thep.lu.se/trac/svndigest/ticket/ 69 /// 70 std::string trac_revision(void) const { return trac_revision_; } 71 55 72 private: 56 73 /// … … 60 77 /// 61 78 Configuration(void); 79 // Copy Constructor not implemented 80 Configuration(const Configuration&); 62 81 63 82 void clear(void); … … 69 88 std::map<std::string, std::string> copyright_alias_; 70 89 90 std::string trac_ticket_; 91 std::string trac_revision_; 92 71 93 }; 72 94 -
trunk/lib/Date.cc
r235 r274 208 208 else 209 209 ss << timeinfo->tm_wday; 210 else if (*i == 'y') 211 ss << timeinfo->tm_year % 100; 210 else if (*i == 'y') { 211 int y(timeinfo->tm_year % 100); 212 if (y<10) 213 ss << "0"; 214 ss << y; 215 } 212 216 else if (*i == 'Y') 213 217 ss << timeinfo->tm_year+1900; -
trunk/lib/Directory.cc
r259 r274 209 209 os << "<td>" << stats_.empty(user) << "</td>\n"; 210 210 } 211 os << "<td>" << stats_.last_changed_rev() << "</td>\n";211 os << "<td>" << trac_revision(stats_.last_changed_rev()) << "</td>\n"; 212 212 os << "<td>" << author() << "</td>\n"; 213 213 os << "</tr>\n"; -
trunk/lib/Node.cc
r259 r274 116 116 << "<td>" << stats_.empty(user) << "</td>\n"; 117 117 } 118 os << "<td>" << stats_.last_changed_rev() << "</td>\n"118 os << "<td>" << trac_revision(stats_.last_changed_rev()) << "</td>\n" 119 119 << "<td>" << author() << "</td>\n" 120 120 << "</tr>\n"; … … 195 195 << "</td><td>" << stats_.empty(*i); 196 196 Commitment lc(log.latest_commit(*i)); 197 os << "</td>" << "<td>" << lc.revision()197 os << "</td>" << "<td>" << trac_revision(lc.revision()) 198 198 << "</td>" << "<td>" << lc.date()(timefmt) 199 199 << "</td></tr>\n"; … … 214 214 os << "<td>" << stats_.empty() << "</td>\n"; 215 215 Commitment lc(log.latest_commit()); 216 os << "<td>" << lc.revision() << "</td>\n";216 os << "<td>" << trac_revision(lc.revision()) << "</td>\n"; 217 217 os << "<td>" << lc.date()(timefmt)<< "</td>\n"; 218 218 os << "</tr>\n"; -
trunk/lib/html_utility.cc
r263 r274 25 25 26 26 #include "Commitment.h" 27 #include "Configuration.h" 27 28 #include "Date.h" 28 29 #include "HtmlStream.h" … … 421 422 std::string timefmt("%b %d %H:%M:%S %Y"); 422 423 const size_t maxlength = 80; 424 const Configuration* conf = Configuration::instance(); 423 425 for (size_t i=0; i<10 && a!=log.author().rend(); ++i) { 424 426 os << "<tr><td>" << anchor(*a+"/total/index.html",*a) << "</td>"; 425 427 Date date(*d); 426 428 os << "<td>" << date(timefmt) << "</td>"; 427 os << "<td>" << *r << "</td>"; 429 os << "<td>"; 430 os << trac_revision(*r); 431 os << "</td>"; 428 432 os << "<td>"; 429 433 std::string mess = *m; … … 434 438 if (mess.size()>maxlength) 435 439 mess = mess.substr(0,maxlength-3) + "..."; 436 hs << mess; 440 441 if (conf->trac_ticket().empty()) 442 hs << mess; 443 else { // make anchors to trac 444 char c; 445 std::stringstream ss(mess); 446 for (ss.get(c); ss.good(); ss.get(c)) { 447 if (c=='#') { 448 std::string str; 449 ss >> str; 450 if (is_int(str)) 451 os << anchor(conf->trac_ticket()+str,"#"+str); 452 else 453 hs << "#" << str; 454 } 455 else 456 hs << c; 457 } 458 } 459 437 460 os << "</td></tr>"; 438 461 ++a; … … 444 467 } 445 468 469 470 std::string trac_revision(size_t r) 471 { 472 Configuration* conf = Configuration::instance(); 473 std::stringstream ss; 474 if (conf->trac_revision().empty()) 475 ss << r; 476 else { 477 std::stringstream rev; 478 rev << r; 479 ss << anchor(conf->trac_revision()+rev.str(), rev.str()); 480 } 481 return ss.str(); 482 } 483 446 484 }} // end of namespace svndigest and namespace theplu -
trunk/lib/html_utility.h
r256 r274 89 89 90 90 91 /// 92 /// @return if trac-revision is set in config file anchor to trac is 93 /// given otherwise just a string corresponding to passed parameter. 94 /// 95 std::string trac_revision(size_t); 96 91 97 }} // end of namespace svndigest end of namespace theplu 92 98 -
trunk/lib/utility.cc
r226 r274 88 88 89 89 90 bool is_int(std::string s) 91 { 92 std::stringstream ss(s); 93 int a; 94 ss >> a; 95 if(ss.fail()) 96 return false; 97 // Check that nothing is left on stream 98 std::string b; 99 ss >> b; 100 return b.empty(); 101 } 102 103 90 104 std::string ltrim(std::string str) 91 105 { -
trunk/lib/utility.h
r234 r274 68 68 /// 69 69 std::string htrim(std::string str); 70 71 /// 72 /// @return true if \a str is an integer 73 /// 74 bool is_int(std::string str); 70 75 71 76 ///
Note: See TracChangeset
for help on using the changeset viewer.