@@ -31,22 +31,16 @@ module.exports = {
31
31
options . enabled = [ ]
32
32
}
33
33
34
- if ( typeof options . lighthouse === 'undefined' ) {
35
- options . lighthouse = {
36
- enabled : false
37
- }
38
- }
39
-
40
34
if ( typeof options . puppeteer === 'undefined' ) {
41
35
options . puppeteer = {
42
36
headless : true ,
43
37
defaultViewport : null
44
38
}
45
39
}
46
40
47
- let actions = [ articleParser ( options , socket ) ] ;
41
+ const actions = [ articleParser ( options , socket ) ]
48
42
49
- if ( options . enabled . includes ( 'lighthouse' ) ) {
43
+ if ( options . enabled . includes ( 'lighthouse' ) ) {
50
44
actions . push ( lighthouseAnalysis ( options , socket ) )
51
45
}
52
46
@@ -108,12 +102,10 @@ const articleParser = async function (options, socket) {
108
102
article . meta . title . text = await page . title ( )
109
103
110
104
// Take mobile screenshot
111
- if ( options . enabled . includes ( 'screenshot' ) ) {
112
-
105
+ if ( options . enabled . includes ( 'screenshot' ) ) {
113
106
socket . emit ( 'parse:status' , 'Taking Mobile Screenshot' )
114
107
115
108
article . mobile = await page . screenshot ( { encoding : 'base64' , type : 'jpeg' , quality : 60 } )
116
-
117
109
}
118
110
119
111
// Evaluate meta
@@ -172,8 +164,7 @@ const articleParser = async function (options, socket) {
172
164
article . title . text = content . title
173
165
174
166
// Get in article links
175
- if ( options . enabled . includes ( 'links' ) ) {
176
-
167
+ if ( options . enabled . includes ( 'links' ) ) {
177
168
socket . emit ( 'parse:status' , 'Evaluating Links' )
178
169
179
170
const { window } = new JSDOM ( article . processed . html )
@@ -204,8 +195,7 @@ const articleParser = async function (options, socket) {
204
195
article . excerpt = helpers . capitalizeFirstLetter ( article . processed . text . raw . replace ( / ^ ( .{ 200 } [ ^ \s ] * ) .* / , '$1' ) )
205
196
206
197
// Sentiment
207
- if ( options . enabled . includes ( 'sentiment' ) ) {
208
-
198
+ if ( options . enabled . includes ( 'sentiment' ) ) {
209
199
socket . emit ( 'parse:status' , 'Sentiment Analysis' )
210
200
211
201
const sentiment = new Sentiment ( )
@@ -218,12 +208,10 @@ const articleParser = async function (options, socket) {
218
208
} else {
219
209
article . sentiment . result = 'Neutral'
220
210
}
221
-
222
211
}
223
212
224
213
// Named Entity Recognition
225
- if ( options . enabled . includes ( 'entities' ) ) {
226
-
214
+ if ( options . enabled . includes ( 'entities' ) ) {
227
215
socket . emit ( 'parse:status' , 'Named Entity Recognition' )
228
216
229
217
// People
@@ -253,21 +241,17 @@ const articleParser = async function (options, socket) {
253
241
article . topics . sort ( function ( a , b ) {
254
242
return ( a . percent > b . percent ) ? - 1 : 1
255
243
} )
256
-
257
244
}
258
245
259
246
// Spelling
260
- if ( options . enabled . includes ( 'spelling' ) ) {
261
-
262
- socket . emit ( 'parse:status' , 'Check Spelling' )
247
+ if ( options . enabled . includes ( 'spelling' ) ) {
248
+ socket . emit ( 'parse:status' , 'Check Spelling' )
263
249
264
250
article . spelling = await spellCheck ( article . processed . text . formatted , article . topics , options . retextspell )
265
-
266
251
}
267
252
268
253
// Evaluate keywords & keyphrases
269
- if ( options . enabled . includes ( 'keywords' ) ) {
270
-
254
+ if ( options . enabled . includes ( 'keywords' ) ) {
271
255
socket . emit ( 'parse:status' , 'Evaluating Keywords' )
272
256
273
257
// Evaluate meta title keywords & keyphrases
@@ -281,7 +265,6 @@ const articleParser = async function (options, socket) {
281
265
282
266
// Evaluate processed content keywords & keyphrases
283
267
Object . assign ( article . processed , await keywordParser ( article . processed . text . raw , options . retextkeywords ) )
284
-
285
268
}
286
269
287
270
await browser . close ( )
@@ -483,7 +466,6 @@ const keywordParser = function (html, options) {
483
466
}
484
467
485
468
const lighthouseAnalysis = async function ( options , socket ) {
486
-
487
469
socket . emit ( 'parse:status' , 'Starting Lighthouse' )
488
470
489
471
// Init puppeteer
@@ -499,7 +481,6 @@ const lighthouseAnalysis = async function (options, socket) {
499
481
socket . emit ( 'parse:status' , 'Lighthouse Analysis Complete' )
500
482
501
483
return results . lhr
502
-
503
484
}
504
485
505
486
const getContent = function ( document ) {
0 commit comments