Browse Source

Improving the profile page

Improving the profile page by adding posts list.
pull/4/merge
Danang Probo Sayekti 12 years ago
parent
commit
d84bfb48fd
6 changed files with 149 additions and 21 deletions
  1. +1
    -0
      system/config.ini
  2. +27
    -14
      system/htmly.php
  3. +64
    -4
      system/includes/functions.php
  4. +20
    -2
      themes/default/css/style.css
  5. +1
    -1
      themes/default/main.html.php
  6. +36
    -0
      themes/default/profile.html.php

+ 1
- 0
system/config.ini View File

@ -29,6 +29,7 @@ posts.perpage = "5"
tag.perpage = "10" tag.perpage = "10"
archive.perpage = "10" archive.perpage = "10"
search.perpage = "10" search.perpage = "10"
profile.perpage = "30"
rss.count = "30" rss.count = "30"
json.count = "10" json.count = "10"


+ 27
- 14
system/htmly.php View File

@ -157,7 +157,7 @@ get('/:year/:month/:name', function($year, $month, $name){
)); ));
}); });
// The static page
// The search page
get('/search/:keyword', function($keyword){ get('/search/:keyword', function($keyword){
$page = from($_GET, 'page'); $page = from($_GET, 'page');
@ -211,24 +211,37 @@ get('/:spage', function($spage){
}); });
// The author page // The author page
get('/author/:author', function($author){
get('/author/:profile',function($profile){
$page = from($_GET, 'page');
$page = $page ? (int)$page : 1;
$perpage = config('profile.perpage');
$posts = get_profile($profile);
$bio = bio($profile);
$post = find_author($author);
$total = count($posts);
if(!$post){
// Extract a specific page with results
$posts = array_slice($posts, ($page-1) * $perpage, $perpage);
if(empty($posts) || $page < 1){
// a non-existing page
not_found(); not_found();
} }
render('post',array(
'title' => $post->title .' - ' . config('blog.title'),
'canonical' => $post->url,
'description' => $description = get_description($post->body),
'bodyclass' => 'inpage',
'breadcrumb' => '<a href="' . config('site.url') . '">Home</a> &#187; ' . $post->title,
'p' => $post,
'type' => 'profilepage',
render('profile',array(
'title' => 'Author - '. $bio->title .' - ' . config('blog.title'),
'page' => $page,
'posts' => $posts,
'bio' => $bio->body,
'name' => $bio->title,
'canonical' => config('site.url') . '/author/' . $profile,
'description' => 'Profile page and all posts by ' . $bio->title . ' on ' . config('blog.title') . '.',
'bodyclass' => 'inprofile',
'breadcrumb' => '<a href="' . config('site.url') . '">Home</a> &#187; Profile page for ' . $bio->title,
'pagination' => has_pagination($total, $perpage, $page)
)); ));
}); });
// The JSON API // The JSON API


+ 64
- 4
system/includes/functions.php View File

@ -395,8 +395,68 @@ function find_spage($spage){
return false; return false;
} }
// Return author page
function get_author($names, $author){
// Return profile page
function get_profile($profile){
$posts = get_post_names();
$tmp = array();
// Create a new instance of the markdown parser
$md = new MarkdownParser();
foreach($posts as $index => $v){
if( strpos($v, "$profile") !== false){
$post = new stdClass;
// Extract the date
$arr = explode('_', $v);
// Replaced string
$replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/';
// Author string
$str = explode('/', $replaced);
$author = $str[count($str)-3];
// Make sure the tag request available
if ($profile === $author) {
// The post author + author url
$post->author = $author;
$post->authorurl = site_url() . 'author/' . $author;
// The post date
$post->date = strtotime(str_replace($replaced,'',$arr[0]));
// The post URL
$post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[2]);
// The post tag
$post->tag = str_replace($replaced,'',$arr[1]);
// The post tag URL
$post->tagurl = site_url(). 'tag/' . $arr[1];
// Get the contents and convert it to HTML
$content = $md->transformMarkdown(file_get_contents($v));
// Extract the title and body
$arr = explode('</h1>', $content);
$post->title = str_replace('<h1>','',$arr[0]);
$post->body = $arr[1];
$tmp[] = $post;
}
}
}
return $tmp;
}
// Return author bio
function get_bio($names, $author){
$tmp = array(); $tmp = array();
@ -438,7 +498,7 @@ function get_author($names, $author){
} }
// Find static page // Find static page
function find_author($author){
function bio($author){
$names = get_author_names(); $names = get_author_names();
@ -446,7 +506,7 @@ function find_author($author){
if( strpos($v, $author) !== false && strpos($v, 'author.md') !== false){ if( strpos($v, $author) !== false && strpos($v, 'author.md') !== false){
// Use the get_spage method to return // Use the get_spage method to return
// a properly parsed object // a properly parsed object
$arr = get_author($names, $author);
$arr = get_bio($names, $author);
if (isset($arr[0])) { if (isset($arr[0])) {
return $arr[0]; return $arr[0];
} }


+ 20
- 2
themes/default/css/style.css View File

@ -137,7 +137,7 @@ h1.title-post a:hover, h2.title-index a:hover {
text-decoration:none; text-decoration:none;
} }
.infront .post, .intag .post, .inarchive .post, .insearch .post{
.infront .post, .intag .post, .inarchive .post, .insearch .post, .inprofile .post{
border-bottom: 1px solid #dfdfdf; border-bottom: 1px solid #dfdfdf;
padding: 30px 0 10px 0; padding: 30px 0 10px 0;
} }
@ -146,7 +146,7 @@ h1.title-post a:hover, h2.title-index a:hover {
padding-top:50px; padding-top:50px;
} }
.intag .post.first, .inarchive .post.first, .insearch .post.first {
.intag .post.first, .inarchive .post.first, .insearch .post.first , .inprofile .post.first{
padding-top: 0px; padding-top: 0px;
} }
@ -494,6 +494,24 @@ aside .copyright p{
border: 0; border: 0;
} }
/*----------------------------
Profile
-----------------------------*/
.profile {
font-size: 12px;
font-style:italic;
border-bottom: solid 1px #dfdfdf;
margin-bottom: 2em;
padding-bottom: 1em;
}
.post-list {
padding-bottom:1.2em;
border-bottom: solid 1px #dfdfdf;
font-size: 12px;
}
/*---------------------------- /*----------------------------
Media queries Media queries
-----------------------------*/ -----------------------------*/


+ 1
- 1
themes/default/main.html.php View File

@ -16,7 +16,7 @@
<div class="post <?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"> <div class="post <?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="main"> <div class="main">
<h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2> <h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2>
<div class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><a href="<?php echo $p->tagurl ?>"><?php echo ucfirst($p->tag) ?></a></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count() == true):?> - <span><a href="<?php echo $p->url?>#disqus_thread">Komentar</a></span><?php endif;?></div>
<div class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><a href="<?php echo $p->tagurl ?>"><?php echo ucfirst($p->tag) ?></a></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count() == true):?> - <span><a href="<?php echo $p->url?>#disqus_thread">Comments</a></span><?php endif;?></div>
<div itemprop="articleBody"> <div itemprop="articleBody">
<?php if (config('img.thumbnail') == 'true'):?> <?php if (config('img.thumbnail') == 'true'):?>
<?php echo get_thumbnail($p->body)?> <?php echo get_thumbnail($p->body)?>


+ 36
- 0
themes/default/profile.html.php View File

@ -0,0 +1,36 @@
<?php if (!empty($breadcrumb)):?><div class="breadcrumb"><?php echo $breadcrumb ?></div><?php endif;?>
<div class="profile">
<h1 class="title-post"><?php echo $name ?></h1>
<div class="bio"><?php echo $bio ?></div>
</div>
<h2 class="post-index">Posts by this author</h2>
<ul class="post-list">
<?php $i = 0; $len = count($posts);?>
<?php foreach($posts as $p):?>
<?php
if ($i == 0) {
$class = 'first';
}
elseif ($i == $len - 1) {
$class = 'last';
}
else {
$class = '';
}
$i++;
?>
<li>
<span><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></span> on <span><?php echo date('d F Y', $p->date)?></span> - Posted in <span><a href="<?php echo $p->tagurl ?>"><?php echo ucfirst($p->tag) ?></a></span>
</li>
<?php endforeach;?>
</ul>
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])):?>
<div class="pager">
<?php if (!empty($pagination['prev'])):?>
<span><a href="?page=<?php echo $page-1?>" class="pagination-arrow newer" rel="prev">Newer</a></span>
<?php endif;?>
<?php if (!empty($pagination['next'])):?>
<span><a href="?page=<?php echo $page+1?>" class="pagination-arrow older" rel="next">Older</a></span>
<?php endif;?>
</div>
<?php endif;?>

Loading…
Cancel
Save