<?vsp
--
--  $Id$
--
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--
--  Copyright (C) 1998-2018 OpenLink Software
--
--  This project 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; only version 2 of the License, dated June 1991.
--
--  This program 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, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--

  declare _cmd varchar;
  declare _note_id varchar;
  declare _text varchar;
  declare _note "NoteInfo";
  declare _uid integer;
  declare _uname, _md5 varchar;
  declare _startofs integer;
  declare _base_adjust varchar;
  if (not WV.WIKI.VSPCHECKDAVAUTH(path,params,lines))
    return;
again:
--  if (WV.WIKI.VSPLOGIN (path, params, lines, _uid, _uname, _md5) is not null) return;
  if (length (path) < 1)
    {
      http('<H3>Wiki resource not found</H3>Path to resource must be of form /wikiview/<i>Cluster</i>/<i>PageName</i>');
      WV.WIKI.VSPFOOTER (path,params,lines);
      return;
    }
  if ('DAV' = aref (path, 0))
    {
      _startofs := 2;
      if (length (path) > 4)
	{
	  http('<H3>Wiki resource not found</H3>Path to resource must be of form /DAV/wikiview/<i>Cluster</i>/<i>PageName</i>');
	  WV.WIKI.VSPFOOTER (path,params,lines);
	  return;
	}
    }
  else
    {
      _startofs := 1;
      if (length (path) > 3)
	{
	  http('<H3>Wiki resource not found</H3>Path to resource must be of form /wikiview/<i>Cluster</i>/<i>PageName</i>');
	  WV.WIKI.VSPFOOTER (path,params,lines);
	  return;
	}
    }
  _note := WV.WIKI.NOTEINFO();
  _base_adjust := '';
  if (length (path) > _startofs)
    {
      _note.ni_cluster_name := aref (path, _startofs);
    }
  else
    {
      _note.ni_cluster_name := 'Main';
      _base_adjust := concat (aref (path, _startofs - 1), '/');
    }
  _note.ni_fill_cluster_by_name();
  if (_note.ni_cluster_id = 0)
    { 
      http (concat ('<H3>Wiki cluster "', _note.ni_cluster_name, '" not found</H3>'));
      WV.WIKI.VSPFOOTER (path,params,lines);
      return;
    }
  if (length (path) > _startofs + 1)
    {
      _note.ni_local_name := aref (path, _startofs + 1);
      _base_adjust := '../';
    }
  else
    {
      _note.ni_local_name := 'WelcomeVisitors';
    }
  _note.ni_find_id_by_local_name();
  --_note.ni_http_debug_print('page info');
  if (_note.ni_id = 0)
    { 
      http(concat ('<H3>Wiki note "', _note.ni_cluster_name, '.', _note.ni_local_name, '" not found</H3>'));
      WV.WIKI.VSPFOOTER (path,params,lines);
      return;
    }
  _note.ni_raw_title := concat (_note.ni_cluster_name, '.', _note.ni_local_name);
  WV.WIKI.VSPHEADER (path,params,lines, _note.ni_raw_title);
  WV.WIKI.VSPNOTEREADONLY (path,params,lines, _uid, _note.ni_id, _base_adjust);
  --declare _searchmode, _searchtext varchar;
  WV.WIKI.VSPFOOTER (path,params,lines); 
?>
