allow optional style file for skins

This commit is contained in:
Martin Rotter 2021-10-04 08:15:15 +02:00
parent c19469a9b0
commit 3bfee2c8c8
7 changed files with 2074 additions and 4 deletions

View File

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" />
<releases>
<release version="4.0.3" date="2021-10-01"/>
<release version="4.0.3" date="2021-10-04"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -75,6 +75,7 @@
<file>skins/vergilius/html_enclosure_image.html</file>
<file>skins/vergilius/html_single_message.html</file>
<file>skins/vergilius/html_wrapper.html</file>
<file>skins/vergilius/html_style.css</file>
<file>skins/vergilius/metadata.xml</file>
<file>skins/vergilius/theme.css</file>

View File

@ -6,6 +6,7 @@ Here is overview of all placeholders used throughtout the skin:
%data% - is replaced by current absolute path to user data folder.
html_wrapper.html:
%style% - Skin-wide CSS, will be replaced by custom CSS if skin provides it in file "style.css".
%1 - Title of the article.
%2 - Body of the preview which is composed from:
- single html_single_message.html (single article preview),

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -91,7 +91,9 @@
#define EXECUTION_LINE_SEPARATOR "#"
#define EXTERNAL_TOOL_SEPARATOR "|||"
#define USER_DATA_PLACEHOLDER "%data%"
#define SKIN_STYLE_PLACEHOLDER "%style%"
#define CLI_VER_SHORT "v"
#define CLI_VER_LONG "version"

View File

@ -2,6 +2,7 @@
#include "miscellaneous/skinfactory.h"
#include "exceptions/ioexception.h"
#include "miscellaneous/application.h"
#include <QDir>
@ -143,9 +144,24 @@ Skin SkinFactory::skinInfo(const QString& skin_name, bool* ok) const {
// So if one uses "%data%/images/border.png" in QSS then it is
// replaced by fully absolute path and target file can
// be safely loaded.
//
// %style% placeholder is used in main wrapper HTML file to be replaced with custom skin-wide CSS.
skin.m_layoutMarkupWrapper = QString::fromUtf8(IOFactory::readFile(skin_folder + QL1S("html_wrapper.html")));
skin.m_layoutMarkupWrapper = skin.m_layoutMarkupWrapper.replace(QSL(USER_DATA_PLACEHOLDER),
skin_folder_no_sep);
try {
auto custom_css = IOFactory::readFile(skin_folder + QL1S("html_style.css"));
skin.m_layoutMarkupWrapper = skin.m_layoutMarkupWrapper.replace(QSL(SKIN_STYLE_PLACEHOLDER),
QString::fromUtf8(custom_css));
}
catch (const IOException& ex) {
qWarningNN << "Skin"
<< QUOTE_W_SPACE(skin_name)
<< "does not support separated custom CSS.";
}
skin.m_enclosureImageMarkup = QString::fromUtf8(IOFactory::readFile(skin_folder + QL1S("html_enclosure_image.html")));
skin.m_enclosureImageMarkup = skin.m_enclosureImageMarkup.replace(QSL(USER_DATA_PLACEHOLDER),
skin_folder_no_sep);