]> skyeroc.xyz Git - flatmark/commitdiff
rename file
authorelektrischerwalfisch <mail@elektrischerwalfisch.de>
Sat, 12 Apr 2025 15:31:20 +0000 (17:31 +0200)
committerelektrischerwalfisch <mail@elektrischerwalfisch.de>
Sat, 12 Apr 2025 15:31:20 +0000 (17:31 +0200)
README.md
index.php
theme/functions.php [new file with mode: 0644]
theme/shortcodes.php [deleted file]

index f7de02ec4068bb9a0c38530b0ac5cca4705faccc..e23865f130a4a6664f52e196eb21bfef0b84748a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -109,13 +109,13 @@ flatMark supports simple shortcodes for structured content. You can see all shor
     This content has a colored background.
     {/background}
   
-These shortcodes are part of the theme and are all located in the file `/theme/shortcodes.php`.
+These shortcodes are part of the theme and are all located in the file `/theme/functions.php`.
 You can edit this file to change existing shortcodes or add even more.
 An example-page with all shortcodes is provided with the installation: `/pages-en/shortcode-examples.md`
 
 
 ## Customization
-All customizable parts of flatMark are located in the `theme/` folder. This includes the main stylesheet (`theme/css/style.css`), a JavaScript file for interactive behavior (`theme/js/presets.js`), and the `theme/shortcodes.php` file where custom shortcodes can be defined. You can freely modify these files to match your design and functionality needs. Additional assets like images, fonts, or scripts can also be placed in this folder to keep everything neatly organized in one place.
+All customizable parts of flatMark are located in the `theme/` folder. This includes the main stylesheet (`theme/css/style.css`), a JavaScript file for interactive behavior (`theme/js/presets.js`), and the `theme/functions.php` file where custom shortcodes can be defined. You can freely modify these files to match your design and functionality needs. Additional assets like images, fonts, or scripts can also be placed in this folder to keep everything neatly organized in one place.
 
 
 ## flatMark as CMS
index be614eafa1f5c5dd2fc2b15ef36dba821751900f..23cc7da6c00519974e082d26015077eda66c50c4 100644 (file)
--- a/index.php
+++ b/index.php
@@ -13,8 +13,8 @@
         ob_start();
 
     // Include shortcode functions (if file exists)
-        if (file_exists('theme/shortcodes.php')) {
-            require 'theme/shortcodes.php';
+        if (file_exists('theme/functions.php')) {
+            require 'theme/functions.php';
         }
     
     // Include Parsedown
@@ -72,7 +72,7 @@
             $footerContent = $Parsedown->text($footerContent);
         }
 
-    // Apply theme/shortcodes.php before converting to HTML (if function exists)
+    // Apply theme/functions.php before converting to HTML (if function exists)
         if (function_exists('processShortcodes')) {
             $markdown = processShortcodes($markdown);
         }
