yass_3.1.0_9bcb0cc5/src/config.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
--    Copyright 2019-2021 Bartek thindil Jasicki & 2022-2024 A.J. Ianozi
--
--    This file is part of YASS.
--
--    YASS is free software: you can redistribute it and/or modify
--    it under the terms of the GNU General Public License as published by
--    the Free Software Foundation, either version 3 of the License, or
--    (at your option) any later version.
--
--    YASS is distributed in the hope that it will be useful,
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--    GNU General Public License for more details.
--
--    You should have received a copy of the GNU General Public License
--    along with YASS.  If not, see <http://www.gnu.org/licenses/>.

with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Containers.Indefinite_Vectors;
with Ada.Strings.Hash;
with AWS.Templates; use AWS.Templates;

-- ****h* Yass/Config
-- FUNCTION
-- Provide code for manipulate config file
-- SOURCE
package Config is
-- ****

   -- ****t* Config/Config.Excluded_Container
   -- FUNCTION
   -- Used to store list of excluded files
   -- SOURCE
   package Excluded_Container is new Ada.Containers.Indefinite_Vectors
     (Index_Type => Positive, Element_Type => String);
   -- ****

   -- ****t* Config/Config.Parser_Config
   -- FUNCTION
   -- Data structure for setting for parser
   -- PARAMETERS
   -- Output_Directory        - Path to directory with generated site
   -- Layouts_Directory       - Path to directory where site layouts are
   -- Modules_Directory       - Path to directory where program modules for this
   --                           site are
   -- Excluded_Files          - List of excluded files (and directories) from
   --                           site
   -- Server_Enabled          - Did web server is enabled
   -- Server_Port             - Port on which web server listen
   -- Monitor_Interval        - Interval (in seconds) how often program should
   --                           check for changes in site to regenerate it
   -- Base_Url                - Base URL for site, needed mostly for creating
   --                           sitemap
   -- Sitemap_Enabled         - Did creating sitemap is enabled
   -- Atom_Feed_Source        - Source of atom feed entries. Possible values
   --                           are: none (don't create atom feed, default),
   --                           tags (create entries from tags in markdown files)
   --                           and [filename] (path to markdown file which will
   --                           be used as a source of feed)
   -- Site_Name               - Name of the site, needed for atom feed
   -- Atom_Feed_Amount        - Number of entries in the Atom feed of the site
   -- Markdown_Comment        - String used to mark comments in markdown files
   -- Stop_Server_On_Error    - Did sever should go down if encounter error
   --                           during creating site
   -- Browser_Command         - Command used to open web browser (if empty,
   --                           don't open anything)
   -- Monitor_Config_Interval - Interval (in seconds) how often program should
   --                           check for changes in site configuration to
   --                           reconfigure it
   -- Author_Name             - Name of author of the site, needed for atom feed
   -- Author_Email            - Email address of author of the site, needed for
   --                           atom feed
   -- Language                - ISO code of the language of the site
   -- SOURCE
   type Parser_Config is record
      Output_Directory: Unbounded_String :=
        To_Unbounded_String(Source => "_output");
      Layouts_Directory: Unbounded_String :=
        To_Unbounded_String(Source => "_layouts");
      Modules_Directory: Unbounded_String :=
        To_Unbounded_String(Source => "_modules");
      Excluded_Files: Excluded_Container.Vector;
      Server_Enabled: Boolean := True;
      Server_Port: Positive := 8_888;
      Monitor_Interval: Duration := 5.0;
      Base_Url: Unbounded_String :=
        To_Unbounded_String(Source => "http://localhost:8888");
      Sitemap_Enabled: Boolean := True;
      HTML_Enabled: Boolean := True;
      Atom_Feed_Source: Unbounded_String :=
        To_Unbounded_String(Source => "none");
      Site_Name: Unbounded_String := To_Unbounded_String(Source => "New Site");
      Atom_Feed_Amount: Positive := 25;
      Markdown_Comment: Unbounded_String :=
        To_Unbounded_String(Source => "--");
      Stop_Server_On_Error: Boolean := False;
      Browser_Command: Unbounded_String :=
        To_Unbounded_String(Source => "none");
      Monitor_Config_Interval: Duration := 60.0;
      Author_Name: Unbounded_String :=
        To_Unbounded_String(Source => "John Doe");
      Author_Email: Unbounded_String :=
        To_Unbounded_String(Source => "johndoe@example.com");
      Language: Unbounded_String := To_Unbounded_String(Source => "en");
   end record;
   -- ****

   -- ****d* Config/Config.Default_Parser_Configuration
   -- FUNCTION
   -- Default parser configuration values
   -- SOURCE
   Default_Parser_Configuration: constant Parser_Config := (others => <>);
   -- ****

   --## rule off GLOBAL_REFERENCES
   -- ****v* Config/Config.Yass_Config
   -- FUNCTION
   -- Settings for the program
   -- SOURCE
   Yass_Config: Parser_Config := Default_Parser_Configuration;
   -- ****

   -- ****t* Config/Config.Tags_Container
   -- FUNCTION
   -- Used to store AWS template tags
   -- SOURCE
   package Tags_Container is new Ada.Containers.Indefinite_Hashed_Maps
     (Key_Type => String, Element_Type => String, Hash => Ada.Strings.Hash,
      Equivalent_Keys => "=");
   -- ****

   -- ****v* Config/Config.Site_Tags
   -- FUNCTION
   -- Site tags (like title, author, etc)
   -- SOURCE
   Site_Tags: Tags_Container.Map;
   -- ****

   -- ****v* Config/Config.Site_Directory
   -- FUNCTION
   -- Directory where site files are
   -- SOURCE
   Site_Directory: Unbounded_String;
   -- ****

   -- ****t* Config/Config.TableTags_Container
   -- FUNCTION
   -- Used to store AWS template table tags
   -- SOURCE
   package TableTags_Container is new Ada.Containers.Indefinite_Hashed_Maps
     (Key_Type => String, Element_Type => Vector_Tag, Hash => Ada.Strings.Hash,
      Equivalent_Keys => "=");
   -- ****

   -- ****v* Config/Config.Global_Table_Tags
   -- FUNCTION
   -- Global table tags, used in @@TABLE@@ statement
   -- SOURCE
   Global_Table_Tags: TableTags_Container.Map;
   -- ****
   --## rule on GLOBAL_REFERENCES

   -- ****e* Config/Config.Invalid_Config_Data
   -- FUNCTION
   -- Raised when invalid data found in site config file
   -- SOURCE
   Invalid_Config_Data: exception;
   -- ****

   -- ****f* Config/Config.Create_Config
   -- FUNCTION
   -- Create default config in directory with full path Directory_Name
   -- PARAMETERS
   -- Directory_Name - Full path to the directory where config file will be
   --                  created
   -- SOURCE
   procedure Create_Config(Directory_Name: String) with
      Pre => Directory_Name'Length > 0,
      Test_Case => (Name => "Test_Create_Config", Mode => Nominal);
   -- ****

   -- ****f* Config/Config.Parse_Config
   -- FUNCTION
   -- Parse config file and set all settings and tags for site in directory
   -- with full path Directory_Name
   -- PARAMETERS
   -- Directory_Name - Full path to the directory from which config file will
   --                  be parsed
   -- SOURCE
   procedure Parse_Config(Directory_Name: String) with
      Pre => Directory_Name'Length > 0,
      Test_Case => (Name => "Test_Parse_Config", Mode => Nominal);
   -- ****

   -- ****f* Config/Config.Create_Interactive_Config
   -- FUNCTION
   -- Create configuration file based on the user answers to the program
   -- questions
   -- PARAMETERS
   -- Directory_Name - Full path to the directory where config file will be
   --                  created
   -- SOURCE
   procedure Create_Interactive_Config(Directory_Name: String) with
      Pre => Directory_Name'Length > 0;
   -- ****

end Config;