/demo/src/my_configuration.ads

http://github.com/ThomasLocke/yolk · Ada · 104 lines · 73 code · 10 blank · 21 comment · 0 complexity · 21ad6b228d94b3e86c64d1ea05be204c 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. -- Application specific configuration.
  18. with Ada.Strings.Unbounded;
  19. with Yolk.Config_File_Parser;
  20. package My_Configuration is
  21. use Ada.Strings.Unbounded;
  22. function U
  23. (S : in String)
  24. return Unbounded_String
  25. renames To_Unbounded_String;
  26. type Keys is (DB_Host,
  27. DB_Name,
  28. DB_User,
  29. DB_Password,
  30. Handler_DB_Test,
  31. Handler_Dir,
  32. Handler_Email,
  33. Handler_Index,
  34. Handler_Session_Test,
  35. Handler_Syndication,
  36. Handler_Websocket,
  37. SQLite_Database,
  38. SMTP_Host,
  39. SMTP_Port,
  40. Template_DB_Test,
  41. Template_Email,
  42. Template_Index,
  43. Template_Session_Test,
  44. Template_Websocket);
  45. -- The valid configuration keys.
  46. type Defaults_Array is array (Keys) of Unbounded_String;
  47. Default_Values : constant Defaults_Array :=
  48. (DB_Host
  49. => U ("localhost"),
  50. DB_Name
  51. => U ("yolk"),
  52. DB_User
  53. => U ("adauser"),
  54. DB_Password
  55. => U ("secret"),
  56. Handler_DB_Test
  57. => U ("/dbtest"),
  58. Handler_Dir
  59. => U ("^/dir/.*"),
  60. Handler_Email
  61. => U ("/email"),
  62. Handler_Index
  63. => U ("/"),
  64. Handler_Session_Test
  65. => U ("/sessiontest"),
  66. Handler_Syndication
  67. => U ("/syndication"),
  68. Handler_Websocket
  69. => U ("/websocket"),
  70. SQLite_Database
  71. => U ("yolk.db"),
  72. SMTP_Host
  73. => U ("localhost"),
  74. SMTP_Port
  75. => U ("25"),
  76. Template_DB_Test
  77. => U ("templates/website/database.tmpl"),
  78. Template_Email
  79. => U ("templates/website/email.tmpl"),
  80. Template_Index
  81. => U ("templates/website/index.tmpl"),
  82. Template_Session_Test
  83. => U ("templates/website/session_test.tmpl"),
  84. Template_Websocket
  85. => U ("templates/website/websocket.tmpl"));
  86. -- Default values for the configuration Keys. These values can be over-
  87. -- written by the configuration file given when instantiating the
  88. -- Yolk.Config_File_Parser generic.
  89. package Config is new Yolk.Config_File_Parser
  90. (Key_Type => Keys,
  91. Defaults_Array_Type => Defaults_Array,
  92. Defaults => Default_Values,
  93. Config_File => "configuration/my_config.ini");
  94. end My_Configuration;