aboutsummaryrefslogtreecommitdiffstats
path: root/src/activitypub/apbase.cpp
blob: 52c995d73e7df21ede8e280374bc0d7025c42f72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "apbase.h"
#include <QHash>
#include <QFile>
#include <QDebug>

const QString APBase::get_html_template(const QString& template_name) {
    static QHash<QString, QString>* templates = new QHash<QString, QString>;

    if (not templates->contains(template_name)) {
        QFile file("src/templates/"+ template_name +".html");
        if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
            templates->insert(template_name, "<i>Error loading status_info template.</i>");
            return templates->value(template_name);
        }

        templates->insert(template_name, file.readAll());
        qDebug() << "Loaded HTML template:" << template_name << "Total loaded:" << templates->size(); // print size to make sure that everything is loaded by the same function
    }

    return templates->value(template_name);
}