even more minor changes, version bump
This commit is contained in:
parent
88b92037c1
commit
d1191caf9b
44
iron
44
iron
|
@ -52,7 +52,7 @@ end_session() {
|
|||
# init
|
||||
main() {
|
||||
# few basic checks
|
||||
[ -z "$(command -v jq)" ] && die "error: jq not found."
|
||||
[ -z "$(command -v jq)" ] && die "fatal error: jq not found."
|
||||
[ -z "$working_dir" ] && working_dir=$HOME/.local/share/iron
|
||||
|
||||
# check args
|
||||
|
@ -88,7 +88,7 @@ main() {
|
|||
|
||||
name="iron"
|
||||
ver="1.3"
|
||||
exver="12-09-2022-r1"
|
||||
exver="09-04-2022"
|
||||
s='─'
|
||||
sc="$(tput cols)"
|
||||
curmode="-- NORMAL --" # default mode is normal mode
|
||||
|
@ -127,7 +127,7 @@ dl_api()
|
|||
{
|
||||
# download everything from the api
|
||||
curl -so "$working_dir/iron-api-orig" "$instance/api.php"
|
||||
[ -e "$working_dir/iron-api-orig" ] && sed "s|\n|${color_01}\n|g" $working_dir/iron-api-orig > $working_dir/iron-api || dl_api
|
||||
[ -e "$working_dir/iron-api-orig" ] && sed "s|\n|${color_01}\n|g" "$working_dir/iron-api-orig" > "$working_dir/iron-api" || dl_api
|
||||
}
|
||||
|
||||
ph() {
|
||||
|
@ -140,10 +140,10 @@ ph() {
|
|||
printstr "${color_07}$name was started: '$(date '+%T')'.\n"
|
||||
printstr "Welcome to $name $ver. $name is a rautafarmi textboard client with Vim keybinds."
|
||||
|
||||
[ -z "$instance" ] && Pinstance="None set." || Pinstance="$instance"
|
||||
[ -z "$instance" ] && pinstance="None set." || pinstance="$instance"
|
||||
|
||||
# print instance text/url
|
||||
printn "\n${color_03}Instance: '$Pinstance'\n${color_01}"
|
||||
printn "\n${color_03}Instance: '$pinstance'\n${color_01}"
|
||||
printn "\n${color_02}iron written by speedie & potential contributors and is licensed under the GNU General Public License version 3.0 free software license."
|
||||
printn "\n${color_05}See https://speedie.gq/projects/iron.php or https://codeberg.org/speedie/iron for more information.${color_01}\n"
|
||||
}
|
||||
|
@ -152,17 +152,17 @@ ph() {
|
|||
|
||||
while true; do
|
||||
# get user cmd
|
||||
read -n 1 iscmd
|
||||
read -r -n 1 iscmd
|
||||
|
||||
# check what to do
|
||||
if [ "$iscmd" != ":" ]; then
|
||||
case "$iscmd" in
|
||||
"Z") read -n 1 zbind ;;
|
||||
"Z") read -r -n 1 zbind ;;
|
||||
esac
|
||||
|
||||
clear; printstrh
|
||||
else
|
||||
read CM
|
||||
read -r bind
|
||||
fi
|
||||
|
||||
# ZZ and ZQ binds
|
||||
|
@ -172,7 +172,7 @@ ph() {
|
|||
esac
|
||||
|
||||
# misc binds
|
||||
case "$CM" in
|
||||
case "$bind" in
|
||||
"Q") exitclient 0 ;;
|
||||
"Z") $0 && exitclient 0 ;;
|
||||
"q") exitclient 0 ;;
|
||||
|
@ -180,7 +180,7 @@ ph() {
|
|||
"quit") exitclient 0 ;;
|
||||
"j") touch "$working_dir/iron-session" && main ;;
|
||||
"set captcha") set_cap ;;
|
||||
"set instance") clear ; printheader ; printn "Enter your instance (Example: https://example.com/ironfarms):\n> " ; read instance ; printf "%s" "$instance" > "$working_dir/iron-instance" && clear && printheader && \
|
||||
"set instance") clear ; printheader ; printn "Enter your instance (Example: https://example.com/ironfarms):\n> " ; read -r instance ; printf "%s" "$instance" > "$working_dir/iron-instance" && clear && printheader && \
|
||||
printf "%s000 - SYSTEM at %s\nSet instance to '%s'.%s" "${color_06}" "$(date '+%Y/%m/%d %T:')" "$instance" "${color_01}" && sleep 3 && ${0} && exitclient 0 ;;
|
||||
"set instance default") echo "$definstance" > "$working_dir/iron-instance" && clear && printheader && \
|
||||
printf "%s000 - SYSTEM at %s\nSet instance to '%s'.%s" "${color_06}" "$(date '+%Y/%m/%d %T:')" "$definstance" "${color_01}" && sleep 3 && ${0} && exitclient 0 ;;
|
||||
|
@ -204,7 +204,7 @@ set_cap() {
|
|||
parse_msgs() {
|
||||
if [ "$do_not_reparse" != "true" ]; then
|
||||
# fail if the json is not valid
|
||||
FAIL_COULD_NOT_PARSE() {
|
||||
failed_to_parse_json() {
|
||||
# originally wanted to fail the client completely if the json isn't valid
|
||||
# there is currently some weird bug though so for now we'll restart it to hide the problem
|
||||
clear
|
||||
|
@ -221,14 +221,14 @@ parse_msgs() {
|
|||
dl_api
|
||||
|
||||
# save individual data to combine later
|
||||
jq -e ".posts[] .username" $working_dir/iron-api > "$working_dir/iron-username" || FAIL_COULD_NOT_PARSE
|
||||
jq -e ".posts[] .message" $working_dir/iron-api > "$working_dir/iron-message" || FAIL_COULD_NOT_PARSE
|
||||
jq -e ".posts[] .time" $working_dir/iron-api > "$working_dir/iron-messagetime" || FAIL_COULD_NOT_PARSE
|
||||
jq -e ".posts[] .postID" $working_dir/iron-api > "$working_dir/iron-messageid" || FAIL_COULD_NOT_PARSE
|
||||
jq -e ".posts[] .imageURL" $working_dir/iron-api > "$working_dir/iron-messageimg" || FAIL_COULD_NOT_PARSE
|
||||
jq -e ".posts[] .username" "$working_dir/iron-api" > "$working_dir/iron-username" || failed_to_parse_json
|
||||
jq -e ".posts[] .message" "$working_dir/iron-api" > "$working_dir/iron-message" || failed_to_parse_json
|
||||
jq -e ".posts[] .time" "$working_dir/iron-api" > "$working_dir/iron-messagetime" || failed_to_parse_json
|
||||
jq -e ".posts[] .postID" "$working_dir/iron-api" > "$working_dir/iron-messageid" || failed_to_parse_json
|
||||
jq -e ".posts[] .imageURL" "$working_dir/iron-api" > "$working_dir/iron-messageimg" || failed_to_parse_json
|
||||
|
||||
# delete prev message data
|
||||
rm -f $working_dir/iron-messagedata
|
||||
rm -f "$working_dir/iron-messagedata"
|
||||
|
||||
# format it somewhat
|
||||
# we will mostly print this file as it is
|
||||
|
@ -239,13 +239,13 @@ parse_msgs() {
|
|||
message="$(head -n "$i" "$working_dir/iron-message" | tail -n 1 | sed "s/%/%%/g; s/>>/DISREPLY/g; s/>/DISGTEXT/g; s/DISREPLY/${color_04}>>/g; s/DISGTEXT/${color_07}>/g; s/\" \"//g")"
|
||||
time="$(head -n "$i" "$working_dir/iron-messagetime" | tail -n 1)"
|
||||
id="$(head -n "$i" "$working_dir/iron-messageid" | tail -n 1)"
|
||||
imageurl="$(head -n "$i" "$working_dir/iron-messageimg" | tail -n 1 | sed 's/""/NoImg/g')"
|
||||
imageurl="$(head -n "$i" "$working_dir/iron-messageimg" | tail -n 1 | sed 's/""/iron_no_image/g')"
|
||||
|
||||
# image url formatting
|
||||
imgformattingb="]"
|
||||
[ -z "$message" ] && [ "$imageurl" != "NoImg" ] && imgformattinga="[URL: "
|
||||
[ ! -z "$message" ] && imgformattinga=" [URL: "
|
||||
[ "$imageurl" = "NoImg" ] && imgformattinga="" && imgformattingb="" && imageurl=""
|
||||
[ -z "$message" ] && [ "$imageurl" != "iron_no_image" ] && imgformattinga="[URL: "
|
||||
[ ! -z "$message" ] && imgformattinga=" [URL: "
|
||||
[ "$imageurl" = "iron_no_image" ] && imgformattinga="" && imgformattingb="" && imageurl=""
|
||||
|
||||
# print it
|
||||
printf "%s%s - %s%s%s at %s%s:%s\n%s%s%s%s%s%s%s\n" \
|
||||
|
@ -356,7 +356,7 @@ zbind() {
|
|||
|
||||
check_mode() {
|
||||
while true; do
|
||||
read -t 1 -n 1 curmode > /dev/null
|
||||
read -r -t 1 -n 1 curmode > /dev/null
|
||||
|
||||
case "$curmode" in
|
||||
"i") curmode="INSERT" && insert ;;
|
||||
|
|
Loading…
Reference in a new issue