30 files changed, 1438 insertions, 0 deletions
diff --git a/htdocs/.htaccess b/htdocs/.htaccess new file mode 100644 index 0000000..1165068 --- a/dev/null +++ b/htdocs/.htaccess @@ -0,0 +1,2 @@ +Options MultiViews +AddType text/html .chtml diff --git a/htdocs/ancestry/.htaccess b/htdocs/ancestry/.htaccess new file mode 100644 index 0000000..8d2f256 --- a/dev/null +++ b/htdocs/ancestry/.htaccess @@ -0,0 +1 @@ +deny from all diff --git a/htdocs/ancestry/layout.chtml b/htdocs/ancestry/layout.chtml new file mode 100644 index 0000000..11bd74a --- a/dev/null +++ b/htdocs/ancestry/layout.chtml @@ -0,0 +1,35 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%derive page = "/ancestry/page.chtml"; +%%impl #include "acconfig.h" +<%method void body() %> + <div id="content"> + <%code> + if(!access(WEB_RUN_ROOT "/conf/banner_top",R_OK)) { + pass_file_through(WEB_RUN_ROOT "/conf/banner_top"); + } + content(); + if(b_strict && !access(WEB_RUN_ROOT "/conf/banner_bottom",R_OK)) { + pass_file_through(WEB_RUN_ROOT "/conf/banner_bottom"); + } + </%code> + </div> + <div id="sidepanel"> +% sidepanel(); + </div> +</%method> +<%method void content() %> +</%method> +<%method void sidepanel() %> + <h1><% PACKAGE_STRING %></h1> +% /* thank MSIE for this awful formatting */ + <ul><li><a href="/" title="introduction to site-C-ing">intro</a></li><li><a href="/exceptions/" title="exceptions handling">exceptions</a><ul><li><a href="/exceptions/preprocess" title="preprocessor errors">preprocess</a></li><li><a href="/exceptions/compile" title="compiler errors">compile-time</a></li><li><a href="/exceptions/runtime" title="runtime exceptions">runtime</a></li></ul></li><li><a href="/sources" title="browse this site source files">sources</a></li></ul> + <%code> + if(!access(WEB_RUN_ROOT "/conf/banner_side",R_OK)) { + pass_file_through(WEB_RUN_ROOT "/conf/banner_side"); + } + </%code> + <ul><li><a href="http://kin.klever.net/sitecing/" title="main site-C-ing page">site-C-ing</a></li><li><a href="http://kin.klever.net/sitecing/sources" title="site-C-ing download page">downloads</a></li></ul> + <div class="copyright"> + © <a href="http://www.klever.net/">Klever Group</a> + </div> +</%method> diff --git a/htdocs/ancestry/page.chtml b/htdocs/ancestry/page.chtml new file mode 100644 index 0000000..28bf7f0 --- a/dev/null +++ b/htdocs/ancestry/page.chtml @@ -0,0 +1,28 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%var bool b_strict = true; +<%decl> + using std::string; +</%decl> +<%method void html() %> +% if(b_strict){ + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +% }else{ + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> +% } + <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + <head> +% __SCIF->headers["Content-Type"] = "text/html"; + <title><% title() %></title> + <meta name="copyright" content="Copyright (c) 1996-2005 Klever Group"/> + <link rel="stylesheet" href="/style.css" type="text/css" /> + </head> + <body> +% body(); + </body> + </html> +</%method> +<%codemethod string title() %> + return "untitled"; +</%codemethod> +<%method void body() %> +</%method> diff --git a/htdocs/ancestry/sources.chtml b/htdocs/ancestry/sources.chtml new file mode 100644 index 0000000..eb9c790 --- a/dev/null +++ b/htdocs/ancestry/sources.chtml @@ -0,0 +1,75 @@ +<%decl> + typedef struct { + const char *dir; + const char *name; + const char *desc; + } sourcefile_t; + extern sourcefile_t source_files[]; + extern int source_files_count; +</%decl> +<%impl> + sourcefile_t source_files[] = { + { "", 0, "the root" }, + { "", "configure.ac", "main configuration file" }, + { "", "acinclude.m4", "autoconf macros" }, + { "", "autogen.sh", "shell script for building out of source repository" }, + { "", "Makefile.am", "automake makefile template" }, + { "", "NEWS.xml", "news since the last release (if any)" }, + { "", "NEWS.xsl", "the styleshhet to make a plaintext version of NEWS.xml" }, + { "", "COPYING", "copyright notice" }, + { "", "AUTHORS", "Klever dissected" }, + { 0, 0, 0 }, + { "bin", 0, "various scripts" }, + { "bin", "build.in", "the template of the script used to precompile the code" }, + { "bin", "run.in", "the template of the script used to start fastcgi server" }, + { 0, 0, 0 }, + { "conf", 0, "configuration files" }, + { "conf", "dudki.conf.in", "the template for the dudki daemon configuration file" }, + { "conf", "httpd.conf.in", "the template for the apache configuration" }, + { "conf", "sitecing.conf.in", "the template for the site-C-ing configuration" }, + { 0, 0, 0 }, + { "htdocs", 0, "the source files" }, + { "htdocs", ".htaccess", "apache access-control file" }, + { "htdocs", "index.chtml", "the introduction" }, + { "htdocs", "sources.chtml", "the source browser" }, + { "htdocs", "style.css", "the CSS style sheet" }, + { "htdocs", "view.chtml", "the source viewer" }, + { "htdocs/exceptions", 0, "exceptions handling overview" }, + { "htdocs/exceptions", "index.chtml", "the overview" }, + { "htdocs/exceptions", "preprocess.chtml", "preprocessor exceptions" }, + { "htdocs/exceptions", "compile.chtml", "compile-time exceptions" }, + { "htdocs/exceptions", "runtime.chtml", "runtime exceptions" }, + { "htdocs/exceptions/development", 0, "development-mode exceptions samples" }, + { "htdocs/exceptions/development", ".htaccess", "apache access control file" }, + { "htdocs/exceptions/development", ".scrc", "site-C-ing local configuration" }, + { "htdocs/exceptions/development", "preprocess.chtml", "the file that can not be preprocessed" }, + { "htdocs/exceptions/development", "runtime.chtml", "exception thrown at runtime" }, + { "htdocs/exceptions/development", "compile.chtml", "the file that can not be compiled" }, + { "htdocs/exceptions/development", "erroneous.h", "the file to include for more errors" }, + { "htdocs/exceptions/development", "compile.html", "compile-time exception handler output" }, + { 0,0,0 }, + { "htdocs/exceptions/production", 0, "production-mode exceptions samples" }, + { "htdocs/exceptions/production", ".htaccess", "apache access control file" }, + { "htdocs/exceptions/production", ".scrc", "site-C-ing local configuration" }, + { "htdocs/exceptions/production", "preprocess.chtml", "the file that can not be preprocessed" }, + { "htdocs/exceptions/production", "runtime.chtml", "exception thrown at runtime" }, + { "htdocs/exceptions/production", "compile.chtml", "the file that can not be compiled" }, + { "htdocs/exceptions/production", "erroneous.h", "the file to include for more errors" }, + { "htdocs/exceptions/production", "compile.html", "compile-time exception handler output" }, + { 0,0,0 }, + { 0,0,0 }, + { "htdocs/handlers", 0, "exception handlers" }, + { "htdocs/handlers", ".htaccess", "apache access-control file" }, + { "htdocs/handlers", "exception_dev", "development mode exception handler" }, + { "htdocs/handlers", "exception_prod", "production mode exception handler" }, + { 0,0,0 }, + { "htdocs/ancestry", 0, "base components to build the rest upon" }, + { "htdocs/ancestry", ".htaccess", "apache access control file" }, + { "htdocs/ancestry", "page.chtml", "the xhtml skeleton" }, + { "htdocs/ancestry", "layout.chtml", "the layout for the most pages" }, + { "htdocs/ancestry", "sources.chtml", "the list of files for source browser" }, + { 0,0,0 }, + { 0,0,0 } + }; + int source_files_count = sizeof(source_files)/sizeof(*source_files); +</%impl> diff --git a/htdocs/exceptions/compile.chtml b/htdocs/exceptions/compile.chtml new file mode 100644 index 0000000..90ee7d8 --- a/dev/null +++ b/htdocs/exceptions/compile.chtml @@ -0,0 +1,50 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%derive layout = "/ancestry/layout.chtml"; +<%constructor> + b_strict = false; +</%constructor> +<%codemethod string title() %> + return "compile-time exceptions handling"; +</%codemethod> +<%method void content() %> + <h1>site-C-ing compile-time exception handling</h1> + <p> + Similar to <a href="/exceptions/preprocess">preprocessing exceptions</a> + there is a wide range of errors you may put into your code which will pass + through preprocessor and will be caught later at the compile-time. + </p> + <p> + Once you complete writing your <a + href="/view/htdocs/exceptions/development/compile.chtml" target="insert" + title="the link opens in the frame below">erroneous code</a> and + <em>site-C-ing</em> is done preprocessing it, it will feed the preprocessed + code into c++ compiler which will refuse to compile the code like this. This + is where <a href="/view/htdocs/handlers/exception_dev" target="insert" + title="the link opens in the frame below">the exception handler</a>, + specified in <a href="/view/htdocs/exceptions/development/.scrc" + target="insert" title="the link opens in the frame below">the configuration + file</a>, takes over the process and gives you <a + href="/exceptions/development/compile" target="insert" title="the link opens + in the frame below">the report</a>. Like with any handler, you may wish to + set some <a href="/view/htdocs/handlers/exception_prod" target="insert" + title="the link opens in the frame below">different handler</a> in your <a + href="/view/htdocs/exceptions/production/.scrc" target="insert" title="the + link opens in the frame below">production configuration</a>, which just gives + user <a href="/exceptions/production/preprocess" target="insert" title="the + link opens in the frame below">a friendly yet lame excuse</a>. + </p> + <p class="note"> + Note, that these output pages are fakes -- I do not want to spawn the + compiler each time you want to see the output and put this unnecessary load + on cpu. These static pages are in fact saved output of the real exception + handlers. + </p> + + <div class="insert"> + <iframe id="insert" name="insert" src="about:blank" width="95%" height="300" border="1"> + <p>I wanted to put an <iframe> here, but your browser does not seem to + support it. That is okay, it still will open links somehow.</p> + </iframe> + </div> + +</%method> diff --git a/htdocs/exceptions/development/.htaccess b/htdocs/exceptions/development/.htaccess new file mode 100644 index 0000000..01cb5ec --- a/dev/null +++ b/htdocs/exceptions/development/.htaccess @@ -0,0 +1,3 @@ +<Files compile.chtml> + deny from all +</Files> diff --git a/htdocs/exceptions/development/.scrc b/htdocs/exceptions/development/.scrc new file mode 100644 index 0000000..da24ef7 --- a/dev/null +++ b/htdocs/exceptions/development/.scrc @@ -0,0 +1,2 @@ +ExceptionHandler /handlers/exception_dev +AutoBuildFiles -* diff --git a/htdocs/exceptions/development/compile.chtml b/htdocs/exceptions/development/compile.chtml new file mode 100644 index 0000000..3611ca9 --- a/dev/null +++ b/htdocs/exceptions/development/compile.chtml @@ -0,0 +1,12 @@ +<html> + <head> + <title>I'm gonna make a number of mistakes!</title> + </head> + <body> +% ind a = 2; +% #include "erroneous.h" +% unsigned int a = -1; +% int j = k; + </body> +</html> +% /* vim:set ft=sitecing: */ diff --git a/htdocs/exceptions/development/compile.html b/htdocs/exceptions/development/compile.html new file mode 100644 index 0000000..c3384a2 --- a/dev/null +++ b/htdocs/exceptions/development/compile.html @@ -0,0 +1,248 @@ + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + <head> + <title>failed to compile component</title> + <style type="text/css"> + <!-- + body { + font-family: sans-serif; + font-size: 11pt; + } + + h1 { + font-family: serif; + font-size: 130%; + font-weight: bold; + text-align: center; + } + p { + text-indent: 2em; + text-align: justify; + } + + dl.exception-props { + margin: 1ex 1em; + padding: 0.5ex; + border: solid 1px gray; + background-color: #e0e0e0; + } + dl.exception-props dt { + font-weight: bold; + color: blue; + } + dl.exception-props dd { + color: gray; + } + + div.exception-codepoint-report { + border: solid 1px black; + margin: 0.5ex 1em 0.ex 3em; + } + div.exception-codepoint-report h3 { + display: block; + color: blue; + border-bottom: 3px double black; + padding: 0.3ex; margin: 0px; + background: #e0e0e0; + } + div.exception-codepoint-report ul { + padding: 0px; + margin: 0px; + background: #87fdff; + font-size: 70%; + } + div.exception-codepoint-report li { + font-family: monospace; + list-style-type: none; + white-space: pre; + overflow: hidden; + } + div.exception-codepoint-report li.focused { + color: red; + border-top: solid 1px red; border-bottom: solid 1px red; + } + div.exception-codepoint-report li .lineno { + padding-right: 0.5ex; + border-right: dotted black 1px; + } + div.exception-codepoint-report div.what { + border-top: double 3px black; + padding: 0.5ex 2em; + font-weight: bold; color: #4040c0; + overflow: auto; + } + div.backtrace div.exception-codepoint-report div.what { + color: gray; + } + + div.exception-compile div.what { + font-weight: normal; + color: red; + } + + div.powered { + margin: 2em 0px 0px 50%; + padding: 1ex 2ex; + text-align: right; + font-family: serif; + font-size: 140%; + font-weight: bold; + border-top: solid 2px black; + border-left: solid 1px gray; border-right: solid 1px gray; border-bottom: solid 1px gray; + background: #c0c0f0; + } + --> + </style> + </head> + <body> + + <div class="exception-compile"> + <h1>error compiling component '<code>exceptions/development/compile.chtml</code>'</h1> + + <div class="exception-codepoint-report"> + <h3>exceptions/development/compile.chtml</h3> + <ul> + <li class="unfocused"><span class="lineno"> 1</span> <span class="line"><html></span></li> + + <li class="unfocused"><span class="lineno"> 2</span> <span class="line"> <head></span></li> + + <li class="unfocused"><span class="lineno"> 3</span> <span class="line"> <title>I'm gonna make a number of mistakes!</title></span></li> + + <li class="unfocused"><span class="lineno"> 4</span> <span class="line"> </head></span></li> + + <li class="unfocused"><span class="lineno"> 5</span> <span class="line"> <body></span></li> + + <li class="focused"><span class="lineno"> 6</span> <span class="line">% ind a = 2;</span></li> + + <li class="unfocused"><span class="lineno"> 7</span> <span class="line">% #include "erroneous.h"</span></li> + + <li class="unfocused"><span class="lineno"> 8</span> <span class="line">% unsigned int a = -1;</span></li> + + <li class="unfocused"><span class="lineno"> 9</span> <span class="line">% int j = k;</span></li> + + <li class="unfocused"><span class="lineno"> 10</span> <span class="line"> </body></span></li> + + <li class="unfocused"><span class="lineno"> 11</span> <span class="line"></html></span></li> + </ul> + <div class="what"> + exceptions/development/compile.chtml: In member function `virtual void _SCC_exceptions_development_compile_chtml::main(int, char*)':<br/> +exceptions/development/compile.chtml:6: error: `ind' undeclared (first use this function)<br/> +exceptions/development/compile.chtml:6: error: (Each undeclared identifier is reported only once for each function it appears in.)<br/> +exceptions/development/compile.chtml:6: error: expected `;' before "a" + </div> + </div> + + <div class="exception-codepoint-report"> + <h3>exceptions/development/compile.chtml</h3> + <ul> + <li class="unfocused"><span class="lineno"> 2</span> <span class="line"> <head></span></li> + + <li class="unfocused"><span class="lineno"> 3</span> <span class="line"> <title>I'm gonna make a number of mistakes!</title></span></li> + + <li class="unfocused"><span class="lineno"> 4</span> <span class="line"> </head></span></li> + + <li class="unfocused"><span class="lineno"> 5</span> <span class="line"> <body></span></li> + + <li class="unfocused"><span class="lineno"> 6</span> <span class="line">% ind a = 2;</span></li> + + <li class="focused"><span class="lineno"> 7</span> <span class="line">% #include "erroneous.h"</span></li> + + <li class="unfocused"><span class="lineno"> 8</span> <span class="line">% unsigned int a = -1;</span></li> + + <li class="unfocused"><span class="lineno"> 9</span> <span class="line">% int j = k;</span></li> + + <li class="unfocused"><span class="lineno"> 10</span> <span class="line"> </body></span></li> + + <li class="unfocused"><span class="lineno"> 11</span> <span class="line"></html></span></li> + + <li class="unfocused"><span class="lineno"> 12</span> <span class="line">% /* vim:set ft=sitecing: */</span></li> + </ul> + <div class="what"> + In file included from exceptions/development/compile.chtml:7: + </div> + </div> + + <div class="exception-codepoint-report"> + <h3>exceptions/development/erroneous.h</h3> + <ul> + <li class="focused"><span class="lineno"> 1</span> <span class="line"> a+2=5;</span></li> + + <li class="unfocused"><span class="lineno"> 2</span> <span class="line"></span></li> + </ul> + <div class="what"> + ./erroneous.h:1: error: `a' undeclared (first use this function) + </div> + </div> + + <div class="exception-codepoint-report"> + <h3>exceptions/development/compile.chtml</h3> + <ul> + <li class="unfocused"><span class="lineno"> 3</span> <span class="line"> <title>I'm gonna make a number of mistakes!</title></span></li> + + <li class="unfocused"><span class="lineno"> 4</span> <span class="line"> </head></span></li> + + <li class="unfocused"><span class="lineno"> 5</span> <span class="line"> <body></span></li> + + <li class="unfocused"><span class="lineno"> 6</span> <span class="line">% ind a = 2;</span></li> + + <li class="unfocused"><span class="lineno"> 7</span> <span class="line">% #include "erroneous.h"</span></li> + + <li class="focused"><span class="lineno"> 8</span> <span class="line">% unsigned int a = -1;</span></li> + + <li class="unfocused"><span class="lineno"> 9</span> <span class="line">% int j = k;</span></li> + + <li class="unfocused"><span class="lineno"> 10</span> <span class="line"> </body></span></li> + + <li class="unfocused"><span class="lineno"> 11</span> <span class="line"></html></span></li> + + <li class="unfocused"><span class="lineno"> 12</span> <span class="line">% /* vim:set ft=sitecing: */</span></li> + + <li class="unfocused"><span class="lineno"> 13</span> <span class="line"></span></li> + </ul> + <div class="what"> + exceptions/development/compile.chtml:8: warning: converting of negative value `-0x000000001' to `unsigned int' + </div> + </div> + + <div class="exception-codepoint-report"> + <h3>exceptions/development/compile.chtml</h3> + <ul> + <li class="unfocused"><span class="lineno"> 4</span> <span class="line"> </head></span></li> + + <li class="unfocused"><span class="lineno"> 5</span> <span class="line"> <body></span></li> + + <li class="unfocused"><span class="lineno"> 6</span> <span class="line">% ind a = 2;</span></li> + + <li class="unfocused"><span class="lineno"> 7</span> <span class="line">% #include "erroneous.h"</span></li> + + <li class="unfocused"><span class="lineno"> 8</span> <span class="line">% unsigned int a = -1;</span></li> + + <li class="focused"><span class="lineno"> 9</span> <span class="line">% int j = k;</span></li> + + <li class="unfocused"><span class="lineno"> 10</span> <span class="line"> </body></span></li> + + <li class="unfocused"><span class="lineno"> 11</span> <span class="line"></html></span></li> + + <li class="unfocused"><span class="lineno"> 12</span> <span class="line">% /* vim:set ft=sitecing: */</span></li> + + <li class="unfocused"><span class="lineno"> 13</span> <span class="line"></span></li> + </ul> + <div class="what"> + exceptions/development/compile.chtml:9: error: `k' undeclared (first use this function)<br/> + + </div> + </div> + + </div> + + <div class="powered">Powered by <a href="http://kin.klever.net/sitecing/" title="site-C-ing">site-C-ing</a>.</div> + </body> +</html> + + + + + + + diff --git a/htdocs/exceptions/development/erroneous.h b/htdocs/exceptions/development/erroneous.h new file mode 100644 index 0000000..060a57e --- a/dev/null +++ b/htdocs/exceptions/development/erroneous.h @@ -0,0 +1 @@ + a+2=5; diff --git a/htdocs/exceptions/development/preprocess.chtml b/htdocs/exceptions/development/preprocess.chtml new file mode 100644 index 0000000..f7405e7 --- a/dev/null +++ b/htdocs/exceptions/development/preprocess.chtml @@ -0,0 +1,14 @@ +<html> + <body> + <p> + I was writing this component in a hurry, having a lot of things to distract + me, so no wonder I made mistake. + <%code> + /* I do not even remember what I was going to put in this code block. And + * of course I didn't mean to forget that this is just a block of code, not + * a constructor... + */ + </%constructor> + </p> + </body> +</html> diff --git a/htdocs/exceptions/development/runtime.chtml b/htdocs/exceptions/development/runtime.chtml new file mode 100644 index 0000000..4a494bd --- a/dev/null +++ b/htdocs/exceptions/development/runtime.chtml @@ -0,0 +1,16 @@ +%%decl #include <konforka/exception.h> +<%code> + try{ + try{ + try{ + throw konforka::exception(CODEPOINT,"throwing an exception to backtrace a bit"); + }catch(konforka::exception& ke){ + ke.see(CODEPOINT); throw; + } + }catch(konforka::exception& ke){ + ke.see(CODEPOINT); throw; + } + }catch(konforka::exception& ke){ + ke.see(CODEPOINT); throw; + } +</%code> diff --git a/htdocs/exceptions/index.chtml b/htdocs/exceptions/index.chtml new file mode 100644 index 0000000..cc0ed8a --- a/dev/null +++ b/htdocs/exceptions/index.chtml @@ -0,0 +1,52 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%derive layout = "/ancestry/layout.chtml"; +<%codemethod string title() %> + return "exceptions handling"; +</%codemethod> +<%method void content() %> + <h1>site-C-ing exception handling</h1> + <p> + The purpose of this section is to give an overview of the <em>site-C-ing</em> + exception handling mechanism. Before the web visitor can see the page each + site-C-ing component goes through a few stages, namely, preprocessing, + compiling and execution. Having three stages to go through also means the + stages one can fail to go through and three exciting opportunities to handle + different errors. + </p> + <p> + First each component is preprocessed so that you can feed the valid c++ code + to the compiler. Here is where the preprocessor can choke at your broken + source code. Once preprocessor failes to parse your code it will throw an + exception which <em>site-C-ing</em> will catch and pass to <a + href="/sources/htdocs/handlers/exception_dev" title="development mode + exception handler source">the exception handler component</a>. Want to <a + href="/exceptions/preprocess">read more</a> about preprocessor exception + handling? + </p> + <p> + After the preprocessing stage is over we have a great opportunity to catch + the compile-time errors. After <em>site-C-ing</em> fails to compile the + component it throws another exception and passes it to the same handler which + may show you some information on what's gone wrong with your source code from + the compiler's perspective. If you've gone this far you definitely want to <a + href="/exceptions/compile">read more</a> about the compiler error handling. + </p> + <p class="note"> + Note, that it is likely that you will want to disable the steps above for the + production environment to save time on unnecessary checking whether the + component is up to date. + </p> + <p> + Finally, we need to execute the component and present its output to the web + site visitor. This is also where things may go wrong and here is where your + component may throw an exception for the engine to catch and pass to the + handler. Feel free to <a href="/exceptions/runtime">learn more</a> about it + as well. + </p> + <p class="note"> + One more thing you will likely want to have differently in production + environment is <a href="/sources/htdocs/handlers/exception_prod" + title="production mode exception handler source">an exception handler</a> + which will not give out that much unnecessary information to the user. + </p> +</%method> diff --git a/htdocs/exceptions/preprocess.chtml b/htdocs/exceptions/preprocess.chtml new file mode 100644 index 0000000..8516139 --- a/dev/null +++ b/htdocs/exceptions/preprocess.chtml @@ -0,0 +1,46 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%derive layout = "/ancestry/layout.chtml"; +<%constructor> + b_strict = false; +</%constructor> +<%codemethod string title() %> + return "preprocessor exceptions handling"; +</%codemethod> +<%method void content() %> + <h1>site-C-ing preprocessor exception handling</h1> + <p> + It was one of those days when you just can't type right and can't think of + what you're typing. It is not unusual that, under such circumstances, you end + up with a code like <a + href="/view/htdocs/exceptions/development/preprocess.chtml" target="insert" + title="the link opens in the frame below">this</a> -- by the time you were + about to close your <code><%code></code> block you were thinking about + some constructor in some component elsewhere in the universe. + </p> + <p> + <em>site-C-ing</em> parser will see the inconsistency and throw an exception + which will be caught and passed to <a + href="/view/htdocs/handlers/exception_dev" target="insert" title="the link + opens in the frame below">the handler</a>, specified in <a + href="/view/htdocs/exceptions/development/.scrc" target="insert" title="the + link opens in the frame below">the configuration file</a>, which will produce + some nice, human-readable <a href="/exceptions/development/preprocess" + target="insert" title="the link opens in the frame below">output</a>. Well, + you may not wish to give out all this information in the production + environment, so you just put in your <a + href="/view/htdocs/exceptions/production/.scrc" target="insert" title="the + link opens in the frame below">configuration file</a> some <a + href="/view/htdocs/handlers/exception_prod" target="insert" title="the link + opens in the frame below">different handler</a>, which just gives user <a + href="/exceptions/production/preprocess" target="insert" title="the link + opens in the frame below">a friendly yet lame excuse</a>. + </p> + + <div class="insert"> + <iframe id="insert" name="insert" src="about:blank" width="95%" height="300"> + <p>I wanted to put an <iframe> here, but your browser does not seem to + support it. That is okay, it still will open links somehow.</p> + </iframe> + </div> + +</%method> diff --git a/htdocs/exceptions/production/.htaccess b/htdocs/exceptions/production/.htaccess new file mode 100644 index 0000000..01cb5ec --- a/dev/null +++ b/htdocs/exceptions/production/.htaccess @@ -0,0 +1,3 @@ +<Files compile.chtml> + deny from all +</Files> diff --git a/htdocs/exceptions/production/.scrc b/htdocs/exceptions/production/.scrc new file mode 100644 index 0000000..d97eeb4 --- a/dev/null +++ b/htdocs/exceptions/production/.scrc @@ -0,0 +1,2 @@ +ExceptionHandler /handlers/exception_prod +AutoBuildFiles -* diff --git a/htdocs/exceptions/production/compile.chtml b/htdocs/exceptions/production/compile.chtml new file mode 100644 index 0000000..3611ca9 --- a/dev/null +++ b/htdocs/exceptions/production/compile.chtml @@ -0,0 +1,12 @@ +<html> + <head> + <title>I'm gonna make a number of mistakes!</title> + </head> + <body> +% ind a = 2; +% #include "erroneous.h" +% unsigned int a = -1; +% int j = k; + </body> +</html> +% /* vim:set ft=sitecing: */ diff --git a/htdocs/exceptions/production/compile.html b/htdocs/exceptions/production/compile.html new file mode 100644 index 0000000..faa0ab9 --- a/dev/null +++ b/htdocs/exceptions/production/compile.html @@ -0,0 +1,44 @@ + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + <head> + <title>Server-side exception</title> + <style type="text/css"> + <!-- + body { + font-family: sans-serif; + font-size: 12pt; + } + h1 { + font-family: serif; + font-size: 130%; + font-weight: bold; + text-align: center; + } + p { + text-indent: 2em; + text-align: justify; + } + + div.powered { + margin: 2em 0px 0px 50%; + padding: 1ex 2ex; + text-align: right; + font-family: serif; + font-size: 140%; + font-weight: bold; + border-top: solid 2px black; + border-left: solid 1px gray; border-right: solid 1px gray; border-bottom: solid 1px gray; + background: #c0c0f0; + } + --> + </style> + </head> + <body> + <h1>server-side exception</h1> + <p>Something has gone really wrong with the server. Feel free to report the + incident to <a href="mailto:root@localhost" title="e-mail + server administrator">webmaster</a>.</p> + <div class="powered">Powered by <a href="http://kin.klever.net/sitecing/" title="site-C-ing">site-C-ing</a>.</div> + </body> +</html> diff --git a/htdocs/exceptions/production/erroneous.h b/htdocs/exceptions/production/erroneous.h new file mode 100644 index 0000000..060a57e --- a/dev/null +++ b/htdocs/exceptions/production/erroneous.h @@ -0,0 +1 @@ + a+2=5; diff --git a/htdocs/exceptions/production/preprocess.chtml b/htdocs/exceptions/production/preprocess.chtml new file mode 100644 index 0000000..f7405e7 --- a/dev/null +++ b/htdocs/exceptions/production/preprocess.chtml @@ -0,0 +1,14 @@ +<html> + <body> + <p> + I was writing this component in a hurry, having a lot of things to distract + me, so no wonder I made mistake. + <%code> + /* I do not even remember what I was going to put in this code block. And + * of course I didn't mean to forget that this is just a block of code, not + * a constructor... + */ + </%constructor> + </p> + </body> +</html> diff --git a/htdocs/exceptions/production/runtime.chtml b/htdocs/exceptions/production/runtime.chtml new file mode 100644 index 0000000..4a494bd --- a/dev/null +++ b/htdocs/exceptions/production/runtime.chtml @@ -0,0 +1,16 @@ +%%decl #include <konforka/exception.h> +<%code> + try{ + try{ + try{ + throw konforka::exception(CODEPOINT,"throwing an exception to backtrace a bit"); + }catch(konforka::exception& ke){ + ke.see(CODEPOINT); throw; + } + }catch(konforka::exception& ke){ + ke.see(CODEPOINT); throw; + } + }catch(konforka::exception& ke){ + ke.see(CODEPOINT); throw; + } +</%code> diff --git a/htdocs/exceptions/runtime.chtml b/htdocs/exceptions/runtime.chtml new file mode 100644 index 0000000..d0a8e14 --- a/dev/null +++ b/htdocs/exceptions/runtime.chtml @@ -0,0 +1,47 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%derive layout = "/ancestry/layout.chtml"; +<%constructor> + b_strict = false; +</%constructor> +<%codemethod string title() %> + return "runtime exceptions handling"; +</%codemethod> +<%method void content() %> + <h1>site-C-ing runtime exception handling</h1> + <p> + The component may throw an exception while executing and the + <em>site-C-ing</em> will gladly pass it to the handler component which will + give the user appropriate output (unless it throws an exception itself, of + course). Here you will see an example output provided by the handler bundled + with the <em>site-C-ing</em>. + </p> + + <p> + Suppose you have <a href="/view/htdocs/exceptions/development/runtime.chtml" + target="insert" title="the link opens in the frame below">a component</a>, + which at some point throws an exception. Of course, <em>site-C-ing</em> will + catch the exception and pass it to <a + href="/view/htdocs/handlers/exception_dev" target="insert" title="the link + opens in the frame below">the handler</a>, specified in <a + href="/view/htdocs/exceptions/development/.scrc" target="insert" title="the + link opens in the frame below">the configuration file</a>, which will produce + some nice, human-readable <a href="/exceptions/development/runtime" + target="insert" title="the link opens in the frame below">output</a>. Well, + you may not wish to give out all this information in the production + environment, so you just put in your <a + href="/view/htdocs/exceptions/production/.scrc" target="insert" title="the + link opens in the frame below">configuration file</a> some <a + href="/view/htdocs/handlers/exception_prod" target="insert" title="the link + opens in the frame below">different handler</a>, which just gives user <a + href="/exceptions/production/runtime" target="insert" title="the link opens + in the frame below">a friendly yet lame excuse</a>. + </p> + + <div class="insert"> + <iframe id="insert" name="insert" src="about:blank" width="95%" height="300"> + <p>I wanted to put an <iframe> here, but your browser does not seem to + support it. That is okay, it still will open links somehow.</p> + </iframe> + </div> + +</%method> diff --git a/htdocs/handlers/.htaccess b/htdocs/handlers/.htaccess new file mode 100644 index 0000000..8d2f256 --- a/dev/null +++ b/htdocs/handlers/.htaccess @@ -0,0 +1 @@ +deny from all diff --git a/htdocs/handlers/exception_dev b/htdocs/handlers/exception_dev new file mode 100644 index 0000000..d8c84e1 --- a/dev/null +++ b/htdocs/handlers/exception_dev @@ -0,0 +1,346 @@ +%%decl using namespace std; +<%impl> + #include <iostream> + #include <fstream> + #include <sstream> + #include <cassert> + #include <cstdarg> + #include <stdexcept> + #include <cxxabi.h> + #include <sitecing/sitecing_util.h> + #include <sitecing/util.h> + #include <sitecing/magic.h> + #include <konforka/exception.h> +</%impl> +%%var string message; +%%var string root_source; +%%var string root_intermediate; +%%var string root_so; +%%var string component; +%%var int line_number = -1; +%%var const exception* exception_caught; +<%code> + __SCIF->headers.clear(); + __SCIF->out->seekp(0); + int magic = _magic; + va_list va = _args; + switch(magic) { + case sitecing::__magic_compile_error: + message = va_arg(va,const char*); + root_source = va_arg(va,const char*); + root_intermediate = va_arg(va,const char*); + root_so = va_arg(va,const char*); + component = va_arg(va,const char*); + break; + case sitecing::__magic_preprocess_error: + message = va_arg(va,const char*); + root_source = va_arg(va,const char*); + root_intermediate = va_arg(va,const char*); + root_so = va_arg(va,const char*); + component = va_arg(va,const char*); + line_number = va_arg(va,int); + break; + case sitecing::__magic_generic_exception: + message = va_arg(va,const char*); + root_source = va_arg(va,const char*); + root_intermediate = va_arg(va,const char *); + root_so = va_arg(va,const char *); + component = va_arg(va,const char*); + exception_caught = va_arg(va,const exception*); + break; + default: + break; + } +</%code> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + <head> + <title><% message %></title> + <style type="text/css"> + <!-- + body { + font-family: sans-serif; + font-size: 11pt; + } + + h1 { + font-family: serif; + font-size: 130%; + font-weight: bold; + text-align: center; + } + p { + text-indent: 2em; + text-align: justify; + } + + dl.exception-props { + margin: 1ex 1em; + padding: 0.5ex; + border: solid 1px gray; + background-color: #e0e0e0; + } + dl.exception-props dt { + font-weight: bold; + color: blue; + } + dl.exception-props dd { + color: gray; + } + + div.exception-codepoint-report { + border: solid 1px black; + margin: 0.5ex 1em 0.ex 3em; + } + div.exception-codepoint-report h3 { + display: block; + color: blue; + border-bottom: 3px double black; + padding: 0.3ex; margin: 0px; + background: #e0e0e0; + } + div.exception-codepoint-report ul { + padding: 0px; + margin: 0px; + background: #87fdff; + font-size: 70%; + } + div.exception-codepoint-report li { + font-family: monospace; + list-style-type: none; + white-space: nowrap; + overflow: hidden; + } + div.exception-codepoint-report li.focused { + color: red; + border-top: solid 1px red; border-bottom: solid 1px red; + } + div.exception-codepoint-report li .lineno { + padding-right: 0.5ex; + border-right: dotted black 1px; + } + div.exception-codepoint-report div.what { + border-top: double 3px black; + padding: 0.5ex 2em; + font-weight: bold; color: #4040c0; + overflow: auto; + } + div.backtrace div.exception-codepoint-report div.what { + color: gray; + } + + div.exception-compile div.what { + font-weight: normal; + color: red; + } + + div.powered { + margin: 2em 0px 0px 50%; + padding: 1ex 2ex; + text-align: right; + font-family: serif; + font-size: 140%; + font-weight: bold; + border-top: solid 2px black; + border-left: solid 1px gray; border-right: solid 1px gray; border-bottom: solid 1px gray; + background: #c0c0f0; + } + --> + </style> +% __SCIF->headers["Content-Type"]="text/html; charset=utf-8"; +% __SCIF->headers["Pragma"]="no-cache"; + </head> + <body> + <%code> + switch(magic) { + case sitecing::__magic_compile_error: + handle_compile_error(); + break; + case sitecing::__magic_preprocess_error: + handle_preprocess_error(); + break; + case sitecing::__magic_generic_exception: + handle_generic_exception(); + break; + default: + handle_unknown_error(); + break; + } + </%code> + <div class="powered">Powered by <a href="http://kin.klever.net/sitecing/" title="site-C-ing">site-C-ing</a>.</div> + </body> +</html> +<%method void handle_generic_exception() %> + <div class="exception-generic"> + <h1>exception caught while running component '<code><% component %></code>'</h1> + <dl class="exception-props"> + <dt><code>typeid(<em>e</em>).name()</code></dt> +% int destat; +% char *demangled = abi::__cxa_demangle(typeid(*exception_caught).name(),NULL,NULL,&destat); + <dd><code><% destat?typeid(*exception_caught).name():demangled %></code></dd> +% if(!destat) free(demangled); + <dt><code><em>e</em>.what()</code></dt> + <dd><% message %></dd> +% if(typeid(*exception_caught)==typeid(konforka::exception&)) { +% konforka::exception* ke = (konforka::exception*)exception_caught; + <dt><code><em>e</em>.where()</code></dt> + <dd><code> +% if(ke->_where.line<0) { + <% ke->where() %> +% }else{ + <% strip_roots(ke->_where.file) %>:<% ke->_where.line %> [<% ke->_where.function %>] +% } + </code></dd> +% } + </dl> +% if(typeid(*exception_caught)==typeid(konforka::exception&)) { +% konforka::exception* ke = (konforka::exception*)exception_caught; +% if(ke->_where.line>=0) { +% report_error(ke->_where.file,ke->_where.line,ke->what()); +% } +% if(!ke->_seen.empty()) { + <h2>seen at:</h2> + <div class="backtrace"> +% for(list<konforka::code_point>::const_iterator i=ke->_seen.begin();i!=ke->_seen.end();++i) { +% if(i->line>=0) { +% report_error(i->file,i->line,i->function); +% } +% } + </div> +% } +% } + </div> +</%method> +<%method void handle_preprocess_error() %> + <div class="exception-preprocess"> + <h1>error preprocessing component '<code><% component %></code>'</h1> +% report_error(root_source+component,line_number,message); + </div> +</%method> +<%method void handle_compile_error() %> + <div class="exception-compile"> + <h1>error compiling component '<code><% component %></code>'</h1> + <%code> + ifstream err((root_intermediate+component+".stderr").c_str(),ios::in); + if(err.bad()) { + <%output> + Failed to access compiler output + </%output> + }else{ + string cumulative; + string error_file; + long error_line = -1; + while(!err.eof()) { + string oef = error_file; + long oel = error_line; + string line; + getline(err,line); + if(line[0]!=' ') { + string::size_type c = line.find(':'); + if(c!=string::npos) { + string fn = line.substr(0,c); + string::size_type c1 = line.find(':',c+1); + if(c1!=string::npos) { + string ln = line.substr(c+1,c1-c-1); + string::size_type nd = ln.find_first_not_of("0123456789"); + if(nd==string::npos) { + try { + error_file = sitecing::strip_prefix(fn,"In file included from "); + }catch(sitecing::utility_no_prefix& unp) { + error_file = fn; + } + error_line = strtol(ln.c_str(),0,10); + } + } + } + if((oel>0 && !oef.empty()) && (oel!=error_line || oef!=error_file)) { + string ef = "/"+sitecing::combine_path(root_source+component,oef); + report_error(ef,oel,remove_roots(cumulative)); + cumulative.clear(); + } + } + if(!cumulative.empty()) + cumulative += '\n'; + cumulative += line; + } + if(!(cumulative.empty() || error_file.empty() || error_line<0)) { + error_file = "/"+sitecing::combine_path(root_source+component,error_file); + report_error(error_file,error_line,remove_roots(cumulative)); + } + } + </%code> + </div> +</%method> +<%method void handle_unknown_error() %> + <div class="exception-unknown"> + <h1>unknown error</h1> + </div> +</%method> +<%method void report_error(const string& file,long line,const string& message) %> + <div class="exception-codepoint-report"> + <h3><% sitecing::html_escape(strip_roots(file)) %></h3> + <%code> + if(line>=0) { + int firstline = line-5, lastline = line+5; + if(firstline<1) + firstline = 1; + ifstream ifs(file.c_str(),ios::in); + if(ifs.bad()) { + // TODO: + }else{ + for(int l=1;l<firstline && !ifs.eof();l++) { + ifs.ignore(65536,'\n'); + } + if(ifs.eof()) { + // TODO: no such line in file + }else{ + <%output><ul></%output> + for(int l=firstline;l<=lastline && !ifs.eof();l++) { + string str; + getline(ifs,str); + for(string::size_type t=str.find('\t');t!=string::npos;t=str.find('\t')) { + str.replace(t,1,8-(t%8),' '); + } + char tln[16]; + snprintf(tln,sizeof(tln),"%5d",l); + <%output> + <li class="<% l==line?"focused":"unfocused" %>"><span class="lineno"><% sitecing::html_escape(tln,sitecing::html_escape_nbsp) %></span> <span class="line"><% sitecing::html_escape(str,sitecing::html_escape_nbsp) %></span></li> + </%output> + } + <%output></ul></%output> + } + } + } + </%code> + <div class="what"> + <% sitecing::html_escape(message,sitecing::html_escape_br) %> + </div> + </div> +</%method> +<%codemethod string strip_roots(const string& filename) %> + string np = sitecing::normalize_path(filename); + try{ + return sitecing::strip_prefix(np,root_source); + }catch(sitecing::utility_no_prefix& e){ } + try{ + return sitecing::strip_prefix(np,root_intermediate); + }catch(sitecing::utility_no_prefix& e){ } +</%codemethod> +<%codemethod string remove_roots(const string& str) %> + string rv = str; + string::size_type rp; + string::size_type rl = root_source.length(); + while((rp=rv.find(root_source))!=string::npos) { + rv.erase(rp,rl); + } + rl = root_intermediate.length(); + while((rp=rv.find(root_intermediate))!=string::npos) { + rv.erase(rp,rl); + } + rl = root_so.length(); + while((rp=rv.find(root_so))!=string::npos) { + rv.erase(rp,rl); + } + return rv; +</%codemethod> +% /* vim:set ft=sitecing: */ diff --git a/htdocs/handlers/exception_prod b/htdocs/handlers/exception_prod new file mode 100644 index 0000000..9768623 --- a/dev/null +++ b/htdocs/handlers/exception_prod @@ -0,0 +1,52 @@ +<%code> + /* vim:set ft=sitecing: */ + __SCIF->headers.clear(); /* reset all headers possibly set by the component throwing an exception. */ + __SCIF->out->seekp(0); /* rollback the output that the exceptional component may have produced. */ + /* set out headers */ + __SCIF->headers["Content-Type"] = "text/html"; + __SCIF->headers["Status"] = "500 server-side exception"; + __SCIF->headers["Pragma"] = "no-cache"; +</%code> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + <head> + <title>Server-side exception</title> + <style type="text/css"> + <!-- + body { + font-family: sans-serif; + font-size: 12pt; + } + h1 { + font-family: serif; + font-size: 130%; + font-weight: bold; + text-align: center; + } + p { + text-indent: 2em; + text-align: justify; + } + + div.powered { + margin: 2em 0px 0px 50%; + padding: 1ex 2ex; + text-align: right; + font-family: serif; + font-size: 140%; + font-weight: bold; + border-top: solid 2px black; + border-left: solid 1px gray; border-right: solid 1px gray; border-bottom: solid 1px gray; + background: #c0c0f0; + } + --> + </style> + </head> + <body> + <h1>server-side exception</h1> + <p>Something has gone really wrong with the server. Feel free to report the + incident to <a href="mailto:<% __CGI->get_meta("SERVER_ADMIN") %>" title="e-mail + server administrator">webmaster</a>.</p> + <div class="powered">Powered by <a href="http://kin.klever.net/sitecing/" title="site-C-ing">site-C-ing</a>.</div> + </body> +</html> diff --git a/htdocs/index.chtml b/htdocs/index.chtml new file mode 100644 index 0000000..aa0979a --- a/dev/null +++ b/htdocs/index.chtml @@ -0,0 +1,46 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%derive layout = "/ancestry/layout.chtml"; +<%codemethod string title() %> + return "introduction"; +</%codemethod> +<%method void content() %> + <h1>introduction to site-C-ing</h1> + <p> + This is a sample site, which is supposed to demonstrate <em>site-C-ing</em> + features. Since the <em>site-C-ing</em> is still at the early stages of + development or rather proof of concept, this site is also far from being + complete. I am planning to add more pages as the time permits, though. + </p> + <p> + Once you download and install <a + href="http://kin.klever.net/sitecing/">site-C-ing</a> you may wish to try + this sample site for yourself. The source is available from <a + href="http://kin.klever.net/sitecing/sources">the site-C-ing download + page</a>. After you download the source code, you should configure it using + the ever so popular <code>configure</code> script. It is likely that you will + want to pass the <code>--with-vhostname</code> option to configure to name + the apache virtual host. + </p> + <p> + The configure script will generate the apache vhost configuration for you, + which you can <code>Include</code> in the main apache configuration file. + </p> + <p class="note"> + Note, that the configuration is tailored for apache 2.x. It is no problem to + get it working with apache 1.3.x, although I haven't tried and so I am not + sure if it will run out of the box (your patches are <a + href="mailto:sitecing-patches@klever.net">welcome</a>). Also note that you + will need <a href="http://fastcgi.com/">mod_fastcgi</a> apache module, which + is the only CGI-interface supported by the <em>site-C-ing</em> engine at the + moment. + </p> + <p> + Once you get it all done you will want to restart your apache and start the + <em>site-C-ing</em> fastcgi server by issuing the <code>make restart</code> + command. + </p> + <p> + Before you download it, you may wish to <a href="/sources" title="source + browser">examine the sources</a> to learn more about how it is done. + </p> +</%method> diff --git a/htdocs/sources.chtml b/htdocs/sources.chtml new file mode 100644 index 0000000..b1eeed3 --- a/dev/null +++ b/htdocs/sources.chtml @@ -0,0 +1,47 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%derive layout = "/ancestry/layout.chtml"; +%%derive sources = "/ancestry/sources.chtml"; +<%impl> + #include <sitecing/sitecing_util.h> +</%impl> +<%constructor> + b_strict = false; +</%constructor> +<%codemethod string title() %> + return "runtime exceptions handling"; +</%codemethod> +<%method void content() %> + <h1>browse this site sources</h1> + + <ul class="sourcebrowser"> +% for(int n=0;n<source_files_count;n++) { +% sourcefile_t& sf = source_files[n]; +% if(!sf.name) { /* the beginning or the end of the directory */ +% if(sf.dir) { /* the beginning */ + <li class="dir"><% sf.dir %>/<ul class="dir"> +% }else{ /* the end */ + </ul></li> +% } +% }else{ + <li class="file"><a href="/view/<% sf.dir %>/<% sf.name %>" title="<% sf.desc %>" target="insert"><% sf.name %></a></li> +% } +% } + </ul> + + <%code> + string rfile = sitecing::normalize_path( + sitecing::strip_prefix(__CGI->get_meta("PATH_INFO"),"/sources.chtml"), + sitecing::restrict_dotdot|sitecing::strip_leading_slash ); + if(rfile.empty()) + rfile = "about:blank"; + else + rfile = "/view/"+rfile; + </%code> + <div class="insert"> + <iframe id="insert" name="insert" src="<% rfile %>" width="95%" height="300"> + <p>I wanted to put an <iframe> here, but your browser does not seem to + support it. That is okay, it still will open links somehow.</p> + </iframe> + </div> + +</%method> diff --git a/htdocs/style.css b/htdocs/style.css new file mode 100644 index 0000000..01fd43a --- a/dev/null +++ b/htdocs/style.css @@ -0,0 +1,168 @@ +body { + font-family: sans-serif; + font-size: 11pt; +} + +a { + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +p { + margin: 1ex 1em; + text-indent: 2em; + text-align: justify; +} +p.note { + margin-left: 10%; + border-width: 1px 1px 1px 6px; + border-color: gray gray gray #0000a0; + border-style: solid solid solid double; + padding: 1ex 1ex 1ex 2em; + font-size: 80%; + background: #c0c0e0; + color: #202020; +} +code { + color: #d04040; +} +em { + white-space: nowrap; +} + +div.google_ad { + text-align: center; + margin: 1ex; +} +div.google_ad.top { + padding-bottom: 1ex; + border-bottom: 1px gray solid; +} +div.google_ad.bottom { + padding-top: 1ex; + border-top: 1px gray solid; +} + +div#sidepanel { + position: absolute; top: 0px; left: 0px; + margin: 0px; + width: 20%; + font-size: 80%; +} +div#content { + position: absolute; top: 0px; right: -0px; + margin: 0px; + width: 80%; +} + +div#sidepanel h1 { + font-size: 80%; + text-align: center; + font-weight: normal; + color: #004080; + white-space: nowrap; + margin-top: 2ex; margin-bottom: 2ex; +} +div#sidepanel ul { + padding: 1ex 0.5ex 1ex 1ex; + margin: 0.5ex; + border-color: #c0c0c0 #404040 #404040 #c0c0c0; + border-width: 1px 2px 2px 1px; + border-style: solid; + background: #d0d0d0; + list-style-type: none; +} +div#sidepanel ul ul { + margin: 0px; padding: 0px; + border: none 0px; +} +div#sidepanel li { + list-style-type: none; + margin: 0px; padding: 0px; + display: block; +} +div#sidepanel ul a { + display: block; + padding: 1px 1ex; + margin: 0.5ex; + border: 1px solid gray; + text-decoration: none; + background: white; + color: black; +} +div#sidepanel ul a:hover { + background: gray; + color: white; +} +div#sidepanel ul ul a { + padding-left: 2.5ex; + background: #e0e0e0; +} +div#sidepanel div.copyright { + text-align: center; +} + +div#content h1 { + font-size: 140%; + color: gray; + font-weight: bold; + text-align: center; + margin: 1em; +} + +div.insert { + text-align: center; +} +iframe#insert { + border: 1px solid black; +} + +div.source h1 { + background: #e0e0e0; + border: 1px solid #808080; + padding-left: 1em; + margin: 0px; + font-size: 100%; + color: #000060; + overflow: hidden; +} +div.source ul { + background: #80c0c0; + margin: 0px; + padding: 1px 0.5ex; + font-family: monospace; + font-size: 80%; + overflow: hidden; +} +div.source li { + list-style-type: none; + white-space: nowrap; +} + +ul.sourcebrowser { + font-size: 70%; +} +ul.sourcebrowser ul.dir { + padding: 1px 0px 2px 1em; + margin: 1px 0px 1px 0px; +} +ul.sourcebrowser li.dir { + margin: 1px 0px 1px 0px; +} +ul.sourcebrowser li.file { + list-style-type: none; + white-space: nowrap; + display: inline; +} +ul.sourcebrowser li.file a { + border: 1px solid gray; + padding: 1px 0.5ex; + text-decoration: none; + font-family: monospace; +} +ul.sourcebrowser li.file a:hover { + background: gray; + border: 1px solid black; + color: white; +} diff --git a/htdocs/view.chtml b/htdocs/view.chtml new file mode 100644 index 0000000..d885330 --- a/dev/null +++ b/htdocs/view.chtml @@ -0,0 +1,54 @@ +% html(); return; /* vim:set ft=sitecing: */ +%%derive page = "/ancestry/page.chtml"; +%%derive sources = "/ancestry/sources.chtml"; +<%impl> + #include <iostream> + #include <fstream> + using namespace std; + #include <sitecing/util.h> + #include <sitecing/sitecing_util.h> + #include <konforka/exception.h> + #include "acconfig.h" +</%impl> +<%codemethod string title() %> + return "introduction"; +</%codemethod> +<%method void body() %> + <%code> + string rfile = sitecing::normalize_path( + sitecing::strip_prefix(__CGI->get_meta("PATH_INFO"),"/view.chtml"), + sitecing::restrict_dotdot|sitecing::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(sitecing::normalize_path(sitecing::combine_path(sof->dir,sof->name,0),sitecing::strip_leading_slash)==rfile) + break; + } + sof = 0; + } + if(!sof) + throw konforka::exception(CODEPOINT,"no access to the file allowed"); + string afile = sitecing::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()?" ":sitecing::html_escape(sfl,sitecing::html_escape_nbsp) %></li> + </%output> + } + </%code> + </ul> + </div> +</%method> |