Днес намерих един супер полезен плъгин, който оцветява код в публикациите в WordPress – Code Snippet. Той е базиран на GeSHi, който е най-мощния highlighting engine, който съм ползвал. Плъгина поддържа много голям набор от езици – actionscript-french, actionscript, ada, apache, applescript, asm, asp, bash, caddcl, cadlisp, c_mac, c, cpp, csharp, css-gen, css, delphi, diff, div, dos, d, eiffel, freebasic, gml, html4strict, ini, inno, java, javascript, lisp, lua, matlab, mpasm, nsis, objc,oobas, oracle8, pascal, perl, php-brief, php, python, qbasic, sdlbasic, smarty, sql, vbnet, vb, vhdl, visualfoxpro и xml.
Ето и по един пример как работи той:
#!/usr/bin/perl
#ex71.plx
use warnings;
use strict;
print "Content-type: text/html\n\n";
print "";
print "";
foreach (keys %ENV){
print "$_ => $ENV{$_}
";
}
class SiteController extends CController
{
/**
* Declares class-based actions.
*/
public function actions()
{
return array(
// captcha action renders the CAPTCHA image
// this is used by the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xEBF4FB,
),
);
}
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index');
}
/**
* Displays the contact page
*/
public function actionContact()
{
$contact=new ContactForm;
if(isset($_POST['ContactForm']))
{
$contact->attributes=$_POST['ContactForm'];
if($contact->validate())
{
$headers="From: {$contact->email}\r\nReply-To: {$contact->email}";
mail(Yii::app()->params['adminEmail'],$contact->subject,$contact->body,$headers);
Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact',array('contact'=>$contact));
}
...
...
?>