aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/source_sisupod.d
blob: 1edbbfcf549d83951b54a58a52f95d8c1969ea13 (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
61
62
63
64
65
66
67
68
template SiSUpod() {
  private import
    std.algorithm,
    std.array,
    std.container,
    std.exception,
    std.file,
    std.getopt,
    std.json,
    std.process,
    std.stdio,
    std.path,
    std.range,
    std.regex,
    std.string,
    std.traits,
    std.typecons,
    std.uni,
    std.utf,
    ao_defaults;
  import
    ao_rgx,
    output_xhtmls;
  
  void SiSUpod(S)(
    S fn_src,
  ) {
    debug(asserts){
      static assert(is(typeof(fn_src) == string));
    }
    mixin SiSUrgxInit;
    mixin SiSUpaths;
    auto pth_sisupod = SiSUpodPaths();
    mixin SiSUlanguageCodes;
    auto lang = Lang();
    auto rgx = Rgx();
    /+
      dir structure
      /tmp/_sisu_processing_/ralph/en/sisupod
        ├── doc
        │   └── en
        └── image
  
      - create directory structure
  
    +/
    assert (match(fn_src, rgx.src_fn));
    try {
      /+ create directory structure +/
      mkdirRecurse(pth_sisupod.doc(fn_src));
      mkdirRecurse(pth_sisupod.conf(fn_src));
      mkdirRecurse(pth_sisupod.css(fn_src));
      mkdirRecurse(pth_sisupod.image(fn_src));
      /+ copy relevant files +/
      auto f_out = pth_sisupod.fn_doc(fn_src, "en"); // you need fn without path and then to insert back language code for output sub-directory
      debug(sisupod) {
        writeln(__LINE__, ": ", fn_src, " -> ", f_out);
      }
      mkdirRecurse(pth_sisupod.doc_lng(fn_src, "en")); // need to extract language code directories (from directory structure or filenames & have a default)
      copy(fn_src, f_out);
    }
    catch (ErrnoException ex) {
      // Handle error
    }
  }
  
  
}