mirror of https://notabug.org/acetone/ircabot.git
parent
f8abf1604b
commit
c187a5869f
|
@ -13,6 +13,8 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
constexpr int MAX_MESSAGE_LENGTH_WITHOUT_WBR = 30;
|
||||||
|
constexpr int MAX_NICKNAME_LENGTH_WITHOUT_WBR = 20;
|
||||||
constexpr int BUFFER_SIZE = 2048;
|
constexpr int BUFFER_SIZE = 2048;
|
||||||
|
|
||||||
HttpServer::HttpServer(const QString &address, quint16 port, const QString& logFolder,
|
HttpServer::HttpServer(const QString &address, quint16 port, const QString& logFolder,
|
||||||
|
@ -46,7 +48,8 @@ QString HttpServer::convertToClickableLink(const QString &httpLine)
|
||||||
|
|
||||||
QString displayedName {httpLine};
|
QString displayedName {httpLine};
|
||||||
displayedName.remove(QRegularExpression("http.?://(www\\.)?"));
|
displayedName.remove(QRegularExpression("http.?://(www\\.)?"));
|
||||||
result = "<a href=\"" + httpLine + "\"> " + displayedName + "</a>";
|
displayedName.remove(QRegularExpression("/$"));
|
||||||
|
result = "<a href=\"" + httpLine + "\"> " + displayedName + " </a>";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +70,16 @@ std::pair<QString, QString> HttpServer::splitUserNameAndMessage(const QString &r
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// long nicks
|
||||||
|
if (nick.size() > MAX_NICKNAME_LENGTH_WITHOUT_WBR) {
|
||||||
|
int lastWbr = 0;
|
||||||
|
for (int i = 0; i < nick.size(); i++) {
|
||||||
|
if (i-lastWbr > MAX_NICKNAME_LENGTH_WITHOUT_WBR) {
|
||||||
|
nick.insert(i, "<wbr>");
|
||||||
|
lastWbr = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// http links
|
// http links
|
||||||
while (QRegularExpression("(^|\\s)http.?://").match(text).hasMatch()) {
|
while (QRegularExpression("(^|\\s)http.?://").match(text).hasMatch()) {
|
||||||
int pos = text.indexOf(QRegularExpression("(^|\\s)http.?://"));
|
int pos = text.indexOf(QRegularExpression("(^|\\s)http.?://"));
|
||||||
|
@ -100,7 +113,7 @@ std::pair<QString, QString> HttpServer::splitUserNameAndMessage(const QString &r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (not isHref and i-space > 30) {
|
if (not isHref and i-space > MAX_MESSAGE_LENGTH_WITHOUT_WBR) {
|
||||||
text.insert(i, "<wbr>");
|
text.insert(i, "<wbr>");
|
||||||
space = i;
|
space = i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue