Browse Source

Add accent translation

Paolo Galli 4 years ago
parent
commit
35728f53ac
2 changed files with 8 additions and 3 deletions
  1. 1 1
      README.md
  2. 7 2
      lcmlog

+ 1 - 1
README.md

@@ -7,7 +7,7 @@ Client side of a tool for reading and writing the lcm staff logs (both admins an
 The `GET` method is called with the `-g` option and is used to print all the logs that meet the required criteria.
 
 #### POST
-The `POST` method is called with the `-p` option and is used to add a log to the database.
+The `POST` method is called with the `-p` option and is used to add a log to the database. Accented characters are allowed and automatically transformed using quotes.
 
 #### UPDATE
 The `UPDATE` method is called with the `-u` option and is used to regenerate the internal server database. It should only be called if a log file is added by hand, or if some of the log files get renamed or corrupted. It assumes that all the log files are correctly formatted.

+ 7 - 2
lcmlog

@@ -280,6 +280,7 @@ method_post()
 	FILE_NAME=$(mktemp)
 	$EDITOR $FILE_NAME
 	cat $FILE_NAME >> $pipe
+	rm $FILE_NAME
 }
 
 
@@ -409,15 +410,19 @@ elif [ "$METHOD" == "POST" ]; then
 	method_post $pipe
 fi
 
+# Remove accents
+pipe2=$(mktemp)
+sed -e 's/à/a`/g' -e 's/è/e`/g' -e "s/é/e'/g" -e 's/ì/i`/g' -e 's/ò/o`/g' -e 's/ù/u`/g' -e 's/È/E`/g' < $pipe > $pipe2
+
 # Call the server
 echo
-ssh -F ~/.config/lcmlog/config -s server lcmlog < $pipe
+ssh -F ~/.config/lcmlog/config -s server lcmlog < $pipe2
 
 
 ### ENDING
 
 # Remove temporary pipe
-rm $pipe
+rm $pipe $pipe2
 
 # Check success or error
 RET=$?