Elide_Tags
Make "#sanfrancisco", "#SanFrancisco", "#san_francisco", "#San.Francisco", and "#SAN-FRANCISCO" all link to http://identi.ca/tag/sanfrancisco but preserve appearance darcs-hash:20080901025932-e3c0d-c0a939eaf7e242d88cbcb0d651c9d53718c60a9d.gz
This commit is contained in:
parent
cca78b26f7
commit
51caab6e5e
|
@ -54,10 +54,13 @@ class Notice extends DB_DataObject
|
||||||
|
|
||||||
function saveTags() {
|
function saveTags() {
|
||||||
/* extract all #hastags */
|
/* extract all #hastags */
|
||||||
$count = preg_match_all('/(?:^|\s)#([A-Za-z0-9]{1,64})/', strtolower($this->content), $match);
|
$count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($this->content), $match);
|
||||||
if (!$count) {
|
if (!$count) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* elide characters we don't want in the tag */
|
||||||
|
$match[1] = str_replace(array('-', '_', '.'), '', $match[1]);
|
||||||
|
|
||||||
/* Add them to the database */
|
/* Add them to the database */
|
||||||
foreach(array_unique($match[1]) as $hashtag) {
|
foreach(array_unique($match[1]) as $hashtag) {
|
||||||
|
|
|
@ -688,16 +688,16 @@ function common_render_content($text, $notice) {
|
||||||
$r = preg_replace('@https?://[^)\]>\s]+@', '<a href="\0" class="extlink">\0</a>', $r);
|
$r = preg_replace('@https?://[^)\]>\s]+@', '<a href="\0" class="extlink">\0</a>', $r);
|
||||||
$r = preg_replace('/(^|\s+)@([a-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
|
$r = preg_replace('/(^|\s+)@([a-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
|
||||||
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
|
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
|
||||||
$r = preg_replace('/(^|\s+)#([A-Za-z0-9]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
|
$r = preg_replace('/(^|\s+)#([A-Za-z0-9_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
|
||||||
# XXX: machine tags
|
# XXX: machine tags
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function common_tag_link($tag) {
|
function common_tag_link($tag) {
|
||||||
if(common_config('site', 'fancy')) {
|
if(common_config('site', 'fancy')) {
|
||||||
return '<a href="' . htmlspecialchars(common_path('tag/' . strtolower($tag))) . '" rel="tag" class="hashlink">' . htmlspecialchars($tag) . '</a>';
|
return '<a href="' . htmlspecialchars(common_path('tag/' . strtolower(str_replace(array('-', '_', '.'), '', $tag)))) . '" rel="tag" class="hashlink">' . htmlspecialchars($tag) . '</a>';
|
||||||
} else {
|
} else {
|
||||||
return '<a href="' . htmlspecialchars(common_path('index.php?action=tag&tag=' . strtolower($tag))) . '" rel="tag" class="hashlink">' . htmlspecialchars($tag) . '</a>';
|
return '<a href="' . htmlspecialchars(common_path('index.php?action=tag&tag=' . strtolower(str_replace(array('-', '_', '.'), '', $tag)))) . '" rel="tag" class="hashlink">' . htmlspecialchars($tag) . '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user