From 84b445e5561526f83cfaba6b118fbc06f007d629 Mon Sep 17 00:00:00 2001 From: xRy0 Date: Sat, 24 May 2025 01:20:06 +0300 Subject: [PATCH 1/5] feat(ModalPosts): added logic. ui broken :-( --- Web/Presenters/WallPresenter.php | 10 +- .../components/post/embeddedpost.xml | 167 ++++++++++++++++++ .../components/post/microblogpost.xml | 2 +- Web/routes.yml | 2 + Web/static/js/al_wall.js | 30 ++++ 5 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 Web/Presenters/templates/components/post/embeddedpost.xml diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index f4a8e898..e5e3b7fc 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -123,6 +123,11 @@ final class WallPresenter extends OpenVKPresenter $this->renderWall($user, true); } + public function renderPostEmbedded(int $wall, int $post_id): void + { + $this->renderPost($wall, $post_id, true); + } + public function renderRSS(int $user): void { $owner = ($user < 0 ? (new Clubs()) : (new Users()))->get(abs($user)); @@ -439,7 +444,7 @@ final class WallPresenter extends OpenVKPresenter } } - public function renderPost(int $wall, int $post_id): void + public function renderPost(int $wall, int $post_id, bool $embedded = false): void { $post = $this->posts->getPostById($wall, $post_id); if (!$post || $post->isDeleted()) { @@ -470,6 +475,9 @@ final class WallPresenter extends OpenVKPresenter $this->template->cCount = $post->getCommentsCount(); $this->template->cPage = (int) ($_GET["p"] ?? 1); $this->template->comments = iterator_to_array($post->getComments($this->template->cPage)); + if ($embedded == true) { + $this->template->_template = "components/post/embeddedpost.xml"; + } } public function renderLike(int $wall, int $post_id): void diff --git a/Web/Presenters/templates/components/post/embeddedpost.xml b/Web/Presenters/templates/components/post/embeddedpost.xml new file mode 100644 index 00000000..e8a6e2fd --- /dev/null +++ b/Web/Presenters/templates/components/post/embeddedpost.xml @@ -0,0 +1,167 @@ +{var $author = $post->getOwner()} +{var $comments = $post->getLastComments(3)} +{var $commentsCount = $post->getCommentsCount()} +{var $platform = $post->getPlatform()} +{var $platformDetails = $post->getPlatformDetails()} +{var $likesCount = $post->getLikesCount()} +{var $repostsCount = $post->getRepostCount()} +{var $canBePinned = $post->canBePinnedBy($thisUser ?? NULL)} +{var $canBeDeleted = $post->canBeDeletedBy($thisUser)} +{var $wallOwner = $post->getWallOwner()} +{if $post->isDeactivationMessage() && $post->getText()} + {var $deac = "post_deact"} +{else} + {var $deac = "post_deact_silent"} +{/if} +{var $compact = isset($compact) ? true : false} +{var $club = isset($club) ? $club} + +{var $commentTextAreaId = $post === NULL ? rand(1,300) : $post->getId()} + + + + + + + +
+ + + {_online} + + + +
+
+ {$post->getText()|noescape} + + {var $width = ($GLOBALS["_bigWall"] ?? false) ? 550 : 320} + {if isset($GLOBALS["_nesAttGloCou"])} + {var $width = $width - 70 * $GLOBALS["_nesAttGloCou"]} + {/if} + {var $attachmentsLayout = $post->getChildrenWithLayout($width)} +
+
+ {include "../attachment.xml", attachment => $attachment[2], parent => $post, parentType => "post", tilesCount => sizeof($attachmentsLayout->tiles)} +
+
+ +
+
+ {include "../attachment.xml", attachment => $attachment, post => $post} +
+
+
+
+ + + + + {$post->getGeo()->name ?? tr("admin_open")} + +
+
+
+  ! {_post_is_ad} +
+
+ {_source}: {$post->getSource(true)|noescape} +
+
+ {var $actualAuthor = $post->getOwner(false)} + +
+ + {$actualAuthor->getCanonicalName()} + +
+
+
+
+
+ {$post->getPublicationTime()} + ({_edited_short}) + + + + + + {if isset($thisUser)} +   + + {_comment} + + + {/if} +
+
+ {_view_other_comments} + {foreach $comments as $comment} + {include "../comment.xml", comment => $comment, $compact => true} + {/foreach} +
+ {var $commentsURL = "/al_comments/create/posts/" . $post->getId()} + {var $club = is_null($club) ? ($post->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($post->getTargetWall())) : NULL) : $club} + {include "../textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), post => $post, club => $club} +
+
+
+ + +
+
\ No newline at end of file diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index b39b8239..4749c97e 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -119,7 +119,7 @@
- {$post->getPublicationTime()} + {$post->getPublicationTime()} ({_edited_short}) diff --git a/Web/routes.yml b/Web/routes.yml index 9738b740..370559cf 100644 --- a/Web/routes.yml +++ b/Web/routes.yml @@ -131,6 +131,8 @@ routes: handler: "Wall->makePost" - url: "/wall{num}_{num}" handler: "Wall->post" + - url: "/wall{num}_{num}_e" + handler: "Wall->postEmbedded" - url: "/wall{num}_{num}/like" handler: "Wall->like" - url: "/wall{num}_{num}/repost" diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 6568ba51..e0a0565b 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -2951,3 +2951,33 @@ u(document).on("submit", "#additional_fields_form", (e) => { } }) }) + +async function getEmbeddedPost(postId) { + let res = await fetch("/wall"+postId+"_e") + res.text().then(function (text) { + CMessageBox.toggleLoader() + let msb = new CMessageBox({ + title: '', + custom_template: u(` +
+ ${text} +
+ `) + }) + CMessageBox.toggleLoader() + }); + +} + +u(document).on("click", "#al-post", (e) => { + e.preventDefault(); + const postId = String(e.target.dataset.id); + getEmbeddedPost(postId) +}); + +const params = new URLSearchParams(window.location.search); + +if (params.has("w")) { + let post_id = params.get("w").replace("wall-", ""); + getEmbeddedPost(post_id) +} \ No newline at end of file From 83e08ae7c9d7770ee7bc2d806d09aad20d92ae8a Mon Sep 17 00:00:00 2001 From: xRy0 Date: Sat, 24 May 2025 01:30:36 +0300 Subject: [PATCH 2/5] feat(ModalPosts): url change after click event --- Web/static/js/al_wall.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index e0a0565b..619a2a25 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -2966,7 +2966,7 @@ async function getEmbeddedPost(postId) { }) CMessageBox.toggleLoader() }); - + history.replaceState(null, null, `?w=wall-${postId}`) } u(document).on("click", "#al-post", (e) => { From b8e7f0ce3e9c7aa56a1af658bd12058ae32786f3 Mon Sep 17 00:00:00 2001 From: xRy0 Date: Sat, 24 May 2025 03:31:50 +0300 Subject: [PATCH 3/5] feat(ModalPosts): Fixed ui and some shinanigans --- .../components/post/embeddedpost.xml | 63 ++++++++++++++----- Web/static/css/main.css | 38 +++++++++++ Web/static/js/al_wall.js | 47 ++++++++++---- 3 files changed, 120 insertions(+), 28 deletions(-) diff --git a/Web/Presenters/templates/components/post/embeddedpost.xml b/Web/Presenters/templates/components/post/embeddedpost.xml index e8a6e2fd..a48c90d6 100644 --- a/Web/Presenters/templates/components/post/embeddedpost.xml +++ b/Web/Presenters/templates/components/post/embeddedpost.xml @@ -1,5 +1,17 @@ +{extends "../../@layout.xml"} + +{block title} + {_post} - OpenVK +{/block} + +{block header} + {_post} +{/block} + + + +{block content} {var $author = $post->getOwner()} -{var $comments = $post->getLastComments(3)} {var $commentsCount = $post->getCommentsCount()} {var $platform = $post->getPlatform()} {var $platformDetails = $post->getPlatformDetails()} @@ -17,17 +29,26 @@ {var $club = isset($club) ? $club} {var $commentTextAreaId = $post === NULL ? rand(1,300) : $post->getId()} - - - - - - - -
+ + +
+ +
- +
\ No newline at end of file +
+ + + +{/block} diff --git a/Web/static/css/main.css b/Web/static/css/main.css index 0332d278..72600cfb 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -4286,3 +4286,41 @@ hr { .deleted_mark_average { padding: 5px 61px; } + + +.post-modal-view { + position: relative; + z-index: 999; + background: #fff; + min-width: 600px; + width: fit-content; + padding: 25px; + padding-top: 15px; + padding-bottom: 10px; + box-shadow: 0px 0px 3px 1px #222; + margin: 20px auto 0 auto; +} + +.post-modal-title { + font-weight: bold; + padding-bottom: 16px; +} + +.post-modal-title div { + float: right; + font-weight: normal; +} + +.post-modal-wrapper { + position: relative; + display: flex; + flex-direction: column; +} + +.post-modal-header { + display: flex; +} + +.post-modal-author { + margin: 5px; +} \ No newline at end of file diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 619a2a25..7065388a 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -2953,20 +2953,45 @@ u(document).on("submit", "#additional_fields_form", (e) => { }) async function getEmbeddedPost(postId) { - let res = await fetch("/wall"+postId+"_e") - res.text().then(function (text) { - CMessageBox.toggleLoader() - let msb = new CMessageBox({ + CMessageBox.toggleLoader() + let request = await fetch("/wall"+postId+"_e") + const body_html = await request.text() + const parser = new DOMParser + const body = parser.parseFromString(body_html, "text/html") + + const preview = body.querySelector('.post') + + if (request.status != 200) { + MessageBox("Error", "Post not found", ["Ок"], [Function.noop]) + } else { + const photo_viewer = new CMessageBox({ title: '', custom_template: u(`
- ${text} -
- `) +
+
+ + ${tr("post")} + +
+ ${tr("close")} +
+
+
+ ${preview.innerHTML} +
+
+ `) }) - CMessageBox.toggleLoader() - }); - history.replaceState(null, null, `?w=wall-${postId}`) + photo_viewer.getNode().find("#ovk-photo-close").on("click", function(e) { + photo_viewer.close() + }); + } + + + CMessageBox.toggleLoader() + + history.replaceState(null, null, `?w=wall${postId}`) } u(document).on("click", "#al-post", (e) => { @@ -2978,6 +3003,6 @@ u(document).on("click", "#al-post", (e) => { const params = new URLSearchParams(window.location.search); if (params.has("w")) { - let post_id = params.get("w").replace("wall-", ""); + let post_id = params.get("w").replace("wall", ""); getEmbeddedPost(post_id) } \ No newline at end of file From a0c2853d6d338989106cf819bbc9e7b0170401d8 Mon Sep 17 00:00:00 2001 From: xRy0 Date: Sun, 25 May 2025 02:12:39 +0300 Subject: [PATCH 4/5] feat(ModalPosts): design modifications --- .../components/post/embeddedpost.xml | 35 ++----------------- .../templates/components/post/oldpost.xml | 2 +- Web/static/css/main.css | 2 ++ 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/Web/Presenters/templates/components/post/embeddedpost.xml b/Web/Presenters/templates/components/post/embeddedpost.xml index a48c90d6..5017d6b8 100644 --- a/Web/Presenters/templates/components/post/embeddedpost.xml +++ b/Web/Presenters/templates/components/post/embeddedpost.xml @@ -46,7 +46,6 @@
- {_online}
-
+
{$post->getText()|noescape} @@ -166,17 +150,6 @@
{/if}
-
- {_view_other_comments} - {foreach $comments as $comment} - {include "../comment.xml", comment => $comment, $compact => true} - {/foreach} -
- {var $commentsURL = "/al_comments/create/posts/" . $post->getId()} - {var $club = is_null($club) ? ($post->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($post->getTargetWall())) : NULL) : $club} - {include "../textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), post => $post, club => $club} -
-
{include "../comments.xml", comments => $comments, @@ -185,10 +158,6 @@ model => "posts", parent => $post }
-
- - -
diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 3612aa1d..add951b4 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -59,7 +59,7 @@ {/if}
- + {$post->getPublicationTime()} ({_edited_short}){if $post->isPinned()}, {_pinned}{/if} diff --git a/Web/static/css/main.css b/Web/static/css/main.css index 72600cfb..fd7d55ee 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -4323,4 +4323,6 @@ hr { .post-modal-author { margin: 5px; + margin-top: 0px; + width: 100%; } \ No newline at end of file From ae5b4705350e0d7f5958b477a99d349f991360e2 Mon Sep 17 00:00:00 2001 From: xRy0 Date: Sun, 25 May 2025 02:15:10 +0300 Subject: [PATCH 5/5] feat(ModalPosts): Small fixes --- Web/Presenters/templates/components/post/embeddedpost.xml | 2 +- Web/static/js/al_wall.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Web/Presenters/templates/components/post/embeddedpost.xml b/Web/Presenters/templates/components/post/embeddedpost.xml index 5017d6b8..3007c216 100644 --- a/Web/Presenters/templates/components/post/embeddedpost.xml +++ b/Web/Presenters/templates/components/post/embeddedpost.xml @@ -1,7 +1,7 @@ {extends "../../@layout.xml"} {block title} - {_post} - OpenVK + {_post} {/block} {block header} diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 7065388a..ab080460 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -3005,4 +3005,4 @@ const params = new URLSearchParams(window.location.search); if (params.has("w")) { let post_id = params.get("w").replace("wall", ""); getEmbeddedPost(post_id) -} \ No newline at end of file +}