-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
114 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ | |
"site_top_about_line1": "Simple PHP-based Static Site generator", | ||
"site_top_about_line2": "Supports Markdown and deployed to GitHub Pages by GitHub Actions", | ||
"hostname": "ssg-test.atasasmaz.com", | ||
"local_hostname": "ssg.local", | ||
"local_hostname": "ssg-local.atasasmaz.com", | ||
"email": "[email protected]", | ||
"full_title": "Ata's SSG - a Simple PHP-based SSG for GitHub Pages", | ||
"appended_title": " - Ata's SSG'", | ||
"appended_title": " - Ata's SSG", | ||
"site_desc": "Welcome to Ata's SSG. This is a simple PHP-based Static Site Generator that supports Markdown and deployed to GitHub Pages by GitHub Actions.", | ||
"linkedin_url": "https://www.linkedin.com/in/atasasmaz", | ||
"twitter_url": "https://twitter.com/AtaSasmaz", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
<?php | ||
|
||
require_once "system/bootstrap.php"; | ||
global $og; | ||
|
||
$og->title = $tpl->meta->title ?? ""; | ||
$og->desc = $tpl->meta->desc ?? ""; | ||
$selectedTab = "home"; | ||
// @var $page_meta PageMeta | ||
global $page_meta; | ||
$page_meta->selectedTab = "home"; | ||
|
||
require_once 'layout/header.php'; | ||
|
||
$posts = get_posts(); | ||
$posts = get_all_posts(); | ||
|
||
echo "<div id='posts'>"; | ||
foreach ($posts as $post) { | ||
echo "<article class='post'><a href='/p/$post->slug'>"; | ||
echo "<div class='left'>"; | ||
echo "<h2>$post->title</h2>"; | ||
echo "<div class='desc'>$post->desc</div>"; | ||
echo "</div>"; | ||
echo '<div class="right"><img src="/assets/images/right-arrow.svg" /></div>'; | ||
echo "</a></article>"; | ||
?> | ||
<article class='post'> | ||
<a href='/p/<?= $post->slug ?>'> | ||
<div class='left'> | ||
<h2><?= $post->title ?></h2> | ||
<div class='desc'><?= $post->desc ?></div> | ||
</div> | ||
<div class="right"><img src="/assets/images/right-arrow.svg" alt="Right arrow"/></div> | ||
</a> | ||
</article> | ||
<?php | ||
} | ||
echo "</div>"; | ||
|
||
require_once 'layout/footer.php'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
<?php | ||
|
||
include "system/bootstrap.php"; | ||
global $og; | ||
global $page_meta; | ||
|
||
$md_path = "pages/$_GET[page].md"; | ||
|
||
/** | ||
* Page parameter can only be alphanumeric and hyphen and .md file must exist. | ||
* If not, return 404. | ||
*/ | ||
if (!preg_match('/^[a-zA-Z0-9\-]+$/', $_GET['page']) || !file_exists($md_path)) { | ||
header('HTTP/1.0 404 Not Found'); | ||
include '404.php'; | ||
exit; | ||
} | ||
|
||
$tpl = get_md($md_path); | ||
$tpl = get_markdown($md_path); | ||
|
||
$og->title = $tpl->meta->title ?? null; | ||
$og->desc = $tpl->meta->desc ?? null; | ||
$selectedTab = $tpl->meta->selectedTab ?? "index"; | ||
$page_meta->title = $tpl->meta->title ?? null; | ||
$page_meta->desc = $tpl->meta->desc ?? null; | ||
$page_meta->selectedTab = $tpl->meta->selectedTab ?? "index"; | ||
include 'layout/header.php'; | ||
|
||
echo "<div class='box singlePage'>"; | ||
echo $tpl->content; | ||
echo "</div>"; | ||
include 'layout/footer.php'; | ||
|
||
?> | ||
|
||
<div class='box singlePage'> | ||
<?= $tpl->content ?> | ||
</div> | ||
|
||
<?php | ||
include 'layout/footer.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,41 @@ | ||
<?php | ||
|
||
require_once "system/bootstrap.php"; | ||
global $og; | ||
global $page_meta; | ||
|
||
/** | ||
* Slug querystring can only be alphanumeric and hyphen | ||
* If not, return 404. | ||
*/ | ||
if (!preg_match('/^[a-zA-Z0-9\-]+$/', $_GET['slug'])) { | ||
echo "<!--POST PATTERN IS WRONG, 404, SLUG: $_GET[slug]-->"; | ||
not_found(); | ||
exit_with_not_found(); | ||
} | ||
|
||
$post = current(array_filter(get_posts(), function ($post) { | ||
// Iterate through all posts and find the one with the same slug | ||
// Not the most performant but once deployed they will all be static websites. | ||
$post = current(array_filter(get_all_posts(), function ($post) { | ||
return $post->slug == $_GET['slug']; | ||
})); | ||
|
||
if (!$post) { | ||
echo "<!--POST NOT FOUND, 404, SLUG: $_GET[slug]-->"; | ||
not_found(); | ||
exit_with_not_found(); | ||
} | ||
|
||
$tpl = get_md($post->filename); | ||
$tpl = get_markdown($post->filename); | ||
|
||
$og->title = $tpl->meta->title ?? null; | ||
$og->type = "article"; | ||
$og->desc = $tpl->meta->desc ?? null; | ||
$page_meta->title = $tpl->meta->title ?? null; | ||
$page_meta->type = "article"; | ||
$page_meta->desc = $tpl->meta->desc ?? null; | ||
|
||
require_once 'layout/header.php'; | ||
|
||
echo "<div class='box singlePost'>"; | ||
echo $tpl->content; | ||
echo "</div>"; | ||
|
||
?> | ||
|
||
<?php require_once 'layout/footer.php'; ?> | ||
<div class='box singlePost'> | ||
<?=$tpl->content?> | ||
</div> | ||
|
||
<?php | ||
require_once 'layout/footer.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
class Post { | ||
public string $title; | ||
public string $desc; | ||
public string $slug; | ||
public string $filename; | ||
} | ||
|
||
class PageMeta | ||
{ | ||
public ?string $title = null; | ||
public string $type = "website"; | ||
public string $desc = ""; | ||
public string $selectedTab = ""; | ||
} | ||
|
||
class ConvertedMarkdown { | ||
public string $content; | ||
public object $meta; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters