Skip to content

Commit

Permalink
Now PagedArticleWebPage won't add the summary page to the list of pag…
Browse files Browse the repository at this point in the history
…es you can switch to.
  • Loading branch information
Relintai committed Dec 24, 2023
1 parent 3d4b294 commit 1f29193
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions modules/web/nodes/paged_article/paged_article_web_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,19 @@ void PagedArticleWebPage::_load() {
ERR_FAIL_COND_MSG(!dir, "Error opening PagedArticleWebPage::folder! folder: " + _articles_folder_abs);

Vector<String> files;
String summary_file;

dir->list_dir_begin();

String file = dir->get_next();

while (!file.empty()) {
if (!dir->current_is_dir()) {
files.push_back(file);
if (file.get_basename() == "summary") {
summary_file = file;
} else {
files.push_back(file);
}
}

file = dir->get_next();
Expand Down Expand Up @@ -218,12 +223,6 @@ void PagedArticleWebPage::_load() {
fd = r->render_to_html(fd);
}

if (files[i].get_file().get_basename() == "summary") {
summary = fd;

continue;
}

String pagination;

pagination = HTMLPaginator::get_pagination_links_old(get_full_uri(false), files, i, _max_pagination_links);
Expand All @@ -237,6 +236,29 @@ void PagedArticleWebPage::_load() {
pages[files[i]] = finals;
}

if (!summary_file.empty()) {
String file_path = _articles_folder_abs;
file_path += summary_file;

String fd;

FileAccess *f = FileAccess::open(file_path, FileAccess::READ);

if (!f) {
ERR_PRINT("Error opening file! " + file_path);
}

fd = f->get_as_utf8_string();
f->close();
memdelete(f);

if (summary_file.get_extension() == "md") {
fd = r->render_to_html(fd);
}

summary = fd;
}

file_cache->clear();

if (serve_folder != "") {
Expand Down

0 comments on commit 1f29193

Please sign in to comment.