ability to open old posts without UUID

This commit is contained in:
2026-07-16 13:17:44 +03:00
parent 7ceae1c81e
commit 975c3f1909
2 changed files with 33 additions and 7 deletions
+31 -5
View File
@@ -7,7 +7,6 @@ use Zotlabs\Web\Controller;
class Link extends Controller { class Link extends Controller {
function init() { function init() {
} }
function get() { function get() {
@@ -20,7 +19,7 @@ class Link extends Controller {
return; return;
} }
$r = q("select uuid from item where id = %d limit 1", $r = q("select uuid, mid from item where id = %d limit 1",
intval($item_id) intval($item_id)
); );
@@ -29,12 +28,39 @@ class Link extends Controller {
return; return;
} }
if (get_config('link','hideasides')) { $identifier = $r[0]['uuid'] ?? '';
goaway(z_root() . '/display/' . $r[0]['uuid'] . '?link_hideasides=1');
if (!$identifier) {
if ($r[0]['mid']) {
$identifier = 'b64.' . base64url_encode($r[0]['mid']);
}
} }
goaway(z_root() . '/display/' . $r[0]['uuid']); if (!$identifier) {
notice( t('Item not found.') . EOL);
return;
}
$old_argv = \App::$argv;
$old_argc = \App::$argc;
\App::$argv = ['display', $identifier];
\App::$argc = 2;
$display = new Display();
$output = $display->get();
\App::$argv = $old_argv;
\App::$argc = $old_argc;
$separator = ' - ';
$page_title = \App::$page['title'];
if (substr($page_title, -strlen($separator)) === $separator) {
$page_title = substr($page_title, 0, -strlen($separator));
}
\App::$page['title'] = $page_title;
return $output;
} }
} }
+2 -2
View File
@@ -2,7 +2,7 @@
/** /**
* Name: Link * Name: Link
* Description: Using short links on whole hub * Description: Using short links on whole hub
* Version: 0.92 * Version: 0.94
* Author: ivan zlax <@zlax@ussr.win> * Author: ivan zlax <@zlax@ussr.win>
* Maintainer: ivan zlax <@zlax@ussr.win> * Maintainer: ivan zlax <@zlax@ussr.win>
*/ */
@@ -59,7 +59,7 @@ function dropdown_link(&$extras) {
} }
function hideasides_header(&$b) { function hideasides_header(&$b) {
if (isset($_GET['link_hideasides'])) { if (get_config('link','hideasides') && isset($_SERVER['REQUEST_URI']) && str_contains($_SERVER['REQUEST_URI'], '/link/')) {
$addScriptTag = "<style>#region_1 { display: none !important; } #region_3 { display: none !important; }</style>\r\n"; $addScriptTag = "<style>#region_1 { display: none !important; } #region_3 { display: none !important; }</style>\r\n";
\App::$page['htmlhead'] .= $addScriptTag; \App::$page['htmlhead'] .= $addScriptTag;
} }