mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 08:40:24 +00:00
Merge branch 'master' of github.com:webmin/webmin
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -96,6 +96,7 @@ if ($current_lang_info->{'rtl'} || $current_lang eq "ar") {
|
||||
# Page header
|
||||
print "<html>\n";
|
||||
print "<head>\n";
|
||||
print &ui_switch_theme_javascript();
|
||||
print "<title>$title</title>\n";
|
||||
my $imgdir = "@{[&get_webprefix()]}/images";
|
||||
my $prod = 'webmin';
|
||||
|
||||
@@ -84,7 +84,7 @@ if (@has > 1) {
|
||||
}
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
print &ui_switch_theme_javascript();
|
||||
print "<div class='wrapper leftmenu'>\n";
|
||||
print "<table id='main' width='100%'><tbody><tr><td>\n";
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -277,24 +277,51 @@ my $html_editor_init_script =
|
||||
theme: 'snow'
|
||||
});
|
||||
|
||||
// Google Mail editor like keybind for quoting
|
||||
// Google Mail like key bind for creating numbered list (Ctrl+Shift+7)
|
||||
editor.keyboard.addBinding({
|
||||
key: '9',
|
||||
shiftKey: true,
|
||||
ctrlKey: !isMac,
|
||||
metaKey: isMac,
|
||||
format: ['blockquote'],
|
||||
key: '7',
|
||||
shiftKey: true,
|
||||
ctrlKey: !isMac,
|
||||
metaKey: isMac,
|
||||
}, function(range, context) {
|
||||
this.quill.format('blockquote', false);
|
||||
const currentFormat = this.quill.getFormat(range.index);
|
||||
if (currentFormat.list === 'ordered') {
|
||||
this.quill.format('list', false);
|
||||
} else {
|
||||
this.quill.format('list', 'ordered');
|
||||
}
|
||||
});
|
||||
|
||||
// Google Mail like key bind for creating bullet list (Ctrl+Shift+8)
|
||||
editor.keyboard.addBinding({
|
||||
key: '9',
|
||||
shiftKey: true,
|
||||
ctrlKey: !isMac,
|
||||
metaKey: isMac,
|
||||
key: '8',
|
||||
shiftKey: true,
|
||||
ctrlKey: !isMac,
|
||||
metaKey: isMac,
|
||||
}, function(range, context) {
|
||||
this.quill.format('blockquote', true);
|
||||
const currentFormat = this.quill.getFormat(range.index);
|
||||
if (currentFormat.list === 'bullet') {
|
||||
this.quill.format('list', false);
|
||||
} else {
|
||||
this.quill.format('list', 'bullet');
|
||||
}
|
||||
});
|
||||
|
||||
// Google Mail like key bind for creating blockquote (Ctrl+Shift+9)
|
||||
editor.keyboard.addBinding({
|
||||
key: '9',
|
||||
shiftKey: true,
|
||||
ctrlKey: !isMac,
|
||||
metaKey: isMac,
|
||||
}, function(range, context) {
|
||||
const currentFormat = this.quill.getFormat(range.index);
|
||||
if (currentFormat.blockquote) {
|
||||
this.quill.format('blockquote', false);
|
||||
} else {
|
||||
this.quill.format('blockquote', true);
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('text-change', function() {
|
||||
// This should most probably go to onSubmit event
|
||||
targ.value = editor.root.innerHTML + "<br>";
|
||||
|
||||
@@ -60,6 +60,7 @@ $vers || usage();
|
||||
"webmin-search-lib.pl", "WebminCore.pm",
|
||||
"record-login.pl", "record-logout.pl", "record-failed.pl",
|
||||
"robots.txt", "unauthenticated", "bin", "html-editor-lib.pl",
|
||||
"switch_theme.cgi",
|
||||
);
|
||||
if ($min) {
|
||||
# Only those required by others
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
# setup-repos-nightly.sh
|
||||
# Configures Webmin development repository for RHEL and Debian systems (derivatives)
|
||||
|
||||
webmin_download="https://download.webmin.com"
|
||||
webmin_host="download.webmin.com"
|
||||
webmin_download="https://$webmin_host"
|
||||
webmin_download_nightly="https://builds.webmin.dev"
|
||||
webmin_key="developers-key.asc"
|
||||
webmin_key_download="$webmin_download/$webmin_key"
|
||||
@@ -163,11 +164,16 @@ rpm)
|
||||
echo " .. done"
|
||||
;;
|
||||
deb)
|
||||
# Remove our keys
|
||||
rm -f "/usr/share/keyrings/debian-$webmin_key_suffix.gpg" "/usr/share/keyrings/$repoid_debian_like-$webmin_key_suffix.gpg"
|
||||
# Install our keys
|
||||
echo " Installing Webmin key .."
|
||||
gpg --import $webmin_key 1>/dev/null 2>&1
|
||||
cat $webmin_key | gpg --dearmor > "/usr/share/keyrings/$repoid_debian_like-$webmin_key_suffix.gpg"
|
||||
echo " .. done"
|
||||
# Remove Webmin repo from sources.list
|
||||
sources_list=$(grep -v "$webmin_host" /etc/apt/sources.list)
|
||||
echo "$sources_list" > /etc/apt/sources.list
|
||||
# Create repo file
|
||||
echo " Setting up Webmin development repository .."
|
||||
echo "deb [signed-by=/usr/share/keyrings/$repoid_debian_like-$webmin_key_suffix.gpg] $webmin_download_nightly ./" >$debian_repo_file
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
# setup-repos.sh
|
||||
# Configures Webmin repository for RHEL and Debian systems (derivatives)
|
||||
|
||||
webmin_download="https://download.webmin.com"
|
||||
webmin_host="download.webmin.com"
|
||||
webmin_download="https://$webmin_host"
|
||||
webmin_key="developers-key.asc"
|
||||
webmin_key_download="$webmin_download/$webmin_key"
|
||||
webmin_key_suffix="webmin-developers"
|
||||
@@ -159,11 +160,16 @@ rpm)
|
||||
echo " .. done"
|
||||
;;
|
||||
deb)
|
||||
# Remove our keys
|
||||
rm -f "/usr/share/keyrings/debian-$webmin_key_suffix.gpg" "/usr/share/keyrings/$repoid_debian_like-$webmin_key_suffix.gpg"
|
||||
# Install our keys
|
||||
echo " Installing Webmin key .."
|
||||
gpg --import $webmin_key 1>/dev/null 2>&1
|
||||
cat $webmin_key | gpg --dearmor > "/usr/share/keyrings/$repoid_debian_like-$webmin_key_suffix.gpg"
|
||||
echo " .. done"
|
||||
# Remove Webmin repo from sources.list
|
||||
sources_list=$(grep -v "$webmin_host" /etc/apt/sources.list)
|
||||
echo "$sources_list" > /etc/apt/sources.list
|
||||
# Create repo file
|
||||
echo " Setting up Webmin repository .."
|
||||
echo "deb [signed-by=/usr/share/keyrings/$repoid_debian_like-$webmin_key_suffix.gpg] $webmin_download/download/newkey/repository stable contrib" >$debian_repo_file
|
||||
|
||||
45
switch_theme.cgi
Executable file
45
switch_theme.cgi
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/local/bin/perl
|
||||
# switch_theme.cgi
|
||||
# Change the theme for the current user if allowed
|
||||
|
||||
BEGIN { push(@INC, "."); };
|
||||
use WebminCore;
|
||||
|
||||
&init_config();
|
||||
&ReadParse();
|
||||
my $err = sub {
|
||||
&PrintHeader();
|
||||
print("<tt>Cannot change theme : $_[0]</tt>\n");
|
||||
exit(1);
|
||||
};
|
||||
# Check if in debug mode
|
||||
&$err("Debug mode is not enabled!")
|
||||
if (!$gconfig{'debug_enabled'} &&
|
||||
!$gconfig{'debug_theme_switcher'});
|
||||
# Check if allowed to change theme,
|
||||
# otherwise throw an error
|
||||
if (!&foreign_available('theme') &&
|
||||
!&foreign_available('change-user') &&
|
||||
!&foreign_available('webmin') &&
|
||||
!&foreign_available('acl')) {
|
||||
&$err("You are not allowed to change themes!");
|
||||
}
|
||||
# Check if the theme is known
|
||||
&$err("Theme identification is not known!")
|
||||
if (!$in{'theme'} || $in{'theme'} !~ /^[123]$/);
|
||||
# Check if the remote user is known
|
||||
&$err("Remote user is not known!") if (!$remote_user);
|
||||
# Define the theme
|
||||
my $themes = {
|
||||
'1' => 'authentic-theme',
|
||||
'2' => 'gray-theme',
|
||||
'3' => '' };
|
||||
my $theme = $themes->{$in{'theme'}};
|
||||
# Change the theme
|
||||
&foreign_require('acl');
|
||||
my @users = &acl::list_users();
|
||||
my ($user) = grep { $_->{'name'} eq $remote_user } @users;
|
||||
$user->{'theme'} = $theme;
|
||||
&acl::modify_user($user->{'name'}, $user);
|
||||
&restart_miniserv();
|
||||
&redirect(&get_webprefix() . "/");
|
||||
29
ui-lib.pl
29
ui-lib.pl
@@ -2280,6 +2280,31 @@ for(var i=0; i<values.length; i++) {
|
||||
EOF
|
||||
}
|
||||
|
||||
=head2 ui_switch_theme_javascript()
|
||||
|
||||
The subroutine is designed to load JavaScript
|
||||
for switching themes using hotkeys.
|
||||
|
||||
Hotkeys are:
|
||||
To activate theme switch mode:
|
||||
Use: `Ctrl+Alt+T` (or `Control+Option+T` on Mac).
|
||||
|
||||
Immediately after, within 1 second, select your desired theme by pressing:
|
||||
- `Shift + A`: Authentic theme
|
||||
- `Shift + G`: Gray theme
|
||||
- `Shift + L`: Legacy theme.
|
||||
|
||||
=cut
|
||||
|
||||
sub ui_switch_theme_javascript
|
||||
{
|
||||
return &theme_ui_switch_theme_javascript(@_) if (defined(&theme_ui_switch_theme_javascript));
|
||||
return "" if (!$gconfig{'debug_enabled'} && !$gconfig{'debug_theme_switcher'});
|
||||
my $switch_script = "<script>const __webmin_webprefix__ = '@{[&get_webprefix()]}';</script>\n";
|
||||
$switch_script .= "<script type=\"text/javascript\" src=\"@{[&get_webprefix()]}/unauthenticated/switch_theme.js?@{[&get_webmin_version(1)]}\"></script>\n";
|
||||
return $switch_script;
|
||||
}
|
||||
|
||||
####################### grid layout functions
|
||||
|
||||
=head2 ui_grid_table(&elements, columns, [width-percent], [&tds], [tabletags], [title])
|
||||
@@ -2779,8 +2804,8 @@ if (defined(&theme_ui_details)) {
|
||||
|
||||
my $rv;
|
||||
if (!$c->{'html'}) {
|
||||
$c->{'title'} = &html_escape($c->{'title'});
|
||||
$c->{'content'} = &html_escape($c->{'content'});
|
||||
$c->{'title'} = &html_escape($c->{'title'}, 1);
|
||||
$c->{'content'} = &html_escape($c->{'content'}, 1);
|
||||
}
|
||||
$c->{'class'} = " class=\"@{["e_escape($c->{'class'})]}\"" if($c->{'class'});
|
||||
$o = ' open' if ($o);
|
||||
|
||||
31
unauthenticated/switch_theme.js
Normal file
31
unauthenticated/switch_theme.js
Normal file
@@ -0,0 +1,31 @@
|
||||
(function () {
|
||||
let firstCombinationPressed = false;
|
||||
document.addEventListener("keydown", function (event) {
|
||||
// Check for Ctrl+Alt+T or Control+Option+T
|
||||
if (event.ctrlKey && event.altKey && event.keyCode === 84) {
|
||||
firstCombinationPressed = true;
|
||||
|
||||
// Set a timeout to reset the state after a short period (e.g., 1 seconds)
|
||||
setTimeout(() => {
|
||||
firstCombinationPressed = false;
|
||||
}, 1000);
|
||||
}
|
||||
if (firstCombinationPressed && event.shiftKey &&
|
||||
(event.keyCode === 65 || event.keyCode === 71 || event.keyCode === 76)) {
|
||||
const theme =
|
||||
// Shift + A : Authentic theme
|
||||
event.keyCode === 65 ? 1 :
|
||||
// Shift + G : Gray theme
|
||||
event.keyCode === 71 ? 2 :
|
||||
// Shift + L : Legacy theme.
|
||||
event.keyCode === 76 ? 3 : null;
|
||||
firstCombinationPressed = false;
|
||||
try {
|
||||
top.document.documentElement.style.filter = 'grayscale(100%) blur(0.5px) brightness(0.75) opacity(0.5)';
|
||||
top.document.documentElement.style.cursor = 'wait';
|
||||
top.document.documentElement.style.pointerEvents = 'none';
|
||||
} catch (error) {}
|
||||
top.location.href = __webmin_webprefix__ + "/switch_theme.cgi?theme=" + theme + "";
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -1119,6 +1119,7 @@ my $text = defined($tconfig{'cs_text'}) ? $tconfig{'cs_text'} :
|
||||
my $bgimage = defined($tconfig{'bgimage'}) ? "background=$tconfig{'bgimage'}" : "";
|
||||
my $dir = $current_lang_info->{'dir'} ? "dir=\"$current_lang_info->{'dir'}\"" : "";
|
||||
my $html_body = "<body bgcolor=\"#$bgcolor\" link=\"#$link\" vlink=\"#$link\" text=\"#$text\" style=\"height:100%\" $bgimage $tconfig{'inbody'} $dir $_[8]>\n";
|
||||
print &ui_switch_theme_javascript();
|
||||
$html_body =~ s/\s+\>/>/g;
|
||||
print $html_body;
|
||||
print "<script>function _document_cookie_set_client_height(){document.cookie='client_height='+document.documentElement.clientHeight+'';}_document_cookie_set_client_height();window.onresize=_document_cookie_set_client_height</script>\n";
|
||||
@@ -4449,10 +4450,16 @@ Returns the version of Webmin currently being run, such as 1.450.
|
||||
=cut
|
||||
sub get_webmin_version
|
||||
{
|
||||
my ($str) = @_;
|
||||
if (!$get_webmin_version) {
|
||||
$get_webmin_version = &read_file_contents("$root_directory/version");
|
||||
$get_webmin_version =~ s/\r|\n//g;
|
||||
}
|
||||
if ($str) {
|
||||
my $get_webmin_version_str = $get_webmin_version;
|
||||
$get_webmin_version_str =~ s/\.//g;
|
||||
return $get_webmin_version_str;
|
||||
}
|
||||
return $get_webmin_version;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@ updays=1
|
||||
cron_mode=0
|
||||
osdn=1
|
||||
warn_days=7
|
||||
letsencrypt_dns_wait=30
|
||||
letsencrypt_dns_wait=10
|
||||
letsencrypt_algo=rsa
|
||||
letsencrypt_reuse=1
|
||||
Reference in New Issue
Block a user