commentSpice:

* Change s9y config for fetching pingback content from plugin
* Added example tpl for smartifying the twitter link on base of 2k11.
This commit is contained in:
Grischa Brockhaus 2012-01-26 13:50:43 +01:00
parent abc15182ce
commit 2c3543596c
5 changed files with 97 additions and 14 deletions

View file

@ -30,6 +30,13 @@
@define('PLUGIN_EVENT_COMMENTSPICE_SMARTIFY_RSS', 'Artikelbewerbung smartifizieren');
@define('PLUGIN_EVENT_COMMENTSPICE_SMARTIFY_RSS_DESC', 'Wenn angeschaltet, wird CommentSpice keinen Code für die Artikelbewerbung darstellen sondern wird benötigte Informationen in den Smarty Hash stecken. Damit das funktioniert, muss die comments.tpl angepasst werden. Verfügbare Variablen sind $comment.spice_article_name (Name des Artikel, sollte auf Vorhandensein gecheckt werden). $comment.spice_article_url (Artikel URL), $comment.spice_article_nofollow (Nofollow Einstellung für Artikelbewerbung), $comment.spice_article_prefix (Prefix in der Sprache des Besuchers).');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK', 'Inhalt von Pingback Artikeln abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_DESC', 'Wenn ein anderes Blog ein Pingback auf einen Artikel dieses Blogs schickt, ist nur die URL des fremden Artikels bekannt. Serendipity kann jedoch den Inhalt des fremden Artikels abholen und darstellen, so wie es von Trackbacks bekannt ist. Aus Performance Gründen tut Serendipity dies jedoch nicht per default. Hiermit kann eine Einstellung in die serendipity_config_local.inc.php geschrieben werden, die Serendipity dazu veranlasst, den Inhalt abzuholen. Wenn der Wert hier unverändert bleibt, dann wurde die Einstellung bereits manuell vorgenommen und überschreibt die Einstellung des Plugins. In dem Fall muss der manuelle Eintrag aus der serendipity_config_local.inc.php wieder entfernt werden, wenn die Einstellung mit diesem Plugin verändert werden soll.');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_LEAVE_ON', 'Behalte: Inhalt abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_LEAVE_OFF', 'Behalte: Inhalt nicht abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_FETCH', 'Setze auf: Inhalt abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_DONTFETCH', 'Setze auf: Inhalt nicht abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_PATH', 'Plugin Pfad');
@define('PLUGIN_EVENT_COMMENTSPICE_PATH_DESC', 'In normalen Installationen ist der Default die korrekte Einstellung.');

View file

@ -30,6 +30,13 @@
@define('PLUGIN_EVENT_COMMENTSPICE_SMARTIFY_RSS', 'Artikelbewerbung smartifizieren');
@define('PLUGIN_EVENT_COMMENTSPICE_SMARTIFY_RSS_DESC', 'Wenn angeschaltet, wird CommentSpice keinen Code für die Artikelbewerbung darstellen sondern wird benötigte Informationen in den Smarty Hash stecken. Damit das funktioniert, muss die comments.tpl angepasst werden. Verfügbare Variablen sind $comment.spice_article_name (Name des Artikel, sollte auf Vorhandensein gecheckt werden). $comment.spice_article_url (Artikel URL), $comment.spice_article_nofollow (Nofollow Einstellung für Artikelbewerbung), $comment.spice_article_prefix (Prefix in der Sprache des Besuchers).');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK', 'Inhalt von Pingback Artikeln abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_DESC', 'Wenn ein anderes Blog ein Pingback auf einen Artikel dieses Blogs schickt, ist nur die URL des fremden Artikels bekannt. Serendipity kann jedoch den Inhalt des fremden Artikels abholen und darstellen, so wie es von Trackbacks bekannt ist. Aus Performance Gründen tut Serendipity dies jedoch nicht per default. Hiermit kann eine Einstellung in die serendipity_config_local.inc.php geschrieben werden, die Serendipity dazu veranlasst, den Inhalt abzuholen. Wenn der Wert hier unverändert bleibt, dann wurde die Einstellung bereits manuell vorgenommen und überschreibt die Einstellung des Plugins. In dem Fall muss der manuelle Eintrag aus der serendipity_config_local.inc.php wieder entfernt werden, wenn die Einstellung mit diesem Plugin verändert werden soll.');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_LEAVE_ON', 'Behalte: Inhalt abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_LEAVE_OFF', 'Behalte: Inhalt nicht abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_FETCH', 'Setze auf: Inhalt abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_DONTFETCH', 'Setze auf: Inhalt nicht abholen');
@define('PLUGIN_EVENT_COMMENTSPICE_PATH', 'Plugin Pfad');
@define('PLUGIN_EVENT_COMMENTSPICE_PATH_DESC', 'In normalen Installationen ist der Default die korrekte Einstellung.');

