trying to add subdirs for blogs
This commit is contained in:
parent
d1bd8100d1
commit
14a11067e0
|
@ -16,38 +16,76 @@ class Blog implements ControllerProviderInterface
|
|||
foreach($dirit as $file){
|
||||
if(!$file->isDot()){
|
||||
$doc = $parser->parse(file_get_contents($dir.'/'.$file));
|
||||
$blogposts[basename($file, ".md")] = $doc->getYAML();
|
||||
$blogposts[basename($file, ".md")]["content"] = $doc->getContent();
|
||||
$blogposts["blog-main"][basename($file, ".md")] = $doc->getYAML();
|
||||
$blogposts["blog-main"][basename($file, ".md")]["content"] = $doc->getContent();
|
||||
|
||||
if($file->isDir()){
|
||||
$subdirit = new \DirectoryIterator($dir .'/'. $file->getFilename());
|
||||
foreach($subdirit as $subdirfile){
|
||||
if(!$subdirfile->isDot()){
|
||||
$subdoc = $parser->parse(file_get_contents($subdir.'/'.$subdirfile));
|
||||
$blogposts[$subdirfile->getFilename()][basename($subdirfile, ".md")] = $subdoc->getYAML();
|
||||
$blogposts[$subdirfile->getFilename()][basename($subdirfile, ".md")]["content"] = $subdoc->getContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uasort($blogposts, function ($a, $b) {
|
||||
return $b['publish_date'] <=> $a['publish_date'];
|
||||
}); // sort blog posts by publish date
|
||||
foreach($blogposts as &$blogdir){
|
||||
uasort($blogdir, function ($a, $b) {
|
||||
return $b['publish_date'] <=> $a['publish_date'];
|
||||
}); // sort blog posts by publish date
|
||||
|
||||
foreach($blogposts as &$post){
|
||||
preg_match('~([A-z0-9 ,.]|<.*?>){1,300}(?=\s+)~', $post["content"], $matches, PREG_OFFSET_CAPTURE);
|
||||
$post["teaser"] = $matches[0][0] . "...";
|
||||
foreach($blogdir as &$post){
|
||||
preg_match('~([A-z0-9 ,.]|<.*?>){1,300}(?=\s+)~', $post["content"], $matches, PREG_OFFSET_CAPTURE);
|
||||
$post["teaser"] = $matches[0][0] . "...";
|
||||
} // trim content for teaser
|
||||
}
|
||||
|
||||
// ROUTES
|
||||
$blog->get('/', function() use($app, $blogposts) {
|
||||
|
||||
foreach($blogposts as $blogdir){
|
||||
foreach($blogdir as $post){
|
||||
if($post["published"]) $all_posts[] = $post;
|
||||
}
|
||||
}
|
||||
|
||||
// echo '<pre>$blogposts Dump ';
|
||||
// print_r($all_posts);
|
||||
// echo '</pre>';die();
|
||||
return $app['twig']->render('blog/blog.twig',
|
||||
['posts' => $blogposts]
|
||||
['posts' => $all_posts]
|
||||
);
|
||||
})->bind('blog-home');
|
||||
|
||||
$blog->get('/{slug}/', function($slug) use($app, $blogposts) {
|
||||
if(empty($blogposts[$slug])){
|
||||
if(empty($blogposts["blog-main"][$slug])){
|
||||
return $app['twig']->render('blog/blog.twig',
|
||||
['alert' => 'Blog post not found. You may have a typo in your URL.',
|
||||
'posts' => $blogposts]
|
||||
'posts' => $blogposts["blog-main"]]
|
||||
);
|
||||
}
|
||||
|
||||
return $app['twig']->render('blog/post.twig',
|
||||
['post' => $blogposts[$slug]]
|
||||
['post' => $blogposts["blog-main"][$slug]]
|
||||
);
|
||||
})->bind('blog-post');
|
||||
|
||||
$blog->get('/{folder}/{slug}/', function($folder, $slug) use($app, $blogposts) {
|
||||
if(empty($blogposts[$folder][$slug])){
|
||||
return $app['twig']->render('blog/blog.twig',
|
||||
['alert' => 'Blog post not found. You may have a typo in your URL.',
|
||||
'posts' => $blogposts["blog-main"]]
|
||||
);
|
||||
}
|
||||
|
||||
return $app['twig']->render('blog/post.twig',
|
||||
['post' => $blogposts[$folder][$slug]]
|
||||
);
|
||||
});
|
||||
|
||||
return $blog;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<h2 style="font-family: 'Cormorant Garamond', serif;">About Me</h2>
|
||||
<hr>
|
||||
<br>
|
||||
<img src="img/me.jpg" style="max-width: 300px;" alt="Me" class="img-fluid figure-img center-block">
|
||||
<img src="img/blog/me.jpg" style="max-width: 300px;" alt="Me" class="img-fluid figure-img center-block">
|
||||
<p>I study computer science at Northern Michigan University</p>
|
||||
{# <p>Traveling the world is one of my favorite hobbies</p> #}
|
||||
<p>I'm into full-stack web development, especially PHP stuff</p>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
title: RNC
|
||||
publish_date: 2016-07-20
|
||||
published: true
|
||||
image:
|
||||
src: /img/blog/me.jpg
|
||||
alt: me
|
||||
caption: me
|
||||
tags:
|
||||
- rnc
|
||||
- politics
|
||||
- national conventions
|
||||
---
|
||||
# Content goes here
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
title: Republican National Convention in Cleveland - Day Four
|
||||
publish_date: 2016-07-21
|
||||
published: false
|
||||
<!-- image:
|
||||
src:
|
||||
alt:
|
||||
caption: -->
|
||||
tags:
|
||||
- RNC
|
||||
- National Conventions
|
||||
- Politics
|
||||
---
|
||||
# Content goes here
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
title: Republican National Convention in Cleveland - Day One
|
||||
publish_date: 2016-07-18
|
||||
published: false
|
||||
published: true
|
||||
image:
|
||||
src: /img/blog/christie.jpg
|
||||
src: https://lh3.googleusercontent.com/LUKxqtT7OGct3NhN7t56O1rhwinYg8Wo_LIG4P9Vi7Y87r_APKWy3Wj7KWGEY4SMDzWCOffMR3inn5_EhY0e9LXFcwq7TQjnXcShT_VUI7kEqKAAYq9TXYeyKhMi5Fx0KlbNw-Dwdg3rkkHbwrQoaUSTrr7-0H1RU8OVpgxvjk41p96yjPKTt6llay6frkvLgO5OZMLl3W3hrE6QrMLGuJslzcp_RIyaSeh-iFX3VgTIzBVpmLGBaZMJemnszdx1ry8ipoHigmf9ynkxQq-AyLLACJ-3neC4HLy8cklfYs0wwsX62-dEsZoXn0unl07CGt1DD5uBMeMbWTYxrRpM-JEP7PXyTS0Lump-VPQY4iv2zqjGisWLnsEkpQfGFIkvRkVByCK_2gk_8MMCKGnApePoeNgHFDtmkjOauWlBsAWzFJexT07wHLKVEc5q9t2izHOHRUMiiCcIx-0SnZX-uZUoG5NAErrv3mPHJi5Pwy-R53hPx--JuJGbmflUnflaz1kMpzFlrVjMMKykCgSvRdRUbo6x8Te5h4SNCg2p-vBdihElyHwJ6b__e9Rt7M__TXgR3PAoQza-acvsUrdee-WtW1O5ufp0=w1187-h672-no
|
||||
alt: New Jersey Governor Chris Christie at the Michigan Delegation Breakfast
|
||||
caption: New Jersey Governor Chris Christie at the Michigan Delegation Breakfast
|
||||
tags:
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: Republican National Convention in Cleveland - Day Three
|
||||
publish_date: 2016-07-20
|
||||
published: false
|
||||
<!-- image:
|
||||
src:
|
||||
alt:
|
||||
caption: -->
|
||||
tags:
|
||||
- RNC
|
||||
- National Conventions
|
||||
- Cleveland
|
||||
- Politics
|
||||
---
|
||||
# Content goes here
|
|
@ -12,7 +12,7 @@ tags:
|
|||
---
|
||||
Our second day at the RNC began once again at the Michigan Delegation Breakfast Session.
|
||||
|
||||
Michigan Speaker of the House Kevin Cotter addressed the delegation with a report on the state of the state.
|
||||
Michigan Speaker of the House Kevin Cotter addressed the delegation with a report on the state of the state. His moderate, compromising stance was all but booed out by the delegation. To me, this highlighted the increasing radicalization of partisan politics. The one reasonable politician who understands that things get done through compromise is now criticized for not doing enough for the "party."
|
||||
|
||||
Despite not attending the RNC itself, Ohio Governor John Kasich
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ of those sections to manage the look and feel of the site. */
|
|||
padding-top: 50px;
|
||||
text-align: center;
|
||||
/*background: #fff;*/
|
||||
background-image: url("/img/blog/oredock2.jpg");
|
||||
background-image: url("https://lh3.googleusercontent.com/WCMJOUBJNjYPfyQNqoFBYscukZAwkzDTx92TrYk4hmmfZgVmhy__BynwiBqvBm_ZRQ8GVO182pl6qLom6x1nDFmia1c-59srG7sIU32YBRdrkHk6RsWNBLDl-OLTyfF0FhjPNSPxkfDhpHAp_pehwBOLl4AqfxUoxJbcV512xZrG-YrMigsYV4HNIw3s7g5_NfY_ssQ8nITFkfA2wyvGb1MRtTo8Z2eExqoe5ZXAfblOHaRImArQq-wtyG4LggBN3n5vE9ciLVgt-MqpdN-jiLA-dUdBqi4qvbJrq2QTZ-K7lZgo9kGr9XDUPAHjyvHO5anHFCz5-LDeiMrous2ehDCOeB7UXuPvsW9ZVGL2ZQpsdF8jojYUHPzYF32MFXSefDmeqsAe9rKWtWkpW4TVy3C42whhP9gCju3rFR8nvDQfz-InhsRn2eIeg108hoE8qO5Fu5an-5AlpTSZVUlOw26oaj5evt_hpDlvxP1i7dVvj1bSeJYCQ9NE3iUy0p8cKaIlwVP9b89k9omqEvEMnobvNdanxOUcPpNe8ZX6Mk_W06r93GZC7smxSMx2KC0wvlnHdi8FCTVZddyLO0w0Y_OmcqhM2NBC=w1187-h672-no");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
|
|
Loading…
Reference in New Issue