summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--configure.ac2
-rw-r--r--htdocs/handlers/exception_dev7
-rw-r--r--htdocs/sources.chtml5
-rw-r--r--htdocs/view.chtml9
4 files changed, 13 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index e60f519..80f6321 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,97 +1,97 @@
-AC_INIT([sitecing-showcase], [0.0.1], [sitecing-bugs@klever.net])
+AC_INIT([sitecing-showcase], [0.0.1-svn], [sitecing-bugs@klever.net])
AC_CONFIG_SRCDIR([htdocs/index.chtml])
AC_CONFIG_AUX_DIR([aux])
AC_CONFIG_HEADER([include/acconfig.h])
AM_INIT_AUTOMAKE([dist-bzip2])
AC_PATH_PROG([XSLTPROC],[xsltproc],[true])
PKG_CHECK_MODULES([SITECING],[sitecing >= 0.0.1],,[
AC_MSG_ERROR([site-C-ing not found. get it at http://kin.klever.net/sitecing/])
])
sitecing_prefix="$(${PKG_CONFIG} --variable=prefix sitecing)"
sitecing_bindir="$(${PKG_CONFIG} --variable=bindir sitecing)"
AC_MSG_CHECKING([for sitecing-fastcgi binary])
sitecing_fastcgi="${sitecing_bindir}/sitecing-fastcgi"
if test -x "${sitecing_fastcgi}" ; then
AC_MSG_RESULT([found ${sitecing_fastcgi}])
else
AC_MSG_RESULT([not found])
AC_MSG_ERROR([broken site-C-ing install detected])
fi
AC_MSG_CHECKING([for sitecing-build binary])
sitecing_build="${sitecing_bindir}/sitecing-build"
if test -x "${sitecing_build}" ; then
AC_MSG_RESULT([found ${sitecing_build}])
else
AC_MSG_RESULT([not found])
AC_MSG_ERROR([broken site-C-ing install detected])
fi
AC_SUBST([sitecing_prefix])
AC_SUBST([sitecing_bindir])
AC_SUBST([sitecing_fastcgi])
AC_SUBST([sitecing_build])
config_sitecing="config.sitecing"
rm -f "${config_sitecing}"
SC_BUILD_CONF([${config_sitecing}],[CPPFLAGS],[${SITECING_CFLAGS}])
SC_BUILD_CONF([${config_sitecing}],[LDFLAGS],[${SITECING_LIBS}])
AC_SUBST_FILE([config_sitecing])
SC_WEB_ROOT([web_src_root],[web_run_root])
SC_USER([sitecing_user])
AC_DEFINE_UNQUOTED([WEB_ROOT],["${web_src_root}"],[the site root])
AC_DEFINE_UNQUOTED([WEB_SRC_ROOT],["${web_src_root}"],[the site root])
AC_DEFINE_UNQUOTED([WEB_RUN_ROOT],["${web_run_root}"],[the site root])
v_hostname="$(hostname)"
AC_MSG_CHECKING([for virtual host name])
AC_ARG_WITH([vhostname],
AC_HELP_STRING([--with-vhostname=virtual-host-name],[set the apache ServerName of VirtualHost]),
[
v_hostname="${withval}"
]
)
AC_MSG_RESULT([${v_hostname}])
AC_SUBST([v_hostname])
HAVE_DUDKI="false"
WANT_DUDKI="true"
AC_ARG_ENABLE([dudki],
AC_HELP_STRING([--disable-dudki],[disable the use of dudki! to restart daemon]),
[
test "${enableval}" = "no" && WANT_DUDKI="false"
]
)
if ${WANT_DUDKI} ; then
AC_PATH_PROG([DUDKI],[dudki],[false],[${PATH}:/usr/local/sbin:/usr/sbin])
test "${DUDKI}" = "false" || HAVE_DUDKI="true"
fi
AM_CONDITIONAL([HAVE_DUDKI],[${HAVE_DUDKI}])
dudki_id=sitecing-showcase
AC_ARG_WITH([dudki-id],
AC_HELP_STRING([--with-dudki-id],[specify dudki process id]),
[
dudki_id="${withval}"
]
)
AC_SUBST([dudki_id])
APACHE_RESTART_CMD="false"
AC_ARG_WITH([apache-restart-cmd],
AC_HELP_STRING([--with-apache-restart-cmd=command],[use the specified command to restart apache]),
[
test "${withval}" = "no" || APACHE_RESTART_CMD="${withval}"
]
)
if test "${APACHE_RESTART_CMD}" = "false" ; then
AC_PATH_PROG([APACHECTL],[apachectl],[false],[${PATH}:/usr/sbin:/usr/local/sbin])
if test "${APACHECTL}" != "false" ; then
APACHE_RESTART_CMD="sudo ${APACHECTL} graceful"
else
AC_PATH_PROG([APACHE2CTL],[apache2ctl],[false],[${PATH}:/usr/sbin:/usr/local/sbin])
if test "${APACHE2CTL}" != "false" ; then
APACHE_RESTART_CMD="sudo ${APACHE2CTL} graceful"
else
diff --git a/htdocs/handlers/exception_dev b/htdocs/handlers/exception_dev
index d8c84e1..d62f462 100644
--- a/htdocs/handlers/exception_dev
+++ b/htdocs/handlers/exception_dev
@@ -1,108 +1,109 @@
%%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/util.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 {
@@ -161,186 +162,186 @@
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);
+ string ef = "/"+konforka::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);
+ error_file = "/"+konforka::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>&nbsp;<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);
+ string np = konforka::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/sources.chtml b/htdocs/sources.chtml
index 268b0e0..57a03e9 100644
--- a/htdocs/sources.chtml
+++ b/htdocs/sources.chtml
@@ -1,49 +1,50 @@
% /* vim:set ft=sitecing: */
%%derive layout = "/ancestry/layout.chtml";
%%derive sources = "/ancestry/sources.chtml";
%%pragma main=page
<%impl>
#include <sitecing/sitecing_util.h>
+ #include <konforka/util.h>
</%impl>
<%constructor>
b_strict = false;
PN_PREV("/quickref/metasyntax","syntax","meta syntax");
</%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(
+ string rfile = konforka::normalize_path(
sitecing::strip_prefix(__CGI->get_meta("PATH_INFO"),"/sources.chtml"),
- sitecing::restrict_dotdot|sitecing::strip_leading_slash );
+ konforka::restrict_dotdot|konforka::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 &lt;iframe&gt; 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/view.chtml b/htdocs/view.chtml
index f729465..809c54f 100644
--- a/htdocs/view.chtml
+++ b/htdocs/view.chtml
@@ -1,55 +1,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 = sitecing::normalize_path(
+ string rfile = konforka::normalize_path(
sitecing::strip_prefix(__CGI->get_meta("PATH_INFO"),"/view.chtml"),
- sitecing::restrict_dotdot|sitecing::strip_leading_slash );
+ 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(sitecing::normalize_path(sitecing::combine_path(sof->dir,sof->name,0),sitecing::strip_leading_slash)==rfile)
+ 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 = sitecing::combine_path(WEB_ROOT,rfile,0);
+ 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>