diff options
-rw-r--r-- | Zotlabs/Daemon/Notifier.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Display.php | 167 | ||||
-rw-r--r-- | Zotlabs/Module/Item.php | 46 | ||||
-rw-r--r-- | Zotlabs/Module/Wfinger.php | 7 | ||||
-rw-r--r-- | include/contact_widgets.php | 8 | ||||
-rw-r--r-- | include/features.php | 9 | ||||
-rw-r--r-- | include/markdown.php | 11 | ||||
-rw-r--r-- | include/network.php | 4 | ||||
-rw-r--r-- | include/text.php | 2 | ||||
-rwxr-xr-x | view/tpl/atom_feed.tpl | 2 | ||||
-rwxr-xr-x | view/tpl/photo_album_portfolio.tpl | 40 | ||||
-rw-r--r-- | view/tpl/photo_portfolio_card.tpl | 6 | ||||
-rw-r--r-- | view/tpl/photo_portfolio_orbit.tpl | 5 |
13 files changed, 212 insertions, 99 deletions
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 84212270f..d0175549b 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -433,7 +433,7 @@ class Notifier { $env_recips = (($private) ? array() : null); - $details = q("select xchan_hash, xchan_instance_url, xchan_network, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . implode(',',$recipients) . ")"); + $details = q("select xchan_hash, xchan_instance_url, xchan_network, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . protect_sprintf(implode(',',$recipients)) . ")"); $recip_list = array(); @@ -500,7 +500,7 @@ class Notifier { // Now we have collected recipients (except for external mentions, FIXME) // Let's reduce this to a set of hubs; checking that the site is not dead. - $r = q("select hubloc.*, site.site_crypto, site.site_flags from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ") + $r = q("select hubloc.*, site.site_crypto, site.site_flags from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . protect_sprintf(implode(',',$recipients)) . ") and hubloc_error = 0 and hubloc_deleted = 0 and ( site_dead = 0 OR site_dead is null ) " ); diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index d5afdd787..785274105 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -12,6 +12,12 @@ class Display extends \Zotlabs\Web\Controller { function get($update = 0, $load = false) { + if(argc() > 1) { + $module_format = substr(argv(1),strrpos(argv(1),'.') + 1); + if(! in_array($module_format,['atom','zot','json'])) + $module_format = 'html'; + } + $checkjs = new \Zotlabs\Web\CheckJS(1); if($load) @@ -22,8 +28,12 @@ class Display extends \Zotlabs\Web\Controller { return; } - if(argc() > 1 && argv(1) !== 'load') + if(argc() > 1 && argv(1) !== 'load') { $item_hash = argv(1); + if($module_format !== 'html') { + $item_hash = substr($item_hash,0,strrpos($item_hash,'.')); + } + } if($_REQUEST['mid']) $item_hash = $_REQUEST['mid']; @@ -44,28 +54,28 @@ class Display extends \Zotlabs\Web\Controller { $channel_acl = array( 'allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], - 'deny_cid' => $channel['channel_deny_cid'], - 'deny_gid' => $channel['channel_deny_gid'] + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] ); $x = array( - 'is_owner' => true, - 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), - 'default_location' => $channel['channel_location'], - 'nickname' => $channel['channel_address'], - 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + 'is_owner' => true, + 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), + 'default_location' => $channel['channel_location'], + 'nickname' => $channel['channel_address'], + 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'acl' => populate_acl($channel_acl), - 'permissions' => $channel_acl, - 'bang' => '', - 'visitor' => true, - 'profile_uid' => local_channel(), - 'return_path' => 'channel/' . $channel['channel_address'], - 'expanded' => true, + 'acl' => populate_acl($channel_acl), + 'permissions' => $channel_acl, + 'bang' => '', + 'visitor' => true, + 'profile_uid' => local_channel(), + 'return_path' => 'channel/' . $channel['channel_address'], + 'expanded' => true, 'editor_autocomplete' => true, - 'bbco_autocomplete' => 'bbcode', - 'bbcode' => true, - 'jotnets' => true + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true, + 'jotnets' => true ); $o = '<div id="jot-popup">'; @@ -139,10 +149,11 @@ class Display extends \Zotlabs\Web\Controller { $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); - //if the target item is not a post (eg a like) we want to address its thread parent + // if the target item is not a post (eg a like) we want to address its thread parent + $mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); - //if we got a decoded hash we must encode it again before handing to javascript + // if we got a decoded hash we must encode it again before handing to javascript if($decoded) $mid = 'b64.' . base64url_encode($mid); @@ -152,32 +163,32 @@ class Display extends \Zotlabs\Web\Controller { \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( '$baseurl' => z_root(), - '$pgtype' => 'display', - '$uid' => '0', - '$gid' => '0', - '$cid' => '0', - '$cmin' => '0', - '$cmax' => '99', - '$star' => '0', - '$liked' => '0', - '$conv' => '0', - '$spam' => '0', - '$fh' => '0', + '$pgtype' => 'display', + '$uid' => '0', + '$gid' => '0', + '$cid' => '0', + '$cmin' => '0', + '$cmax' => '99', + '$star' => '0', + '$liked' => '0', + '$conv' => '0', + '$spam' => '0', + '$fh' => '0', '$nouveau' => '0', - '$wall' => '0', - '$static' => $static, - '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), - '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), - '$search' => '', - '$xchan' => '', - '$order' => '', - '$file' => '', - '$cats' => '', - '$tags' => '', - '$dend' => '', - '$dbegin' => '', - '$verb' => '', - '$mid' => $mid + '$wall' => '0', + '$static' => $static, + '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), + '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), + '$search' => '', + '$xchan' => '', + '$order' => '', + '$file' => '', + '$cats' => '', + '$tags' => '', + '$dend' => '', + '$dbegin' => '', + '$verb' => '', + '$mid' => $mid )); head_add_link([ @@ -195,11 +206,11 @@ class Display extends \Zotlabs\Web\Controller { $sql_extra = public_permissions_sql($observer_hash); - if(($update && $load) || ($checkjs->disabled())) { + if(($update && $load) || ($checkjs->disabled()) || ($module_format !== 'html')) { $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']),intval(\App::$pager['start'])); - if($load || ($checkjs->disabled())) { + if($load || ($checkjs->disabled()) || ($module_format !== 'html')) { $r = null; require_once('include/channel.php'); @@ -311,13 +322,61 @@ class Display extends \Zotlabs\Web\Controller { $items = array(); } - if ($checkjs->disabled()) { - $o .= conversation($items, 'display', $update, 'traditional'); - if ($items[0]['title']) - \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; - } - else { - $o .= conversation($items, 'display', $update, 'client'); + + switch($module_format) { + + case 'html': + + if ($checkjs->disabled()) { + $o .= conversation($items, 'display', $update, 'traditional'); + if ($items[0]['title']) + \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; + } + else { + $o .= conversation($items, 'display', $update, 'client'); + } + + break; + + case 'atom': + + $atom = replace_macros(get_markup_template('atom_feed.tpl'), array( + '$version' => xmlify(\Zotlabs\Lib\System::get_project_version()), + '$red' => xmlify(\Zotlabs\Lib\System::get_platform_name()), + '$feed_id' => xmlify(\App::$cmd), + '$feed_title' => xmlify(t('Article')), + '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)), + '$author' => '', + '$owner' => '', + '$profile_page' => xmlify(z_root() . '/display/' . $target_item['mid']), + )); + + $x = [ 'xml' => $atom, 'channel' => $channel, 'observer_hash' => $observer_hash, 'params' => $params ]; + call_hooks('atom_feed_top',$x); + + $atom = $x['xml']; + + // a much simpler interface + call_hooks('atom_feed', $atom); + + + if($items) { + $type = 'html'; + foreach($items as $item) { + if($item['item_private']) + continue; + $atom .= atom_entry($item, $type, null, '', true, '', false); + } + } + + call_hooks('atom_feed_end', $atom); + + $atom .= '</feed>' . "\r\n"; + + header('Content-type: application/atom+xml'); + echo $atom; + killme(); + } if($updateable) { diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9e5dcfaff..b54de0fb9 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -511,48 +511,20 @@ class Item extends \Zotlabs\Web\Controller { require_once('include/text.php'); - // Markdown doesn't work correctly. Do not re-enable unless you're willing to fix it and support it. - - // Sample that will probably give you grief - you must preserve the linebreaks - // and provide the correct markdown interpretation and you cannot allow unfiltered HTML - - // Markdown - // ======== - // - // **bold** abcde - // fghijkl - // *italic* - // <img src="javascript:alert('hacked');" /> - - // if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { - // require_once('include/markdown.php'); - // $body = escape_tags(trim($body)); - // $body = str_replace("\n",'<br />', $body); - // $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body); - // $body = markdown_to_bb($body,true); - // $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body); - // } + if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { + require_once('include/markdown.php'); + $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body); + $body = markdown_to_bb($body,true,['preserve_lf' => true]); + $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body); + + } // BBCODE alert: the following functions assume bbcode input // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - - // Work around doubled linefeeds in Tinymce 3.5b2 - // First figure out if it's a status post that would've been - // created using tinymce. Otherwise leave it alone. - - $plaintext = true; - - // $plaintext = ((feature_enabled($profile_uid,'richtext')) ? false : true); - // if((! $parent) && (! $api_source) && (! $plaintext)) { - // $body = fix_mce_lf($body); - // } - - - + // If we're sending a private top-level message with a single @-taggable channel as a recipient, @-tag it, if our pconfig is set. - - + if((! $parent) && (get_pconfig($profile_uid,'system','tagifonlyrecip')) && (substr_count($str_contact_allow,'<') == 1) && ($str_group_allow == '') && ($str_contact_deny == '') && ($str_group_deny == '')) { $x = q("select abook_id, abconfig.v from abook left join abconfig on abook_xchan = abconfig.xchan and abook_channel = abconfig.chan and cat= 'their_perms' and abconfig.k = 'tag_deliver' and abconfig.v = 1 and abook_xchan = '%s' and abook_channel = %d limit 1", dbesc(str_replace(array('<','>'),array('',''),$str_contact_allow)), diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 9db95f181..753721d27 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -165,6 +165,13 @@ class Wfinger extends \Zotlabs\Web\Controller { ], [ + 'rel' => 'http://microformats.org/profile/hcard', + 'type' => 'text/html', + 'href' => z_root() . '/hcard/' . $r[0]['channel_address'] + ], + + + [ 'rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address'], ], diff --git a/include/contact_widgets.php b/include/contact_widgets.php index a13f87573..9cc9f0baf 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -65,6 +65,10 @@ function categories_widget($baseurl,$selected = '') { if(! feature_enabled(App::$profile['profile_uid'],'categories')) return ''; + require_once('include/security.php'); + + $sql_extra = item_permissions_sql(App::$profile['profile_uid']); + $item_normal = item_normal(); $terms = array(); @@ -77,6 +81,7 @@ function categories_widget($baseurl,$selected = '') { and item.owner_xchan = '%s' and item.item_wall = 1 $item_normal + $sql_extra order by term.term asc", intval(App::$profile['profile_uid']), intval(TERM_CATEGORY), @@ -105,6 +110,8 @@ function cardcategories_widget($baseurl,$selected = '') { if(! feature_enabled(App::$profile['profile_uid'],'categories')) return ''; + $sql_extra = item_permissions_sql(App::$profile['profile_uid']); + $item_normal = "and item.item_hidden = 0 and item.item_type = 6 and item.item_deleted = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 and item.item_blocked = 0 "; @@ -118,6 +125,7 @@ function cardcategories_widget($baseurl,$selected = '') { and term.otype = %d and item.owner_xchan = '%s' $item_normal + $sql_extra order by term.term asc", intval(App::$profile['profile_uid']), intval(TERM_CATEGORY), diff --git a/include/features.php b/include/features.php index f84c9cb05..d8d98dbaa 100644 --- a/include/features.php +++ b/include/features.php @@ -364,6 +364,15 @@ function get_features($filtered = true) { t('Post/Comment Tools'), [ + 'markdown', + t('Markdown'), + t('Use markdown for editing posts'), + false, + get_config('feature_lock','markdown'), + feature_level('markdown',2), + ], + + [ 'commtag', t('Community Tagging'), t('Ability to tag existing posts'), diff --git a/include/markdown.php b/include/markdown.php index 0cd9ab237..0464cf71a 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -49,14 +49,17 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = $x['text']; - // Escaping the hash tags - doesn't always seem to work - // $s = preg_replace('/\#([^\s\#])/','\\#$1',$s); - // This seems to work + // Escaping the hash tags $s = preg_replace('/\#([^\s\#])/','#$1',$s); $s = MarkdownExtra::defaultTransform($s); - $s = str_replace("\r","",$s); + if($options && $options['preserve_lf']) { + $s = str_replace(["\r","\n"],["",'<br>'],$s); + } + else { + $s = str_replace("\r","",$s); + } $s = str_replace('#','#',$s); diff --git a/include/network.php b/include/network.php index 7e2dbf4cf..2f29a70c4 100644 --- a/include/network.php +++ b/include/network.php @@ -716,6 +716,10 @@ function scale_external_images($s, $include_link = true, $scale_replace = false) $scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[3]); else $scaled = $mtch[3]; + + if(! strpbrk(substr($scaled,0,1),'zhfmt')) + continue; + $i = z_fetch_url($scaled,true); diff --git a/include/text.php b/include/text.php index 8a65be0d5..d81b59d75 100644 --- a/include/text.php +++ b/include/text.php @@ -2846,7 +2846,7 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') { */ function sanitise_acl(&$item) { if (strlen($item)) - $item = '<' . notags(trim($item)) . '>'; + $item = '<' . notags(trim(urldecode($item))) . '>'; else unset($item); } diff --git a/view/tpl/atom_feed.tpl b/view/tpl/atom_feed.tpl index fe38fdc80..b1e92cdbf 100755 --- a/view/tpl/atom_feed.tpl +++ b/view/tpl/atom_feed.tpl @@ -15,7 +15,9 @@ <title>{{$feed_title}}</title> <generator uri="http://hubzilla.org" version="{{$version}}">{{$red}}</generator> <link rel="license" href="http://creativecommons.org/licenses/by/3.0/" /> + {{if $profile_page}} <link rel="alternate" type="text/html" href="{{$profile_page}}" /> + {{/if}} {{if $author}} {{$author}} {{/if}} diff --git a/view/tpl/photo_album_portfolio.tpl b/view/tpl/photo_album_portfolio.tpl index 7aadbc7e0..1635e0ae1 100755 --- a/view/tpl/photo_album_portfolio.tpl +++ b/view/tpl/photo_album_portfolio.tpl @@ -1,3 +1,39 @@ +{{if isset($mode) && $mode == 'orbit'}} +<div class="row"> + <div class="orbit small-12 medium-9 large-9 columns" id="photo-album-contents-{{$album_id}}" role="region" aria-label="portfolioOrbit-{{$album_id}}" data-orbit data-options="animInFromLeft:fade-in; animInFromRight:fade-in; animOutToLeft:fade-out; animOutToRight:fade-out;"> + + <ul class="orbit-container"> + <button class="orbit-previous"><span class="show-for-sr">Previous Slide</span>◀︎</button> + <button class="orbit-next"><span class="show-for-sr">Next Slide</span>▶︎</button> + {{foreach $photos as $photo}} + {{include file="photo_portfolio_orbit.tpl"}} + {{/foreach}} + </ul> + <nav class="orbit-bullets"> + <button class="is-active" data-slide="0"><span class="show-for-sr">First slide details.</span><span class="show-for-sr">Current Slide</span></button> + <button data-slide="1"><span class="show-for-sr">Second slide details.</span></button> + <button data-slide="2"><span class="show-for-sr">Third slide details.</span></button> + <button data-slide="3"><span class="show-for-sr">Fourth slide details.</span></button> + </nav> + <div id="page-end"></div> + </div> +<div class="photos-end"></div> +<script>$(document).ready(function() { loadingPage = false; justifyPhotos('photo-album-contents-{{$album_id}}'); });</script> +<div id="page-spinner"></div> +</div> +{{elseif isset($mode) && $mode =='card'}} +<div class="row"> + <div class="small-12 medium-9 large-9 columns" id="photo-album-contents-{{$album_id}}"> + {{foreach $photos as $photo}} + {{include file="photo_portfolio_card.tpl"}} + {{/foreach}} + <div id="page-end"></div> + </div> +<div class="photos-end"></div> +<script>$(document).ready(function() { loadingPage = false; justifyPhotos('photo-album-contents-{{$album_id}}'); });</script> +<div id="page-spinner"></div> +</div> +{{else}} <div class="row column"> <div id="photo-album-contents-{{$album_id}}"> {{foreach $photos as $photo}} @@ -8,4 +44,6 @@ <div class="photos-end"></div> <script>$(document).ready(function() { loadingPage = false; justifyPhotos('photo-album-contents-{{$album_id}}'); });</script> <div id="page-spinner"></div> -</div>
\ No newline at end of file +</div> +{{/if}} + diff --git a/view/tpl/photo_portfolio_card.tpl b/view/tpl/photo_portfolio_card.tpl new file mode 100644 index 000000000..5fddd3d37 --- /dev/null +++ b/view/tpl/photo_portfolio_card.tpl @@ -0,0 +1,6 @@ +<div class="card" style="width: 300px;box-shadow: 0px 10px 6px -6px rgba(119,119,119,0.6);border-style: solid;border-width: 1px;border=color: rgba(230,230,230,0.6);margin:10px 5px 10px 5px;"> + <img src="{{$photo.src}}" alt="{{if $photo.album.name}}{{$photo.album.name}}{{elseif $photo.desc}}{{$photo.desc}}{{elseif $photo.alt}}{{$photo.alt}}{{else}}{{$photo.unknown}}{{/if}}" title="{{$photo.desc}}" id="photo-top-photo-{{$photo.resource_id}}"> + <div class="card-divider"> + <h4>{{$photo.desc}}</h4> + </div> +</div> diff --git a/view/tpl/photo_portfolio_orbit.tpl b/view/tpl/photo_portfolio_orbit.tpl new file mode 100644 index 000000000..b2883265c --- /dev/null +++ b/view/tpl/photo_portfolio_orbit.tpl @@ -0,0 +1,5 @@ + + <li class="orbit-slide"> + <img class="orbit-image" src="{{$photo.src}}" alt="{{if $photo.album.name}}{{$photo.album.name}}{{elseif $photo.desc}}{{$photo.desc}}{{elseif $photo.alt}}{{$photo.alt}}{{else}}{{$photo.unknown}}{{/if}}" title="{{$photo.desc}}" id="photo-top-photo-{{$photo.resource_id}}o"> + <figcaption class="orbit-caption">{{$photo.desc}}</figcaption> + </li> |