diff --git a/article.php b/article.php index 0f21a6cde3d9a88ec541b42178914490277dff8b..09cb97bf676ef97e098249b981948db310df929a 100644 --- a/article.php +++ b/article.php @@ -1,15 +1,15 @@ <?php theme_include('header'); ?> <section class="content wrap" id="article-<?php echo article_id(); ?>"> - <h1><?php echo article_title(); ?></h1> + <h1><?php echo article_img(article_slug());?><?php echo article_title(); ?></h1> <article> - <?php echo article_markdown(); ?> + <?php echo article_html(); ?> </article> <section class="footnote"> <!-- Unfortunately, CSS means everything's got to be inline. --> <p>Article numéro: <?php echo article_number(article_id()); ?>, <?php echo count_words(article_markdown()); ?> mots <?php if(comments_open()): ?>, - <?php echo total_comments();?> <?php echo pluralise(total_comments(), "commentaire", "s") ?> pour le moment.<?php endif; ?> <?php echo article_custom_field('attribution'); ?></p> + <?php echo total_comments();?> <?php echo pluralise(total_comments(), "commentaire", "s") ?>.<?php endif; ?> <?php echo article_custom_field('attribution'); ?></p> </section> </section> diff --git a/css/reset.css b/css/reset.css index e7bac6e5e706c495bcf488bce3980aa65232912d..c7db331e846def15ac62ff9c1825cdeb2a258bbb 100644 --- a/css/reset.css +++ b/css/reset.css @@ -159,12 +159,12 @@ img.picture{ .odd{ float:left; - margin: 0% 2% 0% 0%; + margin: 0% 10% 0% 0%; } .even{ float:right; - margin: 0% 0% 0% 2%; + margin: 0% 0% 0% 10%; } diff --git a/functions.php b/functions.php index e7333f459a1d0bd709f9f0ce73ae14828c1b3df9..f25562a38963cc300643622fd072b6b276f2b90b 100644 --- a/functions.php +++ b/functions.php @@ -11,7 +11,7 @@ function numeral($number, $hideIfOne = false) { return ''; } - $ext = ((abs($number) % 100 < 21 and abs($number) % 100 > 4) ? 'th' : (($test < 4) ? ($test < 3) ? ($test < 2) ? ($test < 1) ? 'th' : 'st' : 'nd' : 'rd' : 'th')); + $ext = $number == 1 ? 'er' : 'ème'; return $number . $ext; } @@ -97,3 +97,17 @@ function social_list($properties) { function total_articles() { return Post::where(Base::table('posts.status'), '=', 'published')->count(); } + +function article_img_url($slug){ + return '/img/blog/'.$slug.'.png'; +} + +function article_has_img($slug){ + return file_exists('.'.article_img_url($slug)); +} + +function article_img($slug){ + if(article_has_img($slug)){ + echo '<img class="picture odd" src="'.article_img_url($slug).'" />'; + } +} diff --git a/posts.php b/posts.php index f1fbfe3293edb7cfe72e7a7d5f344e018ee3a479..b216c03ec5f0670492b319813aefc6f6db25bc8a 100644 --- a/posts.php +++ b/posts.php @@ -6,28 +6,14 @@ <ul class="items"> <?php posts(); ?> <li> - <article class="wrap"> - <h1> - <a href="<?php echo article_url(); ?>" title="<?php echo article_title(); ?>"><?php echo article_title(); ?></a> - </h1> - - <div class="content"> - <?php echo article_html(); ?> - </div> - - <footer> - Posté <time datetime="<?php echo date(DATE_W3C, article_time()); ?>"><?php echo relative_time(article_time()); ?></time> par <?php echo article_author('real_name'); ?>. - </footer> - </article> + <h1> Dernier article </h1> + <?php include("single_article.php"); ?> </li> + <h1> Articles précédents </h1> <?php $i = 0; while(posts()): ?> - <?php $bg = sprintf('background: hsl(215, 28%%, %d%%);', round(((++$i / posts_per_page()) * 20) + 20)); ?> + <?php $bg = sprintf('background: hsl(132, 22%%, %d%%);', round(((++$i / posts_per_page()) * 20) + 20)); ?> <li style="<?php echo $bg; ?>"> - <article class="wrap"> - <h2> - <a href="<?php echo article_url(); ?>" title="<?php echo article_title(); ?>"><?php echo article_title(); ?></a> - </h2> - </article> + <?php include("single_article.php"); ?> </li> <?php endwhile; ?> </ul> diff --git a/single_article.php b/single_article.php new file mode 100644 index 0000000000000000000000000000000000000000..9fc06500a3f198660df6f2c796435455f089a335 --- /dev/null +++ b/single_article.php @@ -0,0 +1,16 @@ +<article class="wrap"> + <h2> + <a href="<?php echo article_url(); ?>" title="<?php echo article_title(); ?>"><?php echo article_img(article_slug());?><?php echo article_title(); ?></a> + </h2> + + <div class="contents"> + <?php echo article_description(); ?> + </div> + + <footer> + <p>Article numéro: <?php echo article_number(article_id()); ?>, <?php echo count_words(article_markdown()); ?> mots <?php if(comments_open()): ?>, + <?php echo total_comments();?> <?php echo pluralise(total_comments(), "commentaire", "s") ?>.<?php endif; ?> <?php echo article_custom_field('attribution'); ?></p> + Posté <time datetime="<?php echo date(DATE_W3C, article_time()); ?>"><?php echo relative_time(article_time()); ?></time> par <?php echo article_author('real_name'); ?>. + </footer> + </article> +