diff --git a/bl-kernel/archives.class.php b/bl-kernel/archives.class.php index 5b5c79d1..0accf0a7 100644 --- a/bl-kernel/archives.class.php +++ b/bl-kernel/archives.class.php @@ -18,7 +18,7 @@ class Archives extends dbList { $db = $pages->getDB($onlyKeys=false); $archiveIndex = array(); foreach ($db as $pageKey=>$pageFields) { - if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) { + if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_AUTHOR_ARCHIVE'])) { $date = $pageFields['date']; $year = mb_substr($date, 0, 4); $month = mb_substr($date, 0, 7); @@ -46,4 +46,19 @@ class Archives extends dbList { return $this->save(); } + public function getLinkList($month, $class = "", $classActive = "active") + { + $listLink = array(); + foreach ($this->db as $pageKey=>$pageFields) { + if ( + ($month && strlen($pageKey) != 4) + || (!$month && strlen($pageKey) == 4) + ) { + $link = DOMAIN_ARCHIVES . $pageKey; + $listLink[] = new Link($pageFields['name'], $link, $class, $classActive); + } + } + return $listLink; + } + } \ No newline at end of file diff --git a/bl-kernel/authors.class.php b/bl-kernel/authors.class.php index fc6263a7..a60d976f 100644 --- a/bl-kernel/authors.class.php +++ b/bl-kernel/authors.class.php @@ -18,7 +18,7 @@ class Authors extends dbList { $db = $pages->getDB($onlyKeys=false); $authorsIndex = array(); foreach ($db as $pageKey=>$pageFields) { - if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) { + if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_AUTHOR_ARCHIVE'])) { $authorName = $pageFields['username']; if (isset($authorsIndex[$authorName])) { array_push($authorsIndex[$authorName]['list'], $pageKey); diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index d9df020f..5fa6acaa 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -41,6 +41,7 @@ define('PATH_CONTENT', PATH_ROOT . 'bl-content' . DS); define('PATH_ABSTRACT', PATH_KERNEL . 'abstract' . DS); define('PATH_RULES', PATH_KERNEL . 'boot' . DS . 'rules' . DS); define('PATH_HELPERS', PATH_KERNEL . 'helpers' . DS); +define('PATH_CLASSES', PATH_KERNEL . 'class' . DS); define('PATH_AJAX', PATH_KERNEL . 'ajax' . DS); define('PATH_CORE_JS', PATH_KERNEL . 'js' . DS); @@ -116,6 +117,9 @@ include(PATH_KERNEL . 'social.class.php'); // Include functions include(PATH_KERNEL . 'functions.php'); +// Include classes +include(PATH_CLASSES . 'link.class.php'); + // Include Helpers Classes include(PATH_HELPERS . 'text.class.php'); include(PATH_HELPERS . 'log.class.php'); @@ -131,6 +135,7 @@ include(PATH_HELPERS . 'alert.class.php'); include(PATH_HELPERS . 'paginator.class.php'); include(PATH_HELPERS . 'image.class.php'); include(PATH_HELPERS . 'media.class.php'); +include(PATH_HELPERS . 'menus.class.php'); include(PATH_HELPERS . 'tcp.class.php'); include(PATH_HELPERS . 'dom.class.php'); include(PATH_HELPERS . 'cookie.class.php'); diff --git a/bl-kernel/boot/rules/99.paginator.php b/bl-kernel/boot/rules/99.paginator.php index 249dc03c..4547f36a 100644 --- a/bl-kernel/boot/rules/99.paginator.php +++ b/bl-kernel/boot/rules/99.paginator.php @@ -15,6 +15,18 @@ if ($url->whereAmI()=='admin') { $itemsPerPage = $site->itemsPerPage(); $categoryKey = $url->slug(); $numberOfItems = $categories->numberOfPages($categoryKey); +} elseif ($url->whereAmI()=='author') { + $itemsPerPage = $site->itemsPerPage(); + $categoryKey = $url->slug(); + $numberOfItems = $authors->numberOfPages($categoryKey); +} elseif ($url->whereAmI()=='archive') { + $itemsPerPage = $site->itemsPerPage(); + $categoryKey = $url->slug(); + $numberOfItems = $archives->numberOfPages($categoryKey); +} elseif ($url->whereAmI()=='kind') { + $itemsPerPage = $site->itemsPerPage(); + $categoryKey = $url->slug(); + $numberOfItems = $kinds->numberOfPages($categoryKey); } else { $itemsPerPage = $site->itemsPerPage(); $numberOfItems = $pages->count(true); diff --git a/bl-kernel/boot/variables.php b/bl-kernel/boot/variables.php index cd45aa8c..7a597769 100644 --- a/bl-kernel/boot/variables.php +++ b/bl-kernel/boot/variables.php @@ -106,6 +106,9 @@ define('MEDIA_MANAGER_SORT_BY_DATE', true); // Type of pages included in the tag database $GLOBALS['DB_TAGS_TYPES'] = array('published','static','sticky'); +// Type of pages included in the author/archive database +$GLOBALS['DB_TAGS_AUTHOR_ARCHIVE'] = array('published','sticky'); + // Allowed image extensions $GLOBALS['ALLOWED_IMG_EXTENSION'] = array('gif', 'png', 'jpg', 'jpeg', 'svg', 'webp'); diff --git a/bl-kernel/categories.class.php b/bl-kernel/categories.class.php index 17b8c87b..1201aec9 100644 --- a/bl-kernel/categories.class.php +++ b/bl-kernel/categories.class.php @@ -40,4 +40,20 @@ class Categories extends dbList { return $this->save(); } + + public function getLinkList($hideEmpty, $showCount, $class = "", $classActive = "active") + { + $listLink = array(); + foreach ($this->db as $pageKey=>$pageFields) { + $count = count($pageFields['list']); + if ( + (!$hideEmpty || $count > 0) + ) { + $link = DOMAIN_CATEGORIES . $pageKey; + $name = $pageFields['name'] . ($showCount ? ' (' . $count . ')' : ''); + $listLink[] = new Link($name, $link, $class, $classActive); + } + } + return $listLink; + } } \ No newline at end of file diff --git a/bl-kernel/class/link.class.php b/bl-kernel/class/link.class.php new file mode 100644 index 00000000..a4be04ee --- /dev/null +++ b/bl-kernel/class/link.class.php @@ -0,0 +1,42 @@ +label = $label; + $this->href = $href; + $this->class = $class; + $this->classActive = $classActive; + } + + function isActive() + { + global $url; + global $site; + return str_ends_with($this->href, $url->uri()) || ($this->href == $site->url() && $url->uri() == "/"); + } + + function haveClass() + { + return ($this->getClasses() != ""); + } + + function getClasses() + { + return $this->class . ($this->isActive() ? " " . $this->classActive : ""); + } + + function toHTML() + { + return "haveClass() ? "class='" . $this->getClasses() . "'" : "" ) . ($this->isActive() ? "aria-current='page'" : "") . " >".$this->label.""; + } +} \ No newline at end of file diff --git a/bl-kernel/helpers/menus.class.php b/bl-kernel/helpers/menus.class.php new file mode 100644 index 00000000..5a15f51a --- /dev/null +++ b/bl-kernel/helpers/menus.class.php @@ -0,0 +1,46 @@ +getArticleLinkList($numberOfItems, $showStatic, $classLink, $classActive), $classUl, $include); + } + + public static function getStatics($numberOfItems, $showHome = true, $classUl = "", $classLink = "", $classActive = "active", $include = "") + { + global $pages; + return MenuHelper::toMenu($pages->getStaticLinkList($numberOfItems, $showHome, $classLink, $classActive), $classUl, $include); + } + + public static function getArchive($monthly, $classUl = "", $classLink = "", $classActive = "active", $include = "") + { + global $archives; + return MenuHelper::toMenu($archives->getLinkList($monthly, $classLink, $classActive), $classUl, $include); + } + + public static function getCategories($showEmpty, $showCount, $classUl = "", $classLink = "", $classActive = "active", $include = "") + { + global $categories; + return MenuHelper::toMenu($categories->getLinkList($showEmpty, $showCount, $classLink, $classActive), $classUl, $include); + } + + public static function getTags($minArticle = 1, $classUl = "", $classLink = "", $classActive = "active", $include = "") + { + global $tags; + return MenuHelper::toMenu($tags->getLinkList($minArticle, $classLink, $classActive), $classUl, $include); + } + + private static function toMenu($links, $classUl, $include = "") + { + $html = '"; + return $html; + } + +} \ No newline at end of file diff --git a/bl-kernel/helpers/paginator.class.php b/bl-kernel/helpers/paginator.class.php index f8b83ddc..71662c15 100644 --- a/bl-kernel/helpers/paginator.class.php +++ b/bl-kernel/helpers/paginator.class.php @@ -163,7 +163,7 @@ class Paginator { if ($i <= 1 || $i >= self::get('numberOfPages') || abs($i - self::currentPage()) < $maxDistance) { if ($i == self::currentPage()) { $html .= '
  • '; - $html .= ''.($i).''; + $html .= ''.($i).''; $html .= '
  • '; } else { $html .= '
  • '; @@ -198,7 +198,7 @@ class Paginator { return ""; } - $html = ''; return $html; } diff --git a/bl-plugins/last-articles/languages/en.json b/bl-plugins/last-articles/languages/en.json new file mode 100644 index 00000000..ae5708bd --- /dev/null +++ b/bl-plugins/last-articles/languages/en.json @@ -0,0 +1,8 @@ +{ + "plugin-data": + { + "name": "Latest articles", + "description": "Show latest articles in the blog." + }, + "amount-of-items": "Amount of items" +} \ No newline at end of file diff --git a/bl-plugins/last-articles/languages/fr_FR.json b/bl-plugins/last-articles/languages/fr_FR.json new file mode 100755 index 00000000..5ff6ba2b --- /dev/null +++ b/bl-plugins/last-articles/languages/fr_FR.json @@ -0,0 +1,8 @@ +{ + "plugin-data": + { + "name": "Derniers articles", + "description": "Afficher les derniers articles parus sur le blog." + }, + "amount-of-items": "Quantité d’articles" +} \ No newline at end of file diff --git a/bl-plugins/last-articles/metadata.json b/bl-plugins/last-articles/metadata.json new file mode 100644 index 00000000..891c2ded --- /dev/null +++ b/bl-plugins/last-articles/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/last-articles/plugin.php b/bl-plugins/last-articles/plugin.php new file mode 100644 index 00000000..643fd8ec --- /dev/null +++ b/bl-plugins/last-articles/plugin.php @@ -0,0 +1,59 @@ +dbFields = array( + 'label' => $L->get('Lastest articles'), + 'numberOfItems' => 5 + ); + } + + // Method called on the settings of the plugin on the admin area + public function form() + { + global $L; + + $html = '
    '; + $html .= ''; + $html .= ''; + $html .= '' . $L->get('This title is almost always used in the sidebar of the site') . ''; + $html .= '
    '; + + $html .= '
    '; + $html .= ''; + $html .= ''; + $html .= '
    '; + + return $html; + } + + // Method called on the sidebar of the website + public function siteSidebar() + { + global $L; + global $url; + global $site; + global $pages; + + // HTML for sidebar + $html = ''; + + return $html; + } +} diff --git a/bl-plugins/navigation/languages/fr_FR.json b/bl-plugins/navigation/languages/fr_FR.json index fc0521a6..61953cef 100755 --- a/bl-plugins/navigation/languages/fr_FR.json +++ b/bl-plugins/navigation/languages/fr_FR.json @@ -2,9 +2,8 @@ "plugin-data": { "name": "Navigation", - "description": "Créez votre propre menu de navigation avec les dernières pages ou pages statiques." + "description": "Créez votre propre menu de navigation avec les différentes pages non-statiques et leurs enfants." }, "home-link": "Lien de la page d’accueil", - "show-the-home-link-on-the-sidebar": "Afficher un lien vers la page d’accueil dans la barre latérale.", - "amount-of-items": "Quantité d’articles" + "show-the-home-link-on-the-sidebar": "Afficher un lien vers la page d’accueil dans la barre latérale." } \ No newline at end of file diff --git a/bl-plugins/navigation/plugin.php b/bl-plugins/navigation/plugin.php index a859f015..62900c25 100644 --- a/bl-plugins/navigation/plugin.php +++ b/bl-plugins/navigation/plugin.php @@ -8,8 +8,7 @@ class pluginNavigation extends Plugin // Fields and default values for the database of this plugin $this->dbFields = array( 'label' => 'Navigation', - 'homeLink' => true, - 'numberOfItems' => 5 + 'homeLink' => true ); } @@ -33,13 +32,6 @@ class pluginNavigation extends Plugin $html .= '' . $L->get('Show the home link on the sidebar') . ''; $html .= ''; - if (ORDER_BY == 'date') { - $html .= '
    '; - $html .= ''; - $html .= ''; - $html .= '
    '; - } - return $html; } @@ -52,7 +44,7 @@ class pluginNavigation extends Plugin global $pages; // HTML for sidebar - $html = '
    '; + $html = '
  • '; } - // Pages order by position - if (ORDER_BY == 'position') { - // Get parents - $parents = buildParentPages(); - foreach ($parents as $parent) { - $html .= '
  • '; - $html .= '' . $parent->title() . ''; + // Get parents + $parents = buildParentPages(); + foreach ($parents as $parent) { + $html .= '
  • '; + $html .= '' . $parent->title() . ''; - if ($parent->hasChildren()) { - // Get children - $children = $parent->children(); - $html .= ''; - } - $html .= '
  • '; - } - } - // Pages order by date - else { - // List of published pages - $onlyPublished = true; - $pageNumber = 1; - $numberOfItems = $this->getValue('numberOfItems'); - $publishedPages = $pages->getList($pageNumber, $numberOfItems, $onlyPublished); - - foreach ($publishedPages as $pageKey) { - try { - $page = new Page($pageKey); - $html .= '
  • '; - $html .= '' . $page->title() . ''; + if ($parent->hasChildren()) { + // Get children + $children = $parent->children(); + $html .= ''; } + $html .= '
  • '; } $html .= ''; $html .= ''; - $html .= ''; + $html .= ''; return $html; } diff --git a/bl-plugins/static-pages/plugin.php b/bl-plugins/static-pages/plugin.php index 02fe0f04..e7a751d3 100644 --- a/bl-plugins/static-pages/plugin.php +++ b/bl-plugins/static-pages/plugin.php @@ -44,7 +44,7 @@ class pluginStaticPages extends Plugin global $pages; // HTML for sidebar - $html = '
    '; + $html = '
    '; + $html .= ''; return $html; } diff --git a/bl-plugins/tags/plugin.php b/bl-plugins/tags/plugin.php index 850710b9..9ceaeda8 100644 --- a/bl-plugins/tags/plugin.php +++ b/bl-plugins/tags/plugin.php @@ -31,23 +31,12 @@ class pluginTags extends Plugin $filter = $url->filters('tag'); - $html = '
    '; + $html = '
    '; + $html .= ''; return $html; } diff --git a/bl-themes/defaultTheme/css/style.css b/bl-themes/defaultTheme/css/style.css index ec3dd69a..c72d5cae 100755 --- a/bl-themes/defaultTheme/css/style.css +++ b/bl-themes/defaultTheme/css/style.css @@ -48,10 +48,12 @@ header#main-header { padding:8px; a { color:white!important; + outline-color: white; border-radius: var(--border-radius); padding:8px; } - a:hover { + a:hover, + a.active { background-color: rgba(255,255,255,0.2); } } @@ -129,30 +131,34 @@ aside { .plugin { margin-bottom: 1rem; } + + a.active { + font-weight: bold; + } } -nav ul { +header#main-header nav ul { display: flex; flex-wrap: wrap; padding: .5rem 0; } -nav ul li { +header#main-header nav ul li { list-style-type: none; margin: 0 } -nav ul li a, -nav ul li span { +header#main-header nav ul li a, +header#main-header nav ul li span { padding: .5rem } -nav ul li.separator { +header#main-header nav ul li.separator { margin-right: auto } -nav ul li.separator-left { +header#main-header nav ul li.separator-left { margin-left: auto } @@ -179,6 +185,10 @@ article { margin: 0 0 1rem 0 } +.no-margin { + margin: 0; +} + p:last-child { margin-bottom: 0 } diff --git a/bl-themes/defaultTheme/php/header.php b/bl-themes/defaultTheme/php/header.php index cb7517df..4b4e73ba 100644 --- a/bl-themes/defaultTheme/php/header.php +++ b/bl-themes/defaultTheme/php/header.php @@ -1,14 +1,5 @@
    - +
    @@ -18,14 +9,5 @@

    description() ?>

    - +
    \ No newline at end of file diff --git a/bl-themes/defaultTheme/php/home.php b/bl-themes/defaultTheme/php/home.php index d5dd7b7e..9b2c5d9c 100644 --- a/bl-themes/defaultTheme/php/home.php +++ b/bl-themes/defaultTheme/php/home.php @@ -1,4 +1,4 @@ -
    +
    @@ -16,13 +16,13 @@
    -
    +
    -

    - title(); ?> +

    + title(); ?>

    @@ -38,9 +38,9 @@ -
    +
    - +