#!/bin/sh

#turn off auto expansion
set -f

_()
{
LANG=${in_language%%;*}.utf8 gettext "alterator-services" "$1"
}


. /usr/share/alterator/build/backend3.sh

on_message()
{
	case "$in_action" in
		#information for renderer
		template)
			case "$in__objects" in
			/)
			    if [ -n "$in_new" ]; then
				echo '('
				echo ' template "form"'
				echo ' redirect "/services/new"'
				echo ')'
				return
			    fi

			    echo '('
			    echo ' template "card-index"'
			    echo ' url "services.html"'
			    echo ' help "services.html"'
			    echo ')'
			    ;;
			new)
			    if [ -n "$in_cancel" ]; then
				echo '('
				echo ' template "form"'
				echo ' redirect "/services"'
				echo ')'
				return
			    fi
			    echo '('
			    echo ' template "card-index"'
			    echo ' url "services-new.html"'
			    echo ' help "services.html"'
			    echo ' translate "alterator-services"'
			    echo ' redirect "/services"'
			    echo ')'
			    ;;
			*)
			    echo '#f'
			    ;;
		    esac
			;;
		info)
			echo '('
			printf ' title "%s"' "$(_ "System services")"
			printf ' description "%s"' "$(_ "System services administration")"
			printf ' group "%s"' "$(_ "System")"
			printf ' weight 108'
			echo ')'
			;;
		*)
			echo '#f'
			;;
	esac
}

message_loop
