Просмотр исходного кода

Feature/2493 change logo support (#3572)

* Update whitelabel.php

* Add support for custom logo's

* Update web/templates/pages/edit_whitelabel.php

Co-authored-by: Alec Rust <me@alecrust.com>

---------

Co-authored-by: Alec Rust <me@alecrust.com>
Jaap Marcus 2 лет назад
Родитель
Сommit
705a4ae8b0

+ 64 - 0
bin/v-update-white-label-logo

@@ -0,0 +1,64 @@
+#!/bin/bash
+# info: update white label logo's
+# options: [DOWNLOAD]
+#
+# example: v-update-white-label-logo
+#
+# Replace Hestia logos with User created logo's
+
+download=${1-no}
+#----------------------------------------------------------#
+#                Variables & Functions                     #
+#----------------------------------------------------------#
+
+# Argument definition
+restart=$1
+skip=$2
+
+# Includes
+# shellcheck source=/etc/hestiacp/hestia.conf
+source /etc/hestiacp/hestia.conf
+# shellcheck source=/usr/local/hestia/func/main.sh
+source $HESTIA/func/main.sh
+# load config file
+source_conf "$HESTIA/conf/hestia.conf"
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+if [ -f "$HESTIA/web/images/custom/logo.svg" ]; then
+	cp -f $HESTIA/web/images/custom/logo.svg $HESTIA/web/images/logo.svg
+elif [ ! -f "$HESTIA/web/images/custom/logo.svg" ] && [ "$download" = "yes" ]; then
+	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo.svg $HESTIA/web/images/logo.svg
+fi
+
+if [ -f "$HESTIA/web/images/custom/logo.png" ]; then
+	cp -f $HESTIA/web/images/custom/logo.png $HESTIA/web/images/logo.png
+elif [ ! -f "$HESTIA/web/images/custom/logo.png" ] && [ "$download" = "yes" ]; then
+	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo.png $HESTIA/web/images/logo.png
+fi
+
+if [ -f "$HESTIA/web/images/custom/logo-header.svg" ]; then
+	cp -f $HESTIA/web/images/custom/logo-header.svg $HESTIA/web/images/logo-header.svg
+elif [ ! -f "$HESTIA/web/images/custom/logo-header.svg" ] && [ "$download" = "yes" ]; then
+	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/logo-header.svg $HESTIA/web/images/logo-header.svg
+fi
+
+if [ -f "$HESTIA/web/images/custom/favicon.png" ]; then
+	cp -f $HESTIA/web/images/custom/favicon.png $HESTIA/web/images/favicon.png
+elif [ ! -f "$HESTIA/web/images/custom/favicon.png" ] && [ "$download" = "yes" ]; then
+	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/images/favicon.png $HESTIA/web/images/favicon.png
+fi
+
+if [ -f "$HESTIA/web/images/custom/favicon.ico" ]; then
+	cp -f $HESTIA/web/images/custom/favicon.ico $HESTIA/web/favicon.ico
+elif [ ! -f "$HESTIA/web/images/custom/favicon.ico" ] && [ "$download" = "yes" ]; then
+	download_file https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/favicon.ico $HESTIA/web/favicon.ico
+fi
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+exit

+ 4 - 0
func/upgrade.sh

@@ -780,6 +780,10 @@ upgrade_rebuild_users() {
 	fi
 }
 
+update_whitelabel_logo() {
+	$BIN/v-update-white-label-logo
+}
+
 upgrade_replace_default_config() {
 	syshealth_update_web_config_format
 	syshealth_update_mail_config_format

+ 3 - 0
src/deb/hestia/postinst

@@ -98,6 +98,9 @@ upgrade_phppgadmin | tee -a $LOG
 # Upgrade blackblaze-cli-took if applicable
 upgrade_b2_tool | tee -a $LOG
 
+# update whitelabel logo's
+update_whitelabel_logo | tee -a $LOG
+
 # Set new version number in hestia.conf
 upgrade_set_version $new_version
 upgrade_set_branch $new_version

+ 3 - 0
src/rpm/hestia/hestia.spec

@@ -119,6 +119,9 @@ if [ -e "/usr/local/hestia/data/users/admin" ]; then
     # Upgrade blackblaze-cli-took if applicable
     upgrade_b2_tool | tee -a $LOG
 
+	# update whitelabel logo's
+	update_whitelabel_logo | tee -a $LOG
+
     # Set new version number in hestia.conf
     upgrade_set_version
 

+ 29 - 0
web/templates/pages/edit_whitelabel.php

@@ -113,6 +113,35 @@
 					</div>
 				</div>
 			</details>
+			<!-- Basic options section -->
+			<details class="collapse u-mb10">
+				<summary class="collapse-header">
+					<i class="fas fa-gear u-mr15"></i>
+					<?= _("Custom Logo") ?>
+				</summary>
+				<div class="collapse-content">
+					<div class="u-mb10">
+						<label for="v_custom_logo" class="form-label">
+							<?= _("Custom logo") ?>
+						</label>
+					</div>
+					<div class="u-mb10">
+						<p><?=sprintf(_("Upload the files to %s"), '/usr/local/hestia/web/images/custom/');?></p>
+						<ul>
+							<li>logo.svg <small>(100px x 120px)</small></li>
+							<li>logo.png <small>(100px x 120px)</small></li>
+							<li>logo-header.png <small>(54x x 29px)</small></li>
+							<li>favicon.png <small>(64px x 64px)</small></li>
+							<li>favicon.ico<<small>(16px x 16px)</small></li>
+						</ul>
+					</div>
+					<div class="u-mb10">
+						<input type="checkbox" id="v_update_logo" name="v_update_logo">
+						<label for="v_update_logo" class="form-label">
+							<?= _("Update logo") ?>
+						</label>
+					</div>
+			</details>
 		</div>
 	</form>
 </div>