function sitemap(goUp) % Web Site Map Generation % Version 1.0 % Last modified 26.12.01 % For Matlab 5.x % File sitemap.m % Copyright (c) 2000-2001 Igor Kagan % kigor@tx.technion.ac.il % http://igoresha.virtualave.net % % Usage: In Matlab Command Window, change to your site root directory and type: % sitemap (first add the directory containing sitemap.m to Matlab search path) % % Description: % This function uses ... and % html tags % to fill entry for each html/htm file. % If these tags are not specified, sitemap wil just list the files % and dirs in the current dir. % Sitemap will create (and _overwrite_ if file with this name already exists!) % file Sitemap.html, which can be edited in any HTML/text % editor later, if there is a need to do so. % % Note that links in Sitemap.html will _not_ work while you are in your local hard drive! % Once you upload this file in the root dir of your server, they will work. % Changes history % Version 1.0 - first version global smc nfiles ndirs baseurl % need access these variables during recursive calls if nargin < 1, % add to path curdir = cd; matlabpath = path; if isempty(findstr(lower(matlabpath),lower(curdir))), path(matlabpath,curdir); end; % define startup parameters baseurl = pwd; goUp = 0; smc = []; % site map html contents nfiles = 0; ndirs = 1; % first is root dir startentry = ['Site Map' sprintf('\n')]; smc = [smc startentry]; end % finish prevoius dir smc = [smc ['']]; % get current dir listing d = dir; dirname = [strrep(pwd,baseurl,'') '/']; % for root dir dirname = [strrep(dirname,'\','/')]; direntry = ['' sprintf('\n')]; ndirs = ndirs + 1; smc = [smc direntry]; d = d(3:length(d)); [t,ind]=sort(cat(1,d.isdir)); d = d(ind); for i=1:size(d,1), if d(i).isdir, cd(d(i).name); sitemap(1); else if findstr(d(i).name,'.htm'), disp(d(i).name); fidr=fopen(d(i).name,'r'); F = fread(fidr); fclose(fidr); F = F(find(F~=10 & F~=13 & F~=9)); S = char(F'); s = lower(S); % find title i1 = findstr(s,''); % length 7 i2 = findstr(s,''); Title = S(i1+7:i2-1); % find description i1 = findstr(s,''); Description = S(i1+34:i1+i2(1)-1); else Description = '(no content specified)'; end % write file entry fileentry = ['' sprintf('\n')]; nfiles = nfiles + 1; smc = [smc fileentry]; end end end if (goUp), cd .. else % finish html finishentry = ['
Sitemap

',dirname,'
',d(i).name,' ',Title,'
',Description,'


',num2str(nfiles),' files in ',num2str(ndirs),' dirs
This site map was generated at ',date,' by sitemap.m
']; smc = [smc finishentry]; % write Sitemap.html file if exist([cd '\Sitemap.html']), !del Sitemap.html end fidw = fopen('Sitemap.html','wt'); fwrite(fidw,smc,'char'); fclose(fidw); end return