From a870e605715a280f6e6bcb996f12943c47a623ce Mon Sep 17 00:00:00 2001 From: Slava Petrov Date: Fri, 13 Dec 2024 16:57:19 +0300 Subject: [PATCH 1/4] news left menu --- Web/Presenters/templates/@layout.xml | 8 ++++++++ Web/static/css/main.css | 8 +++++++- locales/en.strings | 2 ++ locales/ru.strings | 2 ++ openvk-example.yml | 4 ++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index b7d84b96..8fef2bfb 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -239,6 +239,14 @@ + +
+ {_news} +
+ {php echo OPENVK_ROOT_CONF['openvk']['preferences']['news']['title'];} +

+ Подробнее » +
{tr("you_still_have_x_points", $thisUser->getCoins())|noescape} diff --git a/Web/static/css/main.css b/Web/static/css/main.css index 8f465432..31b049e9 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -2305,7 +2305,7 @@ li { padding-left: 15px; } -#votesBalance { +#votesBalance, #news { margin-top: 10px; padding: 7px; background-color: #f6f6f6; @@ -2314,6 +2314,12 @@ li { user-select: none; } +#news b +{ + color: #8A0000; + font-size: 12px; +} + .cookies-popup { position: fixed; bottom: 0; diff --git a/locales/en.strings b/locales/en.strings index 9909b736..b5e211a2 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -1125,6 +1125,8 @@ "increased_your_rating_by" = "increased your rating by"; +"news" = "News"; + /* Gifts */ "gift" = "Gift"; diff --git a/locales/ru.strings b/locales/ru.strings index 7337b27f..714be3f1 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -1065,6 +1065,8 @@ "negative_rating_value" = "Мы не можем украсть рейтинг у другого человека, извините."; "increased_your_rating_by" = "повысил ваш рейтинг на"; +"news" = "Новость"; + /* Gifts */ "gift" = "Подарок"; diff --git a/openvk-example.yml b/openvk-example.yml index b58660f7..5254b3d6 100644 --- a/openvk-example.yml +++ b/openvk-example.yml @@ -17,6 +17,10 @@ openvk: minLength: 3 # won't affect existing short urls or the ones set via admin panel forbiddenNames: - "index.php" + news: + enable: false + link: "/link" + title: "я покакал" photos: upgradeStructure: false photoSaving: "quick" From 7977a84b49094c11662dc2909b3e94246f3ee317 Mon Sep 17 00:00:00 2001 From: Slava Petrov Date: Fri, 20 Dec 2024 16:57:30 +0300 Subject: [PATCH 2/4] added locale --- Web/Presenters/templates/@layout.xml | 2 +- locales/en.strings | 1 + locales/ru.strings | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index 8fef2bfb..e95579e3 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -245,7 +245,7 @@
{php echo OPENVK_ROOT_CONF['openvk']['preferences']['news']['title'];}