View file

@ -1,4 +1,5 @@
<?php
@define('PLUGIN_EVENT_COMMENTSPICE_TITLE', 'Comment Spice');
@define('PLUGIN_EVENT_COMMENTSPICE_DESC', 'Spice up your comments area with goodies like commenters twitter or last posted article link.');
@ -30,6 +31,13 @@
@define('PLUGIN_EVENT_COMMENTSPICE_SMARTIFY_RSS', 'Smartify article output');
@define('PLUGIN_EVENT_COMMENTSPICE_SMARTIFY_RSS_DESC', 'If switched on, CommentSpice won\'t emit code for the announced post but will put all needed infos to the smarty hash. For this to work you have to add new smarty content to your comments.tpl. Available variables are $comment.spice_article_name (articles title, check if empty). $comment.spice_article_url (articles url), $comment.spice_article_nofollow (nofollow configured for article links), $comment.spice_article_prefix (prefix in language of visitor).');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK', 'Fetch content of pingback articles');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_DESC', 'If another blog sends a pingback to one of your articles, only the URL of the foreign article is known. Serendipity is able to fetch the content of the foreign article and displays it like it is known from trackbacks. But for performance reasons Serendipity does not by default. With this option you can let the plugin save a config into your serendipity_config_local.inc.php ordering Serendipity to fetch the content. If you can not change the value, you have done that manualy already overwriting the setting here. In this case you should remove your manual change from serendipity_config_local.inc.php in order to be able to change this setting with this plugin.');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_LEAVE_ON', 'Leave as: fetch content');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_LEAVE_OFF', 'Leave as: don\'t fetch content');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_FETCH', 'Change to: fetch content');
@define('PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_DONTFETCH', 'Change to: don\'t fetch content');
@define('PLUGIN_EVENT_COMMENTSPICE_PATH', 'Plugins path');
@define('PLUGIN_EVENT_COMMENTSPICE_PATH_DESC', 'In normal installations the default is correct.');

View file

