From: Ben Sherratt Date: Sat, 4 Jul 2026 19:37:58 +0000 (+0100) Subject: Better paths for images and editor links X-Git-Url: https://git.bts.cx/cx.git/commitdiff_plain/68d07e0d4c200b6675d8068a1b10e29bcce1e681?ds=inline;hp=c31a7eee27fd40e7aa558ad15e33f65f9fb6aed2 Better paths for images and editor links --- diff --git a/cx/lib/images.php b/cx/lib/images.php index ea29f74..358a1ba 100644 --- a/cx/lib/images.php +++ b/cx/lib/images.php @@ -17,6 +17,11 @@ class Image { $this->alt_text = $dict['image_alt_text']; $this->url = $this->uid . '.' . $dict['image_type']; } + + public function get_permalink_path() { + $permalink = '/data/images/' . $this->url; + return $permalink; + } } function cx_images_add_image($site_id, $alt_text, $image_path, $image_original_filename) { diff --git a/cx/lib/markdown.php b/cx/lib/markdown.php index aab58d5..b79fb85 100644 --- a/cx/lib/markdown.php +++ b/cx/lib/markdown.php @@ -20,14 +20,12 @@ class ExtendedParsedown extends Parsedown { return; } - $permalink = '/data/images/' . $image->url; - return array( 'extent' => strlen($matches[0]) + 1, 'element' => array( 'name' => 'img', 'attributes' => array( - 'src' => cx_url_site($permalink), + 'src' => cx_url_site($image->get_permalink_path()), 'alt' => $image->alt_text, ), ), diff --git a/cx/lib/posts.php b/cx/lib/posts.php index 326d81c..4d122df 100644 --- a/cx/lib/posts.php +++ b/cx/lib/posts.php @@ -46,8 +46,11 @@ class Post { } public function get_permalink_path() { - $post_permalink = $this->is_page ? '/' . $this->slug : '/' . date('Y', $this->date) . '/' . date('m', $this->date) . '/' . $this->slug; - return $post_permalink; + $permalink = '/' . $this->slug; + if ($this->is_page == false) { + $permalink = '/' . date('Y', $this->date) . '/' . date('m', $this->date) . '/' . $this->slug; + } + return $permalink; } public function get_metadata() { diff --git a/cx/templates/admin/pages/main.php b/cx/templates/admin/pages/main.php index 14ea9c4..f9ab483 100644 --- a/cx/templates/admin/pages/main.php +++ b/cx/templates/admin/pages/main.php @@ -4,9 +4,9 @@ - - - + + +
title ?>EditDeletetitle ?>EditDelete
@@ -15,9 +15,9 @@ - - - + + +
title ?>EditDeletetitle ?>EditDelete
@@ -26,9 +26,9 @@ - - - + + +
url ?>EditDeleteurl ?>EditDelete
diff --git a/cx/templates/public/pages/base.php b/cx/templates/public/pages/base.php index 5caac0d..7629cae 100644 --- a/cx/templates/public/pages/base.php +++ b/cx/templates/public/pages/base.php @@ -52,7 +52,7 @@
  • Home
  • -
  • title ?>
  • +
  • title ?>
  • diff --git a/cx/templates/public/pages/list.php b/cx/templates/public/pages/list.php index 0f02a71..3069f72 100644 --- a/cx/templates/public/pages/list.php +++ b/cx/templates/public/pages/list.php @@ -17,7 +17,7 @@

    - Older Posts - 0): ?>Newer Posts + ← Older Posts + 0): ?>Newer Posts →