Ignore:
Timestamp:
May 6, 2007, 9:03:28 PM (14 years ago)
Author:
Peter Johansson
Message:

moving first page generation to separate file.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/lib/first_page.cc

    r284 r285  
    2121  02111-1307, USA.
    2222*/
     23
     24#include "first_page.h"
    2325
    2426#include "html_utility.h"
     
    4749namespace svndigest{
    4850
    49   std::string anchor(const std::string& href,
    50                      const std::string& name, u_int level,
    51                      const std::string& title)
    52   {
    53     std::stringstream ss;
    54     HtmlStream hs(ss);
    55     ss << "<a title=\"";
    56     hs << title;
    57     ss << "\" href=\"";
    58     for (size_t i=0; i<level; ++i)
    59       ss << "../";
    60     hs << href;
    61     ss << "\">";
    62     hs << name;
    63     ss << "</a>";
    64     return ss.str();
    65   }
    66 
    67  
    6851  void print_main_page(const std::string& dir, const SVNlog& log,
    6952                       const Stats& stats)
     
    123106       << "</td></tr>\n"
    124107       << "</table></div>\n";
    125   }
    126 
    127 
    128   void print_footer(std::ostream& os)
    129   {
    130     Date date;
    131     os << "<p align=center><font size=-2>\nGenerated on "
    132        << date("%a %b %d %H:%M:%S %Y") << " (UTC) by "
    133        << anchor("http://lev.thep.lu.se/trac/svndigest/",
    134                  PACKAGE_STRING, 0, "")
    135        << "</font>\n</p>\n</div>\n</body>\n</html>\n";
    136   }
    137 
    138 
    139   void print_header(std::ostream& os, std::string title, u_int level,
    140                     std::string user, std::string item, std::string path)
    141   {
    142     os << "<!DOCTYPE html\n"
    143        << "PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
    144        << "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
    145        << "<html xmlns=\"http://www.w3.org/1999/xhtml\""
    146        << " xml:lang=\"en\" lang=\"en\"><head>\n"
    147        << "<head>\n"
    148        << "<title> " << title << " - svndigest</title>\n"
    149        << "</head>\n"
    150        << "<link rel=\"stylesheet\" "
    151        << "href=\"";
    152     for (u_int i=0; i<level; ++i)
    153       os << "../";
    154     os << "svndigest.css\" type=\"text/css\" />\n"
    155        << "<body>\n"
    156        << "<div id=\"menu\">"
    157        << "<ul><li></li>";
    158     if (item=="main")
    159       os << "<li class=\"highlight\">";
    160     else
    161       os << "<li>";
    162     os << anchor("index.html", "Main", level, "Main page");
    163     os << "</li>";
    164 
    165     if (item=="total")
    166       os << "<li class=\"highlight\">";
    167     else
    168       os << "<li>";
    169     os << anchor(user+"/total/"+path, "Total", level,
    170            "View statistics of all lines");
    171     os << "</li>";
    172 
    173     if (item=="code")
    174       os << "<li class=\"highlight\">";
    175     else
    176       os << "<li>";
    177     os << anchor(user+"/code/"+path, "Code", level,
    178                  "View statistics of code lines");
    179     os << "</li>";
    180 
    181     if (item=="comments")
    182       os << "<li class=\"highlight\">";
    183     else
    184       os << "<li>";
    185     os << anchor(user+"/comments/"+path, "Comment", level,
    186                  "View statistics of comment lines");
    187     os << "</li>";
    188 
    189 
    190     if (item=="empty")
    191       os << "<li class=\"highlight\">";
    192     else
    193       os << "<li>";
    194     os << anchor(user+"/empty/"+path, "Other", level,
    195                  "View statistics of empty lines");
    196     os << "</li>"
    197        << "</ul></div>"
    198        << "<div id=\"main\">\n";
    199108  }
    200109
     
    305214
    306215
    307   std::string trac_revision(size_t r)
    308   {
    309     Configuration* conf = Configuration::instance();
    310     std::stringstream ss;
    311     if (conf->trac_revision().empty())
    312       ss << r;
    313     else {
    314       std::stringstream rev;
    315       rev << r;
    316       ss << anchor(conf->trac_revision()+rev.str(), rev.str());
    317     }
    318     return ss.str();
    319   }
    320 
    321216}} // end of namespace svndigest and namespace theplu
Note: See TracChangeset for help on using the changeset viewer.