Changeset 289
- Timestamp:
- May 8, 2007, 2:48:07 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.svndigest/config
r274 r289 12 12 ### Section for setting trac environment 13 13 [trac] 14 # If trac-ticket is set, svndigest will create anchors for 15 # ticket to the Trac page. 16 trac-ticket = http://lev.thep.lu.se/trac/svndigest/ticket/ 17 # If trac-revision is set, svndigest will create anchors for 18 # revisions to the Trac page. 19 trac-revision = http://lev.thep.lu.se/trac/svndigest/changeset/ 14 # If trac-root is set, svndigest will create anchors to # the Trac page. 15 # trac-root = http://lev.thep.lu.se/trac/svndigest/ 16 trac-root = http://lev.thep.lu.se/trac/svndigest/ 20 17 -
trunk/bin/svndigest.cc
r285 r289 62 62 63 63 // Reading configuration file 64 Configuration *config = Configuration::instance();64 Configuration& config = Configuration::instance(); 65 65 if (node_exist(option->config_file())) { 66 66 std::ifstream is(option->config_file().c_str()); … … 71 71 exit(-1); 72 72 } 73 config ->load(is);73 config.load(is); 74 74 is.close(); 75 75 } 76 76 else 77 config->load(); 78 assert(config); 77 config.load(); 79 78 80 79 // write configuration 81 80 if (option->generate_config()) { 82 std::cout << *config;81 std::cout << config; 83 82 exit(0); 84 83 } … … 92 91 } 93 92 catch (SVNException e) { 94 std::cerr << "\nsvndigest: " << e.what() << "\nsvndigest: " << option->root() 93 std::cerr << "\nsvndigest: " << e.what() << "\nsvndigest: " 94 << option->root() 95 95 << " is not under subversion control\n" << std::endl; 96 96 exit(-1); … … 180 180 if (option->verbose()) 181 181 std::cout << "Updating copyright statements" << std::endl; 182 std::map<std::string, std::string> alias(config ->copyright_alias());182 std::map<std::string, std::string> alias(config.copyright_alias()); 183 183 tree.print_copyright(alias); 184 184 } -
trunk/lib/Configuration.cc
r274 r289 79 79 getline(ss, tmp); 80 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 81 if (key=="trac-ticket"){ 82 std::cerr << "svndigest: warning: config variable trac-ticket " 83 << "is deprecated. Use trac-root instead.\n"; 84 trac_root_ = value.substr(0,value.size()-7); 85 } 86 if (key=="trac-revision"){ 87 std::cerr << "svndigest: warning: config variable trac-revision " 88 << "is deprecated. Use trac-root instead.\n"; 89 trac_root_ = value.substr(0,value.size()-10); 90 } 91 if (key=="trac-root") 92 trac_root_=value; 86 93 } 87 94 } … … 89 96 90 97 91 Configuration *Configuration::instance(void)98 Configuration& Configuration::instance(void) 92 99 { 93 100 if (!instance_) 94 101 instance_ = new Configuration; 95 return instance_;102 return *instance_; 96 103 } 97 104 … … 100 107 { 101 108 copyright_alias_.clear(); 102 trac_ticket_ = ""; 103 trac_revision_ = ""; 109 trac_root_ = ""; 110 } 111 112 113 std::string Configuration::trac_root(void) const 114 { 115 return trac_root_; 104 116 } 105 117 … … 124 136 << "### Section for setting trac environment\n" 125 137 << "[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"; 138 << "# If trac-root is set, svndigest will create anchors to " 139 << "the Trac page.\n" 140 << "# trac-root = http://lev.thep.lu.se/trac/svndigest/\n"; 141 if (!conf.trac_root().empty()) 142 os << "trac-root = " << conf.trac_root() << "\n"; 132 143 133 144 return os; -
trunk/lib/Configuration.h
r274 r289 40 40 { 41 41 public: 42 static Configuration *instance(void);42 static Configuration& instance(void); 43 43 44 44 /// … … 60 60 /// 61 61 /// @return root for the trac envrionment, e.g., 62 /// http://lev.thep.lu.se/trac/svndigest/ ticket/62 /// http://lev.thep.lu.se/trac/svndigest/ 63 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_; } 64 std::string trac_root(void) const; 71 65 72 66 private: … … 79 73 // Copy Constructor not implemented 80 74 Configuration(const Configuration&); 75 // assignment not implemented because assignment is always self-assignment 76 Configuration& operator=(const Configuration&); 81 77 82 78 void clear(void); … … 88 84 std::map<std::string, std::string> copyright_alias_; 89 85 90 std::string trac_ticket_; 91 std::string trac_revision_; 92 86 std::string trac_root_; 93 87 }; 94 88 -
trunk/lib/Trac.cc
r288 r289 27 27 #include "HtmlStream.h" 28 28 #include "html_utility.h" 29 #include "utility.h" 29 30 30 31 namespace theplu{ … … 59 60 return false; 60 61 ++first; 61 std::string ticket; 62 for (;first!=last && isdigit(*first); ++first) 63 ticket.append(1,*first); 62 std::string ticket = match(first, last, Digit()); 64 63 65 if (ticket.empty()) 64 if (ticket.empty()) { 65 first = first_orig; 66 66 return false; 67 } 67 68 68 Configuration*conf = Configuration::instance();69 hs_.stream() << anchor(conf ->trac_ticket()+ticket,"#"+ticket);69 const Configuration& conf = Configuration::instance(); 70 hs_.stream() << anchor(conf.trac_root()+"ticket/"+ticket,"#"+ticket); 70 71 return true; 71 72 } … … 79 80 80 81 const std::string::const_iterator first_orig(first); 81 if (*first != '#') 82 83 const std::string log_str("log:"); 84 if (!match_begin(first, last, log_str)) { 85 first = first_orig; 82 86 return false; 87 } 88 first += log_str.size(); 89 std::string node = match(first, last, not2Char('#', '@')); 83 90 ++first; 84 std::string ticket; 85 for (;first!=last && isdigit(*first); ++first) 86 ticket.append(1,*first); 87 88 if (ticket.empty()) 91 std::string stop_rev = match(first, last, Digit()); 92 if (stop_rev.empty() || first == last || *first != ':') { 93 first = first_orig; 89 94 return false; 90 91 Configuration* conf = Configuration::instance(); 92 hs_.stream() << anchor(conf->trac_ticket()+ticket,"#"+ticket); 95 } 96 ++first; 97 std::string rev = match(first, last, Digit()); 98 std::string href(Configuration::instance().trac_root()+"log"+node+ 99 "?rev="+rev+"&stop_rev="+stop_rev); 100 std::string str(first_orig, first); 101 hs_.stream() << anchor(href, str); 93 102 return true; 94 103 } -
trunk/lib/first_page.cc
r286 r289 164 164 std::string timefmt("%b %d %H:%M:%S %Y"); 165 165 const size_t maxlength = 80; 166 const Configuration *conf = Configuration::instance();166 const Configuration& conf = Configuration::instance(); 167 167 for (size_t i=0; i<10 && a!=log.author().rend(); ++i) { 168 168 os << "<tr><td>" << anchor(*a+"/total/index.html",*a) << "</td>"; … … 181 181 mess = mess.substr(0,maxlength-3) + "..."; 182 182 183 if (conf ->trac_ticket().empty())183 if (conf.trac_root().empty()) 184 184 hs << mess; 185 185 else {// make anchors to trac -
trunk/lib/html_utility.cc
r285 r289 130 130 std::string trac_revision(size_t r) 131 131 { 132 Configuration*conf = Configuration::instance();132 const Configuration& conf = Configuration::instance(); 133 133 std::stringstream ss; 134 if (conf ->trac_revision().empty())134 if (conf.trac_root().empty()) 135 135 ss << r; 136 136 else { 137 137 std::stringstream rev; 138 138 rev << r; 139 ss << anchor(conf ->trac_revision()+rev.str(), rev.str());139 ss << anchor(conf.trac_root()+"changeset/"+rev.str(), rev.str()); 140 140 } 141 141 return ss.str(); -
trunk/lib/utility.cc
r274 r289 165 165 166 166 167 notChar::notChar(char c) 168 : char_(c) 169 {} 170 171 172 not2Char::not2Char(char c1, char c2) 173 : char1_(c1), char2_(c2) 174 {} 175 176 167 177 }} // end of namespace svndigest and namespace theplu -
trunk/lib/utility.h
r274 r289 132 132 /// 133 133 inline std::string trim(std::string str) { return htrim(ltrim(str)); } 134 135 136 template <class T> 137 std::string match(std::string::const_iterator& first, 138 const std::string::const_iterator& last, 139 const T& func) 140 { 141 std::string res; 142 for (;first!=last && func(*first); ++first) 143 res.append(1,*first); 144 return res; 145 } 146 147 struct Digit 148 { 149 inline bool operator()(char c) const { return isdigit(c); } 150 }; 151 152 class notChar 153 { 154 public: 155 notChar(char); 156 inline bool operator()(char c) const { return c!=char_; } 157 private: 158 char char_; 159 }; 160 161 class not2Char 162 { 163 public: 164 not2Char(char, char); 165 inline bool operator()(char c) const 166 { return c!=char1_ && c!=char2_; } 167 private: 168 const char char1_; 169 const char char2_; 170 }; 134 171 135 172 /// -
trunk/test/repo/db/current
r270 r289 1 4 71i 11 49 1i 1
Note: See TracChangeset
for help on using the changeset viewer.