frontend: add script to change frontend base URL
This commit is contained in:
parent
76a4c09f37
commit
b31f009d2e
2 changed files with 46 additions and 12 deletions
44
frontend/chbase.sh
Executable file
44
frontend/chbase.sh
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# You can define the current base URL in your environment
|
||||||
|
[ -n "${CURRENT_BASE}" ] || CURRENT_BASE="/"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "$0 NEWBASE STATICDIR"
|
||||||
|
echo
|
||||||
|
echo " This script can be used to change the base URL of the frontend."
|
||||||
|
echo " Gives as PATH, the path to the static directory."
|
||||||
|
echo " You should use this script only one time (ie. from a fresh git repository),"
|
||||||
|
echo " as it doesn't erase previously defined base: it assumes the current base is /."
|
||||||
|
echo
|
||||||
|
echo " For example:"
|
||||||
|
echo
|
||||||
|
echo " $0 /$(date -d 'next year' +%Y)/" static/
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
run() {
|
||||||
|
local NEWBASE=$1
|
||||||
|
local FILE=$2
|
||||||
|
|
||||||
|
if [ -d "${FILE}" ]
|
||||||
|
then
|
||||||
|
for f in "${FILE}/"*.html "${FILE}/"*.js
|
||||||
|
do
|
||||||
|
run "${NEWBASE}" "${f}"
|
||||||
|
done
|
||||||
|
[ -d "${FILE}/js/" ] && run "${NEWBASE}" "${FILE}/js"
|
||||||
|
[ -d "${FILE}/views/" ] && run "${NEWBASE}" "${FILE}/views"
|
||||||
|
elif [ -f "${FILE}" ]
|
||||||
|
then
|
||||||
|
sed -ri "s@(href|src)=\"${CURRENT_BASE}@\1=\"${NEWBASE}@g;s@\\\$http.get\(\"${CURRENT_BASE}@\$http.get\(\"${NEWBASE}@g;s@\\\$http\((.*)\"${CURRENT_BASE}@\$http(\1\"${NEWBASE}@g" ${FILE}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -gt 1 ]
|
||||||
|
then
|
||||||
|
run $1 $2
|
||||||
|
else
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -172,13 +172,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||||
|
|
||||||
$scope.hsubmit = function(hint) {
|
$scope.hsubmit = function(hint) {
|
||||||
hint.submitted = true;
|
hint.submitted = true;
|
||||||
$http({
|
$http({ url: "/openhint/" + $rootScope.current_exercice, method: "POST", data: { id: hint.id } }).success(function(data, status, header, config) {
|
||||||
url: "/openhint/" + $rootScope.current_exercice,
|
|
||||||
method: "POST",
|
|
||||||
data: {
|
|
||||||
id: hint.id
|
|
||||||
}
|
|
||||||
}).success(function(data, status, header, config) {
|
|
||||||
var checkDiffHint = function() {
|
var checkDiffHint = function() {
|
||||||
$http.get("/my.json").success(function(my) {
|
$http.get("/my.json").success(function(my) {
|
||||||
angular.forEach(my.exercices[$rootScope.current_exercice].hints, function(h,hid){
|
angular.forEach(my.exercices[$rootScope.current_exercice].hints, function(h,hid){
|
||||||
|
@ -231,11 +225,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||||
flgs[flag.name] = flag.value;
|
flgs[flag.name] = flag.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
$http({
|
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: flgs }).success(function(data, status, header, config) {
|
||||||
url: "/submit/" + $rootScope.current_exercice,
|
|
||||||
method: "POST",
|
|
||||||
data: flgs
|
|
||||||
}).success(function(data, status, header, config) {
|
|
||||||
$rootScope.messageClass = {"text-success": true};
|
$rootScope.messageClass = {"text-success": true};
|
||||||
$rootScope.message = data.errmsg;
|
$rootScope.message = data.errmsg;
|
||||||
$rootScope.sberr = "";
|
$rootScope.sberr = "";
|
||||||
|
|
Reference in a new issue