Add @csgen.redirectTo

This commit is contained in:
Jacob 2024-03-25 22:10:10 +01:00
parent b305cbd433
commit cea8423eda
2 changed files with 14 additions and 0 deletions

View file

@ -55,6 +55,7 @@ Markdown document and it can be at any point.
- `@csgen.addAuthor = "one author here";`
- `@csgen.markAsFeed = "false";`
- `@csgen.includePage = "/blog/my-awesome-blog-post";`
- `@csgen.redirectTo = "/blog/rss.xml";`
- `@csgen.span<STYLE, TEXT>("color: #0000ff;", "thisIsRedText");`
- `@csgen.span<STYLE, HTML>("color: #0000ff;", "<p>thisIsARedHTMLTag</p>");`
- `@csgen.inline<HTML>("<small>myHtmlHere</small>");`

View file

@ -19,6 +19,7 @@ class parsedMarkdown {
public $displaySource = true;
public $displayAuthors = false;
public $displayLicense = false;
public $redirectTo = '';
public $pages = array();
public $isFeed = false;
}
@ -227,6 +228,7 @@ function convertMarkdownToHTML($contents) {
'/.*@csgen\.displayLicense.*=.*&quot;(.*)(&quot;);/',
'/.*@csgen\.markAsFeed.*=.*&quot;(.*)(&quot;);/',
'/.*@csgen\.includePage.*=.*&quot;(.*)(&quot;);/',
'/.*@csgen\.redirectTo.*=.*&quot;(.*)(&quot;);/',
'/.*@csgen\.span.*&lt;STYLE.*,.*TEXT&gt;\(.*&quot;(.*)&quot;.*, &quot;(.*)&quot;\);/',
'/.*@csgen\.span.*&lt;STYLE.*,.*HTML&gt;\(.*&quot;(.*)&quot;.*, &quot;(.*)&quot;\);/',
'/.*@csgen\.inline.*&lt;HTML&gt;\(.*&quot;(.*)&quot;\);/',
@ -318,6 +320,11 @@ function convertMarkdownToHTML($contents) {
$ret->pages[] = $matches[1];
$out = str_replace($matches[0], '', $out);
break;
case '/.*@csgen\.redirectTo.*=.*&quot;(.*)(&quot;);/':
$ret->redirectTo = $matches[1];
$out = str_replace($matches[0], '', $out);
break;
case '/.*@csgen\.span.*&lt;STYLE.*,.*TEXT&gt;\(.*&quot;(.*)&quot;.*, &quot;(.*)&quot;\);/':
$cssCode = htmlspecialchars_decode($matches[1]);
@ -535,6 +542,12 @@ function printHeader($html, $printpage) {
$html .= "\t\t<div class=\"content\">\n";
if ($printpage == 1) {
if ($ret->redirectTo != '') {
$path = $ret->redirectTo;
header("Location: $path");
die();
}
$License = $ret->license;
$sourceFile = $line['file'];