- Подробнее » + {_news_more} »
diff --git a/locales/en.strings b/locales/en.strings index b5e211a2..37bef931 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -1063,6 +1063,7 @@ "points_count" = "votes"; "on_your_account" = "on your account"; "top_up_your_account" = "Get more"; +"news_more" = "More"; "you_still_have_x_points" = "You have $1 unused votes."; "vouchers" = "Vouchers"; diff --git a/locales/ru.strings b/locales/ru.strings index 714be3f1..9b351358 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -1015,6 +1015,7 @@ "on_your_account" = "на вашем счету"; "top_up_your_account" = "Пополнить баланс"; "you_still_have_x_points" = "У Вас $1 неиспользованных голосов."; +"news_more" = "Подробнее"; "vouchers" = "Ваучеры"; "have_voucher" = "Есть ваучер"; "voucher_token" = "Код ваучера"; From 7d6a8fbbbfb8c92aaf051243ae7b5bd5435ebb02 Mon Sep 17 00:00:00 2001 From: Slava Petrov Date: Fri, 20 Dec 2024 17:45:38 +0300 Subject: [PATCH 3/4] feat(global): news on left menu Co-Authored-By: Vladimir Barinov <22993408+veselcraft@users.noreply.github.com> --- Web/Presenters/OpenVKPresenter.php | 12 +++++++++++- Web/Presenters/templates/@layout.xml | 10 +++++----- Web/static/css/main.css | 3 +-- locales/en.strings | 3 ++- locales/ru.strings | 4 +++- openvk-example.yml | 3 +++ 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index 1d03a1c2..3b42608c 100644 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -7,7 +7,7 @@ use Chandler\Security\Authenticator; use Latte\Engine as TemplatingEngine; use openvk\Web\Models\Entities\IP; use openvk\Web\Themes\Themepacks; -use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets, Reports, CurrentUser}; +use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets, Reports, CurrentUser, Posts}; use WhichBrowser; abstract class OpenVKPresenter extends SimplePresenter @@ -207,6 +207,16 @@ abstract class OpenVKPresenter extends SimplePresenter $userValidated = 0; $cacheTime = OPENVK_ROOT_CONF["openvk"]["preferences"]["nginxCacheTime"] ?? 0; + if(OPENVK_ROOT_CONF['openvk']['preferences']['news']['show']) { + $post = (new Posts)->getPostsFromUsersWall(-OPENVK_ROOT_CONF['openvk']['preferences']['news']['groupId'], 1, 1); + $post = iterator_to_array($post)[0]; + $text = wordwrap($post->getText(false), 150, '\n', false); + $text = explode('\n', $text)[0]; + + $this->template->newsText = $text; + $this->template->newsLink = '/wall' . $post->getPrettyId(); + } + if(!is_null($user)) { $this->user = (object) []; $this->user->raw = $user; diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index e95579e3..5ec579a8 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -240,12 +240,12 @@
-
+
{_news} -
- {php echo OPENVK_ROOT_CONF['openvk']['preferences']['news']['title'];} -

- {_news_more} » +
+ {$newsText}... +

+ {_news_more}
diff --git a/Web/static/css/main.css b/Web/static/css/main.css index 31b049e9..24fd9625 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -2314,8 +2314,7 @@ li { user-select: none; } -#news b -{ +#news b { color: #8A0000; font-size: 12px; } diff --git a/locales/en.strings b/locales/en.strings index 37bef931..a04cc2f5 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -1059,11 +1059,12 @@ "time_today" = "today"; "time_yesterday" = "yesterday"; +"news" = "News"; +"news_more" = "More »"; "points" = "Votes"; "points_count" = "votes"; "on_your_account" = "on your account"; "top_up_your_account" = "Get more"; -"news_more" = "More"; "you_still_have_x_points" = "You have $1 unused votes."; "vouchers" = "Vouchers"; diff --git a/locales/ru.strings b/locales/ru.strings index 9b351358..47ce8e0b 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -1010,12 +1010,14 @@ "time_minutes_ago" = "$1 минут назад"; "time_today" = "сегодня"; "time_yesterday" = "вчера"; + +"news" = "Новости"; +"news_more" = "Подробнее »"; "points" = "Голоса"; "points_count" = "голосов"; "on_your_account" = "на вашем счету"; "top_up_your_account" = "Пополнить баланс"; "you_still_have_x_points" = "У Вас $1 неиспользованных голосов."; -"news_more" = "Подробнее"; "vouchers" = "Ваучеры"; "have_voucher" = "Есть ваучер"; "voucher_token" = "Код ваучера"; diff --git a/openvk-example.yml b/openvk-example.yml index 5254b3d6..d0880bf4 100644 --- a/openvk-example.yml +++ b/openvk-example.yml @@ -112,6 +112,9 @@ openvk: defaultMobileTheme: "" defaultFeaturePhoneTheme: "" logs: true + news: + show: false + groupId: 1 telemetry: plausible: From a6b96f716a6c68d34f014585425732b8ef30e380 Mon Sep 17 00:00:00 2001 From: Slava Petrov Date: Fri, 20 Dec 2024 17:47:21 +0300 Subject: [PATCH 4/4] fuck conflict --- Web/Presenters/OpenVKPresenter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index 3b42608c..1ca60265 100644 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -210,6 +210,7 @@ abstract class OpenVKPresenter extends SimplePresenter if(OPENVK_ROOT_CONF['openvk']['preferences']['news']['show']) { $post = (new Posts)->getPostsFromUsersWall(-OPENVK_ROOT_CONF['openvk']['preferences']['news']['groupId'], 1, 1); $post = iterator_to_array($post)[0]; + $text = wordwrap($post->getText(false), 150, '\n', false); $text = explode('\n', $text)[0]; @@ -373,4 +374,4 @@ abstract class OpenVKPresenter extends SimplePresenter return false; } } -} +}