%% -*- latex -*-
%%
\documentclass[portrait,a1]{a0poster}
\usepackage[twocolumn]{natposter}
\usepackage[latin1]{inputenc}
\usepackage{url}
\usepackage{aeguill}
\usepackage{fancyvrb}
\usepackage{graphicx}
\usepackage{amsmath}

\def\NAV{\orange{Navegante}}

\fvset{fontsize= } %, numberblanklines=false, xleftmargin=6mm,  numbers=left}
\newrgbcolor{DarkBlue}{0 0 0}
\newcommand{\azul}[1]{{\DarkBlue #1}}

\newcommand{\mytitle}[1]{\begin{center}\Large\orange{#1}\end{center}}

\begin{document}

\title{{\Huge Navegante}}
\subtitle{An Intrusive Proxy Domain Specific Language}
\author{Nuno Carvalho and Alberto Simões and José João Almeida}

\maketitle

\begin{framed}
\mytitle{1. The Proxy Pattern}
\vskip 3mm
\noindent { 
\NAV{} is a compiler aimed to craft applications that
behaves as proxies, but with an extra processing layer capability. This extra
layer, allows to do any kind of transformation, on the fly, over the
browsed content before being delivered to the client.}
\begin{center}
\includegraphics[scale=1.2]{images/n1}
\end{center}
\noindent { This compiler can be used to build applications 
that work as proxies for the Internet, but that perform some additional 
task on the browsed content. These applications are capable of 
\orange{giving feedback} to the user about any processed data at 
any given time and in different ways. Applications are also capable of 
storing \orange{state information} associated with browsed content. State
can be \orange{persistent} over sequential requests.}

$$Navegante = Proxy + ProcFunction + UserNotes + State$$

\end{framed}

\begin{framed}
\mytitle{2. Domain Specific Language}
\vskip 3mm
\noindent{ \orange{Programs} are written using a Perl-based DSL where the user defines:}

\begin{description}
\item[\orange{proc}] 
\noindent { function to process each visited page}

  $$ proc : content \longrightarrow HTML \times state $$

\item[\orange{feedback}] 
\noindent { function to give feedback about current state}

  $$ feedback : state \longrightarrow HTML $$

\item[\orange{livefeedback}] 
\noindent { function to give inforation about each page processing results}

  $$ livefeedback : content \times state \longrightarrow HTML $$

\item[\orange{form}]
\noindent{ form structure for user-submitted information}

\item[\orange{annotate}] 
\noindent { function that stores user-submitted information}

  $$ annotate : content \times formdata \longrightarrow state $$

\item[\orange{quit}] 
\noindent{ function called when application finishes, and creates final results}

  $$ quit : state \longrightarrow HTML $$



\end{description}
\end{framed}

\begin{framed}
\mytitle{3. Navegante's Compiler}
\vskip 13mm
\begin{center}
    \includegraphics[scale=1.2]{images/n2}
\end{center}
\noindent{Navegante is a compiler. It compiles a \orange{DSL program} and creates a \orange{CGI application}
based on a specific \orange{CGI skeleton}.}
\vskip 6mm
\end{framed}

\vfill
\begin{flushleft}
Projecto Natura --- Departamento de Informática, Universidade do Minho	
\end{flushleft}
\pagebreak

\begin{framed}
\mytitle{4. Case Study: \emph{htspell}}
\noindent{
This \orange{sample application}, behaves as a CGI, and performs a
simple task: annotates each unknown word in the content being browsed.
It keeps track of unknown words, and highlights them in the document.

The \orange{proc} function is defined as follows:}

$$
\mathbf{proc} \left( \mathit{content} \right) = \textbf{foreach } \mathit{word } \textbf{ in } \mathit{content} 
$$
$$
\left\{\begin{matrix}
\mathit{word} \in \mathbf{D} & 
   \left\{  \begin{matrix} state \{ \mathit{word} \} \mathit{++} \hfill\cr
             HTML \leftarrow highlight \left( \mathit{word} \right) \hfill\end{matrix} \right. \cr
\mathit{word} \notin \mathbf{D} & 
          \left\{ \begin{matrix} HTML \leftarrow \mathit{word} \hfill \end{matrix}\right.\hfill
\end{matrix}\right.
$$

\vskip 15mm
\noindent{
We are also defining \orange{livefeedback} to print some usefull
information regarding every processed page in the application's 
banner:}

$$
\mathbf{livefeedback} \left( \mathit{content} \right) = \textbf{foreach } \mathit{word } \textbf{ in } \mathit{content} 
$$
$$
\left\{\begin{matrix}
\mathit{word} \in \mathbf{D} & 
   \left\{  \begin{matrix} \mathit{found} \mathit{++} \hfill\cr
             \mathit{total} \mathit{++} \hfill\end{matrix} \right. \cr
\mathit{word} \notin \mathbf{D} &  \left\{ \begin{matrix}
                                  \mathit{total} \mathit{++} 
                              \end{matrix}\right.\hfill
\end{matrix}\right.
$$
$$
HTML \leftarrow \left(\mathit{total} ,\left( found / total \right)\right)
$$


\vskip 15mm
\noindent{
Follows a screenshot of this application.}

\begin{center}
    \includegraphics[width=\textwidth]{images/shot1}
\end{center}

\noindent{
When finishing our spell checking task we can gather the state data:}

$$
\mathbf{feedback} \left( \mathit{state} \right) = \textbf{foreach } \mathit{word } \textbf{ in } \mathit{state} 
$$
$$
\begin{cases}
HTML \leftarrow \left(\mathit{word} , \mathit{state} \{ \mathit{word} \}\right)
\end{cases}
$$

\vskip 15mm
\noindent{
We can check the result of calling this function in the screenshot
bellow.}

\begin{center}
    \includegraphics{images/sc2}
\end{center}

\end{framed}

\begin{framed}
	\mytitle{5. Case Study: \emph{htspell} Program}
	
\begin{Verbatim}[fontsize=\small]
cginame(./htspell)
proc(htspellFunction)
feedback(htspellFeedback)
livefeedback(htspellLive)
##
sub htspellLive {
    my $p = int($not_found/$proc*100);
    "I checked $proc words, $p% were not found in the dictionary.";	
} 
...
\end{Verbatim}
\end{framed}

\begin{flushright}
	\vfill
	URL: \url{http://natura.di.uminho.pt/navegante/}
\end{flushright}

\end{document}

