diff --git a/saoriview.cpp b/saoriview.cpp
index 76a0199..f09164b 100644
--- a/saoriview.cpp
+++ b/saoriview.cpp
@@ -104,18 +104,18 @@
auto i = SaoriApplication::findInstance(QUrl(instance));
if (!i) return QString();
QString result;
- result = (tr("
";
- } else {
- result += "
";
- }
- if (rebloged) {
- result += "
";
- result += tr("boosted by: %1").arg(json["account"].toObject()["display_name"].toString());
- } else {
- result += accountParser(json["account"].toObject());
- result += "
";
- result += tr("created at :");
- QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ");
- dt.setTimeSpec(Qt::UTC);
- result += dt.toLocalTime().toString();
- result += "
";
- }
- if (!rebloged) {
- result += "
";
- result += contentParser(json["content"].toString());
- result += "
";
+
+ QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ");
+ dt.setTimeSpec(Qt::UTC);
+
+ result = (!json["reblog"].isNull()) ?
+ (statusParser(json["reblog"].toObject()) +
+ htmlDiv("reblogger",htmlHr() +
+ htmlImg("mavatar",json["account"].toObject()["avatar"].toString()) +
+ tr("boosted by: %1").arg(json["account"].toObject()["display_name"].toString()))
+ ) :
+ (htmlDiv("status",accountParser(json["account"].toObject()) +
+ htmlDiv("created_at",tr("created at :") +
+ dt.toLocalTime().toString()) +
+ htmlDiv("content",contentParser(json["content"].toString())))
+ );
+ if (json["reblog"].isNull()) {
+ QString media;
for (auto j:json["media_attachments"].toArray()) {
- result += mediaParser(j.toObject());
+ media += mediaParser(j.toObject());
}
- result += "
";
- result += "
";
+ result += htmlDiv("media",media);
}
- result += "
";
return result;
}
@@ -183,19 +172,10 @@
const QString SaoriView::mediaParser(const QJsonObject json)
{
QString result;
- result += "
";
- if (json["type"].toString() == "image") {
- result += "";
- }
- result += "";
- if (json["type"].toString() == "image") {
- result += "";
- }
- result += "";
+ result = htmlSpan("media_preview",
+ json["type"].toString() == "image" ?
+ htmlAnc("media:" + json["url"].toString(),htmlImg("media",json["preview_url"].toString())) :
+ htmlImg("media",json["preview_url"].toString()));
return result;
}
@@ -234,47 +214,42 @@
{
QString result;
if (json.isEmpty()) return QString();
- result += "
";
+
+ QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ");
+ dt.setTimeSpec(Qt::UTC);
+
QStringList type;
type << "mention" << "reblog" << "favourite" << "follow";
- result += "
";
+ QString title;
switch (type.indexOf(json["type"].toString())) {
case 0:
- result += "
";
- result += tr("%1 mentioned your status.").arg(json["account"].toObject()["display_name"].toString());
+ title += htmlImg("mavatar",":/icons/ionicons/chatbubbles.svg");
+ title += tr("%1 mentioned your status.").arg(json["account"].toObject()["display_name"].toString());
break;
case 1:
- result += "
";
- result += tr("%1 boosted your status.").arg(json["account"].toObject()["display_name"].toString());
+ title += htmlImg("mavatar",":/icons/ionicons/share.svg");
+ title += tr("%1 boosted your status.").arg(json["account"].toObject()["display_name"].toString());
break;
case 2:
- result += "
";
- result += tr("%1 favourited your status.").arg(json["account"].toObject()["display_name"].toString());
+ title += htmlImg("mavatar",":/icons/ionicons/heart.svg");
+ title += tr("%1 favourited your status.").arg(json["account"].toObject()["display_name"].toString());
break;
case 3:
- result += "
";
- result += tr("%1 followed you.").arg(json["account"].toObject()["display_name"].toString());
+ title += htmlImg("mavatar",":/icons/ionicons/person-add.svg");
+ title += tr("%1 followed you.").arg(json["account"].toObject()["display_name"].toString());
break;
default:
break;
}
- result += "
";
- result += "
";
- result += tr("created at :");
- QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ");
- dt.setTimeSpec(Qt::UTC);
- result += dt.toLocalTime().toString();
- result += "
";
- result += statusParser(json["status"].toObject());
-
- result += "
";
- result += "
";
- result += tr("%1").arg(json["account"].toObject()["display_name"].toString());
- result += "
";
- result += "
";
+ result = htmlDiv("notification",
+ htmlDiv("notification_type",title + htmlHr()) +
+ htmlDiv("created_at",tr("created at :") + dt.toLocalTime().toString()) +
+ statusParser(json["status"].toObject()) +
+ htmlDiv("reblogger",htmlHr() +
+ htmlImg("mavatar",json["account"].toObject()["avatar"].toString()) +
+ tr("%1 (@%2)").arg(json["account"].toObject()["display_name"].toString(),
+ json["account"].toObject()["acct"].toString())));
return result;
}
@@ -290,7 +265,7 @@
const QString SaoriView::htmlImg(const QString type, const QString url)
{
- return QString("
").arg(type,url);
+ return QString("
").arg(type,url);
}
const QString SaoriView::htmlAnc(const QString link, const QString text)