From c4ed04fc827ec5a1039959e260702141083836c8 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sat, 3 Jun 2017 10:13:42 +0200 Subject: convert randprof to use chanlink_hash() instead of chanlink_url() and filter sys channels by xchan.xchan_system instead of xchan_addr != sys@% --- Zotlabs/Module/Randprof.php | 2 +- include/connections.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Zotlabs/Module/Randprof.php b/Zotlabs/Module/Randprof.php index dc2e925fe..94ec095cb 100644 --- a/Zotlabs/Module/Randprof.php +++ b/Zotlabs/Module/Randprof.php @@ -8,7 +8,7 @@ class Randprof extends \Zotlabs\Web\Controller { function init() { $x = random_profile(); if($x) - goaway(chanlink_url($x)); + goaway(chanlink_hash($x)); /** FIXME this doesn't work at the moment as a fallback */ goaway(z_root() . '/profile'); diff --git a/include/connections.php b/include/connections.php index 8f4f84e1a..167f7e2c4 100644 --- a/include/connections.php +++ b/include/connections.php @@ -415,9 +415,9 @@ function random_profile() { for($i = 0; $i < $retryrandom; $i++) { - $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_addr not like '%s' and xchan_hidden = 0 and hubloc_connected > %s - interval %s order by $randfunc limit 1", - dbesc('sys@%'), - db_utcnow(), db_quoteinterval('30 day') + $r = q("select xchan_url, xchan_hash from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_hidden = 0 and xchan_system = 0 and hubloc_connected > %s - interval %s order by $randfunc limit 1", + db_utcnow(), + db_quoteinterval('30 day') ); if(!$r) return ''; // Couldn't get a random channel @@ -425,12 +425,12 @@ function random_profile() { if($checkrandom) { $x = z_fetch_url($r[0]['xchan_url']); if($x['success']) - return $r[0]['xchan_url']; + return $r[0]['xchan_hash']; else logger('Random channel turned out to be bad.'); } else { - return $r[0]['xchan_url']; + return $r[0]['xchan_hash']; } } @@ -712,4 +712,4 @@ function vcard_query(&$r) { } } } -} \ No newline at end of file +} -- cgit v1.2.3 From 7562f77bdf7040d5cc63473a3c6ff7c499600f13 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sat, 3 Jun 2017 17:23:53 +0200 Subject: rewrite wiki pages widget - no need for ajax on pageload, show the pages to not authenticated people. --- Zotlabs/Module/Wiki.php | 18 ++++++++------ Zotlabs/Widget/Wiki_pages.php | 57 +++++++++++++++++++++---------------------- view/tpl/wiki.tpl | 19 ++++++--------- view/tpl/wiki_page_list.tpl | 16 +++++++----- 4 files changed, 57 insertions(+), 53 deletions(-) diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index f3b34401d..2f1fa01b7 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -207,9 +207,10 @@ class Wiki extends \Zotlabs\Web\Controller { $ignore_language = true; continue; } - if($page_name) + if($page_name) { $page_name .= '/'; - $page_name .= argv($x); + } + $page_name .= argv($x); } $pageUrlName = urldecode($page_name); @@ -296,7 +297,8 @@ class Wiki extends \Zotlabs\Web\Controller { '$showPageControls' => $showPageControls, '$editOrSourceLabel' => (($showPageControls) ? t('Edit') : t('Source')), '$tools_label' => 'Page Tools', - '$channel' => $owner['channel_address'], + '$channel_address' => $owner['channel_address'], + '$channel_id' => $owner['channel_id'], '$resource_id' => $resource_id, '$page' => $pageUrlName, '$mimeType' => $mimeType, @@ -495,10 +497,12 @@ class Wiki extends \Zotlabs\Web\Controller { $x = new \Zotlabs\Widget\Wiki_pages(); - $page_list_html = $x->widget(array( - 'resource_id' => $resource_id, - 'refresh' => true, - 'channel' => argv(1))); + $page_list_html = $x->widget([ + 'resource_id' => $resource_id, + 'channel_id' => $owner['channel_id'], + 'channel_address' => $owner['channel_address'], + 'refresh' => true + ]); json_return_and_die(array('pages' => $page_list_html, 'message' => '', 'success' => true)); } diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php index f992b3f93..53966b06f 100644 --- a/Zotlabs/Widget/Wiki_pages.php +++ b/Zotlabs/Widget/Wiki_pages.php @@ -7,58 +7,57 @@ class Wiki_pages { function widget($arr) { - $channelname = ((array_key_exists('channel',$arr)) ? $arr['channel'] : ''); - $c = channelx_by_nick($channelname); + if(argc() < 3) + return; + + if(! $arr['resource_id']) { - if(! $c) $c = \App::get_channel(); - if(! $c) - return ''; + if(! $c) + $c = channelx_by_nick(argv(1)); - $wikiname = ''; - if(array_key_exists('refresh', $arr)) { - $not_refresh = (($arr['refresh']=== true) ? false : true); - } - else { - $not_refresh = true; + $w = \Zotlabs\Lib\NativeWiki::exists_by_name($c['channel_id'],argv(2)); + + $arr = array( + 'resource_id' => $w['resource_id'], + 'channel_id' => $c['channel_id'], + 'channel_address' => $c['channel_address'], + 'refresh' => false + ); } + $wikiname = ''; + $pages = array(); - if(! array_key_exists('resource_id', $arr)) { - $hide = true; - } - else { - $p = \Zotlabs\Lib\NativeWikiPage::page_list($c['channel_id'],get_observer_hash(),$arr['resource_id']); - - if($p['pages']) { - $pages = $p['pages']; - $w = $p['wiki']; - // Wiki item record is $w['wiki'] - $wikiname = $w['urlName']; - if (!$wikiname) { - $wikiname = ''; - } + + $p = \Zotlabs\Lib\NativeWikiPage::page_list($arr['channel_id'],get_observer_hash(),$arr['resource_id']); + + if($p['pages']) { + $pages = $p['pages']; + $w = $p['wiki']; + // Wiki item record is $w['wiki'] + $wikiname = $w['urlName']; + if (!$wikiname) { + $wikiname = ''; } } - $can_create = perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'write_wiki'); $can_delete = ((local_channel() && (local_channel() == \App::$profile['uid'])) ? true : false); return replace_macros(get_markup_template('wiki_page_list.tpl'), array( - '$hide' => $hide, '$resource_id' => $arr['resource_id'], - '$not_refresh' => $not_refresh, '$header' => t('Wiki Pages'), - '$channel' => $channelname, + '$channel_address' => $arr['channel_address'], '$wikiname' => $wikiname, '$pages' => $pages, '$canadd' => $can_create, '$candel' => $can_delete, '$addnew' => t('Add new page'), '$pageName' => array('pageName', t('Page name')), + '$refresh' => $arr['refresh'] )); } } diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index 564db3324..7cd3708b8 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -115,7 +115,7 @@ }); $( "#rename-page-form" ).submit(function( event ) { - $.post("wiki/{{$channel}}/rename/page", + $.post("wiki/{{$channel_address}}/rename/page", { oldName: window.wiki_page_name, newName: $('#id_pageRename').val(), @@ -177,7 +177,7 @@ }); $('#wiki-get-preview').click(function (ev) { - $.post("wiki/{{$channel}}/preview", { + $.post("wiki/{{$channel_address}}/preview", { {{if !$mimeType || $mimeType == 'text/markdown'}} content: editor.getValue(), {{else}} @@ -200,7 +200,7 @@ }); $('#wiki-get-history').click(function (ev) { - $.post("wiki/{{$channel}}/history/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id}, function (data) { + $.post("wiki/{{$channel_address}}/history/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id}, function (data) { if (data.success) { $('#page-history-list').html(data.historyHTML); $('#page-tools').hide(); @@ -215,10 +215,9 @@ if (window.wiki_resource_id === '') { return false; } - $.post("wiki/{{$channel}}/get/page/list/", {resource_id: window.wiki_resource_id}, function (data) { + $.post("wiki/{{$channel_address}}/get/page/list/", {channel_id: '{{$channel_id}}', resource_id: window.wiki_resource_id}, function (data) { if (data.success) { - $('#wiki_page_list_container').html(data.pages); - $('#wiki_page_list_container').show(); + $('#wiki_page_list').html(data.pages); } else { alert('Error fetching page list!'); window.console.log('Error fetching page list!'); @@ -245,7 +244,7 @@ ev.preventDefault(); return false; } - $.post("wiki/{{$channel}}/save/page", { + $.post("wiki/{{$channel_address}}/save/page", { content: currentContent, commitMsg: $('#id_commitMsg').val(), name: window.wiki_page_name, @@ -276,7 +275,7 @@ window.console.log('You must have a wiki page open in order to revert pages.'); return false; } - $.post("wiki/{{$channel}}/revert/page", {commitHash: commitHash, name: window.wiki_page_name, resource_id: window.wiki_resource_id}, + $.post("wiki/{{$channel_address}}/revert/page", {commitHash: commitHash, name: window.wiki_page_name, resource_id: window.wiki_resource_id}, function (data) { if (data.success) { $('button[id^=revert-]').removeClass('btn-success'); @@ -299,7 +298,7 @@ window.console.log('You must have a wiki page open in order to revert pages.'); return false; } - $.post("wiki/{{$channel}}/compare/page", { + $.post("wiki/{{$channel_address}}/compare/page", { compareCommit: compareCommit, currentCommit: window.wiki_page_commit, name: window.wiki_page_name, @@ -442,8 +441,6 @@ }; $(document).ready(function () { - wiki_refresh_page_list(); - {{if !$mimeType || $mimeType == 'text/markdown'}} $("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"}); window.editor.on("input", function() { diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl index 44fba15cc..6d09fcd5d 100644 --- a/view/tpl/wiki_page_list.tpl +++ b/view/tpl/wiki_page_list.tpl @@ -1,5 +1,6 @@ -{{if $not_refresh}}{{/if}} +{{/if}} +{{if $canadd}} +{{/if}} -- cgit v1.2.3 From e8a4e9a31f57e53e076b440fc3b728044c42adda Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sun, 4 Jun 2017 12:52:52 +0200 Subject: class mixup --- view/tpl/nav.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl index 39fe686a9..4719e1b17 100755 --- a/view/tpl/nav.tpl +++ b/view/tpl/nav.tpl @@ -233,7 +233,7 @@ {{if $localuser}} {{$addapps}} - {{$orderapps}} + {{$orderapps}} {{/if}} -- cgit v1.2.3 From e7c3ca9bd832f83bf2f66d6a06761062f2118185 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sun, 4 Jun 2017 16:39:52 +0200 Subject: fix allow setting a default schema for the hub (issue #797) and allow selecting of focus (hubzilla default) schema if a default is set. --- view/theme/redbasic/php/config.php | 15 +++++++++++++-- view/theme/redbasic/php/style.php | 7 +++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/view/theme/redbasic/php/config.php b/view/theme/redbasic/php/config.php index 752a02a6a..8dbe1be9c 100644 --- a/view/theme/redbasic/php/config.php +++ b/view/theme/redbasic/php/config.php @@ -5,10 +5,20 @@ namespace Zotlabs\Theme; class RedbasicConfig { function get_schemas() { - $scheme_choices = array(); - $scheme_choices["---"] = t("Focus (Hubzilla default)"); $files = glob('view/theme/redbasic/schema/*.php'); + + $scheme_choices = []; + if($files) { + + if(in_array('view/theme/redbasic/schema/default.php', $files)) { + $scheme_choices['---'] = t('Default'); + $scheme_choices['focus'] = t('Focus (Hubzilla default)'); + } + else { + $scheme_choices['---'] = t('Focus (Hubzilla default)'); + } + foreach($files as $file) { $f = basename($file, ".php"); if($f != 'default') { @@ -17,6 +27,7 @@ class RedbasicConfig { } } } + return $scheme_choices; } diff --git a/view/theme/redbasic/php/style.php b/view/theme/redbasic/php/style.php index a666f96f2..06cf23ba2 100644 --- a/view/theme/redbasic/php/style.php +++ b/view/theme/redbasic/php/style.php @@ -56,10 +56,9 @@ if (($schema) && ($schema != '---')) { } -// If we haven't got a schema, load the default. We shouldn't touch this - we -// should leave it for admins to define for themselves. -// default.php and default.css MUST be symlinks to existing schema files. -if (! $schema) { +// Allow admins to set a default schema for the hub. +// default.php and default.css MUST be symlinks to existing schema files in view/theme/redbasic/schema +if ((!$schema) || ($schema == '---')) { if(file_exists('view/theme/redbasic/schema/default.php')) { $schemefile = 'view/theme/redbasic/schema/default.php'; -- cgit v1.2.3 From 10ecb6d3681788ae535f4168bd85f6f2fc22232f Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sun, 4 Jun 2017 16:58:59 +0200 Subject: remove duplicate code --- include/nav.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/include/nav.php b/include/nav.php index 91bade5a7..2eba2894c 100644 --- a/include/nav.php +++ b/include/nav.php @@ -215,18 +215,6 @@ EOT; $nav['admin'] = array('admin/', t('Admin'), "", t('Site Setup and Configuration'),'admin_nav_btn'); } - - /** - * - * Provide a banner/logo/whatever - * - */ - - $banner = get_config('system','banner'); - - if($banner === false) - $banner = get_config('system','sitename'); - $x = array('nav' => $nav, 'usermenu' => $userinfo ); call_hooks('nav', $x); -- cgit v1.2.3 From 4784f847c9d752c34ff4eeec8a6c40455fe313ce Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sun, 4 Jun 2017 17:15:33 +0200 Subject: fix nav-tabs for dark scheme --- view/theme/redbasic/schema/dark.css | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/view/theme/redbasic/schema/dark.css b/view/theme/redbasic/schema/dark.css index ebef68a52..4154c88fa 100644 --- a/view/theme/redbasic/schema/dark.css +++ b/view/theme/redbasic/schema/dark.css @@ -270,26 +270,20 @@ nav .dropdown-menu { background: #999; } -.nav-tabs{ +.nav-tabs { border-bottom:1px solid #333; } -.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{ - border:1px solid #333; -} - -.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus { +.nav-tabs .nav-link.active { color: #fff; - background-color: #111; -} - -.nav-tabs.nav-justified > li > a { - color: #ccc; + background-color: #111; + border-color: #333; } -.nav-tabs > li > a:hover, .nav-tabs > li > a:focus { - text-decoration: underline; - background-color: #222; +.nav-tabs .nav-link:hover, +.nav-tabs .nav-link:focus { + text-decoration: underline; + background-color: #222; color: #ccc; border-color: #333; } -- cgit v1.2.3