Skip to content

Commit

Permalink
Fixed shortening links after upload
Browse files Browse the repository at this point in the history
  • Loading branch information
zenden2k committed Dec 7, 2024
1 parent 11b6959 commit 6339139
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Data/servers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
<Actions>
<Action
Type="get"
Url="http://tinyurl.com/api-create.php?url=$(_ORIGINALURL|urlencode)"
Url="https://tinyurl.com/api-create.php?url=$(_ORIGINALURL|urlencode)"
RegExp='tinyurl\.com\/(\w+)'
AssignVars="surl:0"
/>
Expand Down
15 changes: 8 additions & 7 deletions Lang/imageuploader.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: imageuploader\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-07 10:41+0300\n"
"POT-Creation-Date: 2024-12-07 17:14+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -381,16 +381,17 @@ msgstr ""
msgid "Are you sure you want to delete profile '%s'?"
msgstr ""

#: ../Source/Gui/Dialogs/HistoryWindow.cpp:386
#, c-format
msgid "Are you sure you want to delete the file '%s' from the server?"
msgstr ""

#: ../Source/Gui/Dialogs/LoginDlg.cpp:168
msgid ""
"Are you sure you want to delete this account from Image Uploader's internal "
"list?"
msgstr ""

#: ../Source/Gui/Dialogs/HistoryWindow.cpp:381
msgid "Are you sure?"
msgstr ""

#: ../Source/ImageEditor/Gui/ImageEditorWindow.cpp:934
msgid "Arrow"
msgstr ""
Expand Down Expand Up @@ -1054,7 +1055,7 @@ msgstr ""
msgid "Delete file from server"
msgstr ""

#: ../Source/Gui/Dialogs/HistoryWindow.cpp:381
#: ../Source/Gui/Dialogs/HistoryWindow.cpp:389
msgid "Deleting the file from the server"
msgstr ""

Expand Down Expand Up @@ -1618,7 +1619,7 @@ msgstr ""
msgid "History"
msgstr ""

#: ../Source/Gui/Dialogs/HistoryWindow.cpp:494
#: ../Source/Gui/Dialogs/HistoryWindow.cpp:499
msgid "History has been cleared successfully."
msgstr ""

Expand Down
20 changes: 12 additions & 8 deletions Lang/locale/ru/LC_MESSAGES/imageuploader.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: imageuploader\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-07 10:41+0300\n"
"PO-Revision-Date: 2024-12-07 10:42+0300\n"
"POT-Creation-Date: 2024-12-07 17:14+0300\n"
"PO-Revision-Date: 2024-12-07 17:15+0300\n"
"Last-Translator: \n"
"Language-Team: [email protected]\n"
"Language: ru\n"
Expand Down Expand Up @@ -397,17 +397,18 @@ msgstr "Вы действительно хотите выйти из прогр
msgid "Are you sure you want to delete profile '%s'?"
msgstr "Вы действительно хотите удалить профиль '%s'?"

#: ../Source/Gui/Dialogs/HistoryWindow.cpp:386
#, c-format
msgid "Are you sure you want to delete the file '%s' from the server?"
msgstr "Вы действительно хотите удалить файл '%s' с сервера?"

#: ../Source/Gui/Dialogs/LoginDlg.cpp:168
msgid ""
"Are you sure you want to delete this account from Image Uploader's internal "
"list?"
msgstr ""
"Вы действительно хотите удалить этот аккаунт из внутреннего списка программы?"

#: ../Source/Gui/Dialogs/HistoryWindow.cpp:381
msgid "Are you sure?"
msgstr "Вы уверены?"

#: ../Source/ImageEditor/Gui/ImageEditorWindow.cpp:934
msgid "Arrow"
msgstr "Стрелка"
Expand Down Expand Up @@ -1087,7 +1088,7 @@ msgstr "Удалить аккаунт"
msgid "Delete file from server"
msgstr "Удалить файл с сервера"

#: ../Source/Gui/Dialogs/HistoryWindow.cpp:381
#: ../Source/Gui/Dialogs/HistoryWindow.cpp:389
msgid "Deleting the file from the server"
msgstr "Удаление файла с сервера"

