Added a new paged list module.

This commit is contained in:
Relintai 2021-07-07 10:47:37 +02:00
parent 4c0ec16bdc
commit 9b0a8eb970
4 changed files with 110 additions and 0 deletions

12
modules/paged_list/SCsub Normal file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env python
Import("env_mod")
Import("env")
env_mod.core_sources = []
env_mod.add_source_files(env_mod.core_sources, "*.cpp")
# Build it all as a library
lib = env_mod.add_library("paged_list", env_mod.core_sources)
env.Prepend(LIBS=[lib])

View File

@ -0,0 +1,27 @@
import os
import platform
import sys
def is_active():
return True
def get_name():
return "paged_list"
def can_build():
return True
def get_opts():
return []
def get_flags():
return []
def configure(env):
pass

View File

@ -0,0 +1,45 @@
#include "paged_list.h"
#include "core/http/request.h"
#include <iostream>
#include "core/file_cache.h"
#include "core/http/handler_instance.h"
#include "core/database/database_manager.h"
#include "core/html/html_builder.h"
void PagedList::index(Request *request) {
const std::string path = request->get_current_path_segment();
if (request->get_remaining_segment_count() == 0) {
main_page->index(request);
return;
}
articles->index(request);
}
void PagedList::load() {
main_page->folder = folder;
main_page->load();
articles->base_path = base_path;
articles->folder = folder;
articles->load();
}
PagedList::PagedList() :
Object() {
main_page = new ListPage();
articles = new PagedArticle();
}
PagedList::~PagedList() {
delete main_page;
delete articles;
}

View File

@ -0,0 +1,26 @@
#ifndef PAGED_LIST_H
#define PAGED_LIST_H
#include "core/object.h"
#include <string>
#include "modules/list_page/list_page.h"
#include "modules/paged_article/paged_article.h"
class PagedList : public Object {
public:
void index(Request *request);
void load();
PagedList();
~PagedList();
ListPage *main_page;
PagedArticle *articles;
std::string folder;
std::string base_path;
};
#endif