Przeglądaj źródła

Bring back www-alias to rework the function.

Raphael Schneeberger 6 lat temu
rodzic
commit
2c80ec025e
3 zmienionych plików z 30 dodań i 11 usunięć
  1. 12 1
      bin/v-add-web-domain
  2. 8 0
      web/js/pages/add_web.js
  3. 10 10
      web/templates/admin/add_web.html

+ 12 - 1
bin/v-add-web-domain

@@ -115,7 +115,18 @@ fi
 if [ "$aliases" = 'none' ]; then
 if [ "$aliases" = 'none' ]; then
     ALIAS=''
     ALIAS=''
 else
 else
-    ALIAS="$aliases"
+    ALIAS="www.$domain"
+    if [ -z "$aliases" ]; then
+        # Check and skip www alias for subdomains.
+        IFS='.' read -r -a domain_elements <<< "$domain"
+        if [ "${#domain_elements[@]}" -gt 2 ]; then
+            ALIAS=""
+        else
+            ALIAS="www.$domain"
+        fi
+    else
+        ALIAS="$aliases"
+    fi
 
 
     ip_alias=$(get_ip_alias $domain)
     ip_alias=$(get_ip_alias $domain)
     if [ ! -z "$ip_alias" ]; then
     if [ ! -z "$ip_alias" ]; then

+ 8 - 0
web/js/pages/add_web.js

@@ -172,6 +172,14 @@ App.Listeners.WEB.keypress_domain_name();
 
 
 
 
 $(function() {
 $(function() {
+    $('#v_domain').change(function() {
+        var prefix = 'www.';
+        if (((document.getElementById('v_domain').value).split(".")).length > 2) {
+            document.getElementById('v_aliases').value = "";
+        } else {
+            document.getElementById('v_aliases').value = prefix + document.getElementById('v_domain').value;
+        }
+    });
     App.Actions.WEB.toggle_letsencrypt($('input[name=v_letsencrypt]'))
     App.Actions.WEB.toggle_letsencrypt($('input[name=v_letsencrypt]'))
 
 
     $('select[name="v_stats"]').change(function(evt){
     $('select[name="v_stats"]').change(function(evt){

+ 10 - 10
web/templates/admin/add_web.html

@@ -67,16 +67,6 @@
                                 <input type="text" size="20" class="vst-input" name="v_domain" id="v_domain" value="<?=htmlentities(trim($v_domain, "'"))?>">
                                 <input type="text" size="20" class="vst-input" name="v_domain" id="v_domain" value="<?=htmlentities(trim($v_domain, "'"))?>">
                             </td>
                             </td>
                         </tr>
                         </tr>
-                        <tr>
-                            <td class="vst-text input-label">
-                                <?php print __('Aliases');?>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td>
-                                <textarea size="20" class="vst-textinput short" name="v_aliases" id="v_aliases" ><?=htmlentities(trim($v_aliases, "'"))?></textarea>
-                            </td>
-                        </tr>
                         <tr>
                         <tr>
                             <td class="vst-text input-label">
                             <td class="vst-text input-label">
                                 <?php print __('IP address');?>
                                 <?php print __('IP address');?>
@@ -116,6 +106,16 @@
                         </tr>
                         </tr>
                     </table>
                     </table>
                     <table class="data-col2" width="600px" style="display:<?php if (empty($v_adv)) echo 'none';?> ;" id="advtable">
                     <table class="data-col2" width="600px" style="display:<?php if (empty($v_adv)) echo 'none';?> ;" id="advtable">
+                        <tr>
+                            <td class="vst-text input-label">
+                                <?php print __('Aliases');?>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td>
+                                <textarea size="20" class="vst-textinput short" name="v_aliases" id="v_aliases" ><?=htmlentities(trim($v_aliases, "'"))?></textarea>
+                            </td>
+                        </tr>
                         <?php if (!empty($_SESSION['PROXY_SYSTEM'])) { echo ""; ?>
                         <?php if (!empty($_SESSION['PROXY_SYSTEM'])) { echo ""; ?>
                         <tr>
                         <tr>
                             <td class="vst-text step-top" >
                             <td class="vst-text step-top" >