Merge branch 'dev' of /home/macgirvin/z into dev

This commit is contained in:
nobody 2021-09-08 01:39:37 -07:00
commit 0a69c8c535
24 changed files with 846 additions and 766 deletions

View file

@ -4133,24 +4133,40 @@ class Activity {
} }
static function get_actor_hublocs($url, $options = 'all') { static function get_actor_hublocs($url, $options = 'all,not_deleted') {
$hublocs = false; $hublocs = false;
$sql_options = EMPTY_STR;
$options_arr = explode(',',$options);
if (count($options_arr) > 1) {
for ($x = 1; $x < count($options_arr); $x ++) {
switch (trim($options_arr[$x])) {
case 'not_deleted':
$sql_options .= ' and hubloc_deleted = 0 ';
break;
default:
break;
}
}
}
switch ($options) {
switch (trim($options_arr[0])) {
case 'activitypub': case 'activitypub':
$hublocs = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_hash = '%s' ", $hublocs = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_hash = '%s' $sql_options ",
dbesc($url) dbesc($url)
); );
break; break;
case 'zot6': case 'zot6':
$hublocs = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_id_url = '%s' ", $hublocs = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_id_url = '%s' $sql_options ",
dbesc($url) dbesc($url)
); );
break; break;
case 'all': case 'all':
default: default:
$hublocs = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where ( hubloc_id_url = '%s' OR hubloc_hash = '%s' ) ", $hublocs = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where ( hubloc_id_url = '%s' OR hubloc_hash = '%s' ) $sql_options ",
dbesc($url), dbesc($url),
dbesc($url) dbesc($url)
); );

View file

