1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/element_ynh.git synced 2024-09-03 18:36:08 +02:00

Fix patch source

This commit is contained in:
Josué Tille 2018-09-11 09:38:27 +02:00
parent 924859de87
commit 88e6a1492e

View file

@ -18,7 +18,7 @@ config_riot() {
install_source() {
ynh_setup_source $final_path/
# if the default homeserver is external we dont add the sso support
if [[ $(yunohost domain list | grep "$default_home_server") ]]
then
@ -27,16 +27,16 @@ install_source() {
test -n $cert_path && cp "$cert_path" $final_path/crt.pem
chmod 600 $final_path/crt.pem
chown $app:root $final_path/crt.pem
cp ../sources/get_user_token.php $final_path/
# Patch the riot bundle.js file
# This file is a minified javascript so it's not possible to use the standrad patch because everything is only on one line.
# The other problem is that some variable a renamed to be more short.
# Here this variable is named unamed_object. By the regular expression we will be able to get this name and to put in the new code.
# To make the code more readable (for debug), we can use the tool js-beautify available here : https://github.com/beautify-web/js-beautify
# We escape all char witch could be a problem in regular expression.
escape_string() {
a=${a//'\'/'\\'}
@ -47,10 +47,12 @@ install_source() {
a=${a//'}'/'\}'}
a=${a//'.'/'\.'}
a=${a//'*'/'\*'}
a=${a//'^'/'\^'}
a=${a//'$'/'\$'}
}
# We get the name of the Lifecycle objet
Lifecycle_object_name=$(egrep -o "onLoggedIn:\w+\.setLoggedIn," bundle.js $final_path/bundles/*/bundle.js | egrep -o ":\w+\." | egrep -o "\w")
Lifecycle_object_name=$(egrep -o 'onLoggedIn:[\w\$]+\.setLoggedIn,' $final_path/bundles/*/bundle.js | egrep -o ':[\w\$]+\.' | egrep -o '[\w\$]')
# We get the part witch we need to patch and create a regular expression
a='case"start_login":this.setStateForNewView({view:unnamed_object.LOGIN}),this.notifyNewScreen("login");break;'