Dynamic: Add DynamicContentIncludePage to allow including pages
Tá an tiomantas seo le fáil i:
@ -11,9 +11,15 @@ class DynamicContent
|
||||
Database *database;
|
||||
UrlProvider *urlProvider;
|
||||
|
||||
std::string argument;
|
||||
|
||||
public:
|
||||
DynamicContent(Template &templ, Database &database, UrlProvider &urlProvider);
|
||||
virtual std::string render() = 0;
|
||||
virtual void setArgument(std::string argument)
|
||||
{
|
||||
this->argument = argument;
|
||||
}
|
||||
virtual ~DynamicContent()
|
||||
{
|
||||
}
|
||||
|
14
dynamic/dynamiccontentincludepage.cpp
Comhad gnáth
14
dynamic/dynamiccontentincludepage.cpp
Comhad gnáth
@ -0,0 +1,14 @@
|
||||
#include "dynamiccontentincludepage.h"
|
||||
#include "../parser.h"
|
||||
std::string DynamicContentIncludePage::render()
|
||||
{
|
||||
auto revisionDao = this->database->createRevisionDao();
|
||||
auto rev = revisionDao->getCurrentForPage(this->argument);
|
||||
if(rev)
|
||||
{
|
||||
Parser parser;
|
||||
auto result = parser.parse(*this->database->createPageDao(), *this->urlProvider, rev->content);
|
||||
return result;
|
||||
}
|
||||
return {};
|
||||
}
|
12
dynamic/dynamiccontentincludepage.h
Comhad gnáth
12
dynamic/dynamiccontentincludepage.h
Comhad gnáth
@ -0,0 +1,12 @@
|
||||
#ifndef DYNAMICCONTENTINCLUDEPAGE_H
|
||||
#define DYNAMICCONTENTINCLUDEPAGE_H
|
||||
#include "dynamiccontent.h"
|
||||
class DynamicContentIncludePage : public DynamicContent
|
||||
{
|
||||
public:
|
||||
using DynamicContent::DynamicContent;
|
||||
|
||||
std::string render();
|
||||
};
|
||||
|
||||
#endif // DYNAMICCONTENTINCLUDEPAGE_H
|
@ -1,11 +1,6 @@
|
||||
#include <chrono>
|
||||
#include "dynamiccontentpostlist.h"
|
||||
|
||||
void DynamicContentPostList::setCategory(std::string catname)
|
||||
{
|
||||
this->catname = catname;
|
||||
}
|
||||
|
||||
std::string DynamicContentPostList::render()
|
||||
{
|
||||
auto categoryDao = this->database->createCategoryDao();
|
||||
@ -13,7 +8,7 @@ std::string DynamicContentPostList::render()
|
||||
auto revisionDao = this->database->createRevisionDao();
|
||||
QueryOption option;
|
||||
option.includeInvisible = false;
|
||||
auto members = categoryDao->fetchMembers(this->catname, option);
|
||||
auto members = categoryDao->fetchMembers(this->argument, option);
|
||||
std::vector<std::pair<std::string, time_t>> pageList;
|
||||
for(std::string &member : members)
|
||||
{
|
||||
|
@ -4,12 +4,8 @@
|
||||
#include "dynamiccontent.h"
|
||||
class DynamicContentPostList : public DynamicContent
|
||||
{
|
||||
private:
|
||||
std::string catname;
|
||||
|
||||
public:
|
||||
using DynamicContent::DynamicContent;
|
||||
void setCategory(std::string catname);
|
||||
std::string render() override;
|
||||
};
|
||||
|
||||
|
Tagairt in Eagrán Nua
Cuir bac ar úsáideoir