diff --git a/theme/functions.php b/theme/functions.php
new file mode 100644 (file)
index 0000000..eb79be0
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Shortcode definitions and handlers.
+ * 
+ * @package flatMark
+ * @subpackage Theme
+ */
+
+    function processShortcodes($markdown) {
+
+    // Initialize Parsedown
+        $Parsedown = new Parsedown();
+
+    // Shortcode: code 1/2
+        $codeBlocks = [];
+        $markdown = preg_replace_callback('/\{code\}(.*?)\{\/code\}/s', function ($matches) use (&$codeBlocks) {
+            // Generate a unique placeholder
+            $placeholder = '[[[CODEBLOCK_' . count($codeBlocks) . ']]]';
+            // Store the raw code block content
+            $codeBlocks[$placeholder] = '<pre><code>' . htmlspecialchars($matches[1]) . '</code></pre>';
+            return $placeholder;
+        }, $markdown);
+
+    // Shortcode: extras for header
+        $pattern = '/\{extras\}(.*?)\{\/extras\}/s';
+        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+            // Process Markdown inside
+            $extrasContent = $Parsedown->text($matches[1]);
+            return '<div class="extras">' . $extrasContent . '</div>';
+        }, $markdown);
+    
+    // Shortcode: year (current year)
+        $pattern = '/\{year\}/s';
+        $markdown = preg_replace_callback($pattern, function () {
+            return date("Y"); // Return current year
+        }, $markdown);
+
+    // Shortcode: columns with optional classes
+        $pattern = '/\{columns(.*?)\}(.*?)\{\/columns\}/s';
+        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+            // Capture the additional class (if any exists) directly after {columns}
+            $colsAttributes = trim($matches[1]);    // e.g., "50-50" from {background 50-50}
+            $colsContent = $matches[2]; // Capture the content inside {columns} ... {/columns}
+            
+            // Add prefix to the class
+            $colsPrefix = 'cols-'; // Define the prefix here
+            $colsClass = !empty($colsAttributes) ? $colsPrefix . $colsAttributes : ''; // Prefix added to class (e.g., cols-50-50)
+
+            // Split the columns by {columns-seperator}
+            $cols = preg_split('/\{columns-seperator\}/', $colsContent);
+
+            // Wrap each column in <div class="column">
+            $colHtml = '';
+            foreach ($cols as $col) {
+                $colHtml .= '<div class="column">' . $Parsedown->text(trim($col)) . '</div>';
+            }
+
+            // Wrap everything in a div and add class if available
+            return '<div class="columns ' . $colsClass . '">' . $colHtml . '</div>';
+        }, $markdown);
+
+    // Shortcode: background with optional class
+        $pattern = '/\{background(.*?)\}(.*?)\{\/background\}/s';
+        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+            // Capture the additional class (if any exists) directly after {background}
+            $bgAttributes = trim($matches[1]);  // e.g., "color-01" from {background color-01}
+            $bgContent = $matches[2];   // Capture the content inside {background} ... {/background}
+
+            // Add prefix to the class
+            $bgPrefix = 'bg-'; // Define the prefix here
+            $bgClass = !empty($bgAttributes) ? $bgPrefix . $bgAttributes : '';  // Prefix added to class (e.g., bg-color-01)
+
+            // Convert the inner Markdown content
+            $bgHtml = $Parsedown->text($bgContent);
+
+            // Wrap everything in a div and add class if available
+            return '<div class="background ' . $bgClass . '">' . $bgHtml . '</div>';
+        }, $markdown);
+
+    // Shortcode: img rounded
+        $pattern = '/\{img-rounded\}(.*?)\{\/img-rounded\}/s';
+        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+            // Process Markdown 
+            $imgRounded = $Parsedown->text($matches[1]);
+            return '<div class="img-rounded">' . $imgRounded . '</div>';
+        }, $markdown);
+
+    // Shortcode: output readme-file
+        $pattern = '/\{readme\}/s';
+        $markdown = preg_replace_callback($pattern, function () use ($Parsedown) {
+            $readmePath = __DIR__ . '/../README.md'; // path to root folder
+            if (file_exists($readmePath)) {
+                $readmeContent = file_get_contents($readmePath);
+                return '<div class="readme">' . $Parsedown->text($readmeContent) . '</div>';
+            } else {
+                return '<div class="readme"><em>README not found.</em></div>';
+            }
+        }, $markdown);
+
+    // Shortcode: code 2/2 - restore code blocks (so no shortcode inside was processed)
+        foreach ($codeBlocks as $placeholder => $codeBlock) {
+            $markdown = str_replace($placeholder, $codeBlock, $markdown);
+        }
+
+        return $markdown;
+
+    }
+
+?>
+
+
diff --git a/theme/shortcodes.php b/theme/shortcodes.php
deleted file mode 100644 (file)
index eb79be0..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-/**
- * Shortcode definitions and handlers.
- * 
- * @package flatMark
- * @subpackage Theme
- */
-
-    function processShortcodes($markdown) {
-
-    // Initialize Parsedown
-        $Parsedown = new Parsedown();
-
-    // Shortcode: code 1/2
-        $codeBlocks = [];
-        $markdown = preg_replace_callback('/\{code\}(.*?)\{\/code\}/s', function ($matches) use (&$codeBlocks) {
-            // Generate a unique placeholder
-            $placeholder = '[[[CODEBLOCK_' . count($codeBlocks) . ']]]';
-            // Store the raw code block content
-            $codeBlocks[$placeholder] = '<pre><code>' . htmlspecialchars($matches[1]) . '</code></pre>';
-            return $placeholder;
-        }, $markdown);
-
-    // Shortcode: extras for header
-        $pattern = '/\{extras\}(.*?)\{\/extras\}/s';
-        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
-            // Process Markdown inside
-            $extrasContent = $Parsedown->text($matches[1]);
-            return '<div class="extras">' . $extrasContent . '</div>';
-        }, $markdown);
-    
-    // Shortcode: year (current year)
-        $pattern = '/\{year\}/s';
-        $markdown = preg_replace_callback($pattern, function () {
-            return date("Y"); // Return current year
-        }, $markdown);
-
-    // Shortcode: columns with optional classes
-        $pattern = '/\{columns(.*?)\}(.*?)\{\/columns\}/s';
-        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
-            // Capture the additional class (if any exists) directly after {columns}
-            $colsAttributes = trim($matches[1]);    // e.g., "50-50" from {background 50-50}
-            $colsContent = $matches[2]; // Capture the content inside {columns} ... {/columns}
-            
-            // Add prefix to the class
-            $colsPrefix = 'cols-'; // Define the prefix here
-            $colsClass = !empty($colsAttributes) ? $colsPrefix . $colsAttributes : ''; // Prefix added to class (e.g., cols-50-50)
-
-            // Split the columns by {columns-seperator}
-            $cols = preg_split('/\{columns-seperator\}/', $colsContent);
-
-            // Wrap each column in <div class="column">
-            $colHtml = '';
-            foreach ($cols as $col) {
-                $colHtml .= '<div class="column">' . $Parsedown->text(trim($col)) . '</div>';
-            }
-
-            // Wrap everything in a div and add class if available
-            return '<div class="columns ' . $colsClass . '">' . $colHtml . '</div>';
-        }, $markdown);
-
-    // Shortcode: background with optional class
-        $pattern = '/\{background(.*?)\}(.*?)\{\/background\}/s';
-        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
-            // Capture the additional class (if any exists) directly after {background}
-            $bgAttributes = trim($matches[1]);  // e.g., "color-01" from {background color-01}
-            $bgContent = $matches[2];   // Capture the content inside {background} ... {/background}
-
-            // Add prefix to the class
-            $bgPrefix = 'bg-'; // Define the prefix here
-            $bgClass = !empty($bgAttributes) ? $bgPrefix . $bgAttributes : '';  // Prefix added to class (e.g., bg-color-01)
-
-            // Convert the inner Markdown content
-            $bgHtml = $Parsedown->text($bgContent);
-
-            // Wrap everything in a div and add class if available
-            return '<div class="background ' . $bgClass . '">' . $bgHtml . '</div>';
-        }, $markdown);
-
-    // Shortcode: img rounded
-        $pattern = '/\{img-rounded\}(.*?)\{\/img-rounded\}/s';
-        $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
-            // Process Markdown 
-            $imgRounded = $Parsedown->text($matches[1]);
-            return '<div class="img-rounded">' . $imgRounded . '</div>';
-        }, $markdown);
-
-    // Shortcode: output readme-file
-        $pattern = '/\{readme\}/s';
-        $markdown = preg_replace_callback($pattern, function () use ($Parsedown) {
-            $readmePath = __DIR__ . '/../README.md'; // path to root folder
-            if (file_exists($readmePath)) {
-                $readmeContent = file_get_contents($readmePath);
-                return '<div class="readme">' . $Parsedown->text($readmeContent) . '</div>';
-            } else {
-                return '<div class="readme"><em>README not found.</em></div>';
-            }
-        }, $markdown);
-
-    // Shortcode: code 2/2 - restore code blocks (so no shortcode inside was processed)
-        foreach ($codeBlocks as $placeholder => $codeBlock) {
-            $markdown = str_replace($placeholder, $codeBlock, $markdown);
-        }
-
-        return $markdown;
-
-    }
-
-?>
-
-