@ -50,7 +50,7 @@ class serendipity_event_commentspice extends serendipity_event
'followme_widget', 'followme_widget_counter','followme_widget_dark','smartifytwitter',
'title_announcerss', 'announcerss', 'announcerssmax','announcersscachemin','announcerss_nofollow','smartifyannouncerss',
'title_general');
if (!$serendipity['pingbackFetchPage'] && function_exists('fetchPingbackData')) {
if (function_exists('fetchPingbackData') && $this->isLocalConfigWritable()) {
$config[] = 'fetchPingback';
}
$config[] = 'plugin_path';
@ -150,10 +150,16 @@ class serendipity_event_commentspice extends serendipity_event
$propbag->add('default', '<h3>' . PLUGIN_EVENT_COMMENTSPICE_CONFIG_GENERAL .'</h3>');
break;
case 'fetchPingback':
$propbag->add('type', 'boolean');
$fetchPingbackValues = array (
'none' => $serendipity['pingbackFetchPage']?PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_LEAVE_ON:PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_LEAVE_OFF,
);
if ($serendipity['pingbackFetchPage']) $fetchPingbackValues['false'] = PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_DONTFETCH;
else $fetchPingbackValues['true'] = PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_FETCH;
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK);
$propbag->add('description', PLUGIN_EVENT_COMMENTSPICE_FETCH_PINGBACK_DESC);
$propbag->add('default', $serendipity['pingbackFetchPage']);
$propbag->add('select_values', $fetchPingbackValues);
$propbag->add('default', 'none');
return true;
break;
default:
@ -162,7 +168,7 @@ class serendipity_event_commentspice extends serendipity_event
return true;
}
function event_hook($event, &$bag, &$eventData, &$addData) {
function event_hook($event, &$bag, &$eventData, $addData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
@ -190,7 +196,6 @@ class serendipity_event_commentspice extends serendipity_event
break;
case 'frontend_saveComment':
$result = $this->checkComment($eventData, $addData);
$this->log("after checkComment: " . print_r($eventData, true) . "\n" . print_r($addData,TRUE));
return $result;
break;
case 'frontend_saveComment_finish' :
@ -228,6 +233,8 @@ class serendipity_event_commentspice extends serendipity_event
DbSpice::install($this);
}
function cleanup() {
global $serendipity;
DbSpice::install($this);
$announcerssmax = $this->get_config('announcerssmax',3);
if (!is_numeric($announcerssmax)) {
@ -322,15 +329,6 @@ class serendipity_event_commentspice extends serendipity_event
}
}
}
elseif ("PINGBACK" == $addData['type']) {
if (!$serendipity['pingbackFetchPage']) { // Only fetch if S9Y does not already.
if (serendipity_db_bool($this->get_config('fetchPingback', false))) {
$serendipity['pingbackFetchPage'] = true;
$serendipity['pingbackFetchPageMaxLength'] = 200;
fetchPingbackData($addData); // method declared in functions_trackbacks.php
}
}
}
return true;
}
function readRss() {
@ -618,6 +616,41 @@ class serendipity_event_commentspice extends serendipity_event
}
return md5($installation_secret . ':' . $what);
}
function saveFetchPingbackDataConfig($fetchPingback) {
global $serendipity;
if (is_writeable($serendipity['serendipityPath'] . 'serendipity_config_local.inc.php')) {
$privateVariables = array('pingbackFetchPage' => $fetchPingback);
serendipity_updateLocalConfig($serendipity['dbName'], $serendipity['dbPrefix'], $serendipity['dbHost'], $serendipity['dbUser'], $serendipity['dbPass'], $serendipity['dbType'], $serendipity['dbPersistent'], $privateVariables);
}
else {
echo "serendipity_config_local.inc.php is not writeable for plugins";
}
}
function isLocalConfigWritable() {
global $serendipity;
$file = $serendipity['serendipityPath'] . 'serendipity_config_local.inc.php';
return !file_exists($file) || is_writeable($file);
}
function set_config($name, $value, $implodekey = '^') {
global $serendipity;
if ($name == 'fetchPingback') {
if ('none' != $value) {
// This will be updated later, so save it in memory, too:
$serendipity['pingbackFetchPage'] = serendipity_db_bool($value);
// now make the config persistant.
$this->saveFetchPingbackDataConfig($serendipity['pingbackFetchPage']);
}
}
else {
parent::set_config($name, $value, $implodekey);
}
}
function log($message){
if (!PLUGIN_EVENT_COMMENTSPICE_DEBUG) return;
$fp = fopen(dirname(__FILE__) . '/spice.log','a');

View file

@ -0,0 +1,28 @@
{foreach from=$comments item=comment name="comments"}
<article id="c{$comment.id}" class="serendipity_comment{if $entry.author == $comment.author} serendipity_comment_author_self{/if} {cycle values="odd,even"} {if $comment.depth > 8}commentlevel-9{else}commentlevel-{$comment.depth}{/if}">
{if $comment.avatar}{$comment.avatar}{/if}
<h4>{if $comment.url}<a href="{$comment.url}" rel="nofollow">{/if}{$comment.author|@default:$CONST.ANONYMOUS}{if $comment.url}</a>{/if} {if $comment.spice_twitter_name}<a href="{$comment.spice_twitter_url}" target="_blank"{if $comment.spice_twitter_nofollow} rel="nofollow"{/if}>{$comment.spice_twitter_icon_html}</a>{/if} {$CONST.ON} <time datetime="{$comment.timestamp|@serendipity_smarty_html5time}" pubdate>{$comment.timestamp|@formatTime:$template_option.date_format}</time>:</h4>
{if $comment.spice_twitter_followme}{$comment.spice_twitter_followme}{/if}
<div class="serendipity_commentBody clearfix content">
{if $comment.body == 'COMMENT_DELETED'}
{$CONST.COMMENT_IS_DELETED}
{else}
{$comment.body}
{/if}
</div>
<footer>
<time>{$comment.timestamp|@formatTime:'%H:%M'}</time>
| <a class="comment_source_trace" href="#c{$comment.id}" title="{$CONST.TWOK11_PLINK_TITLE}" rel="nofollow">{$CONST.TWOK11_PLINK_TEXT}</a>
{if $entry.is_entry_owner}
| <a class="comment_source_ownerlink" href="{$comment.link_delete}" title="{$CONST.COMMENT_DELETE_CONFIRM|@sprintf:$comment.id:$comment.author}" rel="nofollow">{$CONST.DELETE}</a>
{/if}
{if $entry.allow_comments AND $comment.body != 'COMMENT_DELETED'}
| <a class="comment_reply" href="#serendipity_CommentForm" id="serendipity_reply_{$comment.id}"{if $comment_onchange != ''} onclick="{$comment_onchange}"{/if} rel="nofollow">{$CONST.REPLY}</a>
<div id="serendipity_replyform_{$comment.id}"></div>
{/if}
</footer>
</article>
{foreachelse}
<p class="nocomments">{$CONST.NO_COMMENTS}</p>
{/foreach}