Changeset 175


Ignore:
Timestamp:
Sep 2, 2006, 5:22:52 AM (13 years ago)
Author:
Peter Johansson
Message:

fixes #53

Location:
trunk/lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Directory.cc

    r173 r175  
    9595  }
    9696
    97   std::string Directory::html_link(void) const
     97  std::string Directory::href(void) const
    9898  {
    99     return "<a href=\"" + name() + "/index.html\">" + name() + "</a>";
     99    return name() + "/index.html";
    100100  }
    101101
     
    145145    for (NodeConstIterator d = daughters_.begin(); d!=daughters_.end(); ++d) {
    146146      if (dark)
    147         os << (*d)->html_tablerow("dark");
     147        (*d)->html_tablerow(os,"dark");
    148148      else
    149         os << (*d)->html_tablerow("light");
     149        (*d)->html_tablerow(os,"light");
    150150      dark = !dark;
    151151    }
  • trunk/lib/Directory.h

    r165 r175  
    6666
    6767    ///
    68     /// @return A properly formatted html link to this directory.
     68    /// @return directory-name/index.html
    6969    ///
    70     std::string html_link(void) const;
     70    std::string href(void) const;
    7171
    7272    const Stats& parse(const bool verbose=false);
  • trunk/lib/File.cc

    r149 r175  
    3232namespace svndigest{
    3333
    34   std::string File::html_link(void) const
     34  std::string File::href(void) const
    3535  {
    36     return "<a href=\"" + name() + ".html\">" + name() + "</a>";
     36    return name()+".html";
    3737  }
    3838
  • trunk/lib/File.h

    r165 r175  
    4343
    4444    ///
    45     /// @return A properly formatted html link to this node.
     45    /// @return href to this file
    4646    ///
    47     std::string html_link(void) const;
     47    std::string href(void) const;
    4848
    4949    ///
  • trunk/lib/Node.cc

    r158 r175  
    4646  }
    4747
    48   std::string Node::html_tablerow(const std::string& css_class) const
     48  void Node::path_anchor(std::ostream& os) const
    4949  {
    50     std::stringstream ss;
    51     ss << "<tr class=\"" << css_class << "\">\n"
    52        << "<td>" << html_link() << "</td>\n"
     50    std::vector<std::string> words;
     51    words.reserve(level_+1);
     52    std::string word;
     53    std::stringstream ss(output_name());
     54    while(getline(ss,word,'/'))
     55      words.push_back(word);
     56    for (size_t i=0; i<words.size()-1; ++i){
     57      anchor(os,"index.html", words[i], level_-i, "View " + words[i]);
     58      os << "<span class=\"sep\">/</span>\n";
     59    }
     60    anchor(os,href(), words.back(), level_+2-words.size(),
     61           "View " + words.back());
     62  }
     63
     64  void Node::html_tablerow(std::ostream& os,
     65                           const std::string& css_class) const
     66  {
     67    os << "<tr class=\"" << css_class << "\">\n"
     68       << "<td>" ;
     69    anchor(os,href(), name());
     70    os << "</td>\n"
    5371       << "<td>" << stats_.lines() << "</td>\n"
    5472       << "<td>" << stats_.code() << "</td>\n"
     
    5775       << "<td>" << author() << "</td>\n"
    5876       << "</tr>\n";
    59     return ss.str();
    6077  }
    6178
     
    97114    os << "index.html\">Home</a></li>"
    98115       << "</ul></div>"
    99        << "<div id=\"main\">"
    100        << "<h2>" << output_name() << "</h2>\n";
     116       << "<div id=\"main\">\n"
     117       << "<h2 class=\"path\">\n";
     118    path_anchor(os);
     119    os << "\n</h2>\n";
    101120  }
    102121
  • trunk/lib/Node.h

    r165 r175  
    7272
    7373    ///
    74     /// @return A properly formatted html link to this node.
     74    /// @return href to this node
    7575    ///
    76     virtual std::string html_link(void) const=0;
     76    virtual std::string href(void) const=0;
    7777
    7878    ///
    7979    ///
    8080    ///
    81     std::string html_tablerow(const std::string&) const;
     81    void html_tablerow(std::ostream&, const std::string&) const;
    8282
    8383    ///
     
    134134    Node(const Node&);
    135135
     136    ///
     137    /// print path in html format (with anchors) to @a os
     138    ///
     139    void path_anchor(std::ostream& os) const;
     140
    136141    SVNinfo svninfo_;
    137142  };
  • trunk/lib/utility.cc

    r174 r175  
    5555      }
    5656    return access(path.c_str(),mode);
     57  }
     58
     59
     60  void anchor(std::ostream& os, const std::string& href,
     61              const std::string& name, u_int level,
     62              const std::string& title)
     63  {
     64    os << "<a title=\"" << title << "\" href=\"" ;
     65    for (size_t i=0; i<level; ++i)
     66      os << "../";
     67    os << href << "\">" << name << "</a>";
    5768  }
    5869
     
    148159    s << "table.listings tbody td { text-align: left }\n";
    149160    s << "\n";
     161    s << ".sep { color: #666}\n";
    150162    s << "\n";
    151163    s << "\n";
  • trunk/lib/utility.h

    r165 r175  
    3636namespace theplu{
    3737namespace svndigest{
     38
     39  ///
     40  /// @brief send anchor to stream @a os
     41  ///
     42  /// @param address to link to
     43  /// @param name text visible on page
     44  /// @param level '../' is added @a level times before @a href
     45  /// @param title title of anchor
     46  ///
     47  void anchor(std::ostream& os, const std::string& href,
     48              const std::string& name, u_int level=0,
     49              const std::string& title="");
    3850
    3951  ///
Note: See TracChangeset for help on using the changeset viewer.