IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
log_html.m
Go to the documentation of this file.
1 %> @brief Generated by @ref irreport, carries HTML contents
2 classdef log_html < irlog
3  properties
4  %> HTML string. Please note that it should contain only things inside the BODY tag. @c html will be "embodied" by embody()
5  html;
6  %> File name to save to. If left empty, an unexisting filename will be generated when necessary
7  filename;
8  end;
9  methods
10  function o = log_html()
11  o.flag_ui = 0;
12  o.moreactions{end+1} = 'open_in_browser';
13  end;
14 
15  function s = get_embodied(o)
16  s = [...
17 '<html>', 10, ...
18 '<head>', 10, ...
19 '<title>', o.title, '</title>', 10, ...
20 stylesheet(), 10, ...
21 '<body>', 10, ...
22 o.html, 10, ...
23 '</body>', 10, ...
24 '</html>', 10, ...
25 ];
26  end;
27 
28  %> @return
29  function fn = save(o)
30  if isempty(o.filename)
31  fn = find_filename('irr_html', [], 'html');
32  else
33  fn = o.filename;
34  end;
35 
36  h = fopen(fn, 'w');
37  if h <= 0
38  irerror(sprintf('Could''t create file "%s"', fn));
39  end;
40  fwrite(h, o.get_embodied());
41  fclose(h);
42  end;
43 
44  function o = open_in_browser(o)
45  fn = o.save();
46  web(fn, '-new');
47  end;
48  end;
49 end
function irerror(in s)
function stylesheet()
Generated by irreport, carries HTML contents.
Definition: log_html.m:2
Log base class.
Definition: irlog.m:5
function find_filename(in prefix, in suffix, in extension, in flag_return_ext)
Report base class.
Definition: irreport.m:8