1 /* DrawOfPages: Take notes with touchscreen input.
2  * Copyright (C) 2019  Marko Semet
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Affero General Public License for more details.
13  * 
14  * You should have received a copy of the GNU Affero General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 module dop.authorship;
18 
19 private
20 {
21     import std.algorithm;
22     import std.array;
23     import std.json;
24 
25     struct __DataLoader
26     {
27         string[] authors;
28         string[] translators;
29         string[] artists;
30         string[] documenters;
31         string copyright_infos;
32         string prog_version;
33 
34         /++
35          + Loads a string list out of a json
36          + Params:
37          +     data = The source json list
38          + Returns: The read list of strings. When empty null.
39          +/
40         static string[] loadArray(JSONValue[] data)
41         {
42             auto result = data.map!((x) => x.str).filter!((x) => x.length != 0).array;
43             if(result.length == 0)
44             {
45                 return null;
46             }
47             else
48             {
49                 return result;
50             }
51         }
52 
53         /++
54          + Load the base input from resource file "authors.json"
55          + Returns: The loaded values
56          +/
57         static __DataLoader load()
58         {
59             __DataLoader result;
60             auto data = parseJSON(import("dop/authors.json")).object;
61             assert(data["authors"].type == JSONType.array);
62             result.authors = loadArray(data["authors"].array);
63             assert(data["translators"].type == JSONType.array);
64             result.translators = loadArray(data["translators"].array);
65             assert(data["artists"].type == JSONType.array);
66             result.artists = loadArray(data["artists"].array);
67             assert(data["documenters"].type == JSONType.array);
68             result.documenters = loadArray(data["documenters"].array);
69             assert(data["copyright_infos"].type == JSONType..string);
70             result.copyright_infos = data["copyright_infos"].str;
71             assert(data["version"].type == JSONType..string);
72             result.prog_version = data["version"].str;
73             return result;
74         }
75     }
76     enum __DataLoader __loader = __DataLoader.load();       
77 }
78 
79 public
80 {
81     /++
82      + List of the developers.
83      +/
84     enum string[] authorship_authors = __loader.authors;
85     /++
86      + List of the translators.
87      +/
88     enum string[] authorship_translators = __loader.translators;
89     /++
90      + List of the artists.
91      +/
92     enum string[] authorship_artists = __loader.artists;
93     /++
94      + List of the documenters.
95      +/
96     enum string[] authorship_documenters = __loader.documenters;
97     /++
98      + Additional copyright informations.
99      +/
100     enum string authorship_copyright_infos = __loader.copyright_infos;
101     /++
102      + The current programm version.
103      +/
104     enum string programm_version = __loader.prog_version;
105 }