summaryrefslogtreecommitdiff
path: root/board.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'board.cpp')
-rw-r--r--board.cpp36
1 files changed, 14 insertions, 22 deletions
diff --git a/board.cpp b/board.cpp
index b3e113e..1be4076 100644
--- a/board.cpp
+++ b/board.cpp
@@ -118,6 +118,19 @@ QString Board::bbcodeToRichText(QString text) const
text.replace(pair.first, pair.second);
}
+ // Unfortunately, we have to process images separately
+ static QRegExp img_bbcode("\\[img\\]([^[]*)\\[/img\\]", Qt::CaseInsensitive);
+ int pos = 0;
+ while ((pos = img_bbcode.indexIn(text, pos)) != -1) {
+ QString imageUrl = img_bbcode.cap(1);
+ QString providerUrl = image_provider->getProviderImageUrl(imageUrl);
+ qDebug() << "Image" << imageUrl << "->" << providerUrl;
+ text.replace(pos, img_bbcode.matchedLength(), "<img src=\"" + providerUrl + "\" />");
+ }
+
+ // HTML newlines
+ text.replace("\n", "<br>");
+
return text;
}
@@ -171,28 +184,9 @@ QString Board::createSlug(const QString &forumUrl)
return url;
}
-QString Board::getDbDir()
-{
- QString path;
-
-#ifdef Q_OS_LINUX
- char * xdg_cache_dir = getenv("XDG_CACHE_HOME");
- if (xdg_cache_dir) {
- path = QString::fromLocal8Bit(xdg_cache_dir) + "/tapasboard";
- } else {
- path = QDir::homePath() + "/.cache/tapasboard";
- }
- if (!QDir().mkpath(path)) {
- qWarning() << "Failed to create directory for databases:" << path;
- }
-#endif
-
- return path;
-}
-
QString Board::getDbPathFor(const QString &slug)
{
- return getDbDir() + "/" + slug + ".sqlite";
+ return board_manager->getCachePath() + "/" + slug + ".sqlite";
}
QString Board::getTempDbPathFor(const QString& slug)
@@ -330,8 +324,6 @@ void Board::initializeBbCode()
_bbcodes << qMakePair(QRegExp("\\[/url\\]", Qt::CaseInsensitive), QString("</a>"));
_bbcodes << qMakePair(QRegExp("\\[hr\\]", Qt::CaseInsensitive), QString("<hr>"));
-
- _bbcodes << qMakePair(QRegExp("\n"), QString("<br>"));
}
void Board::fetchConfigIfOutdated()