Ejemplo n.º 1
0
$p = new blog\Post();
$posts = $p->by($page->author, $page->limit, $page->offset);
$page->count = $p->query()->where('published', 'yes')->where('author', $page->author)->count();
$page->last = $page->offset + count($posts);
$page->more = $page->count > $page->last ? true : false;
$page->next = $page->num + 2;
$footer = Appconf::blog('Blog', 'post_footer');
$footer_stripped = strip_tags($footer);
$footer = $footer && !empty($footer_stripped) ? $tpl->run_includes($footer) : false;
if (Appconf::blog('Blog', 'post_format') === 'markdown') {
    require_once 'apps/blog/lib/markdown.php';
}
foreach ($posts as $post) {
    $post->url = '/blog/post/' . $post->id . '/' . URLify::filter($post->title);
    $post->tag_list = strlen($post->tags) > 0 ? explode(',', $post->tags) : array();
    $post->social_buttons = $appconf['Social Buttons'];
    if (Appconf::blog('Blog', 'post_format') === 'html') {
        $post->body = $tpl->run_includes($post->body);
    } else {
        $post->body = $tpl->run_includes(Markdown($post->body));
    }
    if ($preview_chars) {
        $post->body = blog_filter_truncate($post->body, $preview_chars) . ' <a href="' . $post->url . '">' . __('Read more') . '</a>';
    } else {
        $post->footer = $footer;
    }
    echo $tpl->render('blog/post', $post);
}
$page->title = __('Posts by %s', $tpl->sanitize($page->author));
$page->add_script(sprintf('<link rel="alternate" type="application/rss+xml" href="http://%s/blog/rss" />', $_SERVER['HTTP_HOST']));
echo $tpl->render('blog/by', $page);
Ejemplo n.º 2
0
}

if (! is_array ($posts) || count ($posts) === 0) {
	echo '<p>' . __ ('No posts yet... :(') . '</p>';
	if (User::require_admin ()) {
		echo '<p class="hide-in-preview"><a href="/blog/add">' . __ ('Add Blog Post') . '</a></p>';
	}
} else {
	if (User::require_admin ()) {
		echo '<p class="hide-in-preview"><a href="/blog/add">' . __ ('Add Blog Post') . '</a></p>';
	}

	foreach ($posts as $_post) {
		$post = $_post->orig();
		$post->url = '/blog/post/' . $post->id . '/';
		$post->fullurl = $post->url . URLify::filter ($post->title);
		$post->tag_list = (strlen ($post->tags) > 0) ? explode (',', $post->tags) : array ();
		$post->social_buttons = Appconf::blog ('Social Buttons');
		if (Appconf::blog ('Blog', 'post_format') === 'html') {
			$post->body = $tpl->run_includes ($post->body);
		} else {
			$post->body = $tpl->run_includes (Markdown ($post->body));
		}
		if ($preview_chars) {
			$post->body = blog_filter_truncate ($post->body, $preview_chars)
				. ' <a href="' . $post->fullurl . '">' . __ ('Read more') . '</a>';
		}
		echo $tpl->render ('blog/post', $post);
	}
}
Ejemplo n.º 3
0
$res = $cache->get('blog_rss');
if (!$res) {
    $p = new blog\Post();
    $page->posts = $p->latest(10, 0);
    $page->title = $appconf['Blog']['title'];
    $page->date = gmdate('Y-m-d\\TH:i:s');
    if (Appconf::blog('Blog', 'post_format') === 'markdown') {
        require_once 'apps/blog/lib/markdown.php';
    }
    $preview_chars = (int) Appconf::blog('Blog', 'preview_chars') ? (int) Appconf::blog('Blog', 'preview_chars') : false;
    if ($preview_chars) {
        require_once 'apps/blog/lib/Filters.php';
    }
    foreach ($page->posts as $k => $post) {
        $page->posts[$k]->url = '/blog/post/' . $post->id . '/' . URLify::filter($post->title);
        if (Appconf::blog('Blog', 'post_format') === 'html') {
            $page->posts[$k]->body = $tpl->run_includes($page->posts[$k]->body);
        } else {
            $page->posts[$k]->body = $tpl->run_includes(Markdown($page->posts[$k]->body));
        }
        if ($preview_chars) {
            $page->posts[$k]->body = blog_filter_truncate($page->posts[$k]->body, $preview_chars);
        }
    }
    $res = $tpl->render('blog/rss', $page);
    $cache->set('blog_rss', $res, 1800);
    // half an hour
}
$page->layout = FALSE;
header('Content-Type: text/xml');
echo $res;
Ejemplo n.º 4
0
        echo $this->run('blog/disqus/comments', $post);
        break;
    case 'facebook':
        echo $this->run('social/facebook/comments', $post);
        break;
    default:
        if (Appconf::blog('Blog', 'comments') != false) {
            echo $this->run(Appconf::blog('Blog', 'comments'), array('identifier' => $post->url));
        }
        break;
}
// add rss discovery
$page->add_script(sprintf('<link rel="alternate" type="application/rss+xml" href="http://%s/blog/rss" />', $_SERVER['HTTP_HOST']));
// add opengraph/twitter card meta tags
$url = ($this->is_https() ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $post->fullurl;
$desc = blog_filter_truncate(strip_tags($post->body), 300);
$page->add_meta('og:type', 'article', 'property');
$page->add_meta('og:site_name', conf('General', 'site_name'), 'property');
$page->add_meta('og:title', $post->title, 'property');
$page->add_meta('og:description', $desc, 'property');
$page->add_meta('og:url', $url, 'property');
if ($post->thumbnail !== '') {
    $page->add_meta('og:image', ($this->is_https() ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $post->thumbnail, 'property');
}
$page->add_meta('twitter:card', 'summary_large_image');
$twitter_id = Appconf::user('Twitter', 'twitter_id');
if (is_string($twitter_id) && $twitter_id !== '') {
    $page->add_meta('twitter:site', '@' . $twitter_id);
}
$page->add_meta('twitter:title', $post->title);
$page->add_meta('twitter:description', $desc);