Expand Down Expand Up @@ -1659,7 +1660,7 @@ msgstr "Подсвечивающий маркер"
msgid "History"
msgstr "История"

#: ../Source/Gui/Dialogs/HistoryWindow.cpp:494
#: ../Source/Gui/Dialogs/HistoryWindow.cpp:499
msgid "History has been cleared successfully."
msgstr "История была успешно очищена."

Expand Down Expand Up @@ -3390,6 +3391,9 @@ msgstr "Переводчикам:"
msgid "unknown server"
msgstr "неизвестный сервер"

#~ msgid "Are you sure?"
#~ msgstr "Вы уверены?"

#~ msgid "Add folder"
#~ msgstr "Добавить папку"

Expand Down
3 changes: 2 additions & 1 deletion Source/Gui/Dialogs/FloatingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,8 @@ void CFloatingWindow::ShowImageUploadedMessage(UploadTask* task, const CString&
auto generator = factory.createOutputGenerator(generatorId, codeType);
generator->setPreferDirectLinks(settings->UseDirectLinks);
generator->setItemsPerLine(settings->ThumbsPerLine);
generator->setGroupByFile(settings->GroupByFilename);
generator->setGroupByFile(settings->GroupByFilename);
generator->setShortenUrl(task->serverProfile().shortenLinks());

if (generatorId == gidXmlTemplate) {
int templateIndex = settings->CodeType - 4;
Expand Down
15 changes: 10 additions & 5 deletions Source/Gui/Dialogs/HistoryWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,16 @@ LRESULT CHistoryWindow::OnDeleteFileOnServer(WORD wNotifyCode, WORD wID, HWND hW
{
TreeItem* item = m_treeView.selectedItem();
if (!item) return 0;
if (LocalizedMessageBox(TR("Are you sure?"), TR("Deleting the file from the server"), MB_ICONQUESTION|MB_YESNO) == IDYES) {
HistoryItem* historyItem = CHistoryTreeControl::getItemData(item);
if (historyItem) {
DesktopUtils::ShellOpenUrl(historyItem->deleteUrl);
}
HistoryItem* historyItem = CHistoryTreeControl::getItemData(item);
if (!historyItem) {
return 0;
}
std::string message = str(
boost::format(_("Are you sure you want to delete the file '%s' from the server?"))
% historyItem->displayName
);
if (LocalizedMessageBox(U2W(message), TR("Deleting the file from the server"), MB_ICONQUESTION|MB_YESNO) == IDYES) {
DesktopUtils::ShellOpenUrl(historyItem->deleteUrl);
}

return 0;
Expand Down
3 changes: 3 additions & 0 deletions Source/Gui/Dialogs/ResultsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ std::string CResultsPanel::GenerateOutput()
generator->setPreferDirectLinks(preferDirectLinks);
generator->setItemsPerLine(p);
generator->setGroupByFile(groupByFileName_);
generator->setShortenUrl(shortenUrl_);

if (generatorId == OG::gidXmlTemplate) {
int templateIndex = Index - 4;
Expand Down Expand Up @@ -531,6 +532,8 @@ LRESULT CResultsPanel::OnShortenUrlClicked(WORD /*wNotifyCode*/, WORD /*wID*/, H
shortenUrl_ = !shortenUrl_;
if (onShortenUrlChanged_) {
onShortenUrlChanged_(shortenUrl_);
} else {
UpdateOutput(true);
}
return 0;
}
Expand Down
7 changes: 6 additions & 1 deletion Source/ServerListTool/ServersChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,16 @@ void ServersChecker::checkShortUrl(UploadTask* task) {
int i = 0; //counter for limiting max redirects
if (!targetUrl.empty()) {
int responseCode = 0;

do {
client->setCurlOptionInt(CURLOPT_FOLLOWLOCATION, 0);
client->doGet(targetUrl);

responseCode = client->responseCode();
targetUrl = client->responseHeaderByName("Location");
if (responseCode == 302 || responseCode == 301) {
targetUrl = client->getCurlInfoString(CURLINFO_REDIRECT_URL);
}

i++;
} while (i < 6 && !targetUrl.empty() && (responseCode == 302 || responseCode == 301) && targetUrl != urlTask->getUrl());

Expand Down

0 comments on commit 6339139

Please sign in to comment.