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
|
const { Record, OrderedMap, Map, List } = require('immutable');
const Git = require('../utils/git');
const LocationUtils = require('../utils/location');
const Book = require('./book');
const URIIndex = require('./uriIndex');
const DEFAULTS = {
book: new Book(),
// Name of the generator being used
generator: String(),
// Map of plugins to use (String -> Plugin)
plugins: OrderedMap(),
// Map pages to generation (String -> Page)
pages: OrderedMap(),
// List of file that are not pages in the book (String)
assets: List(),
// Option for the generation
options: Map(),
// Internal state for the generation
state: Map(),
// Index of urls
urls: new URIIndex(),
// Git repositories manager
git: new Git()
};
class Output extends Record(DEFAULTS) {
getBook() {
return this.get('book');
}
getGenerator() {
return this.get('generator');
}
getPlugins() {
return this.get('plugins');
}
getPages() {
return this.get('pages');
}
getOptions() {
return this.get('options');
}
getAssets() {
return this.get('assets');
}
getState() {
return this.get('state');
}
getURLIndex() {
return this.get('urls');
}
/**
* Return a page byt its file path
*
* @param {String} filePath
* @return {Page|undefined}
*/
getPage(filePath) {
filePath = LocationUtils.normalize(filePath);
const pages = this.getPages();
return pages.get(filePath);
}
/**
* Get root folder for output.
* @return {String}
*/
getRoot() {
return this.getOptions().get('root');
}
/**
* Update state of output
*
* @param {Map} newState
* @return {Output}
*/
setState(newState) {
return this.set('state', newState);
}
/**
* Update options
*
* @param {Map} newOptions
* @return {Output}
*/
setOptions(newOptions) {
return this.set('options', newOptions);
}
/**
* Return logegr for this output (same as book)
*
* @return {Logger}
*/
getLogger() {
return this.getBook().getLogger();
}
}
module.exports = Output;
|