@ -686,6 +686,8 @@ class Channel {
'$vnotify14' => array('vnotify14', t('Unseen likes and dislikes'), ($vnotify & VNOTIFY_LIKE), VNOTIFY_LIKE, '', $yes_no), '$vnotify14' => array('vnotify14', t('Unseen likes and dislikes'), ($vnotify & VNOTIFY_LIKE), VNOTIFY_LIKE, '', $yes_no),
'$vnotify15' => array('vnotify15', t('Unseen forum posts'), ($vnotify & VNOTIFY_FORUMS), VNOTIFY_FORUMS, '', $yes_no), '$vnotify15' => array('vnotify15', t('Unseen forum posts'), ($vnotify & VNOTIFY_FORUMS), VNOTIFY_FORUMS, '', $yes_no),
'$vnotify16' => ((is_site_admin()) ? array('vnotify16', t('Reported content'), ($vnotify & VNOTIFY_REPORTS), VNOTIFY_REPORTS, '', $yes_no) : [] ), '$vnotify16' => ((is_site_admin()) ? array('vnotify16', t('Reported content'), ($vnotify & VNOTIFY_REPORTS), VNOTIFY_REPORTS, '', $yes_no) : [] ),
'$desktop_notifications_info' => t('Desktop notifications are unavailable because the required browser permission has not been granted'),
'$desktop_notifications_request' => t('Grant permission'),
'$mailhost' => [ 'mailhost', t('Email notifications sent from (hostname)'), get_pconfig(local_channel(),'system','email_notify_host',App::get_hostname()), sprintf( t('If your channel is mirrored to multiple locations, set this to your preferred location. This will prevent duplicate email notifications. Example: %s'),App::get_hostname()) ], '$mailhost' => [ 'mailhost', t('Email notifications sent from (hostname)'), get_pconfig(local_channel(),'system','email_notify_host',App::get_hostname()), sprintf( t('If your channel is mirrored to multiple locations, set this to your preferred location. This will prevent duplicate email notifications. Example: %s'),App::get_hostname()) ],
'$always_show_in_notices' => array('always_show_in_notices', t('Show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$always_show_in_notices' => array('always_show_in_notices', t('Show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no),
'$permit_all_mentions' => [ 'permit_all_mentions', t('Accept messages from strangers which mention me'), get_pconfig(local_channel(),'system','permit_all_mentions'), t('This setting bypasses normal permissions'), $yes_no ], '$permit_all_mentions' => [ 'permit_all_mentions', t('Accept messages from strangers which mention me'), get_pconfig(local_channel(),'system','permit_all_mentions'), t('This setting bypasses normal permissions'), $yes_no ],

View file

@ -109,7 +109,7 @@ class Sites extends \Zotlabs\Web\Controller {
} }
$o = replace_macros(get_markup_template('sitentry_header.tpl'), [ $o = replace_macros(get_markup_template('sitentry_header.tpl'), [
'$dirlbl' => 'Affiliated Sites', '$dirlbl' => t('Affiliated Sites'),
'$desc' => $desc, '$desc' => $desc,
'$entries' => $j, '$entries' => $j,
]); ]);

View file

@ -17,7 +17,7 @@ use Zotlabs\Daemon\Run;
* @brief This file defines some global constants and includes the central App class. * @brief This file defines some global constants and includes the central App class.
*/ */
define ( 'STD_VERSION', '21.09.03' ); define ( 'STD_VERSION', '21.09.06' );
define ( 'ZOT_REVISION', '10.0' ); define ( 'ZOT_REVISION', '10.0' );
define ( 'DB_UPDATE_VERSION', 1251 ); define ( 'DB_UPDATE_VERSION', 1251 );

View file

@ -1711,7 +1711,12 @@ function bbcode($Text, $options = []) {
// Check for highlighted text // Check for highlighted text
if (strpos($Text,'[/hl]') !== false) { if (strpos($Text,'[/hl]') !== false) {
$Text = preg_replace("(\[hl\](.*?)\[\/hl\])ism", "<span style=\"background-color: yellow;\">$1</span>", $Text); $Text = preg_replace("(\[hl\](.*?)\[\/hl\])ism", "<span style=\"background-color: yellow;\">$1</span>", $Text);
$Text = preg_replace_callback("(\[hl=(.*?)\](.*?)\[\/hl\])ism", 'bb_hltag', $Text); $Text = preg_replace_callback("(\[mark=(.*?)\](.*?)\[\/mark\])ism", 'bb_hltag', $Text);
}
// Check for highlighted text
if (strpos($Text,'[/mark]') !== false) {
$Text = preg_replace("(\[mark\](.*?)\[\/mark\])ism", "<mark style=\"background-color: yellow;\">$1</mark>", $Text);
$Text = preg_replace_callback("(\[mark=(.*?)\](.*?)\[\/mark\])ism", 'bb_hltag', $Text);
} }
// Check for sized text // Check for sized text

View file

@ -2,6 +2,7 @@
function js_strings() { function js_strings() {
return replace_macros(get_markup_template('js_strings.tpl'), array( return replace_macros(get_markup_template('js_strings.tpl'), array(
'$icon' => '/images/' . PLATFORM_NAME . '-64.png',
'$delitem' => t('Delete this item?'), '$delitem' => t('Delete this item?'),
'$comment' => t('Comment'), '$comment' => t('Comment'),
'$showmore' => sprintf( t('%s show all'), '<i class=\'fa fa-chevron-down\'></i>'), '$showmore' => sprintf( t('%s show all'), '<i class=\'fa fa-chevron-down\'></i>'),

View file

@ -109,12 +109,12 @@ function nav($template = 'default') {
$nav['logout'] = ['logout',t('Logout'), "", t('End this session'),'logout_nav_btn']; $nav['logout'] = ['logout',t('Logout'), "", t('End this session'),'logout_nav_btn'];
// user menu // user menu
$nav['usermenu'][] = ['profile/' . $channel['channel_address'], t('View Profile'), ((\App::$nav_sel['raw_name'] == 'Profile') ? 'active' : ''), t('Your profile page'),'profile_nav_btn']; $nav['usermenu'][] = ['profile/' . $channel['channel_address'], t('View Profile'), ((App::$nav_sel['raw_name'] == 'Profile') ? 'active' : ''), t('Your profile page'),'profile_nav_btn'];
if(feature_enabled(local_channel(),'multi_profiles')) if(feature_enabled(local_channel(),'multi_profiles'))
$nav['usermenu'][] = ['profiles', t('Edit Profiles'), ((\App::$nav_sel['raw_name'] == 'Profiles') ? 'active' : '') , t('Manage/Edit profiles'),'profiles_nav_btn']; $nav['usermenu'][] = ['profiles', t('Edit Profiles'), ((App::$nav_sel['raw_name'] == 'Profiles') ? 'active' : '') , t('Manage/Edit profiles'),'profiles_nav_btn'];
else else
$nav['usermenu'][] = ['profiles/' . $prof[0]['id'], t('Edit Profile'), ((\App::$nav_sel['raw_name'] == 'Profiles') ? 'active' : ''), t('Edit your profile'),'profiles_nav_btn']; $nav['usermenu'][] = ['profiles/' . $prof[0]['id'], t('Edit Profile'), ((App::$nav_sel['raw_name'] == 'Profiles') ? 'active' : ''), t('Edit your profile'),'profiles_nav_btn'];
} }
else { else {
@ -252,7 +252,7 @@ function nav($template = 'default') {
if($pinned_list) { if($pinned_list) {
foreach($pinned_list as $app) { foreach($pinned_list as $app) {
if(\App::$nav_sel['name'] == $app['name']) if(App::$nav_sel['name'] == $app['name'])
$app['active'] = true; $app['active'] = true;
if($is_owner) { if($is_owner) {
@ -266,7 +266,7 @@ function nav($template = 'default') {
if($syslist) { if($syslist) {
foreach($syslist as $app) { foreach($syslist as $app) {
if(\App::$nav_sel['name'] == $app['name']) if(App::$nav_sel['name'] == $app['name'])
$app['active'] = true; $app['active'] = true;
if($is_owner) { if($is_owner) {

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys, os import sys, os
import pathlib
sys.path.append('util/py')
sys.path.append(str(pathlib.Path(__file__).parent.resolve()) + '/py')
import configparser import configparser
import requests import requests
from requests.auth import HTTPBasicAuth from requests.auth import HTTPBasicAuth
@ -20,9 +23,9 @@ VERIFY_SSL=True
class CommandNotFound(Exception): class CommandNotFound(Exception):
pass pass
class ZotSH(object): class NSH(object):
commands = ['cd','ls','exists','mkdir','mkdirs','rmdir','delete','upload','download', commands = ['cd','ls','exists','mkdir','mkdirs','rmdir','delete','put','get',
'host', 'pwd','cat', 'conn', 'connect', 'pwd','cat',
'lcd','lpwd', 'lls', 'lcd','lpwd', 'lls',
'quit', 'help'] 'quit', 'help']
def __init__(self, host, session=None, davclient=None): def __init__(self, host, session=None, davclient=None):
@ -66,25 +69,11 @@ class ZotSH(object):
return "%s:%s> " % (self.hostname, self.davclient.cwd) return "%s:%s> " % (self.hostname, self.davclient.cwd)
def get_host_session(self, host=None): def get_host_session(self, host=None):
#~ if host is None:
#~ host = self.host
#~ if not host.startswith("https"):
#~ host = "https://%s/" % (host)
#~ if host in self.sessions:
#~ session = self.sessions[host]
#~ else:
#~ session = requests.Session()
#~ self.sessions[host] = session
#~ if not host == SERVER
#~ session.params.update({'davguest':1})
#~ return session
if self.session is None: if self.session is None:
session = requests.Session() session = requests.Session()
#session.params.update({'davguest':1}) #session.params.update({'davguest':1})
else: else:
session = self.session session = self.session
#session.params.update({'davguest': (not host == SERVER) })
return session return session
def do(self, command, *args): def do(self, command, *args):
@ -128,7 +117,7 @@ class ZotSH(object):
return return
return self.davclient.delete(args[0]) return self.davclient.delete(args[0])
def cmd_upload(self, *args): def cmd_put(self, *args):
if (len(args)==0): if (len(args)==0):
return return
args = list(args) args = list(args)
@ -137,7 +126,7 @@ class ZotSH(object):
return self.davclient.upload(args[0], args[1]) return self.davclient.upload(args[0], args[1])
def cmd_download(self, *args): def cmd_get(self, *args):
if (len(args)==0): if (len(args)==0):
return return
args = list(args) args = list(args)
@ -145,8 +134,11 @@ class ZotSH(object):
args.append(args[0]) args.append(args[0])
return self.davclient.download(args[0], args[1]) return self.davclient.download(args[0], args[1])
def cmd_host(self, *args): def cmd_conn(self, *args):
return self.do('connect', *args)
def cmd_connect(self, *args):
ruser = '' ruser = ''
if (len(args)==0): if (len(args)==0):
return return
@ -235,7 +227,7 @@ class ZotSH(object):
print( f) print( f)
def cmd_help(self, *args): def cmd_help(self, *args):
print("ZotSH",__version__) print("NSH",__version__)
print() print()
print("Commands:") print("Commands:")
for c in self.commands: for c in self.commands:
@ -257,13 +249,13 @@ def load_conf():
if homedir is None: if homedir is None:
homedir = os.path.join(os.getenv("HOMEDRIVE"), os.getenv("HOMEPATH")) homedir = os.path.join(os.getenv("HOMEDRIVE"), os.getenv("HOMEPATH"))
optsfile = ".zotshrc" optsfile = ".nshrc"
if not os.path.isfile(optsfile): if not os.path.isfile(optsfile):
optsfile = os.path.join(homedir, ".zotshrc") optsfile = os.path.join(homedir, ".nshrc")
if not os.path.isfile(optsfile): if not os.path.isfile(optsfile):
print("Please create a configuration file called '.zotshrc':") print("Please create a configuration file called '.nshrc':")
print("[zotsh]") print("[nsh]")
print("host = https://yourhost.com/") print("host = https://yourhost.com/")
print("username = your_username") print("username = your_username")
print("password = your_password") print("password = your_password")
@ -271,18 +263,18 @@ def load_conf():
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(optsfile) config.read(optsfile)
SERVER = config.get('zotsh', 'host') SERVER = config.get('nsh', 'host')
USER = config.get('zotsh', 'username') USER = config.get('nsh', 'username')
PASSWD = config.get('zotsh', 'password') PASSWD = config.get('nsh', 'password')
if config.has_option('zotsh', 'verify_ssl'): if config.has_option('nsh', 'verify_ssl'):
VERIFY_SSL = config.getboolean('zotsh', 'verify_ssl') VERIFY_SSL = config.getboolean('nsh', 'verify_ssl')
def zotsh(): def nsh():
zotsh = ZotSH( SERVER) nsh = NSH(SERVER)
session_home = zotsh.get_host_session() session_home = nsh.get_host_session()
#~ #login on home server #~ #login on home server
print("logging in...") print("logging in...")
@ -293,15 +285,20 @@ def zotsh():
print("Hi - ", r.json()['channel_name']) print("Hi - ", r.json()['channel_name'])
zotsh.session = session_home nsh.session = session_home
# since the site directory may be empty, automatically cd to # since the site directory may be empty, automatically cd to
# your own cloud storage folder # your own cloud storage folder
zotsh.do('cd', *[USER]) nsh.do('cd', *[USER])
# command loop # command loop
input_str = input(zotsh.PS1) try:
input_str = input(nsh.PS1)
except EOFError as e:
input_str = "quit"
while (input_str != "quit"): while (input_str != "quit"):
input_str = input_str.strip() input_str = input_str.strip()
if len(input_str)>0: if len(input_str)>0:
@ -310,7 +307,7 @@ def zotsh():
command = toks[0] command = toks[0]
args = toks[1:] args = toks[1:]
try: try:
ret = zotsh.do(command, *args) ret = nsh.do(command, *args)
except easywebdav.client.OperationFailed as e: except easywebdav.client.OperationFailed as e:
print(e) print(e)
except CommandNotFound as e: except CommandNotFound as e:
@ -320,14 +317,14 @@ def zotsh():
print(ret) print(ret)
input_str = input(zotsh.PS1) input_str = input(nsh.PS1)
if __name__=="__main__": if __name__=="__main__":
load_conf() load_conf()
zotsh() nsh()
sys.exit() sys.exit()

View file

@ -1,40 +1,33 @@
ZotSH - v.0.0.3 NSH - v.0.0.3
Client for browsing RedDAVs. Client for browsing Nomad DAV repositories.
Install Install
------- -------
ZotSH requires 'requests'(1). NSH requires 'requests'(1).
Please refer to requests docs on how to install it (2) Please refer to requests docs on how to install it (2)
Extract somewhere and launch zotsh.py Extract somewhere and launch nsh
If installing in an alternatte location, copy the util/py directory to the
directory containing the nsh script
Description Description
----------- -----------
Update: 2019-08-14 You can connect to a repository using
Have just looked at this after several years of bitrot and made some updates. conn username@hostname
it functions for cli DAV access on your assigned hub, but magic-auth to dav repos on other hubs connect username@hostname
(e.g. the host command) needs to be updated to work with openwebauth.
The ability to browse remote WebDAV repositories outside your own server is not as useful as it was once was; as the top level WebDAV folder on each site might have been hidden by the administrator for security/privacy reasons. On these sites the root directory will be empty. You can only proceed by
cd username
OR you can connect to the site using
host username@hostname
if you know a username on that site and if they have given you the requisite permission *or* their directory contains publicly readable content. if you know a username on that site and if they have given you the requisite permission *or* their directory contains publicly readable content.
---- ----
ZotSH is a command line WebDAV client for Nomad platforms. NSH is a command line WebDAV client for Nomad platforms.
It knows how to magic-auth to remote hubs using OpenWebAuth. It knows how to magic-auth to remote hubs using OpenWebAuth.
ZotSH uses 'easywebdav' library (0) with small modifications NSH uses 'easywebdav' library (0) with small modifications
to 'zotify' it. (See easywebdav/LICENSE) to 'zotify' it. (See easywebdav/LICENSE)
@ -42,10 +35,14 @@ to 'zotify' it. (See easywebdav/LICENSE)
Commands Commands
-------- --------
host <hostname> conn <hostname>
Authenticate to 'hostname' and switch to it connect <hostname>
Authenticate to 'hostname' and switch to it. The root directory may be
hidden/empty. If it is, the only way to proceed is if you know a username on
that server. Then you can 'cd username'.
host <username@hostname> conn <username@hostname>
connect <username@hostname>
Authenticate to 'hostname' and switch to it and automatically cd to the 'username' directory Authenticate to 'hostname' and switch to it and automatically cd to the 'username' directory
cd <dirname|..> cd <dirname|..>
@ -72,10 +69,10 @@ rmdir <name>
delete <path> delete <path>
Delete file 'path' Delete file 'path'
upload <local_path> [remote_path] put <local_path> [remote_path]
Upload local file 'local_path' to 'remote_path' Upload local file 'local_path' to 'remote_path'
download <remote_path> [local_path] get <remote_path> [local_path]
Download remote file 'remote_path' and save it as 'local_path' Download remote file 'remote_path' and save it as 'local_path'
cat <remote_path> cat <remote_path>
@ -97,10 +94,10 @@ help
Config Config
------ ------
Create a .zotshrc file in your home or in same folder with zotsh.py: Create a .nshrc file in your home or in same folder with the nsh script:
[zotsh] [nsh]
host = https://yourhost.com/ host = https://yourhost.com/
username = your_username username = your_username
password = your_password password = your_password
@ -115,6 +112,8 @@ to skip verification of ssl certs
Changelog Changelog
---------- ----------
0.0.3 Convert to python3 and rename from zotsh to nsh
0.0.2 Fix "CommandNotFound" exception, new 'cat' command 0.0.2 Fix "CommandNotFound" exception, new 'cat' command
0.0.1 First release 0.0.1 First release

Binary file not shown.

Binary file not shown.

View file

@ -108,6 +108,18 @@ $(document).ready(function() {
loadNotificationItems(notifyType); loadNotificationItems(notifyType);
} }
$(document).on('z:handleNetWorkNotificationsItems', function(e, obj) {
// push_notification(
// obj.name,
// $('<p>' + obj.message + '</p>').text(),
// obj.b64mid
// );
});
// Allow folks to stop the ajax page updates with the pause/break key // Allow folks to stop the ajax page updates with the pause/break key
$(document).keydown(function(event) { $(document).keydown(function(event) {
if(event.keyCode == '8') { if(event.keyCode == '8') {
@ -585,7 +597,6 @@ function notificationsUpdate(cached_data) {
let pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : ''); let pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
if(cached_data !== undefined) { if(cached_data !== undefined) {
handleNotifications(cached_data); handleNotifications(cached_data);
} else { } else {
@ -644,6 +655,7 @@ function handleNotifications(data) {
$('.all_events-update').addClass('badge-secondary'); $('.all_events-update').addClass('badge-secondary');
} }
$.each(data, function(index, item) { $.each(data, function(index, item) {
//do not process those //do not process those
let arr = ['invalid']; let arr = ['invalid'];
@ -667,6 +679,10 @@ function handleNotificationsItems(notifyType, data) {
notify_menu.html(''); notify_menu.html('');
$(data).each(function() { $(data).each(function() {
if (notifyType == 'notify') {
$(document).trigger('z:handleNetWorkNotificationsItems', this);
}
html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.addr,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum); html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.addr,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum);
notify_menu.append(html); notify_menu.append(html);
}); });
@ -1777,3 +1793,29 @@ function dozid(s) {
return s; return s;
} }
function push_notification_request(e) {
if ('Notification' in window) {
if (Notification.permission !== 'granted') {
Notification.requestPermission(function(permission) {
if(permission === 'granted') {
$(e.target).closest('div').hide();
}
});
}
}
}
function push_notification(title, body, b64mid) {
let options = {
body: body,
data: b64mid,
icon: aStr.icon,
silent: false
}
let n = new Notification(title, options);
n.onclick = function (e) {
window.location.href = baseurl + '/display/' + e.target.data;
}
}

View file

@ -24,7 +24,16 @@ $(document).ready(function() {
loadPermcat(permName); loadPermcat(permName);
}); });
if ('Notification' in window) {
if (Notification.permission !== 'granted') {
$('#desktop-notifications-info').show();
}
}
$('#desktop-notifications-request').on('click', function(e) {
e.preventDefault();
push_notification_request(e);
});
}); });

View file

@ -1,7 +1,7 @@
<script> <script>
var aStr = { var aStr = {
'icon' : "{{$icon}}",
'delitem' : "{{$delitem}}", 'delitem' : "{{$delitem}}",
'comment' : "{{$comment}}", 'comment' : "{{$comment}}",
'showmore' : "{{$showmore}}", 'showmore' : "{{$showmore}}",

View file

@ -120,7 +120,12 @@
<div class="section-content-tools-wrapper"> <div class="section-content-tools-wrapper">
<div id="settings-notifications"> <div id="settings-notifications">
{{include file="field_input.tpl" field=$mailhost}} <div id="desktop-notifications-info" class="section-content-warning-wrapper" style="display: none;">
{{$desktop_notifications_info}}<br>
<a id="desktop-notifications-request" href="#">{{$desktop_notifications_request}}</a>
</div>
{{include file="field_input.tpl" field=$mailhost}}
<h3>{{$activity_options}}</h3> <h3>{{$activity_options}}</h3>
<div class="group"> <div class="group">