Пример #1
0
 // Get the post author Twitter ID.
 $post_author_twitter = str_replace(array("\n", '- '), '', $fcontents[2]);
 // Get the published date.
 $published_iso_date = str_replace('-', '', $fcontents[3]);
 // Generate the published date.
 $published_date = strftime($date_format, strtotime($published_iso_date));
 // Get the post category.
 $post_category = str_replace(array("\n", '-'), '', $fcontents[4]);
 // Get the post status.
 $post_status = str_replace(array("\n", '- '), '', $fcontents[5]);
 // Get the post category link.
 $post_category_link = $blog_url . 'category/' . urlencode(trim(strtolower($post_category)));
 // Get the post link.
 $post_link = $blog_url . str_replace(array($settings->get('file_ext'), $settings->posts_dir), '', $filename);
 // Get the post image url.
 $postHelper = new PostHelper();
 $post_image = $postHelper->get_post_image_url($filename) ?: $postHelper->get_twitter_profile_img($post_author_twitter);
 // Get the post content
 $file_array = array_slice(file($filename), 7);
 $post_content = \Michelf\Markdown::defaultTransform(trim(implode("", $file_array)));
 // free memory
 unset($file_array);
 // Get the site title.
 $page_title = trim(str_replace('# ', '', $fcontents[0]));
 // Generate the page description and author meta.
 $get_page_meta[] = '<meta name="description" content="' . $post_intro . '">';
 $get_page_meta[] = '<meta name="author" content="' . $post_author . '">';
 // Generate the Twitter card.
 $get_page_meta[] = '<meta name="twitter:card" content="summary">';
 $get_page_meta[] = '<meta name="twitter:site" content="' . $blog_twitter . '">';
 $get_page_meta[] = '<meta name="twitter:title" content="' . $page_title . '">';
Пример #2
0
function get_twitter_profile_img($username)
{
    $post = new PostHelper();
    return $post->get_twitter_profile_img($username);
}
Пример #3
0
  * The Home Page (All Posts)
  * /*-----------------------------------------------------------------------------------
  */
 if ($filename == NULL) {
     $page = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 1 ? $_GET['page'] : 1;
     $offset = $page == 1 ? 0 : ($page - 1) * $posts_per_page;
     // Index page cache file name, will be used if index_cache = "on"
     $cachefile = $settings->config("cache_dir") . ($category ? $category : "index") . $page . '.html';
     // If index cache file exists, serve it directly wihout getting all posts
     if (file_exists($cachefile) && $index_cache == 'true') {
         // Get the cached post.
         include $cachefile;
         exit;
         // If there is a file for the selected permalink, display and cache the post.
     }
     $postHelper = new PostHelper();
     if ($category) {
         $all_posts = $postHelper->get_posts_for_category($category);
     } else {
         $all_posts = $postHelper->get_all_posts();
     }
     $posts_per_page = $settings->get('posts_per_page') != "" ? $settings->get('posts_per_page') : 0;
     if ($posts_per_page > 0) {
         $pagination = $settings->get('pagination_on_off') != "off" ? get_pagination($page, round(count($all_posts) / $posts_per_page)) : "";
         define('PAGINATION', $pagination);
     }
     $posts = $settings->get('pagination_on_off') != "off" ? array_slice($all_posts, $offset, $posts_per_page > 0 ? $posts_per_page : null) : $all_posts;
     if ($posts) {
         ob_start();
         $content = '';
         foreach ($posts as $post) {