diff options
| -rw-r--r-- | plugins/NewStory/src/history_array.cpp | 27 | ||||
| -rw-r--r-- | plugins/NewStory/src/templates.cpp | 9 |
2 files changed, 22 insertions, 14 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 9a5185c905..a0e2999cc2 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -386,13 +386,20 @@ void ItemData::load(bool bLoadAlways) {
DB::FILE_BLOB blob(dbe);
if (blob.isOffline()) {
+ CMStringW buf;
+
m_bOfflineFile = true;
- if (blob.isCompleted())
+ if (blob.isCompleted()) {
m_bOfflineDownloaded = 100;
- else
- m_bOfflineDownloaded = uint8_t(100.0 * blob.getTransferred() / blob.getSize());
- CMStringW buf;
+ auto *pwszLocalName = blob.getLocalName();
+ if (ProtoGetAvatarFileFormat(pwszLocalName) != PA_FORMAT_UNKNOWN)
+ buf.AppendFormat(L"[img]%s[/img]", pwszLocalName);
+ else
+ buf.AppendFormat(L"[url]file://%s[/url]", pwszLocalName);
+ }
+ else m_bOfflineDownloaded = uint8_t(100.0 * blob.getTransferred() / blob.getSize());
+
buf.Append(blob.getName() ? blob.getName() : TranslateT("Unnamed"));
if (auto *pwszDescr = blob.getDescr()) {
@@ -414,17 +421,9 @@ void ItemData::load(bool bLoadAlways) CMStringW wszFileName = buf;
wszFileName.Append(blob.getName());
- // if a filename contains spaces, URL will be broken
- if (wszFileName.Find(' ') != -1) {
- wchar_t wszShortPath[MAX_PATH];
- if (GetShortPathNameW(wszFileName, wszShortPath, _countof(wszShortPath))) {
- wszFileName = wszShortPath;
- wszFileName.MakeLower();
- }
- }
-
wszFileName.Replace('\\', '/');
- wszFileName.Insert(0, L"file://");
+ wszFileName.Insert(0, L"[url]file://");
+ wszFileName.Append(L"[/url]");
wtext = wszFileName.Detach();
}
break;
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index 166a3de63c..ef7bba6b9f 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -113,6 +113,15 @@ static void AppendString(CMStringW &buf, const wchar_t *p) buf.AppendFormat(L"<%ss>", pEnd);
p++;
}
+ else if (!wcsncmp(p, L"img]", 4)) {
+ p += 4;
+
+ if (auto *p2 = wcsstr(p, L"[/img]")) {
+ CMStringW wszUrl(p, int(p2 - p));
+ buf.AppendFormat(L"<img style=\"width: 300;\" src=\"file://%s\" /><br>", wszUrl.c_str());
+ p = p2 + 5;
+ }
+ }
else if (!wcsncmp(p, L"url]", 4)) {
p += 4;
|
