Browse Source

Add Facebook comments

Add Facebook comments as comment system options.
pull/31/merge
Danang Probo Sayekti 11 years ago
parent
commit
a6bfc5a7ce
14 changed files with 57 additions and 16 deletions
  1. +8
    -1
      config/config.ini.example
  2. +26
    -4
      system/includes/functions.php
  3. +2
    -2
      themes/clean/css/style.css
  4. +1
    -0
      themes/clean/layout.html.php
  5. +1
    -1
      themes/clean/main.html.php
  6. +4
    -1
      themes/clean/post.html.php
  7. +2
    -2
      themes/default/css/style.css
  8. +1
    -0
      themes/default/layout.html.php
  9. +1
    -1
      themes/default/main.html.php
  10. +4
    -1
      themes/default/post.html.php
  11. +1
    -1
      themes/logs/css/style.css
  12. +1
    -0
      themes/logs/layout.html.php
  13. +1
    -1
      themes/logs/main.html.php
  14. +4
    -1
      themes/logs/post.html.php

+ 8
- 1
config/config.ini.example View File

@ -19,7 +19,14 @@ blog.menu = ""
; Breadcrumb home text. Useful when installed on subfolder. ; Breadcrumb home text. Useful when installed on subfolder.
breadcrumb.home = "Home" breadcrumb.home = "Home"
; Disqus
; Comment system. Choose "facebook" or "disqus".
comment.system = "facebook"
;Facebook comments
fb.num = "5"
fb.color = "light"
; Disqus comments
disqus.shortname = "" disqus.shortname = ""
; Google+ publisher ; Google+ publisher


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

@ -820,6 +820,7 @@ function copyright(){
// Disqus on post. // Disqus on post.
function disqus($title=null, $url=null){ function disqus($title=null, $url=null){
$comment = config('comment.system');
$disqus = config('disqus.shortname'); $disqus = config('disqus.shortname');
$script = <<<EOF $script = <<<EOF
<script type="text/javascript"> <script type="text/javascript">
@ -833,13 +834,14 @@ function disqus($title=null, $url=null){
})(); })();
</script> </script>
EOF; EOF;
if (!empty($disqus)) {
if (!empty($disqus) && $comment == 'disqus') {
return $script; return $script;
} }
} }
// Disqus comment count on teaser // Disqus comment count on teaser
function disqus_count(){ function disqus_count(){
$comment = config('comment.system');
$disqus = config('disqus.shortname'); $disqus = config('disqus.shortname');
$script = <<<EOF $script = <<<EOF
<script type="text/javascript"> <script type="text/javascript">
@ -851,7 +853,7 @@ function disqus_count(){
})(); })();
</script> </script>
EOF; EOF;
if (!empty($disqus)) {
if (!empty($disqus) && $comment == 'disqus') {
return $script; return $script;
} }
} }
@ -899,11 +901,31 @@ function recent_comments(){
} }
</style> </style>
EOF; EOF;
if (!empty($disqus)) {
if (!empty($disqus) && $comment == 'disqus') {
return $script; return $script;
} }
} }
function facebook() {
$comment = config('comment.system');
$script = <<<EOF
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<style>.fb-comments, .fb_iframe_widget span, .fb-comments iframe {width: 100%!important;}</style>
EOF;
if($comment == 'facebook') {
return $script;
}
}
// Google Publisher (Google+ page). // Google Publisher (Google+ page).
function publisher(){ function publisher(){
$publisher = config('google.publisher'); $publisher = config('google.publisher');
@ -1396,7 +1418,7 @@ function head_contents($title, $description, $canonical) {
$output .= $title ."\n". $favicon ."\n". $charset ."\n". $generator ."\n". $xua ."\n". $viewport ."\n". $description ."\n". $sitemap ."\n". $canonical ."\n". $feed ."\n". $lightboxcss ."\n". $jquery ."\n". $lightbox ."\n" .$corejs ."\n"; $output .= $title ."\n". $favicon ."\n". $charset ."\n". $generator ."\n". $xua ."\n". $viewport ."\n". $description ."\n". $sitemap ."\n". $canonical ."\n". $feed ."\n". $lightboxcss ."\n". $jquery ."\n". $lightbox ."\n" .$corejs ."\n";
} }
else { else {
$output .= $title ."\n". $favicon ."\n". $charset ."\n". $generator ."\n". $xua ."\n". $viewport ."\n". $description ."\n". $sitemap ."\n". $canonical ."\n". $feed ."\n";
$output .= $title ."\n". $favicon ."\n". $charset ."\n". $generator ."\n". $xua ."\n". $viewport ."\n". $description ."\n". $sitemap ."\n". $canonical ."\n". $feed ."\n". $jquery ."\n";
} }
return $output; return $output;


+ 2
- 2
themes/clean/css/style.css View File

@ -270,8 +270,8 @@ pre code {
margin-top: 10px; margin-top: 10px;
} }
.border #disqus_thread {
padding-top: 1.2em;
.border .fb-comments, .border #disqus_thread {
padding-top: 1.2em;
} }
#disqus_thread { #disqus_thread {


