mirror of
https://github.com/YunoHost-Apps/snweb_ynh.git
synced 2024-09-03 20:26:22 +02:00
Activate path url
This commit is contained in:
parent
d6f4c167d0
commit
ed38ef8585
6 changed files with 54 additions and 4 deletions
|
@ -17,3 +17,6 @@ DATADOG_ENABLED=false
|
||||||
DEV_DEFAULT_SYNC_SERVER=https://sync.standardnotes.org
|
DEV_DEFAULT_SYNC_SERVER=https://sync.standardnotes.org
|
||||||
DEV_EXTENSIONS_MANAGER_LOCATION=public/extensions/extensions-manager/dist/index.html
|
DEV_EXTENSIONS_MANAGER_LOCATION=public/extensions/extensions-manager/dist/index.html
|
||||||
DEV_BATCH_MANAGER_LOCATION=public/extensions/batch-manager/dist/index.min.html
|
DEV_BATCH_MANAGER_LOCATION=public/extensions/batch-manager/dist/index.min.html
|
||||||
|
|
||||||
|
# Sub-URI
|
||||||
|
RAILS_RELATIVE_URL_ROOT=/
|
||||||
|
|
|
@ -34,6 +34,15 @@
|
||||||
"type": "domain",
|
"type": "domain",
|
||||||
"example": "example.com"
|
"example": "example.com"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "path",
|
||||||
|
"type": "path",
|
||||||
|
"example": "/notes",
|
||||||
|
"default": "/",
|
||||||
|
"help": {
|
||||||
|
"en": "You can use extensions only without a path url."
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
@ -17,8 +17,7 @@ old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
old_path=$YNH_APP_OLD_PATH
|
old_path=$YNH_APP_OLD_PATH
|
||||||
|
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
#new_path=$YNH_APP_NEW_PATH
|
new_path=$YNH_APP_NEW_PATH
|
||||||
new_path="/"
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -108,6 +107,7 @@ fi
|
||||||
|
|
||||||
config_file="$final_path/live/.env"
|
config_file="$final_path/live/.env"
|
||||||
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$new_domain${new_path%/}" --target_file="$config_file"
|
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$new_domain${new_path%/}" --target_file="$config_file"
|
||||||
|
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=$old_path" --replace_string="RAILS_RELATIVE_URL_ROOT=$new_path" --target_file="$config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
#path_url=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
path_url="/"
|
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
snserver_domain=$YNH_APP_ARG_SNSERVER_DOMAIN
|
snserver_domain=$YNH_APP_ARG_SNSERVER_DOMAIN
|
||||||
|
@ -88,6 +87,14 @@ pushd "$final_path/live"
|
||||||
git submodule update --init --recursive --quiet
|
git submodule update --init --recursive --quiet
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
# Apply Patch
|
||||||
|
if [ -f "$YNH_CWD/../sources/patches/app-00-add-path-url.patch" ]
|
||||||
|
then
|
||||||
|
pushd "$final_path/live"
|
||||||
|
patch --strip=1 < "$YNH_CWD/../sources/patches/app-00-add-path-url.patch"
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -134,6 +141,7 @@ if [ "$snserver_domain" = "" ]; then
|
||||||
snserver_domain="sync.standardnotes.org"
|
snserver_domain="sync.standardnotes.org"
|
||||||
fi
|
fi
|
||||||
ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --replace_string="SF_DEFAULT_SERVER=https://$snserver_domain" --target_file="$config_file"
|
ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --replace_string="SF_DEFAULT_SERVER=https://$snserver_domain" --target_file="$config_file"
|
||||||
|
ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=.*$" --replace_string="RAILS_RELATIVE_URL_ROOT=$path_url" --target_file="$config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILDING
|
# BUILDING
|
||||||
|
|
|
@ -53,6 +53,24 @@ if [ -z "$final_path" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ynh_compare_current_package_version --comparison lt --version "3.6.8~ynh1"
|
||||||
|
then
|
||||||
|
# Add variables to .env config file
|
||||||
|
echo -e "\
|
||||||
|
\n# Sub-URI\
|
||||||
|
\nRAILS_RELATIVE_URL_ROOT=/\
|
||||||
|
" >> "$config_file"
|
||||||
|
|
||||||
|
# Apply Patch
|
||||||
|
if [ -f "$YNH_CWD/../sources/patches/app-00-add-path-url.patch" ]
|
||||||
|
then
|
||||||
|
pushd "$final_path/live"
|
||||||
|
patch --strip=1 < "$YNH_CWD/../sources/patches/app-00-add-path-url.patch"
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
12
sources/patches/app-00-add-path-url.patch
Normal file
12
sources/patches/app-00-add-path-url.patch
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
diff --git a/config.ru b/config.ru
|
||||||
|
index bd83b25..6b1bb50 100644
|
||||||
|
--- a/config.ru
|
||||||
|
+++ b/config.ru
|
||||||
|
@@ -1,4 +1,6 @@
|
||||||
|
# This file is used by Rack-based servers to start the application.
|
||||||
|
|
||||||
|
require ::File.expand_path('../config/environment', __FILE__)
|
||||||
|
-run Rails.application
|
||||||
|
+map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
|
||||||
|
+ run Rails.application
|
||||||
|
+end
|
Loading…
Add table
Reference in a new issue