~tim-alwaysreformed/reformedchurcheslocator/rcl-backbone-test_for_directory_type

« back to all changes in this revision

Viewing changes to vendor/couchapp/lib/linkup.js

  • Committer: Tim Black
  • Date: 2012-04-11 05:59:38 UTC
  • Revision ID: tim@alwaysreformed.com-20120411055938-ol24g07q32msyg2f
Re-include default couchapp login div, remove unnecessary templates, JavaScript files, and functions, install Evently

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// this code makes http://example.com into a link, 
 
2
// and also handles @name and #hashtag
 
3
 
 
4
// todo add [[wiki_links]]
 
5
 
 
6
var mustache = require("vendor/couchapp/lib/mustache");
 
7
exports.encode = function(body, person_prefix, tag_prefix) {
 
8
  body = mustache.escape(body);
 
9
  person_prefix = person_prefix || "http://twitter.com/";
 
10
  tag_prefix = tag_prefix || "http://delicious.com/tag/";
 
11
  return body.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi,function(a) {
 
12
    return '<a target="_blank" href="'+a+'">'+a+'</a>';
 
13
  }).replace(/\@([\w\-]+)/g,function(user,name) {
 
14
    return '<a href="'+person_prefix+encodeURIComponent(name)+'">'+user+'</a>';
 
15
  }).replace(/\#([\w\-\.]+)/g,function(word,tag) {
 
16
    return '<a href="'+tag_prefix+encodeURIComponent(tag)+'">'+word+'</a>';
 
17
  });
 
18
};