+ 1
- 0
themes/clean/layout.html.php View File

@ -14,6 +14,7 @@
<meta content="<?php echo blog_title() ?>" itemprop="name"/> <meta content="<?php echo blog_title() ?>" itemprop="name"/>
<meta content="<?php echo blog_description() ?>" itemprop="description"/> <meta content="<?php echo blog_description() ?>" itemprop="description"/>
</div> </div>
<?php if(facebook()) { echo facebook();} ?>
<?php if(login()) { toolbar();} ?> <?php if(login()) { toolbar();} ?>
<aside> <aside>
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1> <h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>


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

@ -16,7 +16,7 @@
<div class="<?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"> <div class="<?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"><?php echo $p->tag ?></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 class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><?php echo $p->tag ?></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count()) {?> - <span><a href="<?php echo $p->url?>#disqus_thread">Comments</a></span><?php } else {?> - <a href="<?php echo $p->url ?>#comments"><span><fb:comments-count href=<?php echo $p->url ?>></fb:comments-count> Comments</span></a> <?php } ?></div>
<div class="teaser-body" itemprop="articleBody"> <div class="teaser-body" itemprop="articleBody">
<?php echo get_thumbnail($p->body)?> <?php echo get_thumbnail($p->body)?>
<?php echo get_teaser($p->body, $p->url)?> <?php echo get_teaser($p->body, $p->url)?>


+ 4
- 1
themes/clean/post.html.php View File

@ -25,7 +25,10 @@
</div> </div>
</div> </div>
<?php echo get_related($p->tag)?> <?php echo get_related($p->tag)?>
<div class="comments border">
<div id="comments" class="comments border">
<?php if (facebook()):?>
<div class="fb-comments" data-href="<?php echo $p->url ?>" data-numposts="<?php echo config('fb.num') ?>" data-colorscheme="<?php echo config('fb.color') ?>"></div>
<?php endif;?>
<?php if (disqus()):?> <?php if (disqus()):?>
<div id="disqus_thread"></div> <div id="disqus_thread"></div>
<?php endif;?> <?php endif;?>


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

@ -586,8 +586,8 @@ h1.title-post a:hover, h2.title-index a:hover {
float:left; float:left;
} }
.border #disqus_thread {
padding-top: 1.2em;
.border .fb-comments, .border #disqus_thread {
padding-top: 1.2em;
} }
#disqus_thread { #disqus_thread {


+ 1
- 0
themes/default/layout.html.php View File

@ -14,6 +14,7 @@
<meta content="<?php echo blog_title() ?>" itemprop="name"/> <meta content="<?php echo blog_title() ?>" itemprop="name"/>
<meta content="<?php echo blog_description() ?>" itemprop="description"/> <meta content="<?php echo blog_description() ?>" itemprop="description"/>
</div> </div>
<?php if(facebook()) { echo facebook();} ?>
<?php if(login()) { toolbar();} ?> <?php if(login()) { toolbar();} ?>
<div id="outer-wrapper"> <div id="outer-wrapper">
<div id="menu-wrapper"> <div id="menu-wrapper">


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

