summaryrefslogtreecommitdiffabout
path: root/htdocs/view.chtml
blob: 809c54ff44394b65780f61a0aa57c4019f03901f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
% /* vim:set ft=sitecing: */
%%derive page = "/ancestry/page.chtml";
%%derive sources = "/ancestry/sources.chtml";
%%pragma main=page
<%impl>
 #include <iostream>
 #include <fstream>
 using namespace std;
 #include <sitecing/util.h>
 #include <sitecing/sitecing_util.h>
 #include <konforka/util.h>
 #include <konforka/exception.h>
 #include "acconfig.h"
</%impl>
<%codemethod string title() %>
 return "introduction";
</%codemethod>
<%method void body() %>
 <%code>
  string rfile = konforka::normalize_path(
   sitecing::strip_prefix(__CGI->get_meta("PATH_INFO"),"/view.chtml"),
   konforka::restrict_dotdot|konforka::strip_leading_slash );
  sourcefile_t *sof = 0;
  for(int n=0;n<source_files_count;n++) {
   sof = &source_files[n];
   if(sof->name && sof->dir) {
    if(konforka::normalize_path(konforka::combine_path(sof->dir,sof->name,0),konforka::strip_leading_slash)==rfile)
     break;
   }
   sof = 0;
  }
  if(!sof)
   throw konforka::exception(CODEPOINT,"no access to the file allowed");
  string afile = konforka::combine_path(WEB_ROOT,rfile,0);
 </%code>
 <div class="source">
  <h1><% rfile %></h1>
  <ul>
   <%code>
    ifstream sf(afile.c_str());
    if(!sf.good())
     throw konforka::exception(CODEPOINT,"could not open source file");
    while(!sf.eof()) {
     string sfl;
     getline(sf,sfl);
     for(string::size_type t=sfl.find('\t');t!=string::npos;t=sfl.find('\t')) {
      sfl.replace(t,1,8-(t%8),' ');
     }
     <%output>
      <li><% sfl.empty()?"&nbsp;":sitecing::html_escape(sfl,sitecing::html_escape_nbsp) %></li>
     </%output>
    }
   </%code>
  </ul>
 </div>
</%method>