aboutsummaryrefslogtreecommitdiffstats
path: root/include/markdown.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-02-05 18:47:35 -0800
committerzotlabs <mike@macgirvin.com>2017-02-05 18:47:35 -0800
commiteb3685f5377be06615de66aba104aad6f4927495 (patch)
tree674ce0820b33eebf2e504644dc2ab9a04116007e /include/markdown.php
parent201a6b8742313d2b58f9668922f18b9ef38cf424 (diff)
downloadvolse-hubzilla-eb3685f5377be06615de66aba104aad6f4927495.tar.gz
volse-hubzilla-eb3685f5377be06615de66aba104aad6f4927495.tar.bz2
volse-hubzilla-eb3685f5377be06615de66aba104aad6f4927495.zip
remove per-page login css (home, login); add support for alternative markdown mention format
Diffstat (limited to 'include/markdown.php')
-rw-r--r--include/markdown.php37
1 files changed, 36 insertions, 1 deletions
diff --git a/include/markdown.php b/include/markdown.php
index b4656f769..7afdc6c54 100644
--- a/include/markdown.php
+++ b/include/markdown.php
@@ -110,6 +110,39 @@ function diaspora_mention_callback($matches) {
}
+function diaspora_mention_callback2($matches) {
+
+ $webbie = $matches[1] . '@' . $matches[2];
+ $link = '';
+ if($webbie) {
+ $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_addr = '%s' limit 1",
+ dbesc($webbie)
+ );
+ if(! $r) {
+ $x = discover_by_webbie($webbie);
+ if($x) {
+ $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_addr = '%s' limit 1",
+ dbesc($webbie)
+ );
+ }
+ }
+ if($r)
+ $link = $r[0]['xchan_url'];
+ }
+
+ $name = (($r) ? $r[0]['xchan_name'] : $matches[1]);
+
+ if(! $link)
+ $link = 'https://' . $matches[2] . '/u/' . $matches[1];
+
+ if($r && $r[0]['hubloc_network'] === 'zot')
+ return '@[zrl=' . $link . ']' . trim($name) . ((substr($matches[0],-1,1) === '+') ? '+' : '') . '[/zrl]' ;
+ else
+ return '@[url=' . $link . ']' . trim($name) . ((substr($matches[0],-1,1) === '+') ? '+' : '') . '[/url]' ;
+
+}
+
+
/**
* @brief
@@ -141,9 +174,11 @@ function markdown_to_bb($s, $use_zrl = false) {
// first try plustags
$s = preg_replace_callback('/\@\{(.+?)\; (.+?)\@(.+?)\}\+/','diaspora_mention_callback',$s);
-
$s = preg_replace_callback('/\@\{(.+?)\; (.+?)\@(.+?)\}/','diaspora_mention_callback',$s);
+ $s = preg_replace_callback('/\@\{(.+?)\@(.+?)\}\+/','diaspora_mention_callback2',$s);
+ $s = preg_replace_callback('/\@\{(.+?)\@(.+?)\}/','diaspora_mention_callback2',$s);
+
// Escaping the hash tags - doesn't always seem to work
// $s = preg_replace('/\#([^\s\#])/','\\#$1',$s);
// This seems to work