<commit_before>\section{Setup}

\subsection{Prerequisites}
To run N2O websites you will need Erlang R17 or higher and basho rebar installed.
N2O works on Windows, Mac and Linux.

\subsection{Kickstart Bootstrap}
To try N2O you only need to fetch it from Github and build. We don't use
fancy scripts so building process is OTP compatible: bootstrap site
is bundled as an Erlang release.

\vspace{1\baselineskip}
\begin{lstlisting}
    $ git clone https://github.com/5HT/n2o
    $ cd n2o/samples
    $ make && make console
\end{lstlisting}
\vspace{1\baselineskip}

Now you can try: \footahref{http://localhost:8000}{http://localhost:8000}.

\newpage
\subsection{Depending N2O Core}
If you want to start using raw N2O core you can use Cowboy dispatch parameter
for passing N2O http and websocket handlers and cowboy static handler:

\begin{lstlisting}[caption=web\_sup.erl]
cowboy:start_http(http, 100, [{port, 8000}],
                             [{env, [{dispatch, dispatch_rules()}]}]),

dispatch_rules() ->
    cowboy_router:compile(
            [{'_', [
            {"/static/[...]", cowboy_static,
                {priv_dir, ?APP, <<"static">>,[{mimetypes,cow_mimetypes,all}]}},
            {"/rest/:resource", rest_cowboy, []},
            {"/rest/:resource/:id", rest_cowboy, []},
            {"/ws/[...]", bullet_handler, [{handler, n2o_bullet}]},
            {'_', n2o_cowboy, []}
    ]}]).
\end{lstlisting}

And then add a minimal {\bf index.erl} page:

\begin{lstlisting}[caption=index.erl]
    -module(index).
    -compile(export_all).
    -include_lib("n2o/include/wf.hrl").

    main() -> #span{text="Hello"}.
\end{lstlisting}

\subsection{Rich Clients Applications Assembling}
You will also need node.js, npm, less and uglify-js to assemble
client-side N2O applications by packaging CSS/LESS, JavaScript and HTML templates.

\vspace{1\baselineskip}
\begin{lstlisting}
    $ sudo apt-get install python-software-properties
    $ sudo add-apt-repository ppa:richarvey/nodejs
    $ sudo apt-get update
    $ sudo apt-get install nodejs npm<commit_msg>setup formatting<commit_after>\section{Setup}

\subsection{Prerequisites}
To run N2O websites you will need Erlang R17 or higher and basho rebar installed.
N2O works on Windows, Mac and Linux.

\subsection{Kickstart Bootstrap}
To try N2O you only need to fetch it from Github and build. We don't use
fancy scripts so building process is OTP compatible: bootstrap site
is bundled as an Erlang release.

\vspace{1\baselineskip}
\begin{lstlisting}
    $ git clone https://github.com/5HT/n2o
    $ cd n2o/samples
    $ make && make console
\end{lstlisting}
\vspace{1\baselineskip}

Now you can try: \footahref{http://localhost:8000}{http://localhost:8000}.

\newpage
\subsection{Depending N2O Core}
If you want to start using raw N2O core you can use Cowboy dispatch parameter
for passing N2O http and websocket handlers and cowboy static handler:

\begin{lstlisting}[caption=web\_sup.erl]
    cowboy:start_http(http, 100, [{port, 8000}],
                                 [{env, [{dispatch, dispatch_rules()}]}]),

    dispatch_rules() ->
        cowboy_router:compile(
            [{'_', [
            {"/static/[...]", cowboy_static,
                {priv_dir, ?APP, <<"static">>,[{mimetypes,cow_mimetypes,all}]}},
            {"/rest/:resource", rest_cowboy, []},
            {"/rest/:resource/:id", rest_cowboy, []},
            {"/ws/[...]", bullet_handler, [{handler, n2o_bullet}]},
            {'_', n2o_cowboy, []} ]}]).
\end{lstlisting}

And then add a minimal {\bf index.erl} page:

\begin{lstlisting}[caption=index.erl]
    -module(index).
    -compile(export_all).
    -include_lib("n2o/include/wf.hrl").

    main() -> #span{text="Hello"}.
\end{lstlisting}

\subsection{Rich Clients Applications Assembling}
You will also need node.js, npm, less and uglify-js to assemble
client-side N2O applications by packaging CSS/LESS, JavaScript and HTML templates.

\vspace{1\baselineskip}
\begin{lstlisting}
    $ sudo apt-get install python-software-properties
    $ sudo add-apt-repository ppa:richarvey/nodejs
    $ sudo apt-get update
    $ sudo apt-get install nodejs npm
{'fraction_non_alphanumeric': 0.13343002175489485, 'fraction_numerical': 0.01595358955765047, 'mean_word_length': 3.3834745762711864, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1944233', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1337, 'n_words': 374}