#!/bin/sh

# view_it
# Copyright (C) 2025 Joseph Rosevear, San Diego CA, USA.

# This file is part of a distribution SAM.

# SAM is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.

# SAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.



# Joseph Rosevear 231229 I wrote this script.

# Joseph Rosevear 231231 I removed "." in two places.

# I added "cd $level/data".

# Joseph Rosevear 240101 I added code which branches and gives an error
# message if sam_view is "".

# I replaced "sam_view" with "viewer".

# Joseph Rosevear 240702 I removed: the line that changes to
# $level/data and, in complementary fashion, I changed two references
# to a target file to use "$level/data" in front of the path.

# Joseph Rosevear 240724 I removed the line that did this:

#    i_browser=/home/joe/gofirefox

# I removed some commented-out lines.

# Joseph Rosevear 240729 I added some comments.  I added definitions of
# path and dir.  I replaced "$level" with "$dir".

# Joseph Rosevear 240729 I removed the use of $2.



# Definitions.
type_set
base=`basename $0`

# This allows for representation of target by symlink name.
if [ "$base" != "view_it" ]; then

   target="$base"
fi

path=`which $target`
dir=`dirname $path`

# Bail if viewer is not defined.
if [ "$viewer" = "" ]; then

   echo
   echo $base: viewer is not defined.
   
# Run $viewer.
else 

   i_browser=$i_browser type=$type \
   $viewer $dir/data/${target}${suf}$1
fi
