aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/paths_source.d
blob: b5a60e80b20f84ea62c3d6e2e982203b412db8f8 (plain)
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
/++
  read configuration files<BR>
  - read config files<BR>
  ao_config_files.d
+/
module sdp.paths_source;
import std.array,
  std.path,
  std.regex,
  std.stdio;
import sdp.ao_rgx;
template SiSUpathsSRC() {
  mixin SiSUrgxInit;
  auto rgx = Rgx();
  auto SiSUpathsSRC(D,Fn)(
    D   _pwd,
    Fn  _fn_src,
  ) {
    struct SisuSrcPaths {
      auto pwd() {
        return _pwd;
      }
      auto language() {
        // use command line info as well?
        string _k;
        if (auto m = _fn_src.match(rgx.language_code_and_filename)) {
          _k = m.captures[1];
        } else {
          _k = "en";
        }
        return _k;
      }
      auto doc_root() {
        return "sisudoc";
      }
      auto text_root() {
        return doc_root.chainPath("text").array;
      }
      auto media_root() {
        return doc_root.chainPath("docmedia").array;
      }
      auto conf_root() {
        return doc_root.chainPath("conf").array;
      }
      auto image_root() {
        return media_root.chainPath("image").array;
      }
      auto doc_src_fn_with_path_for_text_root_and_lng() {
        return text_root.chainPath(language).array;
      }
      auto doc_src_with_relative_path() {
        return pwd.chainPath(_fn_src).array;
      }
      auto doc_src_fn() {
        return _fn_src.baseName.array;
      }
    }
    return SisuSrcPaths();
  }
}