startgitStatic page generator for git repositories | 
          
| git clone git://git.dimitrijedobrota.com/startgit.git | 
| Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING | 
document.hpp (1302B)
    0 #pragma once
          
              2 #include <ostream>
              3 #include <string>
          
              5 #include <hemplate/element.hpp>
          
              7 #include "branch.hpp"
              8 #include "repository.hpp"
          
             10 namespace startgit
             11 {
          
             13 class document
             14 {
             15   std::string m_title;
             16   std::string m_desc;
             17   std::string m_author;
             18   std::string m_relpath;
             19   bool m_has_feed;
          
             21   static auto form_title(const repository& repo, const branch& branch)
             22   {
             23     return std::format(
             24         "{} ({}) - {}",
             25         repo.get_name(),
             26         branch.get_name(),
             27         repo.get_description()
             28     );
             29   }
          
             31 public:
             32   document(
             33       std::string_view title,
             34       std::string_view desc,
             35       std::string_view author,
             36       std::string_view relpath = "./",
             37       bool has_feed = true
             38   )
             39       : m_title(title)
             40       , m_desc(desc)
             41       , m_author(author)
             42       , m_relpath(relpath)
             43       , m_has_feed(has_feed)
             44   {
             45   }
          
             47   document(
             48       const repository& repo,
             49       const branch& branch,
             50       std::string_view desc,
             51       std::string_view relpath = "./",
             52       bool has_feed = true
             53   )
             54       : m_title(form_title(repo, branch))
             55       , m_desc(desc)
             56       , m_author(repo.get_owner())
             57       , m_relpath(relpath)
             58       , m_has_feed(has_feed)
             59   {
             60   }
          
             62   using content_t = std::function<hemplate::element()>;
             63   void render(std::ostream& ost, const content_t& content) const;
             64 };
          
             66 }  // namespace startgit