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.5 - Aug 11 2004 01:32 EST
* Added notes, item, and description templates for more customization
* Linknotes show up in an ordered list by default
* Added footnote functionality, just remove the title and url - :"(This is a footnote)":
* Removed a bunch of excess code
* Fixed a few javascript issues with buttons
* Thanks for Chris J. Davis for some ideas www.chrisjdavis.org
v0.4a - Aug 9 2005 15:11 EST
* Added javascript to superscript links in footnote section, to allow easier maneuverability in Bloglines (and other aggregators that allow extra attributes, but open links in new window)
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['notes_code'] = '
';
$lnCfg['item_code'] = '%title% %desc% ↩';
// This is only shows up if there is a description
$lnCfg['desc_code'] = ' - %desc_text%';
// Toggle quicktag buttons
$lnCfg['ln_button'] = true;
$lnCfg['ln_desc_button'] = false;
$lnCfg['ln_footnote_button'] = true;
/* You can stop Editing Here */
$lnCfg = (object) $lnCfg;
class linknotes
{
function linkify($text) {
$text = preg_replace_callback('/
:" # start
([^"]+)? # $desc
\s?
(?:\(([^)]+)\)(?="))? # $title
":
(\S+\b)? # $url
(\/)? # $slash
([^\w\/;]*) # $post
(?=\s|$)
/Ux', array(&$this, "linkd"), $text);
if ($this->are_links) {
for ($i=1; $i <= $this->count; $i++) {
$links .= $this->items[$i];
}
$linknotes = str_replace('%items%', $links, $this->notes_code);
$text = $text.$linknotes;
}
return $text;
}
function linkd($m) {
list(, $title, $text, $url, $slash, $post) = $m;
$this->count++;
$this->are_links = true;
$itm_replace = array('%noted-id%', '%url%','%title%','%desc%', '%desc_text%', '%return%');
$desc = $text;
if ($text && $url) $desc = str_replace('%desc_text%', $text, $this->desc_code);
$itm = array( "linknote-$this->id-$this->count", $url, $title, $desc, $text, "#noted-$this->id-$this->count");
$this->items[$this->count] = str_replace($itm_replace, $itm, $this->item_code);
$at_title = strip_tags($title.$desc);
return "id.'-'.$this->count."';\" id=\"noted-$this->id-$this->count\" title=\"$at_title\">[$this->count]";
}
function shelve($val) {
$this->shelf[] = $val;
return ' <' . count($this->shelf) . '>';
}
}
function linknotes( $string ) {
global $lnCfg,$id;
$ln = new linknotes;
$ln->id = $id;
$ln->notes_code = $lnCfg->notes_code;
$ln->item_code = $lnCfg->item_code;
$ln->desc_code = $lnCfg->desc_code;
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);
}