forked from scripting/pagePark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.opml
2303 lines (2303 loc) · 122 KB
/
source.opml
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- OPML generated by OPML Editor v10.1b19 on Fri, 12 Nov 2021 15:24:55 GMT -->
<opml version="2.0">
<head>
<title>nodeEditor: pagePark</title>
<dateCreated>Sun, 21 Dec 2014 23:33:23 GMT</dateCreated>
<dateModified>Fri, 12 Nov 2021 15:24:55 GMT</dateModified>
<ownerName>Dave Winer</ownerName>
<ownerId>http://davewiner.com/</ownerId>
<expansionState>1, 2, 3, 12, 20</expansionState>
<vertScrollState>1</vertScrollState>
<windowTop>45</windowTop>
<windowLeft>446</windowLeft>
<windowBottom>1297</windowBottom>
<windowRight>1643</windowRight>
</head>
<body>
<outline text="/scripting.com/code/pagepark/">
<outline text="package.json">
<outline text="{">
<outline text=""name": "PagePark","/>
<outline text=""description": "A simple Node.js folder-based HTTP server that serves static and dynamic pages for domains.","/>
<outline text=""author": "Dave Winer <[email protected]>","/>
<outline text=""version": "0.8.26", "/>
<outline text=""scripts": {">
<outline text=""start": "node pagepark.js"">
<outline text="},"/>
</outline>
</outline>
<outline text=""repository": {">
<outline text=""type" : "git","/>
<outline text=""url" : "https://github.com/scripting/pagePark.git""/>
<outline text="},"/>
</outline>
<outline text=""dependencies" : {">
<outline text=""request": "*","/>
<outline text=""mime": "*"," isComment="true"/>
<outline text=""daveopml": "*"," isComment="true"/>
<outline text=""pagepark": "*","/>
<outline text=""opmltojs": "*","/>
<outline text=""daveutils": "*","/>
<outline text=""daves3": "*","/>
<outline text=""davediskspace": "*","/>
<outline text=""githubpub": "*","/>
<outline text=""pagepark": "*","/>
<outline text=""nodejs-websocket": "*","/>
<outline text=""require-from-string": "*","/>
<outline text=""marked": "*","/>
<outline text=""child_process": "*","/>
<outline text=""forever": "*","/>
<outline text=""forever-monitor": "*""/>
<outline text="}, "/>
</outline>
<outline text=""license": "MIT","/>
<outline text=""engines": {">
<outline text=""node": "*""/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
</outline>
<outline text="pagepark.js">
<outline text="var myProductName = "PagePark", myVersion = "0.8.26";" created="Mon, 03 Feb 2014 03:21:03 GMT" pgfnum="36831"/>
<outline text=""/>
<outline text="/* The MIT License (MIT)">
<outline text="Copyright (c) 2014-2021 Dave Winer"/>
<outline text=""/>
<outline text="Permission is hereby granted, free of charge, to any person obtaining a copy"/>
<outline text="of this software and associated documentation files (the "Software"), to deal"/>
<outline text="in the Software without restriction, including without limitation the rights"/>
<outline text="to use, copy, modify, merge, publish, distribute, sublicense, and/or sell"/>
<outline text="copies of the Software, and to permit persons to whom the Software is"/>
<outline text="furnished to do so, subject to the following conditions:"/>
<outline text=""/>
<outline text="The above copyright notice and this permission notice shall be included in all"/>
<outline text="copies or substantial portions of the Software."/>
<outline text=""/>
<outline text="THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"/>
<outline text="IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"/>
<outline text="FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"/>
<outline text="AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"/>
<outline text="LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"/>
<outline text="OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"/>
<outline text="SOFTWARE."/>
<outline text=" "/>
<outline text="structured listing: http://scripting.com/listings/pagepark.html"/>
<outline text="*/"/>
</outline>
<outline text=""/>
<outline text="const fs = require ("fs");"/>
<outline text="const request = require ("request");"/>
<outline text="const urlpack = require ("url");" created="Tue, 21 Jan 2014 00:09:23 GMT" pgfnum="36074"/>
<outline text="const http = require ("http");" created="Thu, 26 Dec 2013 23:02:58 GMT" pgfnum="34549"/>
<outline text="const marked = require ("marked");"/>
<outline text="const dns = require ("dns");"/>
<outline text="const mime = require ("mime"); //1/8/15 by DW" isComment="true"/>
<outline text="const utils = require ("daveutils"); //6/7/17 by DW"/>
<outline text="const opmlToJs = require ("opmltojs"); //6/16/17 by DW"/>
<outline text="const websocket = require ("nodejs-websocket"); //9/29/17 by DW"/>
<outline text="const s3 = require ("daves3"); //6/4/18 by DW"/>
<outline text="const githubpub = require ("githubpub"); //12/3/19 by DW"/>
<outline text="const freeDiskSpace = require ("davediskspace"); //12/20/19 by DW"/>
<outline text="const requireFromString = require ("require-from-string"); //5/9/20 by DW"/>
<outline text="const thePackage = require ("./lib/pageparkpackage.js"); //6/27/20 by DW -- for testing" isComment="true"/>
<outline text="const thePackage = require ("pagepark"); //5/6/20 by DW"/>
<outline text=""/>
<outline text="var pageparkPrefs = {">
<outline text="myPort: 1339, //1/8/15 by DW -- was 80, see note in readme.md"/>
<outline text="flWebsocketEnabled: false, websocketPort: 1340, //9/29/17 by DW"/>
<outline text="indexFilename: "index","/>
<outline text="flProcessScriptFiles: false, extScriptFiles: "js", //12/4/19 by DW -- breaking change"/>
<outline text="flProcessMarkdownFiles: true, extMarkdownFiles: "md", //5/5/15 by DW"/>
<outline text="flProcessOpmlFiles: true, extOpmlFiles: "opml", //6/23/15 by DW"/>
<outline text="error404File: "prefs/error.html", //7/16/15 by DW"/>
<outline text="legalPathChars: "", //7/19/15 by DW,"/>
<outline text="flCacheTemplatesLocally: false, //12/21/19 by DW -- switched the default from true"/>
<outline text="urlDefaultMarkdownTemplate: "http://scripting.com/code/pagepark/templates/markdown/template.txt", "/>
<outline text="urlDefaultOpmlTemplate: "http://scripting.com/code/pagepark/templates/opml/template.txt","/>
<outline text="urlDefaultErrorPage: "http://scripting.com/code/pagepark/prefs/error.html", "/>
<outline text="flUnicasePaths: false, //11/7/17 by DW"/>
<outline text="defaultType: "text/html", //7/21/18 by DW"/>
<outline text="flHiddenFilesCheck: true, //12/9/19 by DW -- check if file or folder name begins with _"/>
<outline text="ctGithubCacheSecs: 3600, //12/13/19 by DW -- one hour"/>
<outline text="flRunChronologicalScripts: false, //5/13/20 by DW"/>
<outline text="flRunPersistentScripts: false, //5/13/20 by DW"/>
<outline text="flCliPortEnabled: false, cliPort: 1349, //5/27/20 by DW"/>
<outline text="defaultDomanFolderName: "default", //7/5/21 by DW" created="Mon, 05 Jul 2021 14:28:33 GMT"/>
<outline text="defaultExtension: "", //7/25/21 by DW" created="Sun, 25 Jul 2021 16:02:25 GMT"/>
<outline text="flServeConfigJson: false //7/28/21 by DW" created="Wed, 28 Jul 2021 17:10:32 GMT"/>
<outline text="};"/>
</outline>
<outline text="var pageparkStats = {">
<outline text="ctStarts: 0, "/>
<outline text="whenLastStart: new Date (0),"/>
<outline text="ctHits: 0, ctHitsToday: 0, ctHitsSinceStart: 0,"/>
<outline text="whenLastHit: new Date (0),"/>
<outline text="hitsByDomain: {}"/>
<outline text="};"/>
</outline>
<outline text=""/>
<outline text="var fnamePrefs = "prefs/prefs.json";"/>
<outline text="var fnameStats = "prefs/stats.json", flStatsDirty = false;"/>
<outline text="var domainsPath = "domains/";"/>
<outline text="var configFname = "/config.json";"/>
<outline text="var filterFname = "/filter.js";"/>
<outline text="var mdTemplatePath = "prefs/mdTemplate.txt";"/>
<outline text="var opmlTemplatePath = "prefs/opmlTemplate.txt";"/>
<outline text="var folderPathFromEnv = process.env.pageparkFolderPath; //1/3/15 by DW"/>
<outline text="var flEveryMinuteScheduled = false; //7/17/17 by DW"/>
<outline text=""/>
<outline text="//websockets -- 9/29/17 by DW">
<outline text="var theWsServer = undefined;"/>
<outline text="function notifySocketSubscribers (verb, jstruct) {">
<outline text="if (theWsServer !== undefined) {">
<outline text="var ctUpdates = 0, now = new Date (), jsontext = "";"/>
<outline text="if (jstruct !== undefined) { //10/7/16 by DW">
<outline text="jsontext = utils.jsonStringify (jstruct);"/>
<outline text="}"/>
</outline>
<outline text="for (var i = 0; i < theWsServer.connections.length; i++) {">
<outline text="var conn = theWsServer.connections [i];"/>
<outline text="if (conn.pageParkData !== undefined) { //it's one of ours">
<outline text="try {">
<outline text="conn.sendText (verb + "\r" + jsontext);"/>
<outline text="conn.pageParkData.whenLastUpdate = now;"/>
<outline text="conn.pageParkData.ctUpdates++;"/>
<outline text="ctUpdates++;"/>
<outline text="}"/>
</outline>
<outline text="catch (err) {">
<outline text="console.log ("notifySocketSubscribers: socket #" + i + ": error updating");"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="if (ctUpdates > 0) {" isComment="true">
<outline text="console.log ("notifySocketSubscribers: " + ctUpdates + " sockets were updated.");"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function webSocketStartup () {">
<outline text="if (pageparkPrefs.flWebsocketEnabled) {">
<outline text="try {">
<outline text="theWsServer = websocket.createServer (function (conn) {">
<outline text="conn.pageParkData = {">
<outline text="whenLastUpdate: new Date (0),"/>
<outline text="ctUpdates: 0"/>
<outline text="};"/>
</outline>
<outline text="});"/>
</outline>
<outline text="theWsServer.listen (pageparkPrefs.websocketPort);"/>
<outline text="}"/>
</outline>
<outline text="catch (err) {">
<outline text="console.log ("webSocketStartup: err.message == " + err.message);"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
</outline>
<outline text=""/>
<outline text="function httpReadUrl (url, callback) {" created="Mon, 20 Jan 2014 17:26:34 GMT" pgfnum="36035">
<outline text="request (url, function (error, response, body) {">
<outline text="if (!error && (response.statusCode == 200)) {">
<outline text="callback (body) "/>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}" created="Mon, 20 Jan 2014 17:26:49 GMT" pgfnum="36038"/>
</outline>
<outline text="function getFullFilePath (relpath) { //1/3/15 by DW">
<outline text="var folderpath = folderPathFromEnv;"/>
<outline text="if (folderpath == undefined) { //the environment variable wasn't specified">
<outline text="return (relpath);"/>
<outline text="}"/>
</outline>
<outline text="if (!utils.endsWith (folderpath, "/")) {">
<outline text="folderpath += "/";"/>
<outline text="}"/>
</outline>
<outline text="if (utils.beginsWith (relpath, "/")) {">
<outline text="relpath = utils.stringDelete (relpath, 1, 1);"/>
<outline text="}"/>
</outline>
<outline text="return (folderpath + relpath);"/>
<outline text="}"/>
</outline>
<outline text="function getTemplate (myTemplatePath, urlDefaultTemplate, callback) {">
<outline text="Changes" isComment="true">
<outline text="6/17/17; 11:09:48 AM by DW">
<outline text="Support new pageParkPrefs.flCacheTemplatesLocally pref."/>
</outline>
<outline text="12/25/14; 1:32:03 PM by DW">
<outline text="Get the template text. ">
<outline text="Try to read the file, if it's not there, read the default over the web, save it to the file. "/>
</outline>
</outline>
</outline>
<outline text="if (pageparkPrefs.flCacheTemplatesLocally) {">
<outline text="var f = getFullFilePath (myTemplatePath);"/>
<outline text="fs.readFile (f, function (err, data) {">
<outline text="if (err) {">
<outline text="console.log ("getTemplate: error reading the file " + err.message);" isComment="true"/>
<outline text="httpReadUrl (urlDefaultTemplate, function (s) {">
<outline text="fs.writeFile (myTemplatePath, s, function (err) {">
<outline text="if (callback != undefined) {">
<outline text="callback (s);"/>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="if (callback != undefined) {">
<outline text="callback (data.toString ());"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="httpReadUrl (urlDefaultTemplate, function (s) {">
<outline text="if (callback != undefined) {">
<outline text="callback (s);"/>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function getMarkdownTitle (mdtext) { //12/31/19 by DW">
<outline text="Changes" isComment="true">
<outline text="12/31/19; 11:12:26 AM by DW">
<outline text="Look in the first 5 lines in the file for a line that begins with "# ". Assume that's the title of the page."/>
</outline>
</outline>
<outline text="var linenum = 1;"/>
<outline text="for (var i = 1; i <= 5; i++) {">
<outline text="var s = utils.trimWhitespace (utils.stringNthField (mdtext, "\n", i));"/>
<outline text="if (utils.beginsWith (s, "# ")) {">
<outline text="return (utils.stringDelete (s, 1, 2));"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="if (utils.beginsWith (mdtext, "# ")) {" isComment="true">
<outline text="title = utils.stringNthField (mdtext, "\n", 1);"/>
<outline text="title = utils.stringDelete (title, 1, 2);"/>
<outline text="title = utils.trimWhitespace (title);"/>
<outline text="}"/>
</outline>
<outline text="return (undefined);"/>
<outline text="}"/>
</outline>
<outline text="function handleHttpRequest (httpRequest, httpResponse) {">
<outline text="var config; "/>
<outline text="var now = new Date ();"/>
<outline text="var logInfo = { //2/17/18 by DW">
<outline text="when: now"/>
<outline text="};"/>
</outline>
<outline text=""/>
<outline text="function getDiskSpace (callback) { //12/20/19 by DW">
<outline text="var stats = new Object (); "/>
<outline text="freeDiskSpace.get (stats, function () {">
<outline text="stats.productName = myProductName;"/>
<outline text="stats.version = myVersion;"/>
<outline text="callback (undefined, stats);"/>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function getOpmlTemplate (callback) { //6/23/15 by DW">
<outline text="Changes" isComment="true" created="Tue, 17 Aug 2021 20:54:56 GMT">
<outline text="8/19/21; 8:55:10 AM by DW" created="Thu, 19 Aug 2021 12:55:09 GMT">
<outline text="Changed pageparkPrefs.urlDefaultOpmlTemplate to config.urlDefaultOpmlTemplate. This explains why we couldn't set the template from config.json for outlines and could set it for markdown docs. " created="Thu, 19 Aug 2021 12:55:10 GMT"/>
</outline>
<outline text="8/17/21; 4:55:08 PM by DW" created="Tue, 17 Aug 2021 20:55:07 GMT">
<outline text="If config.urlOpmlTemplate is specified, we must use that. It's coming from the website's config.json file. " created="Tue, 17 Aug 2021 20:55:08 GMT"/>
</outline>
</outline>
<outline text="if (config.urlOpmlTemplate !== undefined) { //8/17/21 by DW" created="Tue, 17 Aug 2021 20:54:56 GMT">
<outline text="getTemplate (undefined, config.urlOpmlTemplate, callback);"/>
<outline text="}" created="Tue, 17 Aug 2021 20:56:07 GMT"/>
</outline>
<outline text="else {" created="Tue, 17 Aug 2021 20:56:08 GMT">
<outline text="if (config.opmlTemplatePath !== undefined) {">
<outline text="fs.readFile (config.opmlTemplatePath, function (err, data) {">
<outline text="if (err) {">
<outline text="getTemplate (opmlTemplatePath, config.urlDefaultOpmlTemplate, callback);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="callback (data.toString ());"/>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="getTemplate (opmlTemplatePath, pageparkPrefs.urlDefaultOpmlTemplate, callback);"/>
<outline text="}"/>
</outline>
<outline text="}" created="Tue, 17 Aug 2021 20:56:10 GMT"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function getMarkdownTemplate (callback) {">
<outline text="Changes" isComment="true" created="Tue, 17 Aug 2021 20:54:56 GMT">
<outline text="8/17/21; 5:02:08 PM by DW" created="Tue, 17 Aug 2021 20:55:07 GMT">
<outline text="If config.urlMarkdownTemplate is specified, we must use that. It's coming from the website's config.json file. " created="Tue, 17 Aug 2021 20:55:08 GMT"/>
</outline>
</outline>
<outline text="if (config.urlMarkdownTemplate !== undefined) { //8/17/21 by DW" created="Tue, 17 Aug 2021 21:02:34 GMT">
<outline text="getTemplate (undefined, config.urlMarkdownTemplate, callback);"/>
<outline text="}" created="Tue, 17 Aug 2021 21:02:42 GMT"/>
</outline>
<outline text="else {" created="Tue, 17 Aug 2021 21:02:42 GMT">
<outline text="if (config.mdTemplatePath !== undefined) {">
<outline text="fs.readFile (config.mdTemplatePath, function (err, data) {">
<outline text="if (err) {">
<outline text="getTemplate (mdTemplatePath, config.urlDefaultMarkdownTemplate, callback);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="callback (data.toString ());"/>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="getTemplate (mdTemplatePath, config.urlDefaultMarkdownTemplate, callback);"/>
<outline text="}"/>
</outline>
<outline text="}" created="Tue, 17 Aug 2021 21:02:44 GMT"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function hasAcceptHeader (theHeader) {">
<outline text="Changes" isComment="true">
<outline text="6/24/15; 1:16:10 PM by DW">
<outline text="header string looks like this: text/x-opml, */*" isComment="true"/>
</outline>
</outline>
<outline text="if (httpRequest.headers.accept === undefined) {">
<outline text="return (false);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="var split = httpRequest.headers.accept.split (", ");"/>
<outline text="for (var i = 0; i < split.length; i++) {">
<outline text="if (split [i] == theHeader) {">
<outline text="return (true);"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="return (false);"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function getDomainFolder (host, callback) { //5/11/15 by DW">
<outline text="Changes" isComment="true">
<outline text="7/5/21; 10:26:02 AM by DW" created="Mon, 05 Jul 2021 14:26:02 GMT">
<outline text="If wildcard folder doesn't exist, try using the default folder (assuming it exists)." created="Mon, 05 Jul 2021 14:26:03 GMT"/>
<outline text="Note that it's ok to send back a folder that doesn't exist, the caller is set up to handle that." created="Mon, 05 Jul 2021 14:34:25 GMT"/>
</outline>
<outline text="5/10/15; 6:33:28 PM by DW">
<outline text="We check if the folder exists for this domain. If not we look for a wildcard folder for this domain.">
<outline text="Example, looking for one.hello.com, if it doesn't exist, then return *.hello.com.">
<outline text="If it doesn't exist, the request will fail."/>
</outline>
</outline>
</outline>
</outline>
<outline text="var folder = getFullFilePath (domainsPath);"/>
<outline text="var domainfolder = folder + host;"/>
<outline text="fs.exists (domainfolder, function (flExists) {">
<outline text="function useDefaultFolder () {" created="Mon, 05 Jul 2021 14:40:00 GMT">
<outline text="var name = pageparkPrefs.defaultDomanFolderName;" created="Mon, 05 Jul 2021 14:45:51 GMT"/>
<outline text="callback (folder + name, name);"/>
<outline text="}" created="Mon, 05 Jul 2021 14:40:07 GMT"/>
</outline>
<outline text="if (flExists) {">
<outline text="console.log ("getDomainFolder: looking in normal folder == " + domainfolder);" isComment="true"/>
<outline text="callback (domainfolder, host);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="if (utils.stringCountFields (host, ".") == 3) {">
<outline text="var firstpart = utils.stringNthField (host, ".", 1);"/>
<outline text="var wildcardhost = "*" + utils.stringDelete (host, 1, firstpart.length);"/>
<outline text="domainfolder = folder + wildcardhost;"/>
<outline text="console.log ("getDomainFolder: looking in wildcard folder == " + domainfolder + ", wildcardhost == " + wildcardhost);" isComment="true"/>
<outline text="fs.exists (domainfolder, function (flExists) { //7/5/21 by DW" created="Mon, 05 Jul 2021 14:26:32 GMT">
<outline text="if (flExists) {" created="Mon, 05 Jul 2021 14:27:01 GMT">
<outline text="callback (domainfolder, wildcardhost);"/>
<outline text="}" created="Mon, 05 Jul 2021 14:27:02 GMT"/>
</outline>
<outline text="else {" created="Mon, 05 Jul 2021 14:27:03 GMT">
<outline text="useDefaultFolder ();" created="Mon, 05 Jul 2021 14:40:15 GMT"/>
<outline text="}" created="Mon, 05 Jul 2021 14:27:05 GMT"/>
</outline>
<outline text="});" created="Mon, 05 Jul 2021 14:26:43 GMT"/>
</outline>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="useDefaultFolder ();" created="Mon, 05 Jul 2021 14:40:36 GMT"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function getDomainFolder (host, callback) { //5/11/15 by DW" isComment="true">
<outline text="Changes" isComment="true">
<outline text="5/10/15; 6:33:28 PM by DW">
<outline text="We check if the folder exists for this domain. If not we look for a wildcard folder for this domain.">
<outline text="Example, looking for one.hello.com, if it doesn't exist, then return *.hello.com.">
<outline text="If it doesn't exist, the request will fail."/>
</outline>
</outline>
</outline>
</outline>
<outline text="var folder = getFullFilePath (domainsPath);"/>
<outline text="var domainfolder = folder + host;"/>
<outline text="fs.exists (domainfolder, function (flExists) {">
<outline text="if (flExists) {">
<outline text="console.log ("getDomainFolder: looking in normal folder == " + domainfolder);" isComment="true"/>
<outline text="callback (domainfolder, host);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="if (utils.stringCountFields (host, ".") == 3) {">
<outline text="var firstpart = utils.stringNthField (host, ".", 1);"/>
<outline text="var wildcardhost = "*" + utils.stringDelete (host, 1, firstpart.length);"/>
<outline text="domainfolder = folder + wildcardhost;"/>
<outline text="console.log ("getDomainFolder: looking in wildcard folder == " + domainfolder + ", wildcardhost == " + wildcardhost);" isComment="true"/>
<outline text="callback (domainfolder, wildcardhost);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="callback (domainfolder, host);"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function getConfigFile (host, callback) { ">
<outline text="Changes" isComment="true">
<outline text="12/10/19; 2:52:36 PM by DW">
<outline text="Copy everything in pageparkPrefs into config before reading the config.json file. "/>
<outline text="We were able to comment out everything that's now copied. "/>
</outline>
</outline>
<outline text="var config = {">
<outline text="urlSiteRedirect: undefined,"/>
<outline text="urlSiteContents: undefined,"/>
<outline text="fargoS3Path: undefined,"/>
<outline text="s3Path: undefined,"/>
<outline text="s3ServeFromPath: undefined,"/>
<outline text="githubServeFrom: undefined,"/>
<outline text="localPath: undefined"/>
<outline text="flProcessScriptFiles: false, //12/4/19 by DW -- breaking change" isComment="true"/>
<outline text="flProcessMarkdownFiles: true," isComment="true"/>
<outline text="flProcessOpmlFiles: true," isComment="true"/>
<outline text="extScriptFiles: pageparkPrefs.extScriptFiles," isComment="true"/>
<outline text="extMarkdownFiles: pageparkPrefs.extMarkdownFiles," isComment="true"/>
<outline text="extOpmlFiles: pageparkPrefs.extOpmlFiles" isComment="true"/>
<outline text="};"/>
</outline>
<outline text="for (var x in pageparkPrefs) { //12/10/19 by DW">
<outline text="config [x] = pageparkPrefs [x];"/>
<outline text="}"/>
</outline>
<outline text="var f = getFullFilePath (domainsPath) + host + configFname;"/>
<outline text="fs.readFile (f, function (err, data) {">
<outline text="if (err) {">
<outline text="callback (config);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="try {">
<outline text="var jstruct = JSON.parse (data.toString ());" created="Tue, 11 Jun 2013 13:43:44 GMT" pgfnum="25734"/>
<outline text="for (var x in jstruct) {">
<outline text="config [x] = jstruct [x];"/>
<outline text="}"/>
</outline>
<outline text="callback (config);"/>
<outline text="}"/>
</outline>
<outline text="catch (err) {">
<outline text="console.log ("getConfigFile: error reading " + configFname + " file for host " + host + ". " + err.message);"/>
<outline text="callback (config);"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="" isComment="true"/>
<outline text="function runFilterScript (host, callback) { //3/23/20 by DW">
<outline text="Changes" isComment="true" created="Mon, 21 Jun 2021 15:52:00 GMT">
<outline text="6/21/21; 11:52:03 AM by DW" created="Mon, 21 Jun 2021 15:52:01 GMT">
<outline text="Add httpResponse to the options object. Otherwise how is the plug-in supposed to return a response?" created="Mon, 21 Jun 2021 15:52:03 GMT"/>
</outline>
</outline>
<outline text="var f = getFullFilePath (domainsPath) + host + filterFname;"/>
<outline text="fs.readFile (f, function (err, data) {">
<outline text="if (err) {">
<outline text="callback (false); //file doesn't exist -- we didn't run the filter script"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="const options = {">
<outline text="httpRequest,"/>
<outline text="httpResponse, //6/21/21 by DW" created="Mon, 21 Jun 2021 15:52:32 GMT"/>
<outline text="serveLocalFile: function (f) {">
<outline text="console.log ("serveLocalFile (" + f + ")");"/>
<outline text="serveFile (f, config);"/>
<outline text="}"/>
</outline>
<outline text="};"/>
</outline>
<outline text="try {">
<outline text="thePackage.runJavaScriptCode (f, options, callback);"/>
<outline text="runTheFilter (f, data, options, callback);" isComment="true"/>
<outline text="}"/>
</outline>
<outline text="catch (err) {">
<outline text="httpRespond (500, "text/plain", err.message);"/>
<outline text="}"/>
</outline>
<outline text="callback (true); //we handled it"/>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="" isComment="true"/>
<outline text="function runTheFilter (f, scripttext, options) {" isComment="true">
<outline text="const system = {">
<outline text="};"/>
</outline>
<outline text="const localStorage = {">
<outline text="};"/>
</outline>
<outline text="var leftcode = "module.exports = function (options, localStorage, system) {", rightcode = "}";"/>
<outline text="var code = leftcode + scripttext.toString () + rightcode;"/>
<outline text="requireFromString (code) (options, localStorage, system);"/>
<outline text="}"/>
</outline>
<outline text="function runFilterScript (host, callback) { //3/23/20 by DW" isComment="true">
<outline text="var f = getFullFilePath (domainsPath) + host + filterFname;"/>
<outline text="fs.readFile (f, function (err, data) {">
<outline text="if (err) {">
<outline text="callback (false); //file doesn't exist -- we didn't run the filter script"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="try {">
<outline text="const options = {">
<outline text="httpRequest,"/>
<outline text="serveLocalFile: function (f) {">
<outline text="console.log ("serveLocalFile (" + f + ")");" isComment="true"/>
<outline text="serveFile (f, config);"/>
<outline text="}"/>
</outline>
<outline text="};"/>
</outline>
<outline text="const filterfile = __dirname + "/" + f;"/>
<outline text="if (require.cache [filterfile] !== undefined) {">
<outline text="delete require.cache [filterfile];"/>
<outline text="}"/>
</outline>
<outline text="require (filterfile).filter (options, function (err, httpResponse) {">
<outline text="if (err) {">
<outline text="httpRespond (500, "text/plain", err.message);"/>
<outline text="callback (true); //we handled it"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="if (httpResponse.flNotHandled) { //the plugin doesn't want this, let other functions in pagePark have a try">
<outline text="callback (false);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="httpRespond (httpResponse.code, httpResponse.type, httpResponse.val);"/>
<outline text="callback (true); //we handled it"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="catch (err) {">
<outline text="httpRespond (500, "text/plain", err.message);"/>
<outline text="callback (true); //we handled it"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function httpRespond (code, type, val, headers) {">
<outline text="Changes" isComment="true">
<outline text="7/20/18; 1:19:08 PM by DW">
<outline text="We're getting an error in the server that sometimes type is undefined, and that's something the system can't recover from, so we now look for that. "/>
</outline>
</outline>
<outline text="if (headers === undefined) {">
<outline text="headers = new Object ();"/>
<outline text="}"/>
</outline>
<outline text="if (type === undefined) { //7/20/18 by DW">
<outline text="type = "text/plain";"/>
<outline text="}"/>
</outline>
<outline text="headers ["Content-Type"] = type;"/>
<outline text="httpResponse.writeHead (code, headers);"/>
<outline text="httpResponse.end (val); "/>
<outline text="logInfo.ctSecs = utils.secondsSince (logInfo.when);"/>
<outline text="logInfo.size = val.length;"/>
<outline text="logInfo.code = code;"/>
<outline text="logInfo.type = type;"/>
<outline text=""/>
<outline text="logInfo.serverStats = {">
<outline text="pageParkVersion: myVersion,"/>
<outline text="whenStart: pageparkStats.whenLastStart,"/>
<outline text="ctHits: pageparkStats.ctHits,"/>
<outline text="ctHitsToday: pageparkStats.ctHitsToday,"/>
<outline text="ctHitsSinceStart: pageparkStats.ctHitsSinceStart"/>
<outline text="};"/>
</outline>
<outline text=""/>
<outline text="notifySocketSubscribers ("log", logInfo);"/>
<outline text="}"/>
</outline>
<outline text="function return404 () {">
<outline text="getTemplate (config.error404File, config.urlDefaultErrorPage, function (htmtext) {">
<outline text="httpResponse.writeHead (404, {"Content-Type": "text/html"});" isComment="true"/>
<outline text="httpResponse.end (htmtext); " isComment="true"/>
<outline text="httpRespond (404, "text/html", htmtext);"/>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function returnRedirect (urlRedirectTo, flPermanent) { //7/30/15 by DW">
<outline text="var code = (flPermanent) ? 301 : 302;"/>
<outline text="httpRespond (code, "text/plain", "Redirect to " + urlRedirectTo + ".", {"Location": urlRedirectTo})"/>
<outline text="" isComment="true"/>
<outline text="httpResponse.writeHead (code, {"Location": urlRedirectTo, "Content-Type": "text/plain"});" isComment="true"/>
<outline text="httpResponse.end ("Redirect to " + urlRedirectTo + "."); " isComment="true"/>
<outline text="}"/>
</outline>
<outline text="function isSpecificFile (fname, specificFname) {">
<outline text="if (utils.stringCountFields (fname, ".") == 2) { //something like xxx.yyy">
<outline text="if (utils.stringNthField (fname, ".", 1).toLowerCase () == specificFname) { //something like index.wtf">
<outline text="return (true);"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="return (false);"/>
<outline text="}"/>
</outline>
<outline text="function findSpecificFile (folder, specificFname, callback) {">
<outline text="Changes" isComment="true">
<outline text="7/16/15; 8:02:22 AM by DW">
<outline text="Factored from findIndexFile. Made more general so we can use it to find error files too."/>
</outline>
</outline>
<outline text="specificFname = specificFname.toLowerCase (); //7/16/15 by DW"/>
<outline text="fs.readdir (folder, function (err, list) {">
<outline text="for (var i = 0; i < list.length; i++) {">
<outline text="var fname = list [i];"/>
<outline text="if (isSpecificFile (fname, specificFname)) {">
<outline text="callback (folder + fname);"/>
<outline text="return;"/>
<outline text="}"/>
</outline>
<outline text="if (utils.stringCountFields (fname, ".") == 2) { //something like xxx.yyy" isComment="true">
<outline text="if (utils.stringNthField (fname, ".", 1).toLowerCase () == specificFname) { //something like index.wtf">
<outline text="callback (folder + fname);"/>
<outline text="return;"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="return404 ();"/>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function processResponse (path, data, config, callback) { //9/26/17 by DW">
<outline text="Changes" isComment="true" created="Wed, 25 Aug 2021 20:42:10 GMT">
<outline text="8/25/21; 4:42:13 PM by DW" created="Wed, 25 Aug 2021 20:42:12 GMT">
<outline text="Allow the config.json file for the domain to set urlGlossary for outline files that do not already specify it. " created="Wed, 25 Aug 2021 20:42:14 GMT"/>
</outline>
</outline>
<outline text="var formatParam; //url ends with ?format=abc -- 6/24/15 by DW"/>
<outline text="if (parsedUrl.query.format !== undefined) {">
<outline text="formatParam = parsedUrl.query.format.toLowerCase ()"/>
<outline text="}"/>
</outline>
<outline text="function getFileExtension (path) { //7/25/21 by DW">
<outline text="var fname = utils.stringLastField (path, "/");"/>
<outline text="var ext = utils.stringLastField (fname, ".");"/>
<outline text="if (ext == fname) { //has no extension">
<outline text="ext = config.defaultExtension;"/>
<outline text="if (utils.beginsWith (ext, ".")) {" created="Sun, 25 Jul 2021 21:38:39 GMT">
<outline text="ext = utils.stringDelete (ext, 1, 1);" created="Sun, 25 Jul 2021 21:38:55 GMT"/>
<outline text="}" created="Sun, 25 Jul 2021 21:38:51 GMT"/>
</outline>
<outline text="}"/>
</outline>
<outline text="return (ext.toLowerCase ());"/>
<outline text="}"/>
</outline>
<outline text="function getReturnType (path) { //7/6/18 by DW">
<outline text="var fname = utils.stringLastField (path, "/");"/>
<outline text="var ext = utils.stringLastField (fname, ".");"/>
<outline text="if (ext == fname) { //has no extension">
<outline text="return (config.defaultType);"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="return (utils.httpExt2MIME (ext));"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function httpReturn (val, type) { //2/17/15 by DW">
<outline text="callback (200, type, val.toString ());"/>
<outline text="httpResponse.writeHead (200, {"Content-Type": type});" isComment="true"/>
<outline text="httpResponse.end (val.toString ()); " isComment="true"/>
<outline text="}"/>
</outline>
<outline text="function defaultReturn (type, data) { ">
<outline text="callback (200, type, data);"/>
<outline text="" isComment="true"/>
<outline text="" isComment="true"/>
<outline text="httpResponse.writeHead (200, {"Content-Type": type});" isComment="true"/>
<outline text="httpResponse.end (data); " isComment="true"/>
<outline text="}"/>
</outline>
<outline text="function checkForRedirect () { //6/6/18 by DW">
<outline text="if (ext != "json") {">
<outline text="var jsontext = data.toString ();"/>
<outline text="if (jsontext.length > 0) {">
<outline text="if (jsontext [0] == "{") {">
<outline text="try {">
<outline text="var jstruct = JSON.parse (jsontext);"/>
<outline text="var pstruct = jstruct ["#pagePark"];"/>
<outline text="if (pstruct !== undefined) {">
<outline text="if (pstruct.urlRedirect !== undefined) {">
<outline text="returnRedirect (pstruct.urlRedirect);"/>
<outline text="return (false); //we got it, don't continue processing the file"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="catch (err) {">
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="return (true); //it wasn't a redirect, continue processing"/>
<outline text="}"/>
</outline>
<outline text="var ext = getFileExtension (path);"/>
<outline text="var ext = utils.stringLastField (path, ".").toLowerCase ();" isComment="true"/>
<outline text="var type = getReturnType (path); //12/4/19 by DW -- it was passing ext which was not what the routine calls for"/>
<outline text="var type = utils.httpExt2MIME (ext);" isComment="true"/>
<outline text="console.log ("handleHttpRequest: f == " + f + ", type == " + type);" isComment="true"/>
<outline text="if (checkForRedirect ()) { //it wasn't a redirect file">
<outline text="switch (ext) {">
<outline text="case config.extScriptFiles:">
<outline text="if (config.flProcessScriptFiles) {">
<outline text="console.log ("processResponse: path == " + path); //8/25/19 by DW"/>
<outline text="console.log ("processResponse: data == " + data); //8/25/19 by DW" isComment="true"/>
<outline text="try {">
<outline text="var val = eval (data.toString ());" created="Thu, 23 Jan 2014 16:59:39 GMT" pgfnum="36438"/>
<outline text="if (val !== undefined) { //2/17/15 by DW">
<outline text="httpReturn (val.toString (), "text/html");"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="catch (err) {">
<outline text="callback (500, "text/plain", "Error running " + parsedUrl.pathname + ": \"" + err.message + "\"");"/>
<outline text="httpResponse.writeHead (500, {"Content-Type": "text/plain"});" isComment="true"/>
<outline text="httpResponse.end ("Error running " + parsedUrl.pathname + ": \"" + err.message + "\"");" isComment="true"/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="defaultReturn (type, data);"/>
<outline text="}"/>
</outline>
<outline text="break;"/>
</outline>
<outline text="case config.extMarkdownFiles:">
<outline text="if (config.flProcessMarkdownFiles) {">
<outline text="console.log ("processResponse: config == " + utils.jsonStringify (config));" isComment="true"/>
<outline text="getMarkdownTemplate (function (theTemplate) {">
<outline text="var mdtext = data.toString (), pagetable = new Object ();"/>
<outline text="pagetable.title = getMarkdownTitle (mdtext); //12/31/19 by DW"/>
<outline text="if (pagetable.title === undefined) {">
<outline text="pagetable.title = utils.stringLastField (path, "/");"/>
<outline text="}"/>
</outline>
<outline text="pagetable.bodytext = marked (mdtext);"/>
<outline text="pagetable.config = (config.pageParams === undefined) ? new Object () : utils.jsonStringify (config.pageParams); //12/12/19 by DW"/>
<outline text="var s = utils.multipleReplaceAll (theTemplate, pagetable, false, "[%", "%]");"/>
<outline text="callback (200, "text/html", s);"/>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="defaultReturn (type, data);"/>
<outline text="}"/>
</outline>
<outline text="break;"/>
</outline>
<outline text="case config.extOpmlFiles: //6/23/15 by DW">
<outline text="var flReturnHtml = (!hasAcceptHeader ("text/x-opml")) && (formatParam != "opml");"/>
<outline text="if (config.flProcessOpmlFiles && flReturnHtml) { //6/24/15 by DW">
<outline text="try { //4/18/20 by DW -- XML errors should not crash the server">
<outline text="getOpmlTemplate (function (theTemplate) {">
<outline text="var opmltext = data.toString (), pagetable = new Object ();"/>
<outline text="opmlToJs.parseWithError (opmltext, function (err, theOutline) {">
<outline text="if (err) {">
<outline text="callback (500, "text/plain", "There was an error processing the OPML file."); "/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="if (config.urlGlossary !== undefined) { //8/25/21 by DW" created="Wed, 25 Aug 2021 20:40:56 GMT">
<outline text="if (theOutline.opml.head.urlGlossary === undefined) {" created="Wed, 25 Aug 2021 20:41:12 GMT">
<outline text="theOutline.opml.head.urlGlossary = config.urlGlossary;" created="Wed, 25 Aug 2021 20:41:37 GMT"/>
<outline text="}" created="Wed, 25 Aug 2021 20:41:31 GMT"/>
</outline>
<outline text="}" created="Wed, 25 Aug 2021 20:41:06 GMT"/>
</outline>
<outline text="var pagetable = {">
<outline text="bodytext: utils.jsonStringify (theOutline),"/>
<outline text="title: utils.stringLastField (path, "/"),"/>
<outline text="description: "","/>
<outline text="image: "","/>
<outline text="sitename: "","/>
<outline text="url: "http://" + httpRequest.headers.host + httpRequest.url"/>
<outline text="};"/>
</outline>
<outline text="utils.copyScalars (theOutline.opml.head, pagetable);"/>
<outline text="var htmltext = utils.multipleReplaceAll (theTemplate, pagetable, false, "[%", "%]");"/>
<outline text="httpReturn (htmltext, "text/html");"/>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="catch (err) {">
<outline text="callback (500, "text/plain", err.message); "/>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="defaultReturn ("text/xml", data);"/>
<outline text="}"/>
</outline>
<outline text="break;"/>
</outline>
<outline text="default:">
<outline text="defaultReturn (type, data);"/>
<outline text="break;"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function serveFile (f, config) {">
<outline text="fs.readFile (f, function (err, data) {">
<outline text="if (err) {">
<outline text="return404 ();"/>
<outline text="}"/>
</outline>
<outline text="else {">
<outline text="processResponse (f, data, config, function (code, type, text) {">
<outline text="httpRespond (code, type, text);"/>
<outline text="" isComment="true"/>
<outline text="httpResponse.writeHead (code, {"Content-Type": type});" isComment="true"/>
<outline text="httpResponse.end (text); " isComment="true"/>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="});"/>
</outline>
<outline text="}"/>
</outline>
<outline text="function serveFromS3 (config, parsedUrl) { //serve using S3's HTTP server">
<outline text="var s3url = "http:/" + config.s3Path + parsedUrl.pathname; "/>
<outline text="if (utils.endsWith (s3path, "/")) {" isComment="true">
<outline text="s3path += "index.html";"/>
<outline text="}"/>
</outline>
<outline text="console.log ("\nServing from S3 == " + s3url + "\n");"/>
<outline text="request (s3url, function (error, response, body) {">
<outline text="if (error) {">
<outline text="httpRespond (500, "text/plain", "Error accessing S3 data: " + error.message);"/>