-
Notifications
You must be signed in to change notification settings - Fork 2
/
examplePlugin.js
231 lines (188 loc) · 5.95 KB
/
examplePlugin.js
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// This is how Ryver plugins load ryver
var ryver = module.parent.exports.ryver;
var eventEC = ryver.eventEC;
/*
* PREPROCESS STAGES
beforePreProcessFilters // HOOK
preProcessFilters // FILTER
afterPreProcessFilters // HOOK
* FILTERING STAGES
beforeFilters // HOOK
preFilters // FILTER
filter // FILTER
postFilters // FILTER
afterFilters // HOOK
* POSTPROCESS STAGES
beforeDelayedPostProcess // HOOK. ONLY if processing had been delayed
beforePostProcessFilters // HOOK
postProcessFilters // FILTER
afterPostPocessFilters // HOOK
afterEverything // HOOK
afterDelayedPostProcess // HOOK. ONLY if processin had been delayed
* FINAL AND AFTER-CREATOON STAGES
allDone // HOOK
alsoRefilter // HOOK
watch // HOOK
*/
// INITIAL STAGES: PREPROCESS FILTER (SURROUNDED BY HOOKS)
// The beforePreProcessFilter is particularly important as
// it runs BEFORE the filtering pipeline is establish. this
// enables the frontmatter module to change fileData.filter and
// actually have an effect
// HOOK
eventEC.onCollect( 'beforePreProcessFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// At this point, the changes to filter variables in fileData will no longer have
// any effect as the processing pipeline is already created
// FILTER
eventEC.onCollect( 'preProcessFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// HOOK
eventEC.onCollect( 'afterPreProcessFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// FILTERING STAGES: PREFILTER, FILTER AND POSTFILTER (SURROUNDED BY HOOKS)
// preFilters, filter, postFilters are where users normally set their own
// filtering.
//HOOK
eventEC.onCollect( 'beforeFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// FILTER
eventEC.onCollect( 'preFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// FILTER
eventEC.onCollect( 'filter', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// FILTER
eventEC.onCollect( 'postFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// HOOK
eventEC.onCollect( 'afterFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// DELAYED FILTERING -- FIRST (BEFORE) HOOK
// Some filters are "delayed", which means that their processing will
// actually SUSPEND till ALL of the files to be processes have gone through the
// filters above.
// This is crucial for filters that need to gather information about ALL that
// was filter to function properly (see: lister)
// This happens when `fileData.info.delayPostProcess` is `true`
// If that is the case, 'beforeDelayedPostProcess will be triggered'
// HOOK
eventEC.onCollect( 'beforeDelayedPostProcess', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// POST PROCESS FILTERS (SURROUNDED BY HOOKS)
// postProcessFilter is where users will normally put templating things,
// since they will need ALL of the gathered information to be available.
// HOOK
eventEC.onCollect( 'beforePostProcessFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// FILTER
eventEC.onCollect( 'postProcessFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// HOOK
eventEC.onCollect( 'afterPostPocessFilters', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// HOOK
eventEC.onCollect( 'afterEverything', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// DELAYED FILTERING -- SECOND (AFTER) HOOK
// This hook is called in case the file's processing was effectively delayed
// HOOK
eventEC.onCollect( 'afterDelayedPostProcess', function( cb ){
var f = function( fileData, cb ){
cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// ALLDONE hook. This will trigger once _everything_ is done
// HOOK
eventEC.onCollect( 'allDone', function( cb ){
var f = function( cb ){
return cb( null );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// POST_CHANGES HOOKS.
// These hooks are used to help ryver re-generate files if needed
// HOOK
eventEC.onCollect( 'alsoRefilter', function( cb ){
var f = function( affectedOrigins, cb ){
return cb( null, [] );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});
// HOOK
eventEC.onCollect( 'watch', function( cb ){
var f = function( op, URL, cb ){
return cb( null, r );
}
// Return the function just defined as the filter
cb( null, { name: 'custom', executor: f } );
});