Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Web/Models/Entities/Traits/TRichText.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function formatLinks(string &$text): string
$domainNPath = explode("/", $matches[3], 2);
$href = end($domainNPath);
}
$link = $matches[3];
$link = str_replace("\r", "", $matches[0]); // clears caret return that triggered <br> to be spawned
$rel = $this->isAd() ? "sponsored" : "ugc";

return "<a href='/$href' rel='$rel' target='_blank'>$link</a>" . htmlentities($matches[4]);
Expand Down Expand Up @@ -135,9 +135,10 @@ public function getText(bool $html = true): string
if ($html) {
if ($proc) {
$text = $this->formatLinks($text);
// Mentions: @user, @user (name), [id1|name]
$text = preg_replace("%@([A-Za-z0-9]++) \(((?:[\p{L&}\p{Lo} 0-9]\p{Mn}?)++)\)%Xu", "[$1|$2]", $text);
$text = preg_replace("%([\n\r\s]|^)(@([A-Za-z0-9]++))%Xu", "$1[$3|@$3]", $text);
$text = preg_replace("%\[([A-Za-z0-9]++)\|((?:[\p{L&}\p{Lo} 0-9@]\p{Mn}?)++)\]%Xu", "<a href='/$1'>$2</a>", $text);
$text = preg_replace("%\[([A-Za-z0-9]++)\|((?:[\p{L&}\p{Lo} 0-9\.\-\`\'@]\p{Mn}?)++)\]%Xu", "<a href='/$1'>$2</a>", $text);
$text = preg_replace_callback("%([\n\r\s]|^)(\#([\p{L}_0-9][\p{L}_0-9\(\)\-\']+[\p{L}_0-9\(\)]|[\p{L}_0-9]{1,2}))%Xu", function ($m) {
$slug = rawurlencode($m[3]);

Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/WallPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function renderRSS(int $user): void
}

header("Content-Type: application/rss+xml");
exit($feed);
exit((string) $feed);
}

public function renderFeed(): void
Expand Down
1 change: 1 addition & 0 deletions Web/Presenters/templates/Wall/Wall.latte
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<div n:attr="id => ($type != 'search' ? 'ki' : 'activetabs')" class="tab">
<a n:attr="id => ($type != 'search' ? 'ki' : 'act_tab_a')" href="/wall{$owner}?type=search">{_header_search}</a>
</div>
<a href="/wall{$owner}/rss" class="side_link">{_read_in_rss}</a>
</div>

<div n:if="$canPost && $type == 'all'" class="content_subtitle">
Expand Down
18 changes: 13 additions & 5 deletions Web/static/js/al_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ window.API = new Proxy(Object.create(null), {
xhr.responseType = "arraybuffer";

xhr.onload = e => {
let resp = msgpack.decode(new Uint8Array(e.target.response));
if(typeof resp.error !== "undefined")
rej(resp.error);
else
resolv(resp.result);
try {
let resp = msgpack.decode(new Uint8Array(e.target.response));
if(typeof resp.error !== "undefined")
rej(resp.error);
else
resolv(resp.result);
} catch (e) {
rej({
"code": -1,
"message": `Network error`,
"error": e
})
}
};

xhr.send(msgpack.encode({
Expand Down
11 changes: 6 additions & 5 deletions Web/static/js/al_notifs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function incrementNotificationsCounter() {
}

async function setupNotificationListener() {
console.warn("Setting up notifications listener...");
console.info("Setting up notifications listener...");

const POLL_INTERVAL = 10000;
const CHECK_MORE_INTERVAL = 250;
Expand All @@ -53,18 +53,19 @@ async function setupNotificationListener() {

await new Promise(resolve => setTimeout(resolve, CHECK_MORE_INTERVAL));
} catch(rejection) {
const isEmpty = rejection.message === "Nothing to report" || rejection.code === 1983;

if (isEmpty) {
if (rejection.message === "Nothing to report" || rejection.code === 1983) {
if (isFirstRequest) {
console.info("Cursor synced. Real-time notifications enabled.");
isFirstRequest = false;
} else {
console.info("No new notifications found, sleeping for " + POLL_INTERVAL/1000 + "s...")
}
await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL));
} else if (rejection.message === "Disabled" || rejection.code === 1999) {
console.error("Real-time notifications are disabled. Aborting RPC polling until next page load", rejection);
break;
} else {
console.error("Poll error, sleeping...", rejection);
console.error("Poll error, we'll try again in a minute...", rejection);
await new Promise(resolve => setTimeout(resolve, ERROR_RETRY_INTERVAL));
}
}
Expand Down
1 change: 1 addition & 0 deletions locales/en.strings
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
"users_posts" = "Posts by $1";
"clubs_posts" = "Group's posts";
"others_posts" = "Others posts";
"read_in_rss" = "Read in RSS";

"show_more" = "Show more";
"show_less" = "Show less";
Expand Down
1 change: 1 addition & 0 deletions locales/ru.strings
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@
"show_more" = "Показать больше";
"show_less" = "Показать меньше";
"has_repost" = "Содержит репост";
"read_in_rss" = "Читать в RSS";

"likers_list" = "Список лайкнувших";
"liked_verb" = "Понравилось";
Expand Down
Loading