diff --git a/system/admin/views/edit-content.html.php b/system/admin/views/edit-content.html.php
index 080f500..22a2bc5 100644
--- a/system/admin/views/edit-content.html.php
+++ b/system/admin/views/edit-content.html.php
@@ -48,11 +48,11 @@ $timestamp = $time->format("Y-m-d H:i:s");
// The post date
$postdate = strtotime($timestamp);
// The post URL
-if (config('permalink.type') == 'post') {
- $delete = site_url() . 'post/' . $oldmd . '/delete?destination=' . $destination;
+if (permalink_type() == 'default') {
+ $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination;
} else {
// The post URL
- $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination;
+ $delete = site_url() . permalink_type() . '/' . $oldmd . '/delete?destination=' . $destination;
}
$tags = tag_cloud(true);
diff --git a/system/htmly.php b/system/htmly.php
index b75d782..e6d5065 100644
--- a/system/htmly.php
+++ b/system/htmly.php
@@ -3486,7 +3486,7 @@ get('/feed/opml', function () {
});
// Show blog post without year-month
-get('/post/:name', function ($name) {
+get('/'. permalink_type() .'/:name', function ($name) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
@@ -3494,7 +3494,7 @@ get('/post/:name', function ($name) {
header("Location: $url");
}
- if (config('permalink.type') != 'post') {
+ if (permalink_type() == 'default') {
$post = find_post(null, null, $name);
if (is_null($post)) {
not_found();
@@ -3607,7 +3607,7 @@ get('/post/:name', function ($name) {
});
// Edit blog post
-get('/post/:name/edit', function ($name) {
+get('/'. permalink_type() .'/:name/edit', function ($name) {
if (login()) {
@@ -3677,7 +3677,7 @@ get('/post/:name/edit', function ($name) {
});
// Get edited data from blog post
-post('/post/:name/edit', function () {
+post('/'. permalink_type() .'/:name/edit', function () {
if(!login()) {
$login = site_url() . 'login';
header("location: $login");
@@ -3825,7 +3825,7 @@ post('/post/:name/edit', function () {
});
// Delete blog post
-get('/post/:name/delete', function ($name) {
+get('/'. permalink_type() .'/:name/delete', function ($name) {
if (login()) {
@@ -3886,7 +3886,7 @@ get('/post/:name/delete', function ($name) {
});
// Get deleted data from blog post
-post('/post/:name/delete', function () {
+post('/'. permalink_type() .'/:name/delete', function () {
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
if ($proper && login()) {
@@ -4682,8 +4682,8 @@ get('/:year/:month/:name', function ($year, $month, $name) {
header("Location: $url");
}
- if (config('permalink.type') == 'post') {
- $redir = site_url() . 'post/' . $name;
+ if (permalink_type() !== 'default') {
+ $redir = site_url() . permalink_type() . '/' . $name;
header("location: $redir", TRUE, 301);
}
diff --git a/system/includes/functions.php b/system/includes/functions.php
index df36dc4..714775e 100644
--- a/system/includes/functions.php
+++ b/system/includes/functions.php
@@ -399,7 +399,6 @@ function get_posts($posts, $page = 1, $perpage = 0)
$auto = config('toc.automatic');
$counter = config('views.counter');
$caption = config('fig.captions');
- $permalink = config('permalink.type');
if ($counter == 'true') {
$viewsFile = "content/data/views.json";
@@ -469,10 +468,10 @@ function get_posts($posts, $page = 1, $perpage = 0)
// The archive per day
$post->archive = site_url() . 'archive/' . date('Y-m', $post->date);
- if ($permalink == 'post') {
- $post->url = site_url() . 'post/' . str_replace('.md', '', $arr[2]);
- } else {
+ if (permalink_type() == 'default') {
$post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]);
+ } else {
+ $post->url = site_url() . permalink_type() . '/' . str_replace('.md', '', $arr[2]);
}
$post->slug = str_replace('.md', '', $arr[2]);
@@ -3085,10 +3084,10 @@ function sitemap_post_path($posts, $page = 1, $perpage = 0)
$post->archiveyear = site_url() . 'archive/' . date('Y', $post->date);
// The post URL
- if (config('permalink.type') == 'post') {
- $post->url = site_url() . 'post/' . str_replace('.md', '', $arr[2]);
- } else {
+ if (permalink_type() == 'default') {
$post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]);
+ } else {
+ $post->url = site_url() . permalink_type() . '/' . str_replace('.md', '', $arr[2]);
}
$tmp[] = $post;
@@ -3492,6 +3491,16 @@ function is_index()
}
}
+// Return post permalink type
+function permalink_type()
+{
+ $permalink = config('permalink.type');
+ if (!is_null($permalink) && !empty($permalink)) {
+ return strtolower($permalink);
+ }
+ return 'default';
+}
+
// Return blog path index
function blog_path()
{