diff options
author | ConfuSomu | 2023-03-30 14:21:51 -0400 |
---|---|---|
committer | ConfuSomu | 2023-03-30 14:21:51 -0400 |
commit | 14294369e2ee7e4914757054693fe77b450f7405 (patch) | |
tree | 04e7e52375f936ccbe07364cbcce78fb5c736a4e | |
parent | 6f64a658b3d24912d69fd89ccca341475ebdc07a (diff) | |
download | ActorViewer-14294369e2ee7e4914757054693fe77b450f7405.tar ActorViewer-14294369e2ee7e4914757054693fe77b450f7405.tar.gz ActorViewer-14294369e2ee7e4914757054693fe77b450f7405.zip |
Display content language in status info
-rw-r--r-- | src/archive_parser.cpp | 21 | ||||
-rw-r--r-- | src/templates/status_info.html | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/archive_parser.cpp b/src/archive_parser.cpp index d677f84..d16cd49 100644 --- a/src/archive_parser.cpp +++ b/src/archive_parser.cpp @@ -209,6 +209,25 @@ QString get_html_status_object_as_list(QJsonObject obj, QString element_name) { return text; } +QString get_html_status_object_languages(QJsonObject obj, QString element_name = "contentMap") { + QString text; + + if (obj.contains(element_name) and obj.value(element_name).isObject()) { + QJsonObject content_map = obj.value(element_name).toObject(); + QStringList languages = content_map.keys(); + + for (auto lang : languages) + text.append(lang + ", "); + } + + if (text.isEmpty()) + text = "<em>(unknown)</em>"; + else + text.chop(2); // remove leftover ", " + + return text; +} + QString Archive::get_html_status_attachments(QJsonValueRef attachments_ref, int text_zone_width) { QString text; QJsonArray attachments = attachments_ref.toArray(); @@ -278,6 +297,7 @@ QString Archive::get_html_status_info(int status_index, int text_zone_width, Sta if (activity["content"].isString()) { info_text.replace("{{content}}", activity["content"].toString()); + info_text.replace("{{lang}}", get_html_status_object_languages(activity)); } } else if (obj["object"].isString()) { QString text = obj["object"].toString(); @@ -292,6 +312,7 @@ QString Archive::get_html_status_info(int status_index, int text_zone_width, Sta info_text.replace("{{content}}", content_text); info_text.replace("{{summary}}", "<em>(empty)</em>"); + info_text.replace("{{lang}}", "<em>(not applicable)</em>"); info_text.replace("{{attachment-div}}", ""); } diff --git a/src/templates/status_info.html b/src/templates/status_info.html index a51c066..9ff5ec5 100644 --- a/src/templates/status_info.html +++ b/src/templates/status_info.html @@ -10,6 +10,7 @@ <li id="publication-date"><b>Published:</b> {{published}}</li> <li id="to"><b>To:</b> {{to}}</li> <li id="cc"><b>CC:</b> {{cc}}</li> + <li id="lang"><b>Language:</b> {{lang}}</li> <li>URL to <a href="{{url-status}}">Status</a>, <a href="{{url-id}}">JSON-LD Object</a></li> </ul> |