diff --git a/CHANGELOG.md b/CHANGELOG.md index ef2bfabb..a334c16b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ First forked version from bludit - Admin: Added a sidebar panel that show all sidebar widget to be activated/deactivated - Admin: Show some pages only if the theme support their features +- Site: Add support for archive view (à la Wordpress) +- Site: Add support for author view +- Site: Add support for IndieWeb post kinds +- Site: Add a source URL (usefull for some post kinds) ### Changed diff --git a/bl-kernel/admin/views/content.php b/bl-kernel/admin/views/content.php index d48b4742..479f4f22 100644 --- a/bl-kernel/admin/views/content.php +++ b/bl-kernel/admin/views/content.php @@ -1,7 +1,18 @@ "; + echo Bootstrap::pageTitle(array('title'=>$L->g('Articles and pages'), 'icon'=>'archive')); +echo "
"; +echo Bootstrap::link(array( + 'title'=>$L->g('New'), + 'href'=>HTML_PATH_ADMIN_ROOT.'new-content/', + 'icon'=>'plus', + 'class'=>'btn btn-outline-success' +)); +echo "
"; + function table($type) { global $url; global $L; diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index 272ac0d8..5db9f888 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -146,6 +146,18 @@ echo Bootstrap::formInputHidden(array( 'value' => $page->tags() )); + // Post Kinds + echo Bootstrap::formSelectBlock(array( + 'name' => 'kind', + 'label' => $L->g('Post Kinds'), + 'selected' => $page->kind(), + 'class' => '', + 'emptyOption' => '- ' . $L->g('None') . ' -', + 'options' => $kinds->getKeyNameArray(), + 'mt' => 'mt-0', + 'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts' + )); + // Description echo Bootstrap::formTextareaBlock(array( 'name' => 'description', @@ -156,6 +168,15 @@ echo Bootstrap::formInputHidden(array( 'rows' => 5, 'placeholder' => $L->get('this-field-can-help-describe-the-content') )); + + // Source Link + echo Bootstrap::formInputTextBlock(array( + 'name' => 'sourceLink', + 'label' => $L->g('Source Link'), + 'placeholder' => '', + 'tip' => $L->g('The external link you refer to in the post'), + 'value' => $page->sourceLink() + )); ?> diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 9f2ea280..2e4c6969 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -135,6 +135,18 @@ echo Bootstrap::formInputHidden(array( 'tip' => $L->g('Write the tags separated by comma') )); + // Post Kinds + echo Bootstrap::formSelectBlock(array( + 'name' => 'kind', + 'label' => $L->g('Post Kinds'), + 'selected' => 'article', + 'class' => '', + 'emptyOption' => '- ' . $L->g('None') . ' -', + 'options' => $kinds->getKeyNameArray(), + 'mt' => 'mt-0', + 'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts' + )); + // Description echo Bootstrap::formTextareaBlock(array( 'name' => 'description', @@ -145,6 +157,15 @@ echo Bootstrap::formInputHidden(array( 'rows' => 5, 'placeholder' => $L->get('this-field-can-help-describe-the-content') )); + + // Source Link + echo Bootstrap::formInputTextBlock(array( + 'name' => 'sourceLink', + 'label' => $L->g('Source Link'), + 'placeholder' => '', + 'tip' => $L->g('The external link you refer to in the post'), + 'value' => '' + )); ?> diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php index ba32b519..a9a02f22 100644 --- a/bl-kernel/admin/views/settings.php +++ b/bl-kernel/admin/views/settings.php @@ -306,6 +306,15 @@ echo Bootstrap::formInputHidden(array( 'tip' => DOMAIN_ARCHIVES )); + echo Bootstrap::formInputText(array( + 'name' => 'uriKind', + 'label' => $L->g('Post Kind'), + 'value' => $site->uriFilters('kind'), + 'class' => '', + 'placeholder' => '', + 'tip' => DOMAIN_KINDS + )); + echo Bootstrap::formInputText(array( 'name' => 'uriAuthor', 'label' => $L->g('Authors'), diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 1243e0b3..06644836 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -68,6 +68,7 @@ define('DB_CATEGORIES', PATH_DATABASES . 'categories.php'); define('DB_TAGS', PATH_DATABASES . 'tags.php'); define('DB_AUTHORS', PATH_DATABASES . 'authors.php'); define('DB_ARCHIVES', PATH_DATABASES . 'archives.php'); +define('DB_KINDS', PATH_DATABASES . 'kinds.php'); define('DB_SYSLOG', PATH_DATABASES . 'syslog.php'); define('DB_USERS', PATH_DATABASES . 'users.php'); define('DB_SECURITY', PATH_DATABASES . 'security.php'); @@ -92,6 +93,7 @@ include(PATH_KERNEL . 'users.class.php'); include(PATH_KERNEL . 'tags.class.php'); include(PATH_KERNEL . 'authors.class.php'); include(PATH_KERNEL . 'archives.class.php'); +include(PATH_KERNEL . 'kinds.class.php'); include(PATH_KERNEL . 'language.class.php'); include(PATH_KERNEL . 'site.class.php'); include(PATH_KERNEL . 'categories.class.php'); @@ -132,6 +134,7 @@ $users = new Users(); $tags = new Tags(); $authors = new Authors(); $archives = new Archives(); +$kinds = new Kinds(); $categories = new Categories(); $site = new Site(); $url = new Url(); @@ -203,6 +206,9 @@ define('AUTHOR_URI_FILTER', $url->filters('author')); // Archive URI filter define('ARCHIVE_URI_FILTER', $url->filters('archive')); +// Post kind URI filter +define('KIND_URI_FILTER', $url->filters('kind')); + // Page URI filter define('PAGE_URI_FILTER', $url->filters('page')); @@ -261,6 +267,7 @@ define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE . CATEGORY_URI_FILTER, define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE . PAGE_URI_FILTER, false, true)); define('DOMAIN_AUTHORS', Text::addSlashes(DOMAIN_BASE . AUTHOR_URI_FILTER, false, true)); define('DOMAIN_ARCHIVES', Text::addSlashes(DOMAIN_BASE . ARCHIVE_URI_FILTER, false, true)); +define('DOMAIN_KINDS', Text::addSlashes(DOMAIN_BASE . KIND_URI_FILTER, false, true)); $ADMIN_CONTROLLER = ''; $ADMIN_VIEW = ''; diff --git a/bl-kernel/boot/rules/69.pages.php b/bl-kernel/boot/rules/69.pages.php index 321dd401..4b316987 100644 --- a/bl-kernel/boot/rules/69.pages.php +++ b/bl-kernel/boot/rules/69.pages.php @@ -75,10 +75,14 @@ elseif ($url->whereAmI()==='category') { elseif ($url->whereAmI()==='author') { $content = buildPagesByAuthor(); } -// Build content by author +// Build content by archive elseif ($url->whereAmI()==='archive') { $content = buildPagesByArchive(); } +// Build content by archive +elseif ($url->whereAmI()==='kind') { + $content = buildPagesByKind(); +} // Build content for the homepage elseif ( ($url->whereAmI()==='home') || ($url->whereAmI()==='blog') ) { $content = buildPagesForHome(); diff --git a/bl-kernel/boot/variables.php b/bl-kernel/boot/variables.php index 3425cd85..9427e03c 100644 --- a/bl-kernel/boot/variables.php +++ b/bl-kernel/boot/variables.php @@ -111,3 +111,22 @@ $GLOBALS['ALLOWED_IMG_EXTENSION'] = array('gif', 'png', 'jpg', 'jpeg', 'svg', 'w // Allowed image mime types $GLOBALS['ALLOWED_IMG_MIMETYPES'] = array('image/gif', 'image/png', 'image/jpeg', 'image/svg+xml', 'image/webp'); + +// Supported post kinds +$GLOBALS['POST_KINDS'] = array('article', 'note', 'photo', 'video', 'audio', 'reply', 'bookmark', 'like', 'art', 'literature', 'review', 'event', 'chicken'); + +$GLOBALS['POST_KINDS_EMOJI'] = array( + "article"=>'📄', + 'note'=>'📔', + 'photo'=>'📷', + 'art'=>'🎨', + 'event'=>'📅', + 'video'=>'🎥', + 'audio'=>'🎤', + 'reply'=>'💬', + 'bookmark'=>'🔖', + 'like'=>'👍', + 'review'=>'⭐️', + 'chicken'=>'🐔', + 'literature'=>'📕' +); \ No newline at end of file diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 0547985d..a93e9dfd 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -32,6 +32,14 @@ function reindexArchives() return $archives->reindex(); } +// Re-index database of post kinds +// If you create/edit/remove a page is necessary regenerate the database of archives +function reindexKinds() +{ + global $kinds; + return $kinds->reindex(); +} + // Generate the page 404 Not found function buildErrorPage() { @@ -118,10 +126,20 @@ function buildPagesByArchive() return buildPagesFor('archive', false, false, false, $archiveKey); } +// This function is only used from the rule 69.pages.php, DO NOT use this function! +function buildPagesByKind() +{ + global $url; + + $kindKey = $url->slug(); + return buildPagesFor('kind', false, false, false, false, $kindKey); +} + + // This function is only used from the rule 69.pages.php, DO NOT use this function! // Generate the global variables $content / $content, defined on 69.pages.php // This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag() -function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = false, $archiveKey = false) +function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = false, $archiveKey = false, $kindKey = false) { global $pages; global $categories; @@ -130,6 +148,7 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = global $url; global $authors; global $archives; + global $kinds; // Get the page number from URL $pageNumber = $url->pageNumber(); @@ -156,6 +175,9 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = } elseif ($for == 'archive') { $numberOfItems = $site->itemsPerPage(); $list = $archives->getList($archiveKey, $pageNumber, $numberOfItems); + } elseif ($for == 'kind') { + $numberOfItems = $site->itemsPerPage(); + $list = $kinds->getList($kindKey, $pageNumber, $numberOfItems); } // There are not items, invalid tag, invalid category, out of range, etc... @@ -385,6 +407,7 @@ function createPage($args) reindexTags(); reindexAuthors(); reindexArchives(); + reindexKinds(); // Add to syslog $syslog->add(array( @@ -438,6 +461,7 @@ function editPage($args) reindexTags(); reindexAuthors(); reindexArchives(); + reindexKinds(); // Add to syslog $syslog->add(array( @@ -465,6 +489,7 @@ function deletePage($key) reindexTags(); reindexAuthors(); reindexArchives(); + reindexKinds(); // Add to syslog $syslog->add(array( diff --git a/bl-kernel/kinds.class.php b/bl-kernel/kinds.class.php new file mode 100644 index 00000000..1a697a0f --- /dev/null +++ b/bl-kernel/kinds.class.php @@ -0,0 +1,45 @@ +countItems($key); + } + + public function reindex() + { + global $pages; + global $L; + + $kindArray = array(); + + foreach ($GLOBALS['POST_KINDS'] as $kind) { + $kindArray[$kind]['name'] = $GLOBALS['POST_KINDS_EMOJI'][$kind]." ".$L->g($kind); + $kindArray[$kind]['list'] = array(); + } + + + $db = $pages->getDB($onlyKeys=false); + foreach ($db as $pageKey=>$pageFields) { + if ($pageFields['type'] == "published" && isset($pageFields['kind']) && $pageFields !== '') { + $kind = $pageFields['kind']; + + // Index by years + if (isset($kindArray[$kind])) { + array_push($kindArray[$kind]['list'], $pageKey); + } + + } + } + + $this->db = $kindArray; + return $this->save(); + } + +} \ No newline at end of file diff --git a/bl-kernel/pages.class.php b/bl-kernel/pages.class.php index bac2e2fb..001b4339 100644 --- a/bl-kernel/pages.class.php +++ b/bl-kernel/pages.class.php @@ -10,6 +10,7 @@ class Pages extends dbJSON 'username' => '', 'tags' => array(), 'type' => 'published', // published, static, draft, sticky, scheduled, autosave + 'kind'=>'', 'date' => '', 'dateModified' => '', 'position' => 0, @@ -22,6 +23,7 @@ class Pages extends dbJSON 'noindex' => false, 'nofollow' => false, 'noarchive' => false, + 'sourceLink'=>'', 'custom' => array() ); diff --git a/bl-kernel/pagex.class.php b/bl-kernel/pagex.class.php index 81bee954..e89bc5e9 100644 --- a/bl-kernel/pagex.class.php +++ b/bl-kernel/pagex.class.php @@ -435,6 +435,17 @@ class Page return $this->getValue('noarchive'); } + // retour the source link + public function sourceLink() + { + return $this->getValue('sourceLink'); + } + + public function kind() + { + return $this->getValue('kind'); + } + // Returns the page slug public function slug() { diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index a62c69aa..495031ac 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -21,6 +21,7 @@ class Site extends dbJSON 'uriBlog' => '/blog/', 'uriAuthor' => '/author/', 'uriArchive' => '/archive/', + 'uriKind' => '/kind/', 'url' => '', 'emailFrom' => '', 'dateFormat' => 'F j, Y', @@ -104,7 +105,8 @@ class Site extends dbJSON $filters['tag'] = $this->getField('uriTag'); $filters['category'] = $this->getField('uriCategory'); $filters['author'] = $this->getField('uriAuthor'); - $filters['archive'] = $this->getField(field: 'uriArchive'); + $filters['archive'] = $this->getField('uriArchive'); + $filters['kind'] = $this->getField('uriKind'); if ($this->getField('uriBlog')) { $filters['blog'] = $this->getField('uriBlog'); diff --git a/bl-languages/en.json b/bl-languages/en.json index 4f4411ca..77065591 100644 --- a/bl-languages/en.json +++ b/bl-languages/en.json @@ -258,6 +258,19 @@ "type": "Type", "draft-content": "Draft content", "post": "Post", + "article": "Article", + "note": "Note", + "photo": "Photo", + "video": "Video", + "audio": "Audio", + "reply": "Reply", + "bookmark": "Bookmark", + "like": "Like", + "art": "Art", + "literature": "Literature", + "review": "Review", + "event": "Event", + "chicken": "Chicken", "default": "Default", "latest-content": "Latest content", "default-message": "Default message", diff --git a/bl-languages/fr_FR.json b/bl-languages/fr_FR.json index ca4eaa7c..bfa26afc 100644 --- a/bl-languages/fr_FR.json +++ b/bl-languages/fr_FR.json @@ -8,7 +8,7 @@ "Frédéric K. http:\/\/flatboard.free.fr", "Clickwork https:\/\/clickwork.ch", "Nicolas B.", - "" + "Lake \"Kazhnuz\" M. https\/\/kazhnuz.space" ] }, "dates": { @@ -263,6 +263,21 @@ "type": "Type", "draft-content": "Contenu brouillon", "post": "Article", + "article": "Article", + "note": "Note", + "photo": "Photo", + "video": "Vidéo", + "audio": "Audio", + "reply": "Réponse", + "bookmark": "Marque-Page", + "like": "Favori", + "art": "Art", + "literature": "Littérature", + "review": "Review", + "event": "Évenement", + "chicken": "Poulet", + "post-kind": "Type de contenu", + "post-kinds": "Types de contenu", "default": "Défaut", "latest-content": "Dernier contenu", "default-message": "Message par défaut", @@ -407,5 +422,7 @@ "insert-thumbnail": "Insérer une miniature", "insert-linked-thumbnail": "Insérer une miniature liée", "more-infos": "Infos supplémentaires", - "base-infos": "Infos de bases" + "base-infos": "Infos de bases", + "source-link": "Lien source", + "the-external-link-you-refer-to-in-the-post":"Le lien externe auquel vous vous referrez dans le contenu" } \ No newline at end of file diff --git a/bl-plugins/remote-content/plugin.php b/bl-plugins/remote-content/plugin.php index 4c05aa7d..30b0d102 100644 --- a/bl-plugins/remote-content/plugin.php +++ b/bl-plugins/remote-content/plugin.php @@ -156,6 +156,7 @@ EOF; reindexTags(); reindexAuthors(); reindexArchives(); + reindexKinds(); } return true;