PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/demo/src/view-index.adb

http://github.com/ThomasLocke/yolk
Ada | 62 lines | 32 code | 11 blank | 19 comment | 2 complexity | ba3a4105d9370b8718fe71b0be4864c3 MD5 | raw file
 1-------------------------------------------------------------------------------
 2--                                                                           --
 3--                   Copyright (C) 2010-, Thomas Løcke                   --
 4--                                                                           --
 5--  This is free software;  you can redistribute it and/or modify it         --
 6--  under terms of the  GNU General Public License  as published by the      --
 7--  Free Software  Foundation;  either version 3,  or (at your  option) any  --
 8--  later version. This library is distributed in the hope that it will be   --
 9--  useful, but WITHOUT ANY WARRANTY;  without even the implied warranty of  --
10--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
11--  You should have received a copy of the GNU General Public License and    --
12--  a copy of the GCC Runtime Library Exception along with this program;     --
13--  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
14--  <http://www.gnu.org/licenses/>.                                          --
15--                                                                           --
16-------------------------------------------------------------------------------
17
18with Ada.Calendar;
19with AWS.Session;
20
21package body View.Index is
22
23   ---------------
24   --  Generate --
25   ---------------
26
27   function Generate
28     (Request : in AWS.Status.Data)
29      return AWS.Response.Data
30   is
31      use Ada.Calendar;
32      use AWS.Session;
33      use AWS.Templates;
34
35      Session_Id : Id;
36      T          : Translate_Set;
37   begin
38      if AWS.Status.Has_Session (Request) then
39         Insert (T, Assoc ("SESSION_ENABLED", True));
40
41         Session_Id := AWS.Status.Session (Request);
42
43         if Get (Session_Id, "counter") > 0 then
44            Insert (T, Assoc ("SESSION_COUNTER",
45              Natural'(Get (Session_Id, "counter"))));
46
47            Set (Session_Id, "counter", 0);
48         end if;
49      end if;
50
51      Insert (T, Assoc ("YOLK_VERSION", Yolk.Version));
52      Insert (T, Assoc ("COPYRIGHT_YEAR", Year (Clock)));
53
54      return Build_Response
55        (Status_Data => Request,
56         Content     =>
57           Parse (Filename     => My.Config.Get (My.Template_Index),
58                  Translations => T,
59                  Cached       => True));
60   end Generate;
61
62end View.Index;