/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 ¸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. with Ada.Calendar;
  18. with AWS.Session;
  19. package body View.Index is
  20. ---------------
  21. -- Generate --
  22. ---------------
  23. function Generate
  24. (Request : in AWS.Status.Data)
  25. return AWS.Response.Data
  26. is
  27. use Ada.Calendar;
  28. use AWS.Session;
  29. use AWS.Templates;
  30. Session_Id : Id;
  31. T : Translate_Set;
  32. begin
  33. if AWS.Status.Has_Session (Request) then
  34. Insert (T, Assoc ("SESSION_ENABLED", True));
  35. Session_Id := AWS.Status.Session (Request);
  36. if Get (Session_Id, "counter") > 0 then
  37. Insert (T, Assoc ("SESSION_COUNTER",
  38. Natural'(Get (Session_Id, "counter"))));
  39. Set (Session_Id, "counter", 0);
  40. end if;
  41. end if;
  42. Insert (T, Assoc ("YOLK_VERSION", Yolk.Version));
  43. Insert (T, Assoc ("COPYRIGHT_YEAR", Year (Clock)));
  44. return Build_Response
  45. (Status_Data => Request,
  46. Content =>
  47. Parse (Filename => My.Config.Get (My.Template_Index),
  48. Translations => T,
  49. Cached => True));
  50. end Generate;
  51. end View.Index;