From 057e6c5c6396675de68d958ce034b5acc7dade8e Mon Sep 17 00:00:00 2001 From: veselcraft Date: Mon, 4 Jan 2021 12:33:25 -0500 Subject: [PATCH] [NEW FEATURE] Microblog Can be enabled in settings --- Web/Models/Entities/User.php | 5 + Web/Presenters/UserPresenter.php | 3 + Web/Presenters/templates/@layout.xml | 5 + Web/Presenters/templates/User/Settings.xml | 11 ++ Web/Presenters/templates/components/post.xml | 113 ++---------------- .../components/post/microblogpost.xml | 94 +++++++++++++++ .../templates/components/post/oldpost.xml | 106 ++++++++++++++++ Web/static/css/microblog.css | 60 ++++++++++ Web/static/img/delete.svg | 57 +++++++++ Web/static/img/repost.svg | 61 ++++++++++ 10 files changed, 409 insertions(+), 106 deletions(-) create mode 100644 Web/Presenters/templates/components/post/microblogpost.xml create mode 100644 Web/Presenters/templates/components/post/oldpost.xml create mode 100644 Web/static/css/microblog.css create mode 100644 Web/static/img/delete.svg create mode 100644 Web/static/img/repost.svg diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 8ebaaf6c..0543761e 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -73,6 +73,11 @@ class User extends RowModel { return (bool) $this->getRecord()->milkshake; } + + function hasMicroblogEnabled(): bool + { + return (bool) $this->getRecord()->microblog; + } function getChandlerGUID(): string { diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 20534e5e..a018d4d2 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -263,6 +263,9 @@ final class UserPresenter extends OpenVKPresenter if (in_array($this->postParam("rating"), [0, 1])) $user->setShow_Rating((int) $this->postParam("rating")); + + if (in_array($this->postParam("microblog"), [0, 1])) + $user->setMicroblog((int) $this->postParam("microblog")); }elseif($_GET['act'] === "lMenu") { $settings = [ "menu_bildoj" => "photos", diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index a8232770..2dd98359 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -40,6 +40,11 @@ {if $thisUser->getStyleAvatar() == 2} {css "css/avatar.2.css"} {/if} + + + {if $thisUser->hasMicroblogEnabled() == 1} + {css "css/microblog.css"} + {/if} {else} {css "css/style.css"} {css "css/dialog.css"} diff --git a/Web/Presenters/templates/User/Settings.xml b/Web/Presenters/templates/User/Settings.xml index 823362c6..c40ad907 100644 --- a/Web/Presenters/templates/User/Settings.xml +++ b/Web/Presenters/templates/User/Settings.xml @@ -314,6 +314,17 @@ + + + Вид постов + + + + + diff --git a/Web/Presenters/templates/components/post.xml b/Web/Presenters/templates/components/post.xml index d0853385..a099983a 100644 --- a/Web/Presenters/templates/components/post.xml +++ b/Web/Presenters/templates/components/post.xml @@ -1,106 +1,7 @@ -{var author = $post->getOwner()} - - - - - - - - -
- - - -
-
- {$post->getText()|noescape} - -
-
- {include "attachment.xml", attachment => $attachment} -
-
-
-
-
-  ! Этот пост был размещён за взятку. -
-
- {var acutalAuthor = $post->getOwner(false)} - - Автор: - - {$acutalAuthor->getCanonicalName()} - - -
-
-
- {if $post->canBeDeletedBy($thisUser) && !($forceNoDeleteLink ?? false)} - {_"delete"} |  - {/if} - - {if !($forceNoCommentsLink ?? false)} - - {if $post->getCommentsCount() > 0} - {_"comments"} ({$post->getCommentsCount()}) - {else} - {_"comments"} - {/if} - -  |  - {/if} - - - {if $post->getRepostCount() > 0} - {_"share"} - ({$post->getRepostCount()}) - {else} - {_"share"} - {/if} - - - - -
-
- -
-
+{ifset $thisUser} + {if $thisUser->hasMicroblogEnabled()} + {include "post/microblogpost.xml", post => $post} + {else} + {include "post/oldpost.xml", post => $post} + {/if} +{/ifset} \ No newline at end of file diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml new file mode 100644 index 00000000..2308e223 --- /dev/null +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -0,0 +1,94 @@ +{var author = $post->getOwner()} + + + + + + + + +
+ + + +
+
+ {$post->getText()|noescape} + +
+
+ {include "../attachment.xml", attachment => $attachment} +
+
+
+
+
+  ! Этот пост был размещён за взятку. +
+
+ {var acutalAuthor = $post->getOwner(false)} + + Автор: + + {$acutalAuthor->getCanonicalName()} + + +
+
+
+ {$post->getPublicationTime()} + {if isset($thisUser)} +   + + {if !($forceNoCommentsLink ?? false)} + + {if $post->getCommentsCount() > 0} + {_"comments"} ({$post->getCommentsCount()}) + {else} + {_"comments"} + {/if} + +  |  + {/if} + + + + + + {/if} +
+
+ +
+
diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml new file mode 100644 index 00000000..f3d17ff4 --- /dev/null +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -0,0 +1,106 @@ +{var author = $post->getOwner()} + + + + + + + + +
+ + + +
+
+ {$post->getText()|noescape} + +
+
+ {include "../attachment.xml", attachment => $attachment} +
+
+
+
+
+  ! Этот пост был размещён за взятку. +
+
+ {var acutalAuthor = $post->getOwner(false)} + + Автор: + + {$acutalAuthor->getCanonicalName()} + + +
+
+
+ {if $post->canBeDeletedBy($thisUser) && !($forceNoDeleteLink ?? false)} + {_"delete"} |  + {/if} + + {if !($forceNoCommentsLink ?? false)} + + {if $post->getCommentsCount() > 0} + {_"comments"} ({$post->getCommentsCount()}) + {else} + {_"comments"} + {/if} + +  |  + {/if} + + + {if $post->getRepostCount() > 0} + {_"share"} + ({$post->getRepostCount()}) + {else} + {_"share"} + {/if} + + + + +
+
+ +
+
diff --git a/Web/static/css/microblog.css b/Web/static/css/microblog.css new file mode 100644 index 00000000..3b649852 --- /dev/null +++ b/Web/static/css/microblog.css @@ -0,0 +1,60 @@ +/* VK's Microblog CSS */ +/* Design belongs to Pavel Durov & mail.ru */ + +.post { + padding: 5px 0 5px 0; +} + +.post-divider { + border-bottom: 1px #ddd solid; +} + +.post-author { + background-color: transparent; + border: none; + padding: 0 3px 3px 3px; +} + +.post-author .date { + font-size: 11px; + color: grey; +} + +.post-content { + border: none; +} + +.post-menu { + font-size: 10px; +} + +.post-menu .date { + color: grey; +} + +.repost-icon { + background: url('/assets/packages/static/openvk/img/like.gif') no-repeat 1px -20px; + height: 12px; + margin: 2px 3px 0px; + width: 11px; + float: left; +} + +.repost-icon:hover { + opacity: 1 !important; +} + +.post-author .delete { + float: right; + display: inline-block; + height: 16px; + width: 16px; + overflow: auto; + background: url("/assets/packages/static/openvk/img/delete.svg") no-repeat -4px -4px; + opacity: 0.1; + transition-duration: 0.3s; +} + +.post-author .delete:hover { + opacity: 0.4; +} diff --git a/Web/static/img/delete.svg b/Web/static/img/delete.svg new file mode 100644 index 00000000..2de6ca03 --- /dev/null +++ b/Web/static/img/delete.svg @@ -0,0 +1,57 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/Web/static/img/repost.svg b/Web/static/img/repost.svg new file mode 100644 index 00000000..84b78dd8 --- /dev/null +++ b/Web/static/img/repost.svg @@ -0,0 +1,61 @@ + + + + + + + + image/svg+xml + + + + + + + + +