@ -16,7 +16,7 @@
<div class="<?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"> <div class="<?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"><?php echo $p->tag ?></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 class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><?php echo $p->tag ?></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count()) {?> - <span><a href="<?php echo $p->url?>#disqus_thread">Comments</a></span><?php } else {?> - <a href="<?php echo $p->url ?>#comments"><span><fb:comments-count href=<?php echo $p->url ?>></fb:comments-count> Comments</span></a> <?php } ?></div>
<div class="teaser-body" itemprop="articleBody"> <div class="teaser-body" itemprop="articleBody">
<?php echo get_thumbnail($p->body)?> <?php echo get_thumbnail($p->body)?>
<?php echo get_teaser($p->body, $p->url)?> <?php echo get_teaser($p->body, $p->url)?>


+ 4
- 1
themes/default/post.html.php View File

@ -25,7 +25,10 @@
</div> </div>
</div> </div>
<?php echo get_related($p->tag)?> <?php echo get_related($p->tag)?>
<div class="comments border">
<div id="comments" class="comments border">
<?php if (facebook()):?>
<div class="fb-comments" data-href="<?php echo $p->url ?>" data-numposts="<?php echo config('fb.num') ?>" data-colorscheme="<?php echo config('fb.color') ?>"></div>
<?php endif;?>
<?php if (disqus()):?> <?php if (disqus()):?>
<div id="disqus_thread"></div> <div id="disqus_thread"></div>
<?php endif;?> <?php endif;?>


+ 1
- 1
themes/logs/css/style.css View File

@ -540,7 +540,7 @@ ul li, ol li{
float:right; float:right;
} }
.border #disqus_thread {
.border .fb-comments, .border #disqus_thread {
padding-top: 1.2em; padding-top: 1.2em;
} }


+ 1
- 0
themes/logs/layout.html.php View File

@ -14,6 +14,7 @@
<meta content="<?php echo blog_title() ?>" itemprop="name"/> <meta content="<?php echo blog_title() ?>" itemprop="name"/>
<meta content="<?php echo blog_description() ?>" itemprop="description"/> <meta content="<?php echo blog_description() ?>" itemprop="description"/>
</div> </div>
<?php if(facebook()) { echo facebook();} ?>
<?php if(login()) { toolbar();} ?> <?php if(login()) { toolbar();} ?>
<div id="cover"> <div id="cover">
<div id="header-wrapper"> <div id="header-wrapper">


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

@ -16,7 +16,7 @@
<div class="<?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"> <div class="<?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"><?php echo $p->tag ?></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 class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><?php echo $p->tag ?></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count()) {?> - <span><a href="<?php echo $p->url?>#disqus_thread">Comments</a></span><?php } else {?> - <a href="<?php echo $p->url ?>#comments"><span><fb:comments-count href=<?php echo $p->url ?>></fb:comments-count> Comments</span></a> <?php } ?></div>
<div class="teaser-body" itemprop="articleBody"> <div class="teaser-body" itemprop="articleBody">
<?php echo get_thumbnail($p->body)?> <?php echo get_thumbnail($p->body)?>
<?php echo get_teaser($p->body, $p->url)?> <?php echo get_teaser($p->body, $p->url)?>


+ 4
- 1
themes/logs/post.html.php View File

@ -25,7 +25,10 @@
</div> </div>
</div> </div>
<?php echo get_related($p->tag)?> <?php echo get_related($p->tag)?>
<div class="comments border">
<div id="comments" class="comments border">
<?php if (facebook()):?>
<div class="fb-comments" data-href="<?php echo $p->url ?>" data-numposts="<?php echo config('fb.num') ?>" data-colorscheme="<?php echo config('fb.color') ?>"></div>
<?php endif;?>
<?php if (disqus()):?> <?php if (disqus()):?>
<div id="disqus_thread"></div> <div id="disqus_thread"></div>
<?php endif;?> <?php endif;?>


Loading…
Cancel
Save