Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51024 - in sandbox/SOC/2007/cgi/branches/pickmeup: boost/cgi/utility libs/cgi/doc libs/cgi/doc/src libs/cgi/doc/src/user_guide/tutorial libs/cgi/example/acgi libs/cgi/example/acgi/amortization libs/cgi/example/acgi/cookie_game libs/cgi/example/acgi/cookie_game2
From: lists.drrngrvy_at_[hidden]
Date: 2009-02-04 18:09:45


Author: drrngrvy
Date: 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
New Revision: 51024
URL: http://svn.boost.org/trac/boost/changeset/51024

Log:
Adding examples to documentation again. Fixing redirect.hpp to remove extra '/' when destination starts with one (eg. req.script_name() can return the script name preceeded by a '/').
Added:
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/examples.qbk (contents, props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/doc.qbk (contents, props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/doc.qbk (contents, props changed)
Text files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/redirect.hpp | 6 +++++-
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/Jamfile.v2 | 1 -
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/cgi.qbk | 4 ++--
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/introduction.qbk | 2 +-
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/user_guide/tutorial/tutorial.qbk | 4 +++-
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/Jamfile.v2 | 2 ++
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/Jamfile.v2 | 2 +-
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/main.cpp | 6 +++---
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/main.cpp | 18 ++++++++++++++++++
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/Jamfile.v2 | 5 +----
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/main.cpp | 21 +++++++++++++++++++++
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/doc.qbk | 4 ++++
   12 files changed, 61 insertions(+), 14 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/redirect.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/redirect.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/utility/redirect.hpp 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -26,7 +26,11 @@
            , bool secure, boost::system::error_code& ec)
    {
      std::string url(secure ? "https" : "http");
- url += "://" + req.server_name() + "/" + dest;
+ url += "://" + req.server_name();
+ if (dest[0] == '/')
+ url += dest;
+ else
+ url += "/" + dest;
      basic_header<typename RequestT::char_type> hdr("Location", url);
      return hdr;
    }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/Jamfile.v2 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -6,7 +6,6 @@
 #project boost.cgi.docs
 # ;
 
-import boostbook : boostbook ;
 import doxygen ;
 import quickbook ;
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/cgi.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/cgi.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/cgi.qbk 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -96,7 +96,7 @@
 /
 /[include:server_config user_guide/server_configuration.qbk]
 /
-/[include:headers user_guide/headers.qbk]
+[include:headers user_guide/headers.qbk]
 /
 /[endsect]
 /]
@@ -115,7 +115,7 @@
 
 [include:examples examples.qbk]
 
-[include:reference reference.qbk]
+[/include:reference reference.qbk]
 
 [include:future future_development.qbk]
 

Added: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/examples.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/examples.qbk 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -0,0 +1,3 @@
+
+[include ../example/doc.qbk]
+

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/introduction.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/introduction.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/introduction.qbk 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -40,7 +40,7 @@
   The __amort_example__ example uses Google cTemplate for dealing with HTML templates. Consider having a look at it, or at the upcoming ''Karma'' part of Boost.Spirit.
 ]
 
-[h4 Concepts]:
+[h4 Concepts]
 
 The library provides abstractions which hide details of the varying specifications of CGI, FastCGI and SCGI. The main abstractions are, briefly:
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/user_guide/tutorial/tutorial.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/user_guide/tutorial/tutorial.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/doc/src/user_guide/tutorial/tutorial.qbk 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -1,7 +1,9 @@
 
 [section Tutorial]
 
-[include hello_world.qbk]
+**FIXME** - If this doesn't get fixed, please remind me!
+
+[/include hello_world.qbk]
 
 [section:what_next The next step]
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/Jamfile.v2 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -10,6 +10,7 @@
 build-project hello_world ;
 build-project echo ;
 build-project cookie_game ;
+build-project cookie_game2 ;
 build-project amortization ;
 
 # If the user explicitly passes "install" on the command line, build the
@@ -19,6 +20,7 @@
     hello_world
     echo
     cookie_game
+ cookie_game2
     amortization
   :
     <location>$(cgi-bin)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/Jamfile.v2 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -60,7 +60,7 @@
    <location>$(htdocs)/../templates/
  ;
 
-explicit install-app ;
+explicit install-exe ;
 explicit install-extra ;
 
 install install

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/main.cpp 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -27,14 +27,14 @@
 
 using namespace boost::acgi;
 
-#define DEFAULT_LOAN_AMT "£250,000"
+#define DEFAULT_LOAN_AMT "$250,000"
 #define DEFAULT_INTEREST_RATE "6.000"
 
 /// Convert a string like '$250,000' into one like '250000'.
 std::string string_from_currency(std::string amt)
 {
   // this is much too hardcore, but it works fine...
- boost::algorithm::erase_all_regex(amt, boost::regex("[£$, ]"));
+ boost::algorithm::erase_all_regex(amt, boost::regex("[$, ]"));
   return amt;
 }
 
