From e515ca109faa897e84be8a97a1240c59df612dd4 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Wed, 5 Jul 2023 15:14:46 +0200 Subject: Implement a small library of ActivityPub objects These objects allow, and will allow us, to move HTML rendering out of the archive parser and into separate classes. Each of the derived classes specialise HTML rendering for their specific requirements. Furthermore, these ActivityPub objects will be able to be expanded upon and have support to be written to disk, in a database, for instance. Separating ActivityPub object retrieving from rendering allows us to implement other retrieving sources and methods, such as downloading posts from a configured remote instance. --- src/activitypub/apbase.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/activitypub/apbase.h (limited to 'src/activitypub/apbase.h') diff --git a/src/activitypub/apbase.h b/src/activitypub/apbase.h new file mode 100644 index 0000000..3973886 --- /dev/null +++ b/src/activitypub/apbase.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +struct HtmlRenderDetails { + int text_zone_width; + QLocale* locale; +}; + +class APBase { +public: + // maybe pass HtmlRenderDetails by reference (pointer) instead of by value? will have to be measured + virtual QString get_html_render(HtmlRenderDetails render_info) = 0; + + // having a virtual destructor never hurts. see https://isocpp.org/wiki/faq/virtual-functions#virtual-dtors + // it could always be removed by deleting the line below and removing the trivial destructors that are explicitly defined from classes that inherit from APBase. + virtual ~APBase() {}; +protected: + QString object_url; // this URL represents generally the source of the object. for APObject & derived: object's URL, such as the Note/Statuses' URL for an APPost + static const QString get_html_template(const QString& template_name); +}; -- cgit v1.2.3-54-g00ecf