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;
$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':
$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)
);
break;
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)
);
break;
case 'all':
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)
);

View file

@ -686,6 +686,8 @@ class Channel {
'$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),
'$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()) ],
'$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 ],

View file

@ -109,7 +109,7 @@ class Sites extends \Zotlabs\Web\Controller {
}
$o = replace_macros(get_markup_template('sitentry_header.tpl'), [
'$dirlbl' => 'Affiliated Sites',
'$dirlbl' => t('Affiliated Sites'),
'$desc' => $desc,
'$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.
*/
define ( 'STD_VERSION', '21.09.03' );
define ( 'STD_VERSION', '21.09.06' );
define ( 'ZOT_REVISION', '10.0' );
define ( 'DB_UPDATE_VERSION', 1251 );

View file

@ -1711,7 +1711,12 @@ function bbcode($Text, $options = []) {
// Check for highlighted text
if (strpos($Text,'[/hl]') !== false) {
$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

View file

@ -2,6 +2,7 @@
function js_strings() {
return replace_macros(get_markup_template('js_strings.tpl'), array(
'$icon' => '/images/' . PLATFORM_NAME . '-64.png',
'$delitem' => t('Delete this item?'),
'$comment' => t('Comment'),
'$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'];
// 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'))
$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
$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 {
@ -252,7 +252,7 @@ function nav($template = 'default') {
if($pinned_list) {
foreach($pinned_list as $app) {
if(\App::$nav_sel['name'] == $app['name'])
if(App::$nav_sel['name'] == $app['name'])
$app['active'] = true;
if($is_owner) {
@ -266,7 +266,7 @@ function nav($template = 'default') {
if($syslist) {
foreach($syslist as $app) {
if(\App::$nav_sel['name'] == $app['name'])
if(App::$nav_sel['name'] == $app['name'])
$app['active'] = true;
if($is_owner) {

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,9 @@
#!/usr/bin/env python3
import sys, os
import pathlib
sys.path.append('util/py')
sys.path.append(str(pathlib.Path(__file__).parent.resolve()) + '/py')
import configparser
import requests
from requests.auth import HTTPBasicAuth
@ -20,9 +23,9 @@ VERIFY_SSL=True
class CommandNotFound(Exception):
pass
class ZotSH(object):
commands = ['cd','ls','exists','mkdir','mkdirs','rmdir','delete','upload','download',
'host', 'pwd','cat',
class NSH(object):
commands = ['cd','ls','exists','mkdir','mkdirs','rmdir','delete','put','get',
'conn', 'connect', 'pwd','cat',
'lcd','lpwd', 'lls',
'quit', 'help']
def __init__(self, host, session=None, davclient=None):
@ -66,25 +69,11 @@ class ZotSH(object):
return "%s:%s> " % (self.hostname, self.davclient.cwd)
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:
session = requests.Session()
#session.params.update({'davguest':1})
else:
session = self.session
#session.params.update({'davguest': (not host == SERVER) })
return session
def do(self, command, *args):
@ -128,7 +117,7 @@ class ZotSH(object):
return
return self.davclient.delete(args[0])
def cmd_upload(self, *args):
def cmd_put(self, *args):
if (len(args)==0):
return
args = list(args)
@ -137,7 +126,7 @@ class ZotSH(object):
return self.davclient.upload(args[0], args[1])
def cmd_download(self, *args):
def cmd_get(self, *args):
if (len(args)==0):
return
args = list(args)
@ -145,8 +134,11 @@ class ZotSH(object):
args.append(args[0])
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 = ''
if (len(args)==0):
return
@ -235,7 +227,7 @@ class ZotSH(object):
print( f)
def cmd_help(self, *args):
print("ZotSH",__version__)
print("NSH",__version__)
print()
print("Commands:")
for c in self.commands:
@ -257,13 +249,13 @@ def load_conf():
if homedir is None:
homedir = os.path.join(os.getenv("HOMEDRIVE"), os.getenv("HOMEPATH"))
optsfile = ".zotshrc"
optsfile = ".nshrc"
if not os.path.isfile(optsfile):
optsfile = os.path.join(homedir, ".zotshrc")
optsfile = os.path.join(homedir, ".nshrc")
if not os.path.isfile(optsfile):
print("Please create a configuration file called '.zotshrc':")
print("[zotsh]")
print("Please create a configuration file called '.nshrc':")
print("[nsh]")
print("host = https://yourhost.com/")
print("username = your_username")
print("password = your_password")
@ -271,18 +263,18 @@ def load_conf():
config = configparser.ConfigParser()
config.read(optsfile)
SERVER = config.get('zotsh', 'host')
USER = config.get('zotsh', 'username')
PASSWD = config.get('zotsh', 'password')
if config.has_option('zotsh', 'verify_ssl'):
VERIFY_SSL = config.getboolean('zotsh', 'verify_ssl')
SERVER = config.get('nsh', 'host')
USER = config.get('nsh', 'username')
PASSWD = config.get('nsh', 'password')
if config.has_option('nsh', '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
print("logging in...")
@ -293,15 +285,20 @@ def zotsh():
print("Hi - ", r.json()['channel_name'])
zotsh.session = session_home
nsh.session = session_home
# since the site directory may be empty, automatically cd to
# your own cloud storage folder
zotsh.do('cd', *[USER])
nsh.do('cd', *[USER])
# command loop
input_str = input(zotsh.PS1)
try:
input_str = input(nsh.PS1)
except EOFError as e:
input_str = "quit"
while (input_str != "quit"):
input_str = input_str.strip()
if len(input_str)>0:
@ -310,7 +307,7 @@ def zotsh():
command = toks[0]
args = toks[1:]
try:
ret = zotsh.do(command, *args)
ret = nsh.do(command, *args)
except easywebdav.client.OperationFailed as e:
print(e)
except CommandNotFound as e:
@ -320,14 +317,14 @@ def zotsh():
print(ret)
input_str = input(zotsh.PS1)
input_str = input(nsh.PS1)
if __name__=="__main__":
load_conf()
zotsh()
nsh()
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
-------
ZotSH requires 'requests'(1).
NSH requires 'requests'(1).
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
-----------
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.
it functions for cli DAV access on your assigned hub, but magic-auth to dav repos on other hubs
(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
conn username@hostname
connect 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.
----
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.
ZotSH uses 'easywebdav' library (0) with small modifications
NSH uses 'easywebdav' library (0) with small modifications
to 'zotify' it. (See easywebdav/LICENSE)
@ -42,10 +35,14 @@ to 'zotify' it. (See easywebdav/LICENSE)
Commands
--------
host <hostname>
Authenticate to 'hostname' and switch to it
conn <hostname>
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
cd <dirname|..>
@ -72,10 +69,10 @@ rmdir <name>
delete <path>
Delete file 'path'
upload <local_path> [remote_path]
put <local_path> [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'
cat <remote_path>
@ -97,10 +94,10 @@ help
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/
username = your_username
password = your_password
@ -115,6 +112,8 @@ to skip verification of ssl certs
Changelog
----------
0.0.3 Convert to python3 and rename from zotsh to nsh
0.0.2 Fix "CommandNotFound" exception, new 'cat' command
0.0.1 First release

Binary file not shown.

Binary file not shown.

View file

@ -108,6 +108,18 @@ $(document).ready(function() {
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
$(document).keydown(function(event) {
if(event.keyCode == '8') {
@ -585,7 +597,6 @@ function notificationsUpdate(cached_data) {
let pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
if(cached_data !== undefined) {
handleNotifications(cached_data);
} else {
@ -644,6 +655,7 @@ function handleNotifications(data) {
$('.all_events-update').addClass('badge-secondary');
}
$.each(data, function(index, item) {
//do not process those
let arr = ['invalid'];
@ -667,6 +679,10 @@ function handleNotificationsItems(notifyType, data) {
notify_menu.html('');
$(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);
notify_menu.append(html);
});
@ -1777,3 +1793,29 @@ function dozid(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);
});
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>
var aStr = {
'icon' : "{{$icon}}",
'delitem' : "{{$delitem}}",
'comment' : "{{$comment}}",
'showmore' : "{{$showmore}}",

View file

@ -120,7 +120,12 @@
<div class="section-content-tools-wrapper">
<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>
<div class="group">