@@ -73,7 +73,7 @@
 {
   std::string val(has_key(req[form], "LoanAmt")
                        ? req[form]["LoanAmt"]
- : "£250,000");
+ : DEFAULT_LOAN_AMT);
   dict.SetValue("LoanAmt", val);
   return boost::lexical_cast<double>(string_from_currency(val));
 }

Added: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/doc.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/doc.qbk 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -0,0 +1,13 @@
+
+[section Cookie Game]
+
+This example shows the user their cookies and allows them to set and delete them. You should take a look at the [link ../cookie_game2/doc.qbk Cookie Game 2] example, which uses Google.cTemplate to move HTML out of the program and into HTML template files. This example mixes HTML and source code, which will generally cause you to waste a lot of time when making changes to structure and design of responses.
+
+[import main.cpp]
+
+[acgi_cookie_game]
+
+See the [@../../example/acgi/cookie_game/main.cpp full source listing].
+
+[endsect][/ echo]
+

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game/main.cpp 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -1,3 +1,20 @@
+// -- main.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+////////////////////////////////////////////////////////////////
+//
+//[acgi_cookie_game
+//
+// Cookie Tests
+// ------------
+//
+// This simple example shows the user their cookies and lets them set and
+// delete them.
+//
 #include <boost/cgi/acgi.hpp>
 #include <boost/cgi/utility.hpp>
 
@@ -250,4 +267,5 @@
 
   return_(resp, req, http::ok);
 }
+//]
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/Jamfile.v2 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -6,7 +6,6 @@
 
 project boost/cgi/example/acgi/cookie_game2 ;
 
-
 import os ;
 
 if [ os.name ] = NT
@@ -22,8 +21,6 @@
 exe acgi_cookie_game2
   :
     main.cpp
- /boost/regex/
- /boost/cgi/
   :
     <library>ctemplate
   :
@@ -59,7 +56,7 @@
     <location>$(htdocs)/../templates/
   ;
 
-explicit install-app ;
+explicit install-exe ;
 explicit install-extra ;
 
 install install

Added: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/doc.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/doc.qbk 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -0,0 +1,27 @@
+
+[section MVC Cookie Game]
+
+This example shows the user their cookies and allows them to set and delete them. It uses Google.cTemplate to move HTML out of the program and into HTML template files, which would be easily editable by anyone familiar with HTML.
+
+If you're not familiar with the term, [@http://wikipedia.org/wiki/Model-View-Controller read up on MVC]. The additional time you'll spend learning an HTML templating library, such as Google.cTemplate, will be saved many times over when compiling your CGI app starts taking more than a few seconds!
+
+[note
+ You need to download and install [@http://code.google.com/p/google-ctemplate Google's cTemplate library] and you may have to modify Jamfile.v2 to point to your compiled ctemplate library (see the `lib ctemplate ...` lines).
+]
+
+You can try a demo of the MVC Cookie Game example [@http://omnisplat.com/cgi/acgi_cookie_game2 here].
+
+[import main.cpp]
+
+[acgi_cookie_game2]
+
+[table Files used for this example:
+ [[File] [Contents]]
+ [[[@../../example/acgi/cookie_game2/main.cpp main.cpp]] [The C++ source.]]
+ [[[@../../example/acgi/cookie_game2/style.css style.css]] [CSS styling for the response.]]
+ [[[@../../example/acgi/cookie_game2/main.js main.js]] [Javascript functions (for changing between GET and POST requests.]]
+ [[[@../../example/acgi/cookie_game2/index.html index.html]] [The HTML template itself.]]
+]
+
+[endsect][/ echo]
+

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/cookie_game2/main.cpp 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -1,3 +1,23 @@
+// -- main.hpp --
+//
+// Copyright (c) Darren Garvey 2007.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+////////////////////////////////////////////////////////////////
+//
+//[acgi_cookie_game2
+//
+// Cookie Test With cTemplate
+// --------------------------
+//
+// This file uses Google cTemplate to show the benefits of using an HTML
+// template engine. Using cTemplate to separate how you show the response and
+// how you figure out what to respond with, is keeping to the MVC paradigm.
+// Read up on that if you're not familiar; if you already are, you can
+// probably stop scowling at the last cookie_game example now.
+//
 #include <boost/cgi/acgi.hpp>
 #include <boost/cgi/utility.hpp>
 #include <google/template.h>
@@ -130,4 +150,5 @@
     std::cout<< "boom<blink>.</blink>";
   }
 }
+//]
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/doc.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/doc.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/doc.qbk 2009-02-04 18:09:43 EST (Wed, 04 Feb 2009)
@@ -11,5 +11,9 @@
 
 [include amortization/doc.qbk]
 
+[include cookie_game/doc.qbk]
+
+[include cookie_game2/doc.qbk]
+
 [endsect][/ cgi_examples]
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk