mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Add the new virtuals to the static pages.
This commit is contained in:
parent
34e669c55b
commit
809de8a01c
@ -1,31 +1,39 @@
|
||||
#include "static_page.h"
|
||||
|
||||
#include "core/os/directory.h"
|
||||
#include "web/file_cache.h"
|
||||
#include "web/html/html_builder.h"
|
||||
#include "web/http/request.h"
|
||||
#include "web/html/utils.h"
|
||||
#include "core/os/directory.h"
|
||||
#include "web/http/request.h"
|
||||
|
||||
void StaticPage::_handle_request_main(Request *request) {
|
||||
if (should_render_menu) {
|
||||
render_menu(request);
|
||||
}
|
||||
|
||||
request->body += data;
|
||||
render(request);
|
||||
request->compile_and_send_body();
|
||||
}
|
||||
|
||||
void StaticPage::render(Request *request) {
|
||||
request->body += data;
|
||||
}
|
||||
|
||||
void StaticPage::render_preview(Request *request) {
|
||||
request->body += preview_data;
|
||||
}
|
||||
|
||||
void StaticPage::load_file(const String &path) {
|
||||
Ref<Directory> d;
|
||||
d.instance();
|
||||
|
||||
|
||||
d->read_file_into(path, &data);
|
||||
}
|
||||
|
||||
void StaticPage::load_and_process_file(const String &path) {
|
||||
Ref<Directory> d;
|
||||
d.instance();
|
||||
|
||||
|
||||
d->read_file_into(path, &data);
|
||||
|
||||
if (path.file_get_extension() == "md") {
|
||||
@ -36,21 +44,25 @@ void StaticPage::load_and_process_file(const String &path) {
|
||||
void StaticPage::load_md_file(const String &path) {
|
||||
Ref<Directory> d;
|
||||
d.instance();
|
||||
|
||||
|
||||
d->read_file_into(path, &data);
|
||||
Utils::markdown_to_html(&data);
|
||||
}
|
||||
|
||||
|
||||
void StaticPage::set_data_md(const String &d) {
|
||||
data.clear();
|
||||
|
||||
Utils::markdown_to_html(&data);
|
||||
}
|
||||
|
||||
void StaticPage::set_data(const String &d) {
|
||||
data = d;
|
||||
}
|
||||
|
||||
void StaticPage::set_preview_data(const String &d) {
|
||||
preview_data = d;
|
||||
}
|
||||
|
||||
StaticPage::StaticPage() :
|
||||
WebNode() {
|
||||
|
||||
|
@ -11,14 +11,19 @@ class StaticPage : public WebNode {
|
||||
public:
|
||||
void _handle_request_main(Request *request);
|
||||
|
||||
void render(Request *request);
|
||||
void render_preview(Request *request);
|
||||
|
||||
void load_file(const String &path);
|
||||
void load_and_process_file(const String &path);
|
||||
void load_md_file(const String &path);
|
||||
|
||||
|
||||
void set_data_md(const String &d);
|
||||
void set_data(const String &d);
|
||||
void set_preview_data(const String &d);
|
||||
|
||||
String data;
|
||||
String preview_data;
|
||||
bool should_render_menu;
|
||||
|
||||
StaticPage();
|
||||
|
Loading…
Reference in New Issue
Block a user