stamd

Static Markdown Page Generator
git clone git://git.dimitrijedobrota.com/stamd.git
Log | Files | Refs | README | LICENSE

indexer.hpp (1172B)


      1 #pragma once
      2 
      3 #include <memory>
      4 #include <string>
      5 
      6 #include "article.hpp"
      7 
      8 namespace stamd {
      9 
     10 class indexer
     11 {
     12 public:
     13   using article_s = std::shared_ptr<article>;
     14 
     15   using article_list = std::vector<article_s>;
     16   using categories_t = article::categories_t;
     17 
     18   struct options_t
     19   {
     20     std::string base_url;
     21     std::string author;
     22     std::string email;
     23     std::string description;
     24     std::string summary;
     25   };
     26 
     27   explicit indexer(options_t options)
     28       : m_options(std::move(options))
     29   {
     30     if (m_options.base_url.empty() || m_options.base_url.back() != '/')
     31     {
     32       m_options.base_url += '/';
     33     }
     34   }
     35 
     36   article_s& add(const article_s& article);
     37 
     38   void sort();
     39 
     40   void create_robots(std::ostream& ost) const;
     41   void create_sitemap(std::ostream& ost) const;
     42 
     43   void create_atom(std::ostream& ost, const std::string& name) const;
     44   void create_rss(std::ostream& ost, const std::string& name) const;
     45   void create_index(std::ostream& ost,
     46                     const std::string& name,
     47                     const categories_t& categories);
     48 
     49   void create_categories() const;
     50 
     51 private:
     52   options_t m_options;
     53 
     54   article_list m_articles;
     55 };
     56 
     57 }  // namespace stamd