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
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(
" : "");
+ return $socialString;
+ }
+
public static function title()
{
global $site;
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)];
+ }
}
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->emoji."" : ""). " " . $this->name."";
+ }
+
+}
\ No newline at end of file
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();
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 = '