From 301fea8684f194bd622994494706b3676fdea299 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 28 Oct 2016 05:51:39 -0400 Subject: [PATCH 01/21] ping.php performance: caching baseurl --- boot.php | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/boot.php b/boot.php index e49ffbd221..4fefe6f7ed 100644 --- a/boot.php +++ b/boot.php @@ -787,27 +787,29 @@ class App { if (!is_object($this)) return(self::$a->get_baseurl($ssl)); - $scheme = $this->scheme; + if (!$this->baseurl) { + $scheme = $this->scheme; - if((x($this->config,'system')) && (x($this->config['system'],'ssl_policy'))) { - if(intval($this->config['system']['ssl_policy']) === intval(SSL_POLICY_FULL)) - $scheme = 'https'; - - // Basically, we have $ssl = true on any links which can only be seen by a logged in user - // (and also the login link). Anything seen by an outsider will have it turned off. - - if($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { - if($ssl) + if((x($this->config,'system')) && (x($this->config['system'],'ssl_policy'))) { + if(intval($this->config['system']['ssl_policy']) === intval(SSL_POLICY_FULL)) $scheme = 'https'; - else - $scheme = 'http'; + + // Basically, we have $ssl = true on any links which can only be seen by a logged in user + // (and also the login link). Anything seen by an outsider will have it turned off. + + if($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { + if($ssl) + $scheme = 'https'; + else + $scheme = 'http'; + } } + + if (get_config('config','hostname') != "") + $this->hostname = get_config('config','hostname'); + + $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); } - - if (get_config('config','hostname') != "") - $this->hostname = get_config('config','hostname'); - - $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); return $this->baseurl; } From 63e5342ced5720d1fd55b8d09462edd945474e32 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 28 Oct 2016 05:54:26 -0400 Subject: [PATCH 02/21] ping.php performance: removing datetime_convert --- include/datetime.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/include/datetime.php b/include/datetime.php index ea98f01fe0..626e0b92c4 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -328,12 +328,12 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke * @param string $posted_date * @param string $format (optional) Parsed with sprintf() * %1$d %2$s ago, e.g. 22 hours ago, 1 minute ago - * + * * @return string with relative date */ -function relative_date($posted_date,$format = null) { +function relative_date($posted_date, $format = null) { - $localtime = datetime_convert('UTC',date_default_timezone_get(),$posted_date); + $localtime = $posted_date . ' UTC'; $abs = strtotime($localtime); @@ -347,13 +347,6 @@ function relative_date($posted_date,$format = null) { return t('less than a second ago'); } - /* - $time_append = ''; - if ($etime >= 86400) { - $time_append = ' ('.$localtime.')'; - } - */ - $a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')), 30 * 24 * 60 * 60 => array( t('month'), t('months')), 7 * 24 * 60 * 60 => array( t('week'), t('weeks')), @@ -368,8 +361,9 @@ function relative_date($posted_date,$format = null) { if ($d >= 1) { $r = round($d); // translators - e.g. 22 hours ago, 1 minute ago - if(! $format) + if(! $format) { $format = t('%1$d %2$s ago'); + } return sprintf( $format,$r, (($r == 1) ? $str[0] : $str[1])); } From 747f902e21f7ddf9e94ede295fe3c12c3ade2eb1 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 28 Oct 2016 05:55:19 -0400 Subject: [PATCH 03/21] ping.php performance: optimizing session_write queries --- include/session.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/session.php b/include/session.php index 8f9d64606c..4e7befb1b5 100644 --- a/include/session.php +++ b/include/session.php @@ -40,12 +40,12 @@ function ref_session_write ($id,$data) { if($session_exists) { $r = q("UPDATE `session` SET `data` = '%s' - WHERE `data` != '%s' AND `sid` = '%s'", + WHERE `sid` = '%s' AND `data` != '%s'", dbesc($data), dbesc($data), dbesc($id)); $r = q("UPDATE `session` SET `expire` = '%s' - WHERE `expire` != '%s' AND `sid` = '%s'", + WHERE `sid` = '%s' AND `expire` != '%s'", dbesc($expire), dbesc($expire), dbesc($id)); } else $r = q("INSERT INTO `session` From f1c855e755aa1a51bba210221a5a2c1850cfec88 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 28 Oct 2016 06:28:16 -0400 Subject: [PATCH 04/21] ping.php performance: Cache notification bbcode - Add two fields to notifiy table to store cached bbcode result - Add bbcode conversion on notif creation - Add postfact caching if cache field is empty on retrieval --- boot.php | 2 +- database.sql | 2 ++ include/dbstructure.php | 2 ++ include/enotify.php | 35 +++++++++++++++++++++++++---- mod/ping.php | 49 +++++++++++++++++++++++------------------ update.php | 2 +- 6 files changed, 65 insertions(+), 27 deletions(-) diff --git a/boot.php b/boot.php index 4fefe6f7ed..cb4feef903 100644 --- a/boot.php +++ b/boot.php @@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5.1-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1206 ); +define ( 'DB_UPDATE_VERSION', 1207 ); /** * @brief Constant with a HTML line break. diff --git a/database.sql b/database.sql index f12746e7e5..c5fd49ba01 100644 --- a/database.sql +++ b/database.sql @@ -655,6 +655,8 @@ CREATE TABLE IF NOT EXISTS `notify` ( `seen` tinyint(1) NOT NULL DEFAULT 0, `verb` varchar(255) NOT NULL DEFAULT '', `otype` varchar(16) NOT NULL DEFAULT '', + `name_cache` tinytext, + `msg_name` mediumtext, PRIMARY KEY(`id`), INDEX `uid` (`uid`) ) DEFAULT CHARSET=utf8mb4; diff --git a/include/dbstructure.php b/include/dbstructure.php index fdf09d90de..8053965e03 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -1036,6 +1036,8 @@ function db_definition($charset) { "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""), + "name_cache" => array("type" => "tinytext"), + "msg_cache" => array("type" => "mediumtext") ), "indexes" => array( "PRIMARY" => array("id"), diff --git a/include/enotify.php b/include/enotify.php index 4973bedc24..bcb2ebe7ca 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -418,6 +418,7 @@ function notification($params) { $datarray = array(); $datarray['hash'] = $hash; $datarray['name'] = $params['source_name']; + $datarray['name_cache'] = strip_tags(bbcode($params['source_name'])); $datarray['url'] = $params['source_link']; $datarray['photo'] = $params['source_photo']; $datarray['date'] = datetime_convert(); @@ -439,7 +440,7 @@ function notification($params) { // create notification entry in DB - $r = q("INSERT INTO `notify` (`hash`, `name`, `url`, `photo`, `date`, `uid`, `link`, `iid`, `parent`, `type`, `verb`, `otype`) + $r = q("INSERT INTO `notify` (`hash`, `name`, `url`, `photo`, `date`, `uid`, `link`, `iid`, `parent`, `type`, `verb`, `otype`, `name_cache`) values('%s', '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s')", dbesc($datarray['hash']), dbesc($datarray['name']), @@ -452,7 +453,8 @@ function notification($params) { intval($datarray['parent']), intval($datarray['type']), dbesc($datarray['verb']), - dbesc($datarray['otype']) + dbesc($datarray['otype']), + dbesc($datarray["name_cache"]) ); $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' AND `uid` = %d LIMIT 1", @@ -494,8 +496,10 @@ function notification($params) { $itemlink = $a->get_baseurl().'/notify/view/'.$notify_id; $msg = replace_macros($epreamble, array('$itemlink' => $itemlink)); - $r = q("UPDATE `notify` SET `msg` = '%s' WHERE `id` = %d AND `uid` = %d", + $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg))); + $r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($msg), + dbesc($msg_cache), intval($notify_id), intval($params['uid']) ); @@ -778,4 +782,27 @@ function check_item_notification($itemid, $uid, $defaulttype = "") { if (isset($params["type"])) notification($params); } -?> + +/** + * @brief Formats a notification message with the notification author + * + * Replace the name with {0} but ensure to make that only once. The {0} is used + * later and prints the name in bold. + * + * @param string $name + * @param string $message + * @return string Formatted message + */ +function format_notification_message($name, $message) { + if ($name != '') { + $pos = strpos($message, $name); + } else { + $pos = false; + } + + if ($pos !== false) { + $message = substr_replace($message, '{0}', $pos, strlen($name)); + } + + return $message; +} \ No newline at end of file diff --git a/mod/ping.php b/mod/ping.php index 8c28e74744..a905371226 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -344,6 +344,12 @@ function ping_init(&$a) { killme(); } +/** + * @brief Retrieves the notifications array for the given user ID + * + * @param int $uid + * @return array + */ function ping_get_notifications($uid) { $result = array(); @@ -372,46 +378,47 @@ function ping_get_notifications($uid) { $seensql = ""; $order = "DESC"; $offset = 0; - } elseif (!$r) + } elseif (!$r) { $quit = true; - else + } else { $offset += 50; - + } foreach ($r AS $notification) { - if (is_null($notification["visible"])) + if (is_null($notification["visible"])) { $notification["visible"] = true; + } - if (is_null($notification["spam"])) + if (is_null($notification["spam"])) { $notification["spam"] = 0; + } - if (is_null($notification["deleted"])) + if (is_null($notification["deleted"])) { $notification["deleted"] = 0; + } - $notification["message"] = strip_tags(bbcode($notification["msg"])); - $notification["name"] = strip_tags(bbcode($notification["name"])); + if ($notification["msg_cache"]) { + $notification["name"] = $notification["name_cache"]; + $notification["message"] = $notification["msg_cache"]; + } else { + $notification["name"] = strip_tags(bbcode($notification["name"])); + $notification["message"] = format_notification_message($notification["name"], strip_tags(bbcode($notification["msg"]))); - // Replace the name with {0} but ensure to make that only once - // The {0} is used later and prints the name in bold. + q("UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d", + dbesc($notification["name"]), + dbesc($notification["message"]), + intval($notification["id"]) + ); + } - if ($notification['name'] != "") - $pos = strpos($notification["message"],$notification['name']); - else - $pos = false; - - if ($pos !== false) - $notification["message"] = substr_replace($notification["message"],"{0}",$pos,strlen($notification["name"])); - - $notification['href'] = $a->get_baseurl() . '/notify/view/' . $notification['id']; + $notification["href"] = $a->get_baseurl() . "/notify/view/" . $notification["id"]; if ($notification["visible"] AND !$notification["spam"] AND !$notification["deleted"] AND !is_array($result[$notification["parent"]])) { $result[$notification["parent"]] = $notification; } } - } while ((count($result) < 50) AND !$quit); - return($result); } diff --git a/update.php b/update.php index 7560911134..5eab9c2207 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ Date: Fri, 28 Oct 2016 06:50:08 -0400 Subject: [PATCH 05/21] ping.php performance: improve baseurl caching - Add cache invalidation on set_baseurl - Add documentation - Fix formatting --- boot.php | 58 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/boot.php b/boot.php index cb4feef903..279a9f292e 100644 --- a/boot.php +++ b/boot.php @@ -781,16 +781,25 @@ class App { return($this->scheme); } + /** + * @brief Retrieves the Friendica instance base URL + * + * Caches both SSL and non-SSL version for performance + * + * @param bool $ssl + * @return string + */ function get_baseurl($ssl = false) { // Is the function called statically? - if (!is_object($this)) + if (!is_object($this)) { return(self::$a->get_baseurl($ssl)); + } - if (!$this->baseurl) { + if (!isset($this->baseurl[$ssl ? 'https' : 'http'])) { $scheme = $this->scheme; - if((x($this->config,'system')) && (x($this->config['system'],'ssl_policy'))) { + if((x($this->config, 'system')) && (x($this->config['system'], 'ssl_policy'))) { if(intval($this->config['system']['ssl_policy']) === intval(SSL_POLICY_FULL)) $scheme = 'https'; @@ -798,45 +807,58 @@ class App { // (and also the login link). Anything seen by an outsider will have it turned off. if($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { - if($ssl) + if($ssl) { $scheme = 'https'; - else + } else { $scheme = 'http'; + } } } - if (get_config('config','hostname') != "") - $this->hostname = get_config('config','hostname'); + if (get_config('config','hostname') != '') { + $this->hostname = get_config('config', 'hostname'); + } - $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); + $this->baseurl[$ssl ? 'https' : 'http'] = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); } - return $this->baseurl; + return $this->baseurl[$ssl ? 'https' : 'http']; } + /** + * @brief Initializes the baseurl components + * + * Clears the baseurl cache to prevent inconstistencies + * + * @param string $url + */ function set_baseurl($url) { $parsed = @parse_url($url); - $this->baseurl = $url; + $this->baseurl = []; if($parsed) { $this->scheme = $parsed['scheme']; $hostname = $parsed['host']; - if(x($parsed,'port')) + if (x($parsed, 'port')) { $hostname .= ':' . $parsed['port']; - if(x($parsed,'path')) - $this->path = trim($parsed['path'],'\\/'); + } + if (x($parsed, 'path')) { + $this->path = trim($parsed['path'], '\\/'); + } - if (file_exists(".htpreconfig.php")) + if (file_exists(".htpreconfig.php")) { @include(".htpreconfig.php"); + } - if (get_config('config','hostname') != "") - $this->hostname = get_config('config','hostname'); + if (get_config('config', 'hostname') != '') { + $this->hostname = get_config('config', 'hostname'); + } - if (!isset($this->hostname) OR ($this->hostname == "")) + if (!isset($this->hostname) OR ($this->hostname == '')) { $this->hostname = $hostname; + } } - } function get_hostname() { From cc4363c5c62656512d64025ee25b5c25887303f0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 28 Oct 2016 12:29:55 -0400 Subject: [PATCH 06/21] ping.php performance: fix formatting --- boot.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/boot.php b/boot.php index 279a9f292e..895530351f 100644 --- a/boot.php +++ b/boot.php @@ -793,21 +793,22 @@ class App { // Is the function called statically? if (!is_object($this)) { - return(self::$a->get_baseurl($ssl)); + return self::$a->get_baseurl($ssl); } if (!isset($this->baseurl[$ssl ? 'https' : 'http'])) { $scheme = $this->scheme; - if((x($this->config, 'system')) && (x($this->config['system'], 'ssl_policy'))) { - if(intval($this->config['system']['ssl_policy']) === intval(SSL_POLICY_FULL)) + if ((x($this->config, 'system')) && (x($this->config['system'], 'ssl_policy'))) { + if (intval($this->config['system']['ssl_policy']) === SSL_POLICY_FULL) { $scheme = 'https'; + } // Basically, we have $ssl = true on any links which can only be seen by a logged in user // (and also the login link). Anything seen by an outsider will have it turned off. - if($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { - if($ssl) { + if ($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { + if ($ssl) { $scheme = 'https'; } else { $scheme = 'http'; @@ -815,7 +816,7 @@ class App { } } - if (get_config('config','hostname') != '') { + if (get_config('config', 'hostname') != '') { $this->hostname = get_config('config', 'hostname'); } From bc407080d2832b2096b0f46e715d4f0fe2b97670 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 28 Oct 2016 22:14:51 -0400 Subject: [PATCH 07/21] ping.php performance: improve documentation and formatting --- doc/database/db_notify.md | 36 +++++++++++++++++++----------------- include/session.php | 25 +++++++++++++++++++------ mod/ping.php | 4 ++-- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/doc/database/db_notify.md b/doc/database/db_notify.md index 5ef2aa7ebc..b2bae64717 100644 --- a/doc/database/db_notify.md +++ b/doc/database/db_notify.md @@ -1,22 +1,24 @@ Table notify ============ -| Field | Description | Type | Null | Key | Default | Extra | -| ------ | --------------------------------- | ------------ | ---- | --- | ------------------- | --------------- | -| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment | -| hash | | varchar(64) | NO | | | | -| type | | int(11) | NO | | 0 | | -| name | | varchar(255) | NO | | | | -| url | | varchar(255) | NO | | | | -| photo | | varchar(255) | NO | | | | -| date | | datetime | NO | | 0000-00-00 00:00:00 | | -| msg | | mediumtext | NO | | NULL | | -| uid | user.id of the owner of this data | int(11) | NO | MUL | 0 | | -| link | | varchar(255) | NO | | | | -| parent | | int(11) | NO | | 0 | | -| seen | | tinyint(1) | NO | | 0 | | -| verb | | varchar(255) | NO | | | | -| otype | | varchar(16) | NO | | | | -| iid | item.id | int(11) | NO | | 0 | | +| Field | Description | Type | Null | Key | Default | Extra | +| ---------- | --------------------------------- | ------------ | ---- | --- | ------------------- | --------------- | +| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment | +| hash | | varchar(64) | NO | | | | +| type | | int(11) | NO | | 0 | | +| name | | varchar(255) | NO | | | | +| url | | varchar(255) | NO | | | | +| photo | | varchar(255) | NO | | | | +| date | | datetime | NO | | 0000-00-00 00:00:00 | | +| msg | | mediumtext | YES | | NULL | | +| uid | user.id of the owner of this data | int(11) | NO | MUL | 0 | | +| link | | varchar(255) | NO | | | | +| iid | item.id | int(11) | NO | | 0 | | +| parent | | int(11) | NO | | 0 | | +| seen | | tinyint(1) | NO | | 0 | | +| verb | | varchar(255) | NO | | | | +| otype | | varchar(16) | NO | | | | +| name_cache | Cached bbcode parsing of name | tinytext | YES | | NULL | | +| msg_cache | Cached bbcode parsing of msg | mediumtext | YES | | NULL | | Return to [database documentation](help/database) diff --git a/include/session.php b/include/session.php index 4e7befb1b5..23066be424 100644 --- a/include/session.php +++ b/include/session.php @@ -26,18 +26,30 @@ function ref_session_read ($id) { return ''; }} -if(! function_exists('ref_session_write')) { -function ref_session_write ($id,$data) { +/** + * @brief Standard PHP session write callback + * + * This callback updates the DB-stored session data and/or the expiration depending + * on the case. Uses the $session_expire global for existing session, 5 minutes + * for newly created session. + * + * @global bool $session_exists Whether a session with the given id already exists + * @global int $session_expire Session expiration delay in seconds + * @param string $id Session ID with format: [a-z0-9]{26} + * @param string $data Serialized session data + * @return boolean Returns false if parameters are missing, true otherwise + */ +function ref_session_write($id, $data) { global $session_exists, $session_expire; - if(! $id || ! $data) { + if (!$id || !$data) { return false; } $expire = time() + $session_expire; $default_expire = time() + 300; - if($session_exists) { + if ($session_exists) { $r = q("UPDATE `session` SET `data` = '%s' WHERE `sid` = '%s' AND `data` != '%s'", @@ -47,13 +59,14 @@ function ref_session_write ($id,$data) { SET `expire` = '%s' WHERE `sid` = '%s' AND `expire` != '%s'", dbesc($expire), dbesc($expire), dbesc($id)); - } else + } else { $r = q("INSERT INTO `session` SET `sid` = '%s', `expire` = '%s', `data` = '%s'", dbesc($id), dbesc($default_expire), dbesc($data)); + } return true; -}} +} if(! function_exists('ref_session_close')) { function ref_session_close() { diff --git a/mod/ping.php b/mod/ping.php index a905371226..0ed7eb3fed 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -347,8 +347,8 @@ function ping_init(&$a) { /** * @brief Retrieves the notifications array for the given user ID * - * @param int $uid - * @return array + * @param int $uid User id + * @return array Associative array of notifications */ function ping_get_notifications($uid) { From 0131656a06ddb7162e687cfa598a9d2aecea0a9d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 28 Oct 2016 22:15:24 -0400 Subject: [PATCH 08/21] ping.php perfomance: reverting useless session write changes --- include/session.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/session.php b/include/session.php index 23066be424..5cf4bcc9cf 100644 --- a/include/session.php +++ b/include/session.php @@ -52,12 +52,12 @@ function ref_session_write($id, $data) { if ($session_exists) { $r = q("UPDATE `session` SET `data` = '%s' - WHERE `sid` = '%s' AND `data` != '%s'", + WHERE `data` != '%s' AND `sid` = '%s'", dbesc($data), dbesc($data), dbesc($id)); $r = q("UPDATE `session` SET `expire` = '%s' - WHERE `sid` = '%s' AND `expire` != '%s'", + WHERE `expire` != '%s' AND `sid` = '%s'", dbesc($expire), dbesc($expire), dbesc($id)); } else { $r = q("INSERT INTO `session` From cd3f98d27dc6ffaa188cc81f0f50217cd8b3bf1d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 28 Oct 2016 22:27:26 -0400 Subject: [PATCH 09/21] ping.php improvement: db version bump --- boot.php | 2 +- update.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index 0be1595406..5df6520dbd 100644 --- a/boot.php +++ b/boot.php @@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5.1-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1207 ); +define ( 'DB_UPDATE_VERSION', 1208 ); /** * @brief Constant with a HTML line break. diff --git a/update.php b/update.php index 5eab9c2207..fa03ddd1ac 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ Date: Sun, 30 Oct 2016 23:59:14 -0400 Subject: [PATCH 10/21] bbcode documentation: fix broken bookmark form: #^[url]...[/url] - Prevents the advance recognition of `^` in tags before bbcode() - Formatting - Documentation --- include/text.php | 53 +++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/include/text.php b/include/text.php index 5c9202c580..50e2e81931 100644 --- a/include/text.php +++ b/include/text.php @@ -769,71 +769,74 @@ function activity_match($haystack,$needle) { }} -if(! function_exists('get_tags')) { /** - * Pull out all #hashtags and @person tags from $s; + * Pull out all #hashtags and @person tags from $string; * We also get @person@domain.com - which would make * the regex quite complicated as tags can also * end a sentence. So we'll run through our results * and strip the period from any tags which end with one. * Returns array of tags found, or empty array. * - * @param string $s - * @return array + * @param string $string Post content + * @return array List of tag and person names */ -function get_tags($s) { +function get_tags($string) { $ret = array(); // Convert hashtag links to hashtags - $s = preg_replace("/#\[url\=([^\[\]]*)\](.*?)\[\/url\]/ism", "#$2", $s); + $string = preg_replace('/#\[url\=([^\[\]]*)\](.*?)\[\/url\]/ism', '#$2', $string); // ignore anything in a code block - $s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s); + $string = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $string); // Force line feeds at bbtags - $s = str_replace(array("[", "]"), array("\n[", "]\n"), $s); + $string = str_replace(array('[', ']'), array("\n[", "]\n"), $string); // ignore anything in a bbtag - $s = preg_replace('/\[(.*?)\]/sm','',$s); + $string = preg_replace('/\[(.*?)\]/sm', '', $string); // Match full names against @tags including the space between first and last // We will look these up afterward to see if they are full names or not recognisable. - if(preg_match_all('/(@[^ \x0D\x0A,:?]+ [^ \x0D\x0A@,:?]+)([ \x0D\x0A@,:?]|$)/',$s,$match)) { - foreach($match[1] as $mtch) { - if(strstr($mtch,"]")) { + if (preg_match_all('/(@[^ \x0D\x0A,:?]+ [^ \x0D\x0A@,:?]+)([ \x0D\x0A@,:?]|$)/', $string, $matches)) { + foreach ($matches[1] as $match) { + if (strstr($match, ']')) { // we might be inside a bbcode color tag - leave it alone continue; } - if(substr($mtch,-1,1) === '.') - $ret[] = substr($mtch,0,-1); - else - $ret[] = $mtch; + if (substr($match, -1, 1) === '.') { + $ret[] = substr($match, 0, -1); + } else { + $ret[] = $match; + } } } // Otherwise pull out single word tags. These can be @nickname, @first_last // and #hash tags. - if(preg_match_all('/([!#@][^ \x0D\x0A,;:?]+)([ \x0D\x0A,;:?]|$)/',$s,$match)) { - foreach($match[1] as $mtch) { - if(strstr($mtch,"]")) { + if (preg_match_all('/([!#@][^\^ \x0D\x0A,;:?]+)([ \x0D\x0A,;:?]|$)/', $string, $matches)) { + foreach($matches[1] as $match) { + if (strstr($match, ']')) { // we might be inside a bbcode color tag - leave it alone continue; } - if(substr($mtch,-1,1) === '.') - $mtch = substr($mtch,0,-1); + if (substr($match, -1, 1) === '.') { + $match = substr($match,0,-1); + } // ignore strictly numeric tags like #1 - if((strpos($mtch,'#') === 0) && ctype_digit(substr($mtch,1))) + if ((strpos($match, '#') === 0) && ctype_digit(substr($match, 1))) { continue; + } // try not to catch url fragments - if(strpos($s,$mtch) && preg_match('/[a-zA-z0-9\/]/',substr($s,strpos($s,$mtch)-1,1))) + if (strpos($string, $match) && preg_match('/[a-zA-z0-9\/]/', substr($string, strpos($string, $match) - 1, 1))) { continue; - $ret[] = $mtch; + } + $ret[] = $match; } } return $ret; -}} +} // From 63b1e822cdc6af84973805214eee4c0454a2ff4f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 31 Oct 2016 00:00:12 -0400 Subject: [PATCH 11/21] bbcode documentation: improved webfinger profile regexp --- include/bbcode.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index ed23253648..6d56587ab1 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -892,8 +892,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal // we may need to restrict this further if it picks up too many strays // link acct:user@host to a webfinger profile redirector - $Text = preg_replace('/acct:(.*?)@(.*?)([ ,])/', 'acct:' . "$1@$2$3" . '',$Text); + $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', 'acct:$1@$2',$Text); // Perform MAIL Search $Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '$1', $Text); From db874f0fbe0429cd185c5420daf47db3cc96cc93 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 31 Oct 2016 14:27:19 -0400 Subject: [PATCH 12/21] ping.php improvement: using baser cache key --- boot.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/boot.php b/boot.php index 5df6520dbd..8dd43101c0 100644 --- a/boot.php +++ b/boot.php @@ -800,7 +800,9 @@ class App { return self::$a->get_baseurl($ssl); } - if (!isset($this->baseurl[$ssl ? 'https' : 'http'])) { + $cache_index = $ssl ? 'https' : 'http'; + + if (!isset($this->baseurl[$cache_index])) { $scheme = $this->scheme; if ((x($this->config, 'system')) && (x($this->config['system'], 'ssl_policy'))) { @@ -824,9 +826,9 @@ class App { $this->hostname = get_config('config', 'hostname'); } - $this->baseurl[$ssl ? 'https' : 'http'] = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); + $this->baseurl[$cache_index] = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); } - return $this->baseurl[$ssl ? 'https' : 'http']; + return $this->baseurl[$cache_index]; } /** From 5e188a9250d42a82cd6b8e84d65875f3bc6067fb Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 1 Nov 2016 02:04:59 -0400 Subject: [PATCH 13/21] ping.php improvement: datetime.php formatting --- include/datetime.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/datetime.php b/include/datetime.php index 626e0b92c4..16b134e90b 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -325,7 +325,7 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke * Results relative to current timezone. * Limited to range of timestamps. * - * @param string $posted_date + * @param string $posted_date MySQL-formatted date string (YYYY-MM-DD HH:MM:SS) * @param string $format (optional) Parsed with sprintf() * %1$d %2$s ago, e.g. 22 hours ago, 1 minute ago * @@ -361,11 +361,11 @@ function relative_date($posted_date, $format = null) { if ($d >= 1) { $r = round($d); // translators - e.g. 22 hours ago, 1 minute ago - if(! $format) { + if (!$format) { $format = t('%1$d %2$s ago'); } - return sprintf( $format,$r, (($r == 1) ? $str[0] : $str[1])); + return sprintf($format, $r, (($r == 1) ? $str[0] : $str[1])); } } } From 97c2e99d46efe9f2ff447acebe5d3e7239447d6c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 1 Nov 2016 17:05:23 -0400 Subject: [PATCH 14/21] ping.php improvement: improving get_baseurl - Adding more documentation - Trying hard to make @annando happy --- boot.php | 69 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/boot.php b/boot.php index 8dd43101c0..eb91b26baf 100644 --- a/boot.php +++ b/boot.php @@ -788,10 +788,18 @@ class App { /** * @brief Retrieves the Friendica instance base URL * - * Caches both SSL and non-SSL version for performance + * This function assembles the base URL from multiple parts: + * - Protocol is determined either by the request or a combination of + * system.ssl_policy and the $ssl parameter. + * - Host name is determined either by system.hostname or inferred from request + * - Path is inferred from SCRIPT_NAME * - * @param bool $ssl - * @return string + * Caches the result (depending on $ssl value) for performance. + * + * Note: $ssl parameter value doesn't directly correlate with the resulting protocol + * + * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN + * @return string Friendica server base URL */ function get_baseurl($ssl = false) { @@ -800,34 +808,39 @@ class App { return self::$a->get_baseurl($ssl); } + // Arbitrary values, the resulting url protocol can be different $cache_index = $ssl ? 'https' : 'http'; - if (!isset($this->baseurl[$cache_index])) { - $scheme = $this->scheme; - - if ((x($this->config, 'system')) && (x($this->config['system'], 'ssl_policy'))) { - if (intval($this->config['system']['ssl_policy']) === SSL_POLICY_FULL) { - $scheme = 'https'; - } - - // Basically, we have $ssl = true on any links which can only be seen by a logged in user - // (and also the login link). Anything seen by an outsider will have it turned off. - - if ($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { - if ($ssl) { - $scheme = 'https'; - } else { - $scheme = 'http'; - } - } - } - - if (get_config('config', 'hostname') != '') { - $this->hostname = get_config('config', 'hostname'); - } - - $this->baseurl[$cache_index] = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); + // Cached value found, nothing to process + if (isset($this->baseurl[$cache_index])) { + return $this->baseurl[$cache_index]; } + + $scheme = $this->scheme; + + if ((x($this->config, 'system')) && (x($this->config['system'], 'ssl_policy'))) { + if (intval($this->config['system']['ssl_policy']) === SSL_POLICY_FULL) { + $scheme = 'https'; + } + + // Basically, we have $ssl = true on any links which can only be seen by a logged in user + // (and also the login link). Anything seen by an outsider will have it turned off. + + if ($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { + if ($ssl) { + $scheme = 'https'; + } else { + $scheme = 'http'; + } + } + } + + if (get_config('config', 'hostname') != '') { + $this->hostname = get_config('config', 'hostname'); + } + + $this->baseurl[$cache_index] = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); + return $this->baseurl[$cache_index]; } From 6626ef64a91786ad7e6a32e03fdbc44f07c41bf6 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 1 Nov 2016 23:07:37 -0400 Subject: [PATCH 15/21] bbcode documentation: enable overline --- view/global.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/view/global.css b/view/global.css index 1bc2f11d68..bcf7174ea3 100644 --- a/view/global.css +++ b/view/global.css @@ -27,6 +27,10 @@ a.btn, a.btn:hover { background-color: #2d2d2d; } +.overline { + text-decoration: overline; +} + /* List of social Networks */ img.connector, img.connector-disabled { height: 40px; From aff467adf2f399b64a05c332751cf517f4bf0099 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 1 Nov 2016 23:08:26 -0400 Subject: [PATCH 16/21] bbcode documentation: improve cleancss --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bbcode.php b/include/bbcode.php index 6d56587ab1..ebafc353a4 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -146,7 +146,7 @@ function cleancss($input) { if (($char >= "a") and ($char <= "z")) $cleaned .= $char; - if (!(strpos(" #;:0123456789-_", $char) === false)) + if (!(strpos(" #;:0123456789-_.%", $char) === false)) $cleaned .= $char; } From 68bf1aa4cdd52eb0aab3eef02d5a357896c9fef3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 2 Nov 2016 22:41:07 -0400 Subject: [PATCH 17/21] bbcode documentation: fix anchors on frio --- view/theme/frio/css/style.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 2be7d5cb46..d2467b1355 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -38,6 +38,18 @@ body a { color: $link_color; text-decoration: none; } +/* Anchors incorrectly display with a fixed top menu. This global rule offsets all + * anchors so that accessing them with a # link will actually scroll the associated + * content in the visible part of the page. + * + * anchor.top should be the opposite of body.padding-top + */ +body a[name]:not([href]) { + display: block; + position: relative; + top: -110px; + visibility: hidden; +} body a:hover, body a:focus, body a:active, body a.active, body .btn-link:hover{ /*color: #59d6e4;*/ From 106f003447eae11060f026c48981ebaafd60f279 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 2 Nov 2016 22:42:19 -0400 Subject: [PATCH 18/21] bbcode documentation: BBCodes.md complete rewrite - Switched to table display to put BBCodes and result side-by-side - Added all missing BBCodes --- doc/BBCode.md | 739 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 571 insertions(+), 168 deletions(-) diff --git a/doc/BBCode.md b/doc/BBCode.md index d22f7afa58..aeb5e06c95 100644 --- a/doc/BBCode.md +++ b/doc/BBCode.md @@ -1,208 +1,611 @@ Friendica BBCode tags reference ======================== -* [Home](help) +* [Creating posts](help/Text_editor) -Inline ------ +## Inline + -
[u]underlined[/u]
: underlined + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BBCodeResult
[b]bold[/b]bold
[i]italic[/i]italic
[u]underlined[/u]underlined
[s]strike[/s]strike
[o]overline[/o]overline
[color=red]red[/color]red
[url=http://www.friendica.com]Friendica[/url]Friendica
[img]http://friendica.com/sites/default/files/friendika-32.png[/img]Immagine/foto
[img=64x32]http://friendica.com/sites/default/files/friendika-32.png[/img]
+
Note: provided height is simply discarded.
[size=xx-small]small text[/size]small text
[size=xx-large]big text[/size]big text
[size=20]exact size[/size] (size can be any number, in pixel)exact size
[font=serif]Serif font[/font]Serif font
-
[s]strike[/s]
: strike +### Links -
[color=red]red[/color]
: red + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BBCodeResult
[url]http://friendica.com[/url]http://friendica.com
[url=http://friendica.com]Friendica[/url]Friendica
[bookmark]http://friendica.com[/bookmark]

+#^[url]http://friendica.com[/url]

Friendica: http://friendica.com

[bookmark=http://friendica.com]Bookmark[/bookmark]

+#^[url=http://friendica.com]Bookmark[/url]

+#[url=http://friendica.com]^[/url][url=http://friendica.com]Bookmark[/url]

Friendica: Bookmark

[url=/posts/f16d77b0630f0134740c0cc47a0ea02a]Diaspora post with GUID[/url]Diaspora post with GUID
#Friendica#Friendica
@Mention@Mention
acct:account@friendica.host.com (WebFinger)acct:account@friendica.host.com
[mail]user@mail.example.com[/mail]user@mail.example.com
[mail=user@mail.example.com]Send an email to User[/mail]Send an email to User
-
[url=http://www.friendica.com]Friendica[/url]
: Friendica +## Blocks -
[img]http://friendica.com/sites/default/files/friendika-32.png[/img]
: Immagine/foto + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BBCodeResult
[p]A paragraph of text[/p]

A paragraph of text

Inline [code]code[/code] in a paragraphInline code in a paragraph
[code]Multi
line
code[/code]
Multi +line +code
[code=php]function text_highlight($s,$lang)[/code]
  1.  function text_highlight($s,$lang)
[quote]quote[/quote]
quote
[quote=Author]Author? Me? No, no, no...[/quote]Author wrote:
Author? Me? No, no, no...
[center]Centered text[/center]
Centered text
You should not read any further if you want to be surprised.[spoiler]There is a happy end.[/spoiler] +
+ You should not read any further if you want to be surprised.
+ Click to open/close + +
+
+
[spoiler=Author]Spoiler quote[/spoiler] +
+ Author wrote:
+ Click to open/close + +
+
+
[hr] (horizontal line)
-
[size=xx-small]small text[/size]
: small text +### Titles -
[size=xx-large]big text[/size]
: big text + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BBCodeResult
[h1]Title 1[/h1]

Title 1

[h2]Title 2[/h2]

Title 2

[h3]Title 3[/h3]

Title 3

[h4]Title 4[/h4]

Title 4

[h5]Title 5[/h5]
Title 5
[h6]Title 6[/h6]
Title 6
-
[size=20]exact size[/size] (size can be any number, in pixel)
: exact size +### Tables + + + + + + + + + + + + + + + + + +
BBCodeResult
[table]
+  [tr]
+    [th]Header 1[/th]
+    [th]Header 2[/th]
+    [th]Header 2[/th]
+  [/tr]
+  [tr]
+    [td]Cell 1[/td]
+    [td]Cell 2[/td]
+    [td]Cell 3[/td]
+  [/tr]
+  [tr]
+    [td]Cell 4[/td]
+    [td]Cell 5[/td]
+    [td]Cell 6[/td]
+  [/tr]
+[/table]
+ + + + + + + + + + + + + + + + + + +
Header 1Header 2Header 3
Cell 1Cell 2Cell 3
Cell 4Cell 5Cell 6
+
[table border=0] + + + + + + + + + + + + + + + + + + +
Header 1Header 2Header 3
Cell 1Cell 2Cell 3
Cell 4Cell 5Cell 6
+
[table border=1] + + + + + + + + + + + + + + + + + + +
Header 1Header 2Header 3
Cell 1Cell 2Cell 3
Cell 4Cell 5Cell 6
+
+### Lists + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BBCodeResult
[ul]
+  [li] First list element
+  [li] Second list element
+[/ul]
+[list]
+  [*] First list element
+  [*] Second list element
+[/list]
+
    +
  • First list element
  • +
  • Second list element
  • +
+
[ol]
+  [*] First list element
+  [*] Second list element
+[/ol]
+[list=1]
+  [*] First list element
+  [*] Second list element
+[/list]
+
    +
  • First list element
  • +
  • Second list element
  • +
+
[list=]
+  [*] First list element
+  [*] Second list element
+[/list]
+
    +
  • First list element
  • +
  • Second list element
  • +
+
[list=i]
+  [*] First list element
+  [*] Second list element
+[/list]
+
    +
  • First list element
  • +
  • Second list element
  • +
+
[list=I]
+  [*] First list element
+  [*] Second list element
+[/list]
+
    +
  • First list element
  • +
  • Second list element
  • +
+
[list=a]
+  [*] First list element
+  [*] Second list element
+[/list]
+
    +
  • First list element
  • +
  • Second list element
  • +
+
[list=A]
+  [*] First list element
+  [*] Second list element
+[/list]
+
    +
  • First list element
  • +
  • Second list element
  • +
+
- - - -Block ------ - -
[code]code[/code]
- -code - -

 

- -
[code=php]function text_highlight($s,$lang)[/code]
- -
  1.  function text_highlight($s,$lang)
- -

 

- -
[quote]quote[/quote]
- -
quote
- -

 

- -
[quote=Author]Author? Me? No, no, no...[/quote]
- -Author wrote:
Author? Me? No, no, no...
- -

 

- -
[center]centered text[/center]
- -
centered text
- -

 

- -
You should not read any further if you want to be surprised.[spoiler]There is a happy end.[/spoiler]
- -You should not read any further if you want to be surprised.
*click to open/close* - -(The text between thhe opening and the closing of the spoiler tag will be visible once the link is clicked. So *"There is a happy end."* wont be visible until the spoiler is uncovered.) - -

 

- -**Table** -
[table border=1]
- [tr] 
-   [th]Tables now[/th]
- [/tr]
- [tr]
-   [td]Have headers[/td]
- [/tr]
-[/table]
- -
Tables now
Have headers
- -

 

- -**List** - -
[list]
- [*] First list element
- [*] Second list element
-[/list]
-
    -
  • First list element
    -
  • -
  • Second list element
  • -
- -[list] is equivalent to [ul] (unordered list). - -[ol] can be used instead of [list] to show an ordered list: - -
[ol]
- [*] First list element
- [*] Second list element
-[/ol]
-
  • First list element
  • Second list element
- -For more options on ordered lists, you can define the style of numeration on [list] argument: -
[list=1]
: decimal - -
[list=i]
: lover case roman - -
[list=I]
: upper case roman - -
[list=a]
: lover case alphabetic - -
[list=A] 
: upper case alphabetic - - - - -Embed ------- +## Embed You can embed video, audio and more in a message. -
[video]url[/video]
-
[audio]url[/audio]
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BBCodeResult
[video]url[/video]Where *url* can be an url to youtube, vimeo, soundcloud, or other sites wich supports oembed or opengraph specifications.
[video]Video file url[/video] +[audio]Audio file url[/audio]Full URL to an ogg/ogv/oga/ogm/webm/mp4/mp3 file. An HTML5 player will be used to show it.
[youtube]Youtube URL[/youtube]Youtube video OEmbed display. May not embed an actual player.
[youtube]Youtube video ID[/youtube]Youtube player iframe embed.
[vimeo]Vimeo URL[/vimeo]Vimeo video OEmbed display. May not embed an actual player.
[vimeo]Vimeo video ID[/vimeo]Vimeo player iframe embed.
[iframe]URL[/iframe]General embed, iframe size is limited by the theme size for video players.
[url]*url*[/url]If *url* supports oembed or opengraph specifications the embedded object will be shown (eg, documents from scribd). +Page title with a link to *url* will be shown.
-Where *url* can be an url to youtube, vimeo, soundcloud, or other sites wich supports oembed or opengraph specifications. -*url* can be also full url to an ogg file. HTML5 tag will be used to show it. +## Map -
[url]*url*[/url]
+This require "openstreetmap" addon version 1.3 or newer. If the addon isn't activated, +the raw coordinates are shown instead. -If *url* supports oembed or opengraph specifications the embedded object will be shown (eg, documents from scribd). -Page title with a link to *url* will be shown. + + + + + + + + + + + + + + + + + +
BBCodeResult
[map]address[/map]Embeds a map centered on this address.
[map=lat,long]Embeds a map centered on those coordinates.
[map]Embeds a map centered on the post's location.
-Map ---- +## Abstract for longer posts -
[map]address[/map]
-
[map=lat,long]
+If you want to spread your post to several third party networks you can have the problem that these networks have a length limitation like on Twitter. -You can embed maps from coordinates or addresses. -This require "openstreetmap" addon version 1.3 or newer. - ------------------------------------------------------------ - -Abstract for longer posts -------------------------- - -If you want to spread your post to several third party networks you can have the problem that these networks have (for example) a length limitation. -(Like on Twitter) - -Friendica is using a semi intelligent mechanism to generate a fitting abstract. -But it can be interesting to define an own abstract that will only be displayed on the external network. -This is done with the [abstract]-element. -Example: - -
[abstract]Totally interesting! A must-see! Please click the link![/abstract]
-I want to tell you a really boring story that you really never wanted 
-to hear.
- -Twitter would display the text "Totally interesting! A must-see! Please click the link!". -On Friendica you would only see the text after "I want to tell you a really ..." +Friendica is using a semi intelligent mechanism to generate a fitting abstract. +But it can be interesting to define a custom abstract that will only be displayed on the external network. +This is done with the [abstract]-element. + + + + + + + + + +
BBCodeResult
[abstract]Totally interesting! A must-see! Please click the link![/abstract]
+I want to tell you a really boring story that you really never wanted to hear.
Twitter would display the text "Totally interesting! A must-see! Please click the link!". +On Friendica you would only see the text after "I want to tell you a really ..."
It is even possible to define abstracts for separate networks: -
-[abstract]Hi friends Here are my newest pictures![abstract]
-[abstract=twit]Hi my dear Twitter followers. Do you want to see my new 
-pictures?[abstract]
-[abstract=apdn]Helly my dear followers on ADN. I made sone new pictures 
-that I wanted to share with you.[abstract]
-Today I was in the woods and took some real cool pictures ...
-
- -For Twitter and App.net the system will use the defined abstracts. -For other networks (e.g. when you are using the "statusnet" connector that is used to post to GNU Social) the general abstract element will be used. + + + + + + + + + +
BBCodeResult
+[abstract]Hi friends Here are my newest pictures![/abstract]
+[abstract=twit]Hi my dear Twitter followers. Do you want to see my new +pictures?[/abstract]
+[abstract=apdn]Helly my dear followers on ADN. I made sone new pictures +that I wanted to share with you.[/abstract]
+Today I was in the woods and took some real cool pictures ...
For Twitter and App.net the system will use the defined abstracts.
+For other networks (e.g. when you are using the "statusnet" connector that is used to post to GNU Social) the general abstract element will be used.
If you use (for example) the "buffer" connector to post to Facebook or Google+ you can use this element to define an abstract for a longer blogpost that you don't want to post completely to these networks. -Networks like Facebook or Google+ aren't length limited. -For this reason the [abstract] element isn't used. +Networks like Facebook or Google+ aren't length limited. +For this reason the [abstract] element isn't used. Instead you have to name the explicit network: -
-[abstract]These days I had a strange encounter ...[abstract]
-[abstract=goog]Helly my dear Google+ followers. You have to read my 
-newest blog post![abstract]
-[abstract=face]Hello my Facebook friends. These days happened something 
-really cool.[abstract]
-While taking pictures in the woods I had a really strange encounter ... 
+ + + + + + + + + +
BBCodeResult
+[abstract]These days I had a strange encounter...[/abstract]
+[abstract=goog]Helly my dear Google+ followers. You have to read my newest blog post![/abstract]
+[abstract=face]Hello my Facebook friends. These days happened something really cool.[/abstract]
+While taking pictures in the woods I had a really strange encounter...
Google and Facebook will show the respective abstracts while the other networks will show the default one.
+
Meanwhile, Friendica won't show any of the abstracts.
-The [abstract] element isn't working with the native OStatus connection or with connectors where we post the HTML. -(Like Tumblr, Wordpress or Pump.io) +The [abstract] element isn't working with the native OStatus connection or with connectors where we post the HTML like Tumblr, Wordpress or Pump.io. -Special -------- +## Special -If you need to put literal bbcode in a message, [noparse], [nobb] or [pre] are used to escape bbcode: + + + + + + + + + + + + + + + + + + + + + +
BBCodeResult
If you need to put literal bbcode in a message, [noparse], [nobb] or [pre] are used to escape bbcode:
+
    +
  • [noparse][b]bold[/b][/noparse]
  • +
  • [nobb][b]bold[/b][/nobb]
  • +
  • [pre][b]bold[/b][/pre]
  • +
+
[b]bold[/b]
[nosmile] is used to disable smilies on a post by post basis
+
+ [nosmile] ;-) :-O +
;-) :-O
Custom inline styles
+
+[style=text-shadow: 0 0 4px #CC0000;]You can change all the CSS properties of this block.[/style]
You can change all the CSS properties of this block.
Custom class block
+
+[class=custom]If the class exists, this block will have the custom class style applied.[/class]
<span class="custom">If the class exists,
this block will have the custom class
style applied.</span>
-
[noparse][b]bold[/b][/noparse]
: [b]bold[/b] From 3a2ec5e4db719d09e13f7c17488ebc1cf7a37e26 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Thu, 3 Nov 2016 14:00:20 +0100 Subject: [PATCH 19/21] missing placeholder for name_cache value --- include/enotify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/enotify.php b/include/enotify.php index bcb2ebe7ca..5b2bea2977 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -441,7 +441,7 @@ function notification($params) { // create notification entry in DB $r = q("INSERT INTO `notify` (`hash`, `name`, `url`, `photo`, `date`, `uid`, `link`, `iid`, `parent`, `type`, `verb`, `otype`, `name_cache`) - values('%s', '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s')", + values('%s', '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s')", dbesc($datarray['hash']), dbesc($datarray['name']), dbesc($datarray['url']), @@ -805,4 +805,4 @@ function format_notification_message($name, $message) { } return $message; -} \ No newline at end of file +} From 3579a1494506f8919a9ce2efd5404df7a027d0fe Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 3 Nov 2016 21:01:09 -0400 Subject: [PATCH 20/21] bbcode documentation: minor formatting changes --- include/text.php | 3 ++- view/theme/frio/css/style.css | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/text.php b/include/text.php index 50e2e81931..83eab19270 100644 --- a/include/text.php +++ b/include/text.php @@ -770,7 +770,8 @@ function activity_match($haystack,$needle) { /** - * Pull out all #hashtags and @person tags from $string; + * @brief Pull out all #hashtags and @person tags from $string. + * * We also get @person@domain.com - which would make * the regex quite complicated as tags can also * end a sentence. So we'll run through our results diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index d2467b1355..e284310b86 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -45,7 +45,7 @@ body a { * anchor.top should be the opposite of body.padding-top */ body a[name]:not([href]) { - display: block; + display: block; position: relative; top: -110px; visibility: hidden; From 3d29b7745ccbffe1881798971474475b41aa554e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 4 Nov 2016 11:20:47 -0400 Subject: [PATCH 21/21] bbcode documentation: minor style changes --- doc/BBCode.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/doc/BBCode.md b/doc/BBCode.md index aeb5e06c95..595c2da860 100644 --- a/doc/BBCode.md +++ b/doc/BBCode.md @@ -12,21 +12,21 @@ table.bbcodes { border: 1px solid #aaa; border-collapse: collapse; color: #000; - width: 100%; + width: 100%; } table.bbcodes > tr > th, table.bbcodes > tr > td, table.bbcodes > * > tr > th, table.bbcodes > * > tr > td { - border: 1px solid #aaa; - padding: 0.2em 0.4em + border: 1px solid #aaa; + padding: 0.2em 0.4em } table.bbcodes > tr > th, table.bbcodes > * > tr > th { - background-color: #f2f2f2; - text-align: center + background-color: #f2f2f2; + text-align: center } @@ -522,8 +522,8 @@ This is done with the [abstract]-element. [abstract]Totally interesting! A must-see! Please click the link![/abstract]
I want to tell you a really boring story that you really never wanted to hear. - Twitter would display the text "Totally interesting! A must-see! Please click the link!". -On Friendica you would only see the text after "I want to tell you a really ..." + Twitter would display the text
Totally interesting! A must-see! Please click the link!
+On Friendica you would only see the text after
I want to tell you a really ...
@@ -579,7 +579,7 @@ The [abstract] element isn't working with the native OStatus connection or with Result - If you need to put literal bbcode in a message, [noparse], [nobb] or [pre] are used to escape bbcode:
+ If you need to put literal bbcode in a message, [noparse], [nobb] or [pre] are used to escape bbcode:
  • [noparse][b]bold[/b][/noparse]
  • [nobb][b]bold[/b][/nobb]
  • @@ -608,4 +608,3 @@ The [abstract] element isn't working with the native OStatus connection or with
    <span class="custom">If the class exists,
    this block will have the custom class
    style applied.</span>
    -