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
232
233
234
235
236
|
import {stitchArrays} from '#sugar';
export default {
contentDependencies: ['linkFlash', 'linkFlashIndex'],
extraDependencies: ['html', 'wikiData'],
// So help me Gog, the flash sidebar is heavily hard-coded.
sprawl: ({flashActData}) => ({flashActData}),
query(sprawl, flash) {
const flashActs =
sprawl.flashActData.slice();
const act6 =
flashActs
.findIndex(act => act.name.startsWith('Act 6'));
const postCanon =
flashActs
.findIndex(act => act.name.includes('Post Canon'));
const outsideCanon =
postCanon +
flashActs
.slice(postCanon)
.findIndex(act => !act.name.includes('Post Canon'));
const currentAct = flash.act;
const actIndex =
flashActs
.indexOf(currentAct);
const side =
(actIndex < 0
? 0
: actIndex < act6
? 1
: actIndex < outsideCanon
? 2
: 3);
const sideActs =
flashActs
.filter((act, index) =>
act.name.startsWith('Act 1') ||
act.name.startsWith('Act 6 Act 1') ||
act.name.startsWith('Hiveswap') ||
index >= outsideCanon);
const currentSideIndex =
sideActs
.findIndex(act => {
if (act.name.startsWith('Act 1')) {
return side === 1;
} else if (act.name.startsWith('Act 6 Act 1')) {
return side === 2;
} else if (act.name.startsWith('Hiveswap Act 1')) {
return side === 3;
} else {
return act === currentAct;
}
})
const sideNames =
sideActs
.map(act => {
if (act.name.startsWith('Act 1')) {
return `Side 1 (Acts 1-5)`;
} else if (act.name.startsWith('Act 6 Act 1')) {
return `Side 2 (Acts 6-7)`;
} else if (act.name.startsWith('Hiveswap Act 1')) {
return `Outside Canon (Misc. Games)`;
} else {
return act.name;
}
});
const sideColors =
sideActs
.map(act => {
if (act.name.startsWith('Act 1')) {
return '#4ac925';
} else if (act.name.startsWith('Act 6 Act 1')) {
return '#1076a2';
} else if (act.name.startsWith('Hiveswap Act 1')) {
return '#008282';
} else {
return act.color;
}
});
const sideFirstFlashes =
sideActs
.map(act => act.flashes[0]);
const scopeActs =
flashActs
.filter((act, index) => {
if (index < act6) {
return side === 1;
} else if (index < outsideCanon) {
return side === 2;
} else {
return false;
}
});
const currentScopeActIndex =
scopeActs.indexOf(currentAct);
const scopeActNames =
scopeActs
.map(act => act.name);
const scopeActFirstFlashes =
scopeActs
.map(act => act.flashes[0]);
const currentActFlashes =
currentAct.flashes;
const currentFlashIndex =
currentActFlashes
.indexOf(flash);
return {
currentSideIndex,
sideNames,
sideColors,
sideFirstFlashes,
currentScopeActIndex,
scopeActNames,
scopeActFirstFlashes,
currentActFlashes,
currentFlashIndex,
};
},
relations: (relation, query) => ({
flashIndexLink:
relation('linkFlashIndex'),
sideFirstFlashLinks:
query.sideFirstFlashes
.map(flash => relation('linkFlash', flash)),
scopeActFirstFlashLinks:
query.scopeActFirstFlashes
.map(flash => relation('linkFlash', flash)),
currentActFlashLinks:
query.currentActFlashes
.map(flash => relation('linkFlash', flash)),
}),
data: (query) => ({
currentSideIndex: query.currentSideIndex,
sideColors: query.sideColors,
sideNames: query.sideNames,
currentScopeActIndex: query.currentScopeActIndex,
scopeActNames: query.scopeActNames,
currentFlashIndex: query.currentFlashIndex,
}),
generate(data, relations, {html}) {
const currentActFlashList =
html.tag('ul',
relations.currentActFlashLinks
.map((flashLink, index) =>
html.tag('li',
{class: index === data.currentFlashIndex && 'current'},
flashLink)));
return {
leftSidebarContent: html.tags([
html.tag('h1', relations.flashIndexLink),
html.tag('dl',
stitchArrays({
sideFirstFlashLink: relations.sideFirstFlashLinks,
sideColor: data.sideColors,
sideName: data.sideNames,
}).map(({sideFirstFlashLink, sideColor, sideName}, index) => [
// Side acts are displayed whether part of Homestuck proper or
// not, and they're always the same regardless the current flash
// page. Scope acts, if applicable, and the list of flashes
// belonging to the current act, will be inserted after the
// heading of the current side.
html.tag('dt',
{class: [
'side',
index === data.currentSideIndex && 'current',
]},
sideFirstFlashLink.slots({
color: sideColor,
content: sideName,
})),
// Scope acts are only applicable when inside Homestuck proper.
// Hiveswap and all acts beyond are each considered to be its
// own "side".
index === data.currentSideIndex &&
data.currentScopeActIndex !== -1 &&
stitchArrays({
scopeActFirstFlashLink: relations.scopeActFirstFlashLinks,
scopeActName: data.scopeActNames,
}).map(({scopeActFirstFlashLink, scopeActName}, index) => [
html.tag('dt',
{class: index === data.currentScopeActIndex && 'current'},
scopeActFirstFlashLink.slot('content', scopeActName)),
// Inside Homestuck proper, the flash list of the current
// act should show after the heading for the relevant
// scope act.
index === data.currentScopeActIndex &&
html.tag('dd', currentActFlashList),
]),
// Outside of Homestuck proper, the current act is represented
// by a side instead of a scope act, so place its flash list
// after the heading for the relevant side.
index === data.currentSideIndex &&
data.currentScopeActIndex === -1 &&
html.tag('dd', currentActFlashList),
])),
]),
};
},
};
|