1Jeremy Curry - The guy who made linknotes
Author: Jeremy Curry
Author URI: http://jeremycurry.com
Add Linknotes to your posts. Simply Go
:"Jeremy Curry(The guy who made linknotes)":http://jeremycurry.com
and then a superscript will show up wherever you put that code, and at the bottom of your post, this will follow:
1Jeremy Curry - The guy who made linknotes
*CHANGES*
v0.4 - Aug 9 2005 13:52 EST
* Changed the format in the "CHANGES" section of the file, so I can just copy and paste to and from my blog, and textile will do the rest!
* Changed and added some code bits. Nothing to really notice
* Changed $lnCfg['seperate'] to $lnCfg['item_begin'] and $lnCfg['item_end']
* Added javascript to make sure the superscript link is executed within the same window (Because Bloglines messes up) This Totally messes with textile use of the underscore
v0.3a - Aug 8 2005 14:20 EST
* Added quicktag selection support. The selected text will be set as your Title. Tested in Firefox and IE.
v0.3 - Aug 8 2005 13:00 EST
* Added 2 buttons to quicktags. Add Linknote [linknote], and Add Linknote with Description [linknote+desc]
v0.2 - Aug 8 2005
* In superscript anchor tag, replaced the HREF attribute with actual link URI. Used JavaScript to re-write href to go to linknotes. Used to compensate when RSS agregators remove attributes
* Added Title and description of Linknote to the Title attribute in the superscript Anchor.
* Added a hyphen (-) to seperate the post number, and the number of the linknote in the ID's used to jump to and from the Linknotes
* Wrapped Linknotes into a tag with the CSS class alt
*/
$lnCfg['begin'] = '
Linknotes:';
$lnCfg['end'] = '
';
$lnCfg['item_begin'] = '
';
$lnCfg['item_end'] = '';
/*
This works good for using unordered lists, but isn't nice on some RSS aggregators
$lnCfg['begin'] = '
';
$lnCfg['item_begin'] = '';
$lnCfg['item_end'] = '';
*/
// Toggle quicktag buttons
$lnCfg['ln_button'] = true;
$lnCfg['ln_desc_button'] = false;
$lnCfg = (object) $lnCfg;
class linknotes
{
var $hlgn;
var $vlgn;
var $clas;
var $lnge;
var $styl;
var $cspn;
var $rspn;
var $a;
var $s;
var $c;
var $pnct;
function linknotes()
{
$this->hlgn = "(?:\<(?!>)|(?|\<\>|\=|[()]+)";
$this->vlgn = "[\-^~]";
$this->clas = "(?:\([^)]+\))";
$this->lnge = "(?:\[[^]]+\])";
$this->styl = "(?:\{[^}]+\})";
$this->cspn = "(?:\\\\\d+)";
$this->rspn = "(?:\/\d+)";
$this->a = "(?:{$this->hlgn}?{$this->vlgn}?|{$this->vlgn}?{$this->hlgn}?)";
$this->s = "(?:{$this->cspn}?{$this->rspn}?|{$this->rspn}?{$this->cspn}?)";
$this->c = "(?:{$this->clas}?{$this->styl}?{$this->lnge}?|{$this->styl}?{$this->lnge}?{$this->clas}?|{$this->lnge}?{$this->styl}?{$this->clas}?)";
$this->pnct = '[\!"#\$%&\'()\*\+,\-\./:;<=>\?@\[\\\]\^_`{\|}\~]';
}
function linkify($text)
{
$text = preg_replace_callback('/
:([\s[{(]|[[:punct:]])? # $pre
" # start
(' . $this->c . ') # $atts
([^"]+) # $text
\s?
(?:\(([^)]+)\)(?="))? # $title
":
(\S+\b) # $url
(\/)? # $slash
([^\w\/;]*) # $post
(?=\s|$)
/Ux', array(&$this, "linkd"), $text);
if ($this->are_links) {
$linknotes = $this->begin;
for ($i=1; $i <= $this->count; $i++) {
$linknotes .= $this->item_begin.''.$i.' '.$this->links[$i].$this->item_end;
}
$linknotes .= $this->end;
$text = $text.$linknotes;
}
return $text;
}
function linkd($m)
{
$this->are_links = true;
list(, $pre, $atts, $title, $text, $url, $slash, $post) = $m;
if ($text) $text = ' - ' . $text;
$this->count++;
$this->links[$this->count] = $pre . '' . $title . '' . $text . $post;
return "id.'-'.$this->count."';\" id=\"noted-$this->id-$this->count\" title=\"$title$text\">[$this->count]";
}
function shelve($val)
{
$this->shelf[] = $val;
return ' <' . count($this->shelf) . '>';
}
}
function linknotes( $string ) {
global $lnCfg,$id;
$ln = new linknotes;
$ln->begin = $lnCfg->begin;
$ln->end = $lnCfg->end;
$ln->seperate = $lnCfg->seperate;
$ln->id = $id;
$ln->item_begin= $lnCfg->item_begin;
$ln->item_end= $lnCfg->item_end;
return $ln->linkify($string); //$string
}
function linknote_add_button() {
global $lnCfg;
if(strpos($_SERVER['REQUEST_URI'], 'post.php'))
{
?>
if(toolbar)
{
var theButton = document.createElement('input');
theButton.type = 'button';
theButton.value = '';
theButton.onclick = ;
theButton.className = 'ed_button';
theButton.title = "";
theButton.id = "";
toolbar.appendChild(theButton);
}