From 770a65e15c26e7e8bbe8e8b98cd0c7b9b3ffb1f1 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 2 Jul 2025 20:19:51 +0200 Subject: [PATCH 1/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20an=20array=20for?= =?UTF-8?q?=20the=20site=20socials?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/admin/views/settings.php | 21 ++++++++++++++++++++- bl-kernel/functions.php | 7 +++++++ bl-kernel/site.class.php | 15 ++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php index a9a02f22..0f2d6022 100644 --- a/bl-kernel/admin/views/settings.php +++ b/bl-kernel/admin/views/settings.php @@ -19,7 +19,7 @@ p('General') ?> p('Advanced') ?> p('SEO') ?> - p('Social Networks') >; ?> + p('Social Networks') ?> p('Images') ?> p('Language') ?> p('Logo') ?> @@ -400,6 +400,25 @@ echo Bootstrap::formInputHidden(array( ?> +
+ g('Social Networks')); + + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $value) { + echo Bootstrap::formInputText(array( + 'name' => Text::cleanUrl($value), + 'label' => $value, + 'value' => $site->getSocialNetwork($value), + 'class' => '', + 'placeholder' => '', + 'tip' => '' + )); + } + + echo Bootstrap::cardEnd(); + ?> +
+
setCustomFields($args['customFields']); } + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $social) { + $socialKey = Text::cleanUrl($social); + if (isset($args[$socialKey])) { + $site->setSocialNetwork($socialKey, $args[$socialKey]); + } + } + if ($site->set($args)) { // Check current order-by if changed it reorder the content if ($site->orderBy() != ORDER_BY) { diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index 495031ac..d340895b 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -58,7 +58,8 @@ class Site extends dbJSON 'avatarQuality' => 100, 'logo' => '', 'markdownParser' => true, - 'customFields' => '{}' + 'customFields' => '{}', + 'socials' => array() ); function __construct() @@ -479,4 +480,16 @@ class Site extends dbJSON $customFields = Sanitize::htmlDecode($this->getField('customFields')); return json_decode($customFields, true); } + + public function setSocialNetwork($social, $url) { + $key = Text::cleanUrl($social); + if ($this->getField('socials') == NULL) { + $this->db['socials'] = array(); + } + $this->db['socials'][$key] = $url; + } + + public function getSocialNetwork($social) { + return $this->getField('socials')[Text::cleanUrl($social)]; + } } From 54170e1e30e28d2214528830d9dcfe32c1ffbcca Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 2 Jul 2025 20:20:33 +0200 Subject: [PATCH 2/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20an=20array=20for?= =?UTF-8?q?=20the=20user=20socials?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/admin/views/edit-user.php | 108 +++------------------------- bl-kernel/user.class.php | 4 ++ bl-kernel/users.class.php | 11 ++- 3 files changed, 25 insertions(+), 98 deletions(-) diff --git a/bl-kernel/admin/views/edit-user.php b/bl-kernel/admin/views/edit-user.php index de653be6..f4c8a6ce 100644 --- a/bl-kernel/admin/views/edit-user.php +++ b/bl-kernel/admin/views/edit-user.php @@ -249,104 +249,18 @@ echo Bootstrap::formInputHidden(array(
g('Social Networks')); - echo Bootstrap::formInputText(array( - 'name' => 'twitter', - 'label' => 'Twitter', - 'value' => $user->twitter(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - echo Bootstrap::formInputText(array( - 'name' => 'facebook', - 'label' => 'Facebook', - 'value' => $user->facebook(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'codepen', - 'label' => 'CodePen', - 'value' => $user->codepen(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'instagram', - 'label' => 'Instagram', - 'value' => $user->instagram(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'gitlab', - 'label' => 'GitLab', - 'value' => $user->gitlab(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'github', - 'label' => 'GitHub', - 'value' => $user->github(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'linkedin', - 'label' => 'LinkedIn', - 'value' => $user->linkedin(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'xing', - 'label' => 'Xing', - 'value' => $user->xing(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'telegram', - 'label' => 'Telegram', - 'value' => $user->telegram(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'mastodon', - 'label' => 'Mastodon', - 'value' => $user->mastodon(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'vk', - 'label' => 'VK', - 'value' => $user->vk(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $value) { + echo Bootstrap::formInputText(array( + 'name' => Text::cleanUrl($value), + 'label' => $value, + 'value' => $user->getSocialNetwork($value), + 'class' => '', + 'placeholder' => '', + 'tip' => '' + )); + } + echo Bootstrap::cardEnd(); ?>
diff --git a/bl-kernel/user.class.php b/bl-kernel/user.class.php index 07b0962a..3075d7ff 100644 --- a/bl-kernel/user.class.php +++ b/bl-kernel/user.class.php @@ -205,6 +205,10 @@ class User return $this->getValue('vk'); } + public function getSocialNetwork($social) { + return $this->getValue('socials')[Text::cleanUrl($social)]; + } + public function profilePicture() { $filename = $this->getValue('username') . '.png'; diff --git a/bl-kernel/users.class.php b/bl-kernel/users.class.php index d0a2c076..a5eeb679 100644 --- a/bl-kernel/users.class.php +++ b/bl-kernel/users.class.php @@ -26,7 +26,8 @@ class Users extends dbJSON { 'gitlab'=>'', 'linkedin'=>'', 'mastodon'=>'', - 'vk'=>'' + 'vk'=>'', + 'socials' => array() ); function __construct() @@ -128,6 +129,14 @@ class Users extends dbJSON { $row['tokenAuth'] = $this->generateAuthToken(); } + $row['socials'] = array(); + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $social) { + $socialKey = Text::cleanUrl($social); + if (isset($args[$socialKey])) { + $row['socials'][$socialKey] = $args[$socialKey]; + } + } + // Save the database $this->db[$username] = $row; return $this->save(); From 713e1a35838883ee5db05b59e241b68795964155 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 2 Jul 2025 20:20:50 +0200 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=92=AC=20Add=20a=20list=20of=20social?= =?UTF-8?q?=20networks=20and=20emojis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/boot/variables.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bl-kernel/boot/variables.php b/bl-kernel/boot/variables.php index 9427e03c..cd45aa8c 100644 --- a/bl-kernel/boot/variables.php +++ b/bl-kernel/boot/variables.php @@ -129,4 +129,22 @@ $GLOBALS['POST_KINDS_EMOJI'] = array( 'review'=>'⭐️', 'chicken'=>'🐔', 'literature'=>'📕' +); + +$GLOBALS['SOCIAL_NETWORKS'] = array('Mastodon', 'Fediverse', 'Pixelfed', 'Status Cafe', 'SpaceHey', 'Bluesky', 'Git', 'Github', 'Sheezy', 'Diaspora', 'Youtube', 'Peertube', 'Furaffinity'); + +$GLOBALS['SOCIAL_NETWORKS_EMOJI'] = array( + 'mastodon'=>'🦣', + 'fediverse'=>'⁂', + 'pixelfed'=>'📷', + 'status-cafe'=>'☕', + 'spacehey'=>'🌌', + 'bluesky'=>'🦋', + 'git'=>'🧑‍💻', + 'github'=>'🧑‍💻', + 'sheezy'=>'🎨', + 'diaspora'=>'*️', + 'youtube'=>'📽️', + 'peertube'=>'📽️', + 'furaffinity'=>'🐾' ); \ No newline at end of file From dcf00a1f7158489cdca51100107d45843b0a246c Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 2 Jul 2025 20:21:40 +0200 Subject: [PATCH 4/6] =?UTF-8?q?=E2=9C=A8=20Use=20the=20new=20socials=20in?= =?UTF-8?q?=20themes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/helpers/theme.class.php | 25 ++++++++----------------- bl-themes/alternative/php/navbar.php | 6 +++--- bl-themes/blogx/php/navbar.php | 6 +++--- bl-themes/popeye/php/footer.php | 2 +- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php index 1d97d393..990141bb 100644 --- a/bl-kernel/helpers/theme.class.php +++ b/bl-kernel/helpers/theme.class.php @@ -6,29 +6,20 @@ class Theme public static function socialNetworks() { global $site; - $socialNetworks = array( - 'github' => 'Github', - 'gitlab' => 'GitLab', - 'twitter' => 'Twitter', - 'facebook' => 'Facebook', - 'instagram' => 'Instagram', - 'codepen' => 'Codepen', - 'linkedin' => 'Linkedin', - 'xing' => 'Xing', - 'telegram' => 'Telegram', - 'mastodon' => 'Mastodon', - 'vk' => 'VK', - 'dribbble' => 'Dribbble' - ); + $socialNetworks = array(); - foreach ($socialNetworks as $key => $label) { - if (!$site->{$key}()) { - unset($socialNetworks[$key]); + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $label) { + if ($site->getSocialNetwork($label) != "") { + $socialNetworks[Text::cleanUrl($label)] = $label; } } return $socialNetworks; } + public static function socialNetworkEmoji($socialNetwork) { + return $GLOBALS['SOCIAL_NETWORKS_EMOJI'][Text::cleanUrl($socialNetwork)]; + } + public static function title() { global $site; diff --git a/bl-themes/alternative/php/navbar.php b/bl-themes/alternative/php/navbar.php index ed77ea82..6a17659f 100644 --- a/bl-themes/alternative/php/navbar.php +++ b/bl-themes/alternative/php/navbar.php @@ -20,9 +20,9 @@ $label): ?> diff --git a/bl-themes/blogx/php/navbar.php b/bl-themes/blogx/php/navbar.php index 09e68e34..c10dd66d 100644 --- a/bl-themes/blogx/php/navbar.php +++ b/bl-themes/blogx/php/navbar.php @@ -19,9 +19,9 @@ $label) : ?> diff --git a/bl-themes/popeye/php/footer.php b/bl-themes/popeye/php/footer.php index 798dd1b8..e24666b0 100644 --- a/bl-themes/popeye/php/footer.php +++ b/bl-themes/popeye/php/footer.php @@ -2,7 +2,7 @@
From 449a3be3a80bc18626cf9e9402da522449f830ab Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 2 Jul 2025 20:43:55 +0200 Subject: [PATCH 5/6] =?UTF-8?q?=E2=9C=A8=20Add=20a=20social=20network=20pl?= =?UTF-8?q?ugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/boot/init.php | 1 + bl-kernel/helpers/theme.class.php | 16 ++++++++++ bl-kernel/social.class.php | 22 ++++++++++++++ bl-plugins/socials/languages/en.json | 7 +++++ bl-plugins/socials/languages/fr_FR.json | 7 +++++ bl-plugins/socials/metadata.json | 11 +++++++ bl-plugins/socials/plugin.php | 40 +++++++++++++++++++++++++ 7 files changed, 104 insertions(+) create mode 100644 bl-kernel/social.class.php create mode 100644 bl-plugins/socials/languages/en.json create mode 100644 bl-plugins/socials/languages/fr_FR.json create mode 100644 bl-plugins/socials/metadata.json create mode 100644 bl-plugins/socials/plugin.php diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 06644836..ddd10687 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -106,6 +106,7 @@ include(PATH_KERNEL . 'url.class.php'); include(PATH_KERNEL . 'login.class.php'); include(PATH_KERNEL . 'parsedown.class.php'); include(PATH_KERNEL . 'security.class.php'); +include(PATH_KERNEL . 'social.class.php'); // Include functions include(PATH_KERNEL . 'functions.php'); diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php index 990141bb..2835b4e1 100644 --- a/bl-kernel/helpers/theme.class.php +++ b/bl-kernel/helpers/theme.class.php @@ -20,6 +20,22 @@ class Theme return $GLOBALS['SOCIAL_NETWORKS_EMOJI'][Text::cleanUrl($socialNetwork)]; } + public static function listSiteSocials($list = true, $emoji = false) { + global $site; + $socialList = Theme::socialNetworks(); + + $socialString = ($list == true) ? "" : ""); + return $socialString; + } + public static function title() { global $site; diff --git a/bl-kernel/social.class.php b/bl-kernel/social.class.php new file mode 100644 index 00000000..ea57b883 --- /dev/null +++ b/bl-kernel/social.class.php @@ -0,0 +1,22 @@ +name = $name; + $this->slug = Text::cleanUrl($name); + $this->emoji = $GLOBALS['SOCIAL_NETWORKS_EMOJI'][$this->slug]; + $this->url = $url; + } + + function getLink($useEmoji = false) { + return "".($useEmoji ? '" : ""). " " . $this->name.""; + } + +} \ No newline at end of file diff --git a/bl-plugins/socials/languages/en.json b/bl-plugins/socials/languages/en.json new file mode 100644 index 00000000..0b8c8ded --- /dev/null +++ b/bl-plugins/socials/languages/en.json @@ -0,0 +1,7 @@ +{ + "plugin-data": + { + "name": "Social Networks", + "description": "Shows the social network list in the sidebar." + } +} diff --git a/bl-plugins/socials/languages/fr_FR.json b/bl-plugins/socials/languages/fr_FR.json new file mode 100644 index 00000000..c815606c --- /dev/null +++ b/bl-plugins/socials/languages/fr_FR.json @@ -0,0 +1,7 @@ +{ + "plugin-data": + { + "name": "Réseaux sociaux", + "description": "Affiche la liste des réseaux sociaux dans la barre latérale." + } +} diff --git a/bl-plugins/socials/metadata.json b/bl-plugins/socials/metadata.json new file mode 100644 index 00000000..891c2ded --- /dev/null +++ b/bl-plugins/socials/metadata.json @@ -0,0 +1,11 @@ +{ + "author": "Koblog", + "email": "", + "website": "https://plugins.koblog.com", + "version": "kb_0.0.1", + "releaseDate": "2024-08-23", + "license": "MIT", + "compatible": "kb_0.0.1", + "notes": "", + "type": "widget" +} diff --git a/bl-plugins/socials/plugin.php b/bl-plugins/socials/plugin.php new file mode 100644 index 00000000..44a533e7 --- /dev/null +++ b/bl-plugins/socials/plugin.php @@ -0,0 +1,40 @@ +dbFields = array( + 'label' => 'Social Networks', + ); + } + + public function form() + { + global $L; + + $html = '
'; + $html .= ''; + $html .= ''; + $html .= '' . $L->get('This title is almost always used in the sidebar of the site') . ''; + $html .= '
'; + + return $html; + } + + // Method called on the sidebar of the website + public function siteSidebar() + { + global $L; + global $url; + + $html = '
'; + $html .= '

' . $this->getValue('label') . '

'; + $html .= '
'; + $html .= Theme::listSiteSocials(true, true); + $html .= '
'; + $html .= '
'; + return $html; + } + +} \ No newline at end of file From 01613ec4953f4d41cda6858f89773cb2c9e460c1 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 2 Jul 2025 21:05:27 +0200 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=93=9D=20Update=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a334c16b..4d0a68c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ First forked version from bludit - Site: Add support for author view - Site: Add support for IndieWeb post kinds - Site: Add a source URL (usefull for some post kinds) +- Theme: Add emoji for social network +- Sidebar: Add a social network widget ### Changed @@ -24,3 +26,4 @@ First forked version from bludit - Icons: replaced linearicons by fontawesome - Admin: reworked the theme - Admin/content: The sidebar is now always visible +- Replace social network by a better list and make them more configurable \ No newline at end of file