diff --git a/system/config.ini b/system/config.ini index acefdcf..fe1fc0c 100644 --- a/system/config.ini +++ b/system/config.ini @@ -29,6 +29,7 @@ posts.perpage = "5" tag.perpage = "10" archive.perpage = "10" search.perpage = "10" +profile.perpage = "30" rss.count = "30" json.count = "10" diff --git a/system/htmly.php b/system/htmly.php index eb5b9ca..d3e2381 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -157,7 +157,7 @@ get('/:year/:month/:name', function($year, $month, $name){ )); }); -// The static page +// The search page get('/search/:keyword', function($keyword){ $page = from($_GET, 'page'); @@ -211,24 +211,37 @@ get('/:spage', function($spage){ }); // 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(); } - - render('post',array( - 'title' => $post->title .' - ' . config('blog.title'), - 'canonical' => $post->url, - 'description' => $description = get_description($post->body), - 'bodyclass' => 'inpage', - 'breadcrumb' => 'Home » ' . $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' => 'Home » Profile page for ' . $bio->title, + 'pagination' => has_pagination($total, $perpage, $page) )); - }); // The JSON API diff --git a/system/includes/functions.php b/system/includes/functions.php index 79ce4a5..478194d 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -395,8 +395,68 @@ function find_spage($spage){ 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('', $content); + $post->title = str_replace('

','',$arr[0]); + $post->body = $arr[1]; + + $tmp[] = $post; + } + + } + } + + return $tmp; +} + +// Return author bio +function get_bio($names, $author){ $tmp = array(); @@ -438,7 +498,7 @@ function get_author($names, $author){ } // Find static page -function find_author($author){ +function bio($author){ $names = get_author_names(); @@ -446,7 +506,7 @@ function find_author($author){ if( strpos($v, $author) !== false && strpos($v, 'author.md') !== false){ // Use the get_spage method to return // a properly parsed object - $arr = get_author($names, $author); + $arr = get_bio($names, $author); if (isset($arr[0])) { return $arr[0]; } diff --git a/themes/default/css/style.css b/themes/default/css/style.css index a5799c2..9101192 100644 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css @@ -137,7 +137,7 @@ h1.title-post a:hover, h2.title-index a:hover { 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; padding: 30px 0 10px 0; } @@ -146,7 +146,7 @@ h1.title-post a:hover, h2.title-index a:hover { 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; } @@ -494,6 +494,24 @@ aside .copyright p{ 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 -----------------------------*/ diff --git a/themes/default/main.html.php b/themes/default/main.html.php index adde055..aed5180 100644 --- a/themes/default/main.html.php +++ b/themes/default/main.html.php @@ -16,7 +16,7 @@

title ?>

-
- Posted in tag) ?> by - Komentar
+
- Posted in tag) ?> by - Comments
body)?> diff --git a/themes/default/profile.html.php b/themes/default/profile.html.php new file mode 100644 index 0000000..fd6b2db --- /dev/null +++ b/themes/default/profile.html.php @@ -0,0 +1,36 @@ + +
+

+
+
+

Posts by this author

+ + +
+ + + + + + +
+ \ No newline at end of file