neon_arch commited on
Commit
137c62e
β€’
1 Parent(s): fe8f5de

replace commandline arguments with config.lua & add support for changing themes & coloschemes

Browse files
Cargo.lock CHANGED
@@ -15,7 +15,7 @@ dependencies = [
15
  "log",
16
  "memchr",
17
  "pin-project-lite",
18
- "tokio 1.27.0",
19
  "tokio-util",
20
  ]
21
 
@@ -75,7 +75,7 @@ dependencies = [
75
  "rand 0.8.5",
76
  "sha1",
77
  "smallvec 1.10.0",
78
- "tokio 1.27.0",
79
  "tokio-util",
80
  "tracing",
81
  "zstd",
@@ -111,7 +111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
111
  checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e"
112
  dependencies = [
113
  "futures-core",
114
- "tokio 1.27.0",
115
  ]
116
 
117
  [[package]]
@@ -128,7 +128,7 @@ dependencies = [
128
  "mio 0.8.6",
129
  "num_cpus",
130
  "socket2",
131
- "tokio 1.27.0",
132
  "tracing",
133
  ]
134
 
@@ -268,55 +268,6 @@ dependencies = [
268
  "alloc-no-stdlib",
269
  ]
270
 
271
- [[package]]
272
- name = "anstream"
273
- version = "0.3.0"
274
- source = "registry+https://github.com/rust-lang/crates.io-index"
275
- checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371"
276
- dependencies = [
277
- "anstyle",
278
- "anstyle-parse",
279
- "anstyle-query",
280
- "anstyle-wincon",
281
- "colorchoice",
282
- "is-terminal",
283
- "utf8parse",
284
- ]
285
-
286
- [[package]]
287
- name = "anstyle"
288
- version = "1.0.0"
289
- source = "registry+https://github.com/rust-lang/crates.io-index"
290
- checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
291
-
292
- [[package]]
293
- name = "anstyle-parse"
294
- version = "0.2.0"
295
- source = "registry+https://github.com/rust-lang/crates.io-index"
296
- checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee"
297
- dependencies = [
298
- "utf8parse",
299
- ]
300
-
301
- [[package]]
302
- name = "anstyle-query"
303
- version = "1.0.0"
304
- source = "registry+https://github.com/rust-lang/crates.io-index"
305
- checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
306
- dependencies = [
307
- "windows-sys 0.48.0",
308
- ]
309
-
310
- [[package]]
311
- name = "anstyle-wincon"
312
- version = "1.0.0"
313
- source = "registry+https://github.com/rust-lang/crates.io-index"
314
- checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd"
315
- dependencies = [
316
- "anstyle",
317
- "windows-sys 0.48.0",
318
- ]
319
-
320
  [[package]]
321
  name = "askama_escape"
322
  version = "0.10.3"
@@ -348,7 +299,7 @@ dependencies = [
348
  "cc",
349
  "cfg-if 1.0.0",
350
  "libc",
351
- "miniz_oxide",
352
  "object",
353
  "rustc-demangle",
354
  ]
@@ -419,6 +370,15 @@ dependencies = [
419
  "alloc-stdlib",
420
  ]
421
 
 
 
 
 
 
 
 
 
 
422
  [[package]]
423
  name = "bumpalo"
424
  version = "3.12.1"
@@ -478,48 +438,6 @@ version = "1.0.0"
478
  source = "registry+https://github.com/rust-lang/crates.io-index"
479
  checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
480
 
481
- [[package]]
482
- name = "clap"
483
- version = "4.2.4"
484
- source = "registry+https://github.com/rust-lang/crates.io-index"
485
- checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62"
486
- dependencies = [
487
- "clap_builder",
488
- "clap_derive",
489
- "once_cell",
490
- ]
491
-
492
- [[package]]
493
- name = "clap_builder"
494
- version = "4.2.4"
495
- source = "registry+https://github.com/rust-lang/crates.io-index"
496
- checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749"
497
- dependencies = [
498
- "anstream",
499
- "anstyle",
500
- "bitflags",
501
- "clap_lex",
502
- "strsim",
503
- ]
504
-
505
- [[package]]
506
- name = "clap_derive"
507
- version = "4.2.0"
508
- source = "registry+https://github.com/rust-lang/crates.io-index"
509
- checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4"
510
- dependencies = [
511
- "heck",
512
- "proc-macro2 1.0.56",
513
- "quote 1.0.26",
514
- "syn 2.0.15",
515
- ]
516
-
517
- [[package]]
518
- name = "clap_lex"
519
- version = "0.4.1"
520
- source = "registry+https://github.com/rust-lang/crates.io-index"
521
- checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1"
522
-
523
  [[package]]
524
  name = "cloudabi"
525
  version = "0.0.3"
@@ -529,12 +447,6 @@ dependencies = [
529
  "bitflags",
530
  ]
531
 
532
- [[package]]
533
- name = "colorchoice"
534
- version = "1.0.0"
535
- source = "registry+https://github.com/rust-lang/crates.io-index"
536
- checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
537
-
538
  [[package]]
539
  name = "convert_case"
540
  version = "0.4.0"
@@ -836,12 +748,12 @@ dependencies = [
836
 
837
  [[package]]
838
  name = "flate2"
839
- version = "1.0.25"
840
  source = "registry+https://github.com/rust-lang/crates.io-index"
841
- checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
842
  dependencies = [
843
  "crc32fast",
844
- "miniz_oxide",
845
  ]
846
 
847
  [[package]]
@@ -1049,7 +961,7 @@ dependencies = [
1049
  "http 0.2.9",
1050
  "indexmap",
1051
  "slab",
1052
- "tokio 1.27.0",
1053
  "tokio-util",
1054
  "tracing",
1055
  ]
@@ -1075,12 +987,6 @@ version = "0.12.3"
1075
  source = "registry+https://github.com/rust-lang/crates.io-index"
1076
  checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
1077
 
1078
- [[package]]
1079
- name = "heck"
1080
- version = "0.4.1"
1081
- source = "registry+https://github.com/rust-lang/crates.io-index"
1082
- checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
1083
-
1084
  [[package]]
1085
  name = "hermit-abi"
1086
  version = "0.2.6"
@@ -1241,7 +1147,7 @@ dependencies = [
1241
  "itoa 1.0.6",
1242
  "pin-project-lite",
1243
  "socket2",
1244
- "tokio 1.27.0",
1245
  "tower-service",
1246
  "tracing",
1247
  "want 0.3.0",
@@ -1269,7 +1175,7 @@ dependencies = [
1269
  "bytes 1.4.0",
1270
  "hyper 0.14.26",
1271
  "native-tls",
1272
- "tokio 1.27.0",
1273
  "tokio-native-tls",
1274
  ]
1275
 
@@ -1422,9 +1328,9 @@ checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
1422
 
1423
  [[package]]
1424
  name = "linux-raw-sys"
1425
- version = "0.3.3"
1426
  source = "registry+https://github.com/rust-lang/crates.io-index"
1427
- checksum = "9b085a4f2cde5781fc4b1717f2e86c62f5cda49de7ba99a7c2eae02b61c9064c"
1428
 
1429
  [[package]]
1430
  name = "local-channel"
@@ -1561,6 +1467,15 @@ dependencies = [
1561
  "adler",
1562
  ]
1563
 
 
 
 
 
 
 
 
 
 
1564
  [[package]]
1565
  name = "mio"
1566
  version = "0.6.23"
@@ -1645,6 +1560,15 @@ version = "0.1.14"
1645
  source = "registry+https://github.com/rust-lang/crates.io-index"
1646
  checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
1647
 
 
 
 
 
 
 
 
 
 
1648
  [[package]]
1649
  name = "num_cpus"
1650
  version = "1.15.0"
@@ -1672,9 +1596,9 @@ checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
1672
 
1673
  [[package]]
1674
  name = "openssl"
1675
- version = "0.10.51"
1676
  source = "registry+https://github.com/rust-lang/crates.io-index"
1677
- checksum = "97ea2d98598bf9ada7ea6ee8a30fb74f9156b63bbe495d64ec2b87c269d2dda3"
1678
  dependencies = [
1679
  "bitflags",
1680
  "cfg-if 1.0.0",
@@ -1704,9 +1628,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
1704
 
1705
  [[package]]
1706
  name = "openssl-sys"
1707
- version = "0.9.86"
1708
  source = "registry+https://github.com/rust-lang/crates.io-index"
1709
- checksum = "992bac49bdbab4423199c654a5515bd2a6c6a23bf03f2dd3bdb7e5ae6259bc69"
1710
  dependencies = [
1711
  "cc",
1712
  "libc",
@@ -1783,9 +1707,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
1783
 
1784
  [[package]]
1785
  name = "pest"
1786
- version = "2.5.7"
1787
  source = "registry+https://github.com/rust-lang/crates.io-index"
1788
- checksum = "7b1403e8401ad5dedea73c626b99758535b342502f8d1e361f4a2dd952749122"
1789
  dependencies = [
1790
  "thiserror",
1791
  "ucd-trie",
@@ -1793,9 +1717,9 @@ dependencies = [
1793
 
1794
  [[package]]
1795
  name = "pest_derive"
1796
- version = "2.5.7"
1797
  source = "registry+https://github.com/rust-lang/crates.io-index"
1798
- checksum = "be99c4c1d2fc2769b1d00239431d711d08f6efedcecb8b6e30707160aee99c15"
1799
  dependencies = [
1800
  "pest",
1801
  "pest_generator",
@@ -1803,9 +1727,9 @@ dependencies = [
1803
 
1804
  [[package]]
1805
  name = "pest_generator"
1806
- version = "2.5.7"
1807
  source = "registry+https://github.com/rust-lang/crates.io-index"
1808
- checksum = "e56094789873daa36164de2e822b3888c6ae4b4f9da555a1103587658c805b1e"
1809
  dependencies = [
1810
  "pest",
1811
  "pest_meta",
@@ -1816,9 +1740,9 @@ dependencies = [
1816
 
1817
  [[package]]
1818
  name = "pest_meta"
1819
- version = "2.5.7"
1820
  source = "registry+https://github.com/rust-lang/crates.io-index"
1821
- checksum = "6733073c7cff3d8459fda0e42f13a047870242aed8b509fe98000928975f359e"
1822
  dependencies = [
1823
  "once_cell",
1824
  "pest",
@@ -2310,9 +2234,9 @@ dependencies = [
2310
 
2311
  [[package]]
2312
  name = "reqwest"
2313
- version = "0.11.16"
2314
  source = "registry+https://github.com/rust-lang/crates.io-index"
2315
- checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254"
2316
  dependencies = [
2317
  "base64 0.21.0",
2318
  "bytes 1.4.0",
@@ -2335,7 +2259,7 @@ dependencies = [
2335
  "serde",
2336
  "serde_json",
2337
  "serde_urlencoded 0.7.1",
2338
- "tokio 1.27.0",
2339
  "tokio-native-tls",
2340
  "tower-service",
2341
  "url 2.3.1",
@@ -2345,6 +2269,30 @@ dependencies = [
2345
  "winreg 0.10.1",
2346
  ]
2347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2348
  [[package]]
2349
  name = "rustc-demangle"
2350
  version = "0.1.23"
@@ -2371,9 +2319,9 @@ dependencies = [
2371
 
2372
  [[package]]
2373
  name = "rustix"
2374
- version = "0.37.13"
2375
  source = "registry+https://github.com/rust-lang/crates.io-index"
2376
- checksum = "f79bef90eb6d984c72722595b5b1348ab39275a5e5123faca6863bf07d75a4e0"
2377
  dependencies = [
2378
  "bitflags",
2379
  "errno",
@@ -2719,12 +2667,6 @@ version = "0.3.0"
2719
  source = "registry+https://github.com/rust-lang/crates.io-index"
2720
  checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
2721
 
2722
- [[package]]
2723
- name = "strsim"
2724
- version = "0.10.0"
2725
- source = "registry+https://github.com/rust-lang/crates.io-index"
2726
- checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
2727
-
2728
  [[package]]
2729
  name = "syn"
2730
  version = "0.15.44"
@@ -2897,9 +2839,9 @@ dependencies = [
2897
 
2898
  [[package]]
2899
  name = "tokio"
2900
- version = "1.27.0"
2901
  source = "registry+https://github.com/rust-lang/crates.io-index"
2902
- checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
2903
  dependencies = [
2904
  "autocfg 1.1.0",
2905
  "bytes 1.4.0",
@@ -2911,7 +2853,7 @@ dependencies = [
2911
  "signal-hook-registry",
2912
  "socket2",
2913
  "tokio-macros",
2914
- "windows-sys 0.45.0",
2915
  ]
2916
 
2917
  [[package]]
@@ -2958,9 +2900,9 @@ dependencies = [
2958
 
2959
  [[package]]
2960
  name = "tokio-macros"
2961
- version = "2.0.0"
2962
  source = "registry+https://github.com/rust-lang/crates.io-index"
2963
- checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce"
2964
  dependencies = [
2965
  "proc-macro2 1.0.56",
2966
  "quote 1.0.26",
@@ -2974,7 +2916,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2974
  checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
2975
  dependencies = [
2976
  "native-tls",
2977
- "tokio 1.27.0",
2978
  ]
2979
 
2980
  [[package]]
@@ -3051,15 +2993,15 @@ dependencies = [
3051
 
3052
  [[package]]
3053
  name = "tokio-util"
3054
- version = "0.7.7"
3055
  source = "registry+https://github.com/rust-lang/crates.io-index"
3056
- checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2"
3057
  dependencies = [
3058
  "bytes 1.4.0",
3059
  "futures-core",
3060
  "futures-sink",
3061
  "pin-project-lite",
3062
- "tokio 1.27.0",
3063
  "tracing",
3064
  ]
3065
 
@@ -3193,12 +3135,6 @@ version = "0.7.6"
3193
  source = "registry+https://github.com/rust-lang/crates.io-index"
3194
  checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
3195
 
3196
- [[package]]
3197
- name = "utf8parse"
3198
- version = "0.2.1"
3199
- source = "registry+https://github.com/rust-lang/crates.io-index"
3200
- checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
3201
-
3202
  [[package]]
3203
  name = "uuid"
3204
  version = "0.7.4"
@@ -3351,16 +3287,16 @@ version = "0.1.0"
3351
  dependencies = [
3352
  "actix-files",
3353
  "actix-web",
3354
- "clap",
3355
  "env_logger",
3356
  "fake-useragent",
3357
  "handlebars",
3358
  "log",
3359
- "reqwest 0.11.16",
 
3360
  "scraper",
3361
  "serde",
3362
  "serde_json",
3363
- "tokio 1.27.0",
3364
  ]
3365
 
3366
  [[package]]
 
15
  "log",
16
  "memchr",
17
  "pin-project-lite",
18
+ "tokio 1.28.0",
19
  "tokio-util",
20
  ]
21
 
 
75
  "rand 0.8.5",
76
  "sha1",
77
  "smallvec 1.10.0",
78
+ "tokio 1.28.0",
79
  "tokio-util",
80
  "tracing",
81
  "zstd",
 
111
  checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e"
112
  dependencies = [
113
  "futures-core",
114
+ "tokio 1.28.0",
115
  ]
116
 
117
  [[package]]
 
128
  "mio 0.8.6",
129
  "num_cpus",
130
  "socket2",
131
+ "tokio 1.28.0",
132
  "tracing",
133
  ]
134
 
 
268
  "alloc-no-stdlib",
269
  ]
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  [[package]]
272
  name = "askama_escape"
273
  version = "0.10.3"
 
299
  "cc",
300
  "cfg-if 1.0.0",
301
  "libc",
302
+ "miniz_oxide 0.6.2",
303
  "object",
304
  "rustc-demangle",
305
  ]
 
370
  "alloc-stdlib",
371
  ]
372
 
373
+ [[package]]
374
+ name = "bstr"
375
+ version = "0.2.17"
376
+ source = "registry+https://github.com/rust-lang/crates.io-index"
377
+ checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
378
+ dependencies = [
379
+ "memchr",
380
+ ]
381
+
382
  [[package]]
383
  name = "bumpalo"
384
  version = "3.12.1"
 
438
  source = "registry+https://github.com/rust-lang/crates.io-index"
439
  checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
  [[package]]
442
  name = "cloudabi"
443
  version = "0.0.3"
 
447
  "bitflags",
448
  ]
449
 
 
 
 
 
 
 
450
  [[package]]
451
  name = "convert_case"
452
  version = "0.4.0"
 
748
 
749
  [[package]]
750
  name = "flate2"
751
+ version = "1.0.26"
752
  source = "registry+https://github.com/rust-lang/crates.io-index"
753
+ checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
754
  dependencies = [
755
  "crc32fast",
756
+ "miniz_oxide 0.7.1",
757
  ]
758
 
759
  [[package]]
 
961
  "http 0.2.9",
962
  "indexmap",
963
  "slab",
964
+ "tokio 1.28.0",
965
  "tokio-util",
966
  "tracing",
967
  ]
 
987
  source = "registry+https://github.com/rust-lang/crates.io-index"
988
  checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
989
 
 
 
 
 
 
 
990
  [[package]]
991
  name = "hermit-abi"
992
  version = "0.2.6"
 
1147
  "itoa 1.0.6",
1148
  "pin-project-lite",
1149
  "socket2",
1150
+ "tokio 1.28.0",
1151
  "tower-service",
1152
  "tracing",
1153
  "want 0.3.0",
 
1175
  "bytes 1.4.0",
1176
  "hyper 0.14.26",
1177
  "native-tls",
1178
+ "tokio 1.28.0",
1179
  "tokio-native-tls",
1180
  ]
1181
 
 
1328
 
1329
  [[package]]
1330
  name = "linux-raw-sys"
1331
+ version = "0.3.6"
1332
  source = "registry+https://github.com/rust-lang/crates.io-index"
1333
+ checksum = "b64f40e5e03e0d54f03845c8197d0291253cdbedfb1cb46b13c2c117554a9f4c"
1334
 
1335
  [[package]]
1336
  name = "local-channel"
 
1467
  "adler",
1468
  ]
1469
 
1470
+ [[package]]
1471
+ name = "miniz_oxide"
1472
+ version = "0.7.1"
1473
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1474
+ checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
1475
+ dependencies = [
1476
+ "adler",
1477
+ ]
1478
+
1479
  [[package]]
1480
  name = "mio"
1481
  version = "0.6.23"
 
1560
  source = "registry+https://github.com/rust-lang/crates.io-index"
1561
  checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
1562
 
1563
+ [[package]]
1564
+ name = "num-traits"
1565
+ version = "0.2.15"
1566
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1567
+ checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
1568
+ dependencies = [
1569
+ "autocfg 1.1.0",
1570
+ ]
1571
+
1572
  [[package]]
1573
  name = "num_cpus"
1574
  version = "1.15.0"
 
1596
 
1597
  [[package]]
1598
  name = "openssl"
1599
+ version = "0.10.52"
1600
  source = "registry+https://github.com/rust-lang/crates.io-index"
1601
+ checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56"
1602
  dependencies = [
1603
  "bitflags",
1604
  "cfg-if 1.0.0",
 
1628
 
1629
  [[package]]
1630
  name = "openssl-sys"
1631
+ version = "0.9.87"
1632
  source = "registry+https://github.com/rust-lang/crates.io-index"
1633
+ checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e"
1634
  dependencies = [
1635
  "cc",
1636
  "libc",
 
1707
 
1708
  [[package]]
1709
  name = "pest"
1710
+ version = "2.6.0"
1711
  source = "registry+https://github.com/rust-lang/crates.io-index"
1712
+ checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70"
1713
  dependencies = [
1714
  "thiserror",
1715
  "ucd-trie",
 
1717
 
1718
  [[package]]
1719
  name = "pest_derive"
1720
+ version = "2.6.0"
1721
  source = "registry+https://github.com/rust-lang/crates.io-index"
1722
+ checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb"
1723
  dependencies = [
1724
  "pest",
1725
  "pest_generator",
 
1727
 
1728
  [[package]]
1729
  name = "pest_generator"
1730
+ version = "2.6.0"
1731
  source = "registry+https://github.com/rust-lang/crates.io-index"
1732
+ checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e"
1733
  dependencies = [
1734
  "pest",
1735
  "pest_meta",
 
1740
 
1741
  [[package]]
1742
  name = "pest_meta"
1743
+ version = "2.6.0"
1744
  source = "registry+https://github.com/rust-lang/crates.io-index"
1745
+ checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411"
1746
  dependencies = [
1747
  "once_cell",
1748
  "pest",
 
2234
 
2235
  [[package]]
2236
  name = "reqwest"
2237
+ version = "0.11.17"
2238
  source = "registry+https://github.com/rust-lang/crates.io-index"
2239
+ checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91"
2240
  dependencies = [
2241
  "base64 0.21.0",
2242
  "bytes 1.4.0",
 
2259
  "serde",
2260
  "serde_json",
2261
  "serde_urlencoded 0.7.1",
2262
+ "tokio 1.28.0",
2263
  "tokio-native-tls",
2264
  "tower-service",
2265
  "url 2.3.1",
 
2269
  "winreg 0.10.1",
2270
  ]
2271
 
2272
+ [[package]]
2273
+ name = "rlua"
2274
+ version = "0.19.4"
2275
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2276
+ checksum = "95b38117a836316ef62c02f6751e6d28e2eb53a1c35f0329427a9fb9c1c7b6a0"
2277
+ dependencies = [
2278
+ "bitflags",
2279
+ "bstr",
2280
+ "libc",
2281
+ "num-traits",
2282
+ "rlua-lua54-sys",
2283
+ ]
2284
+
2285
+ [[package]]
2286
+ name = "rlua-lua54-sys"
2287
+ version = "0.1.3"
2288
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2289
+ checksum = "23ae48797c3e76fb2c205fda8f30e28416a15b9fc1d649cc7cea9ff1fb9cf028"
2290
+ dependencies = [
2291
+ "cc",
2292
+ "libc",
2293
+ "pkg-config",
2294
+ ]
2295
+
2296
  [[package]]
2297
  name = "rustc-demangle"
2298
  version = "0.1.23"
 
2319
 
2320
  [[package]]
2321
  name = "rustix"
2322
+ version = "0.37.17"
2323
  source = "registry+https://github.com/rust-lang/crates.io-index"
2324
+ checksum = "bc809f704c03a812ac71f22456c857be34185cac691a4316f27ab0f633bb9009"
2325
  dependencies = [
2326
  "bitflags",
2327
  "errno",
 
2667
  source = "registry+https://github.com/rust-lang/crates.io-index"
2668
  checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
2669
 
 
 
 
 
 
 
2670
  [[package]]
2671
  name = "syn"
2672
  version = "0.15.44"
 
2839
 
2840
  [[package]]
2841
  name = "tokio"
2842
+ version = "1.28.0"
2843
  source = "registry+https://github.com/rust-lang/crates.io-index"
2844
+ checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f"
2845
  dependencies = [
2846
  "autocfg 1.1.0",
2847
  "bytes 1.4.0",
 
2853
  "signal-hook-registry",
2854
  "socket2",
2855
  "tokio-macros",
2856
+ "windows-sys 0.48.0",
2857
  ]
2858
 
2859
  [[package]]
 
2900
 
2901
  [[package]]
2902
  name = "tokio-macros"
2903
+ version = "2.1.0"
2904
  source = "registry+https://github.com/rust-lang/crates.io-index"
2905
+ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
2906
  dependencies = [
2907
  "proc-macro2 1.0.56",
2908
  "quote 1.0.26",
 
2916
  checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
2917
  dependencies = [
2918
  "native-tls",
2919
+ "tokio 1.28.0",
2920
  ]
2921
 
2922
  [[package]]
 
2993
 
2994
  [[package]]
2995
  name = "tokio-util"
2996
+ version = "0.7.8"
2997
  source = "registry+https://github.com/rust-lang/crates.io-index"
2998
+ checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d"
2999
  dependencies = [
3000
  "bytes 1.4.0",
3001
  "futures-core",
3002
  "futures-sink",
3003
  "pin-project-lite",
3004
+ "tokio 1.28.0",
3005
  "tracing",
3006
  ]
3007
 
 
3135
  source = "registry+https://github.com/rust-lang/crates.io-index"
3136
  checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
3137
 
 
 
 
 
 
 
3138
  [[package]]
3139
  name = "uuid"
3140
  version = "0.7.4"
 
3287
  dependencies = [
3288
  "actix-files",
3289
  "actix-web",
 
3290
  "env_logger",
3291
  "fake-useragent",
3292
  "handlebars",
3293
  "log",
3294
+ "reqwest 0.11.17",
3295
+ "rlua",
3296
  "scraper",
3297
  "serde",
3298
  "serde_json",
3299
+ "tokio 1.28.0",
3300
  ]
3301
 
3302
  [[package]]
Cargo.toml CHANGED
@@ -9,12 +9,12 @@ edition = "2021"
9
  reqwest = {version="*",features=["json"]}
10
  tokio = {version="*",features=["full"]}
11
  serde = {version="*",features=["derive"]}
12
- handlebars = { version = "4.2.1", features = ["dir_source"] }
13
  scraper = {version="*"}
14
- actix-web = {version="4"}
15
  actix-files = {version="0.6.2"}
16
  serde_json = {version="*"}
17
  fake-useragent = {version="*"}
18
- clap = {version="*", features = ["derive"] }
19
  env_logger = "0.10.0"
20
  log = "0.4.17"
 
 
9
  reqwest = {version="*",features=["json"]}
10
  tokio = {version="*",features=["full"]}
11
  serde = {version="*",features=["derive"]}
12
+ handlebars = { version = "4.3.6", features = ["dir_source"] }
13
  scraper = {version="*"}
14
+ actix-web = {version="4.3.1"}
15
  actix-files = {version="0.6.2"}
16
  serde_json = {version="*"}
17
  fake-useragent = {version="*"}
 
18
  env_logger = "0.10.0"
19
  log = "0.4.17"
20
+ rlua = {version="*"}
public/static/{catppuccin-mocha.css β†’ colorschemes/catppuccin-mocha.css} RENAMED
File without changes
public/static/{style.css β†’ themes/simple.css} RENAMED
@@ -1,4 +1,4 @@
1
- @import url('./catppuccin-mocha.css');
2
 
3
  * {
4
  padding: 0;
 
1
+ /* @import url('./catppuccin-mocha.css'); */
2
 
3
  * {
4
  padding: 0;
public/templates/404.html CHANGED
@@ -1,4 +1,4 @@
1
- {{>header}}
2
  <main class="error_container">
3
  <img src="images/robot-404.svg" alt="Image of broken robot." />
4
  <div class="error_content">
 
1
+ {{>header this}}
2
  <main class="error_container">
3
  <img src="images/robot-404.svg" alt="Image of broken robot." />
4
  <div class="error_content">
public/templates/about.html CHANGED
@@ -1,4 +1,4 @@
1
- {{>header}}
2
  <main class="about-container">
3
  <h1>Websurfx</h1>
4
  <small
 
1
+ {{>header this}}
2
  <main class="about-container">
3
  <h1>Websurfx</h1>
4
  <small
public/templates/header.html CHANGED
@@ -1,10 +1,11 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
- <title></title>
5
  <meta charset="UTF-8" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <link href="static/style.css" rel="stylesheet" type="text/css" />
 
8
  </head>
9
 
10
  <body>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
+ <title>Websurfx</title>
5
  <meta charset="UTF-8" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <link href="static/colorschemes/{{colorscheme}}.css" rel="stylesheet" type="text/css" />
8
+ <link href="static/themes/{{theme}}.css" rel="stylesheet" type="text/css" />
9
  </head>
10
 
11
  <body>
public/templates/index.html CHANGED
@@ -1,4 +1,4 @@
1
- {{>header}}
2
  <main class="search-container">
3
  <img src="images/fps_logo.png" alt="Websurfx meta-search engine logo" />
4
  {{>search_bar}}
 
1
+ {{>header this}}
2
  <main class="search-container">
3
  <img src="images/fps_logo.png" alt="Websurfx meta-search engine logo" />
4
  {{>search_bar}}
public/templates/search.html CHANGED
@@ -1,4 +1,4 @@
1
- {{>header}}
2
  <main class="results">
3
  {{>search_bar}}
4
  <div class="results_aggregated">
 
1
+ {{>header this.style}}
2
  <main class="results">
3
  {{>search_bar}}
4
  <div class="results_aggregated">
public/templates/settings.html CHANGED
@@ -1,4 +1,4 @@
1
- {{>header}}
2
  <main class="settings">
3
  <h1>Page is under construction</h1>
4
  </main>
 
1
+ {{>header this}}
2
  <main class="settings">
3
  <h1>Page is under construction</h1>
4
  </main>
src/bin/websurfx.rs CHANGED
@@ -3,50 +3,10 @@
3
  //! This module contains the main function which handles the logging of the application to the
4
  //! stdout and handles the command line arguments provided and launches the `websurfx` server.
5
 
6
- use std::{ops::RangeInclusive, net::TcpListener};
7
 
8
- use clap::{command, Parser};
9
  use env_logger::Env;
10
- use websurfx::run;
11
-
12
- /// A commandline arguments struct.
13
- #[derive(Parser, Debug, Default)]
14
- #[clap(author = "neon_arch", version, about = "Websurfx server application")]
15
- #[command(propagate_version = true)]
16
- struct CliArgs {
17
- #[clap(default_value_t = 8080, short, long,value_parser = is_port_in_range)]
18
- /// provide port number in range [1024-65536] to launch the server on.
19
- port: u16,
20
- }
21
-
22
- const PORT_RANGE: RangeInclusive<usize> = 1024..=65535;
23
-
24
- /// A function to check whether port is valid u32 number or is in range
25
- /// between [1024-65536] otherwise display an appropriate error message.
26
- ///
27
- /// # Arguments
28
- ///
29
- /// * `s` - Takes a commandline argument port as a string.
30
- ///
31
- /// # Error
32
- ///
33
- /// Check whether the provided argument to `--port` commandline option is a valid
34
- /// u16 argument and returns it as a u16 value otherwise returns an error with an
35
- /// appropriate error message.
36
- fn is_port_in_range(s: &str) -> Result<u16, String> {
37
- let port: usize = s
38
- .parse()
39
- .map_err(|_| format!("`{s}` is not a valid port number"))?;
40
- if PORT_RANGE.contains(&port) {
41
- Ok(port as u16)
42
- } else {
43
- Err(format!(
44
- "port not found in range {}-{}",
45
- PORT_RANGE.start(),
46
- PORT_RANGE.end()
47
- ))
48
- }
49
- }
50
 
51
  /// The function that launches the main server and registers all the routes of the website.
52
  ///
@@ -56,14 +16,15 @@ fn is_port_in_range(s: &str) -> Result<u16, String> {
56
  /// available for being used for other applications.
57
  #[actix_web::main]
58
  async fn main() -> std::io::Result<()> {
59
- let args = CliArgs::parse();
 
60
 
61
  // Initializing logging middleware with level set to default or info.
62
  env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
63
 
64
- log::info!("started server on port {}", args.port);
65
 
66
- let listener = TcpListener::bind(("127.0.0.1", args.port))?;
67
 
68
- run(listener)?.await
69
  }
 
3
  //! This module contains the main function which handles the logging of the application to the
4
  //! stdout and handles the command line arguments provided and launches the `websurfx` server.
5
 
6
+ use std::net::TcpListener;
7
 
 
8
  use env_logger::Env;
9
+ use websurfx::{config_parser::parser::Config, run};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  /// The function that launches the main server and registers all the routes of the website.
12
  ///
 
16
  /// available for being used for other applications.
17
  #[actix_web::main]
18
  async fn main() -> std::io::Result<()> {
19
+ // Initialize the parsed config file.
20
+ let config = Config::parse().unwrap();
21
 
22
  // Initializing logging middleware with level set to default or info.
23
  env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
24
 
25
+ log::info!("started server on port {}", config.port);
26
 
27
+ let listener = TcpListener::bind((config.binding_ip_addr.clone(), config.port))?;
28
 
29
+ run(listener, config)?.await
30
  }
src/config_parser/mod.rs ADDED
@@ -0,0 +1 @@
 
 
1
+ pub mod parser;
src/config_parser/parser.rs ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //! This module provides the functionality to parse the lua config and convert the config options
2
+ //! into rust readable form.
3
+
4
+ use rlua::Lua;
5
+ use serde::Serialize;
6
+ use std::fs;
7
+
8
+ #[derive(Serialize, Clone)]
9
+ pub struct Style {
10
+ pub theme: String,
11
+ pub colorscheme: String,
12
+ }
13
+
14
+ impl Style {
15
+ pub fn new(theme: String, colorscheme: String) -> Self {
16
+ Style { theme, colorscheme }
17
+ }
18
+ }
19
+
20
+ /// A named struct which stores the parsed config file options.
21
+ ///
22
+ /// # Fields
23
+ //
24
+ /// * `port` - It stores the parsed port number option on which the server should launch.
25
+ /// * `binding_ip_addr` - It stores the parsed ip address option on which the server should launch
26
+ #[derive(Clone)]
27
+ pub struct Config {
28
+ pub port: u16,
29
+ pub binding_ip_addr: String,
30
+ pub style: Style,
31
+ }
32
+
33
+ impl Config {
34
+ /// A function which parses the config.lua file and puts all the parsed options in the newly
35
+ /// contructed Config struct and returns it.
36
+ ///
37
+ /// # Error
38
+ ///
39
+ /// Returns a lua parse error if parsing of the config.lua file fails or has a syntax error
40
+ /// or io error if the config.lua file doesn't exists otherwise it returns a newly contructed
41
+ /// Config struct with all the parsed config options from the parsed config file.
42
+ pub fn parse() -> Result<Self, Box<dyn std::error::Error>> {
43
+ let lua = Lua::new();
44
+
45
+ lua.context(|context| {
46
+ let globals = context.globals();
47
+
48
+ context
49
+ .load(&fs::read_to_string("./websurfx/config.lua")?)
50
+ .exec()?;
51
+
52
+ Ok(Config {
53
+ port: globals.get::<_, u16>("port")?,
54
+ binding_ip_addr: globals.get::<_, String>("binding_ip_addr")?,
55
+ style: Style::new(
56
+ globals.get::<_, String>("theme")?,
57
+ globals.get::<_, String>("colorscheme")?,
58
+ ),
59
+ })
60
+ })
61
+ }
62
+ }
src/lib.rs CHANGED
@@ -1,21 +1,22 @@
1
  //! This main library module provides the functionality to provide and handle the Tcp server
2
  //! and register all the routes for the `websurfx` meta search engine website.
3
 
 
4
  pub mod engines;
5
- pub mod server;
6
  pub mod search_results_handler;
 
7
 
8
  use std::net::TcpListener;
9
 
10
  use crate::server::routes;
11
 
12
  use actix_files as fs;
13
- use actix_web::{middleware::Logger, web, App, HttpServer, dev::Server};
 
14
  use handlebars::Handlebars;
15
 
16
-
17
  /// Runs the web server on the provided TCP listener and returns a `Server` instance.
18
- ///
19
  /// # Arguments
20
  ///
21
  /// * `listener` - A `TcpListener` instance representing the address and port to listen on.
@@ -25,7 +26,7 @@ use handlebars::Handlebars;
25
  /// Returns a `Result` containing a `Server` instance on success, or an `std::io::Error` on failure.
26
  ///
27
  /// # Example
28
- ///
29
  /// ```rust
30
  /// use std::net::TcpListener;
31
  /// use websurfx::run;
@@ -33,7 +34,7 @@ use handlebars::Handlebars;
33
  /// let listener = TcpListener::bind("127.0.0.1:8080").expect("Failed to bind address");
34
  /// let server = run(listener).expect("Failed to start server");
35
  /// ```
36
- pub fn run(listener: TcpListener) -> std::io::Result<Server> {
37
  let mut handlebars: Handlebars = Handlebars::new();
38
 
39
  handlebars
@@ -45,6 +46,7 @@ pub fn run(listener: TcpListener) -> std::io::Result<Server> {
45
  let server = HttpServer::new(move || {
46
  App::new()
47
  .app_data(handlebars_ref.clone())
 
48
  .wrap(Logger::default()) // added logging middleware for logging.
49
  // Serve images and static files (css and js files).
50
  .service(fs::Files::new("/static", "./public/static").show_files_listing())
 
1
  //! This main library module provides the functionality to provide and handle the Tcp server
2
  //! and register all the routes for the `websurfx` meta search engine website.
3
 
4
+ pub mod config_parser;
5
  pub mod engines;
 
6
  pub mod search_results_handler;
7
+ pub mod server;
8
 
9
  use std::net::TcpListener;
10
 
11
  use crate::server::routes;
12
 
13
  use actix_files as fs;
14
+ use actix_web::{dev::Server, middleware::Logger, web, App, HttpServer};
15
+ use config_parser::parser::Config;
16
  use handlebars::Handlebars;
17
 
 
18
  /// Runs the web server on the provided TCP listener and returns a `Server` instance.
19
+ ///
20
  /// # Arguments
21
  ///
22
  /// * `listener` - A `TcpListener` instance representing the address and port to listen on.
 
26
  /// Returns a `Result` containing a `Server` instance on success, or an `std::io::Error` on failure.
27
  ///
28
  /// # Example
29
+ ///
30
  /// ```rust
31
  /// use std::net::TcpListener;
32
  /// use websurfx::run;
 
34
  /// let listener = TcpListener::bind("127.0.0.1:8080").expect("Failed to bind address");
35
  /// let server = run(listener).expect("Failed to start server");
36
  /// ```
37
+ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
38
  let mut handlebars: Handlebars = Handlebars::new();
39
 
40
  handlebars
 
46
  let server = HttpServer::new(move || {
47
  App::new()
48
  .app_data(handlebars_ref.clone())
49
+ .app_data(web::Data::new(config.clone()))
50
  .wrap(Logger::default()) // added logging middleware for logging.
51
  // Serve images and static files (css and js files).
52
  .service(fs::Files::new("/static", "./public/static").show_files_listing())
src/search_results_handler/aggregation_models.rs CHANGED
@@ -3,6 +3,8 @@
3
 
4
  use serde::Serialize;
5
 
 
 
6
  /// A named struct to store and serialize the individual search result from all the scraped
7
  /// and aggregated search results from the upstream search engines.
8
  ///
@@ -117,11 +119,12 @@ impl RawSearchResult {
117
  /// * `results` - Stores the individual serializable `SearchResult` struct into a vector of
118
  /// `SearchResult` structs.
119
  /// * `page_query` - Stores the current pages search query `q` provided in the search url.
120
- #[derive(Debug, Serialize)]
121
  #[serde(rename_all = "camelCase")]
122
  pub struct SearchResults {
123
  pub results: Vec<SearchResult>,
124
  pub page_query: String,
 
125
  }
126
 
127
  impl SearchResults {
@@ -137,6 +140,11 @@ impl SearchResults {
137
  SearchResults {
138
  results,
139
  page_query,
 
140
  }
141
  }
 
 
 
 
142
  }
 
3
 
4
  use serde::Serialize;
5
 
6
+ use crate::config_parser::parser::Style;
7
+
8
  /// A named struct to store and serialize the individual search result from all the scraped
9
  /// and aggregated search results from the upstream search engines.
10
  ///
 
119
  /// * `results` - Stores the individual serializable `SearchResult` struct into a vector of
120
  /// `SearchResult` structs.
121
  /// * `page_query` - Stores the current pages search query `q` provided in the search url.
122
+ #[derive(Serialize)]
123
  #[serde(rename_all = "camelCase")]
124
  pub struct SearchResults {
125
  pub results: Vec<SearchResult>,
126
  pub page_query: String,
127
+ pub style: Style,
128
  }
129
 
130
  impl SearchResults {
 
140
  SearchResults {
141
  results,
142
  page_query,
143
+ style: Style::new("".to_string(), "".to_string()),
144
  }
145
  }
146
+
147
+ pub fn add_style(&mut self, style: Style) {
148
+ self.style = style;
149
+ }
150
  }
src/server/routes.rs CHANGED
@@ -4,7 +4,7 @@
4
 
5
  use std::fs::read_to_string;
6
 
7
- use crate::search_results_handler::aggregator::aggregate;
8
  use actix_web::{get, web, HttpRequest, HttpResponse};
9
  use handlebars::Handlebars;
10
  use serde::Deserialize;
@@ -27,8 +27,9 @@ struct SearchParams {
27
  #[get("/")]
28
  pub async fn index(
29
  hbs: web::Data<Handlebars<'_>>,
 
30
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
31
- let page_content: String = hbs.render("index", &"").unwrap();
32
  Ok(HttpResponse::Ok().body(page_content))
33
  }
34
 
@@ -36,8 +37,9 @@ pub async fn index(
36
  /// website essentially the 404 error page.
37
  pub async fn not_found(
38
  hbs: web::Data<Handlebars<'_>>,
 
39
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
40
- let page_content: String = hbs.render("404", &"")?;
41
 
42
  Ok(HttpResponse::Ok()
43
  .content_type("text/html; charset=utf-8")
@@ -52,7 +54,7 @@ pub async fn not_found(
52
  /// ```bash
53
  /// curl "http://127.0.0.1:8080/search?q=sweden&page=1"
54
  /// ```
55
- ///
56
  /// Or
57
  ///
58
  /// ```bash
@@ -62,6 +64,7 @@ pub async fn not_found(
62
  pub async fn search(
63
  hbs: web::Data<Handlebars<'_>>,
64
  req: HttpRequest,
 
65
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
66
  let params = web::Query::<SearchParams>::from_query(req.query_string())?;
67
  match &params.q {
@@ -71,8 +74,9 @@ pub async fn search(
71
  .insert_header(("location", "/"))
72
  .finish())
73
  } else {
74
- let results_json: crate::search_results_handler::aggregation_models::SearchResults =
75
  aggregate(query, params.page).await?;
 
76
  let page_content: String = hbs.render("search", &results_json)?;
77
  Ok(HttpResponse::Ok().body(page_content))
78
  }
@@ -96,8 +100,9 @@ pub async fn robots_data(_req: HttpRequest) -> Result<HttpResponse, Box<dyn std:
96
  #[get("/about")]
97
  pub async fn about(
98
  hbs: web::Data<Handlebars<'_>>,
 
99
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
100
- let page_content: String = hbs.render("about", &"")?;
101
  Ok(HttpResponse::Ok().body(page_content))
102
  }
103
 
@@ -105,8 +110,9 @@ pub async fn about(
105
  #[get("/settings")]
106
  pub async fn settings(
107
  hbs: web::Data<Handlebars<'_>>,
 
108
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
109
- let page_content: String = hbs.render("settings", &"")?;
110
  Ok(HttpResponse::Ok().body(page_content))
111
  }
112
 
 
4
 
5
  use std::fs::read_to_string;
6
 
7
+ use crate::{config_parser::parser::Config, search_results_handler::aggregator::aggregate};
8
  use actix_web::{get, web, HttpRequest, HttpResponse};
9
  use handlebars::Handlebars;
10
  use serde::Deserialize;
 
27
  #[get("/")]
28
  pub async fn index(
29
  hbs: web::Data<Handlebars<'_>>,
30
+ config: web::Data<Config>,
31
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
32
+ let page_content: String = hbs.render("index", &config.style).unwrap();
33
  Ok(HttpResponse::Ok().body(page_content))
34
  }
35
 
 
37
  /// website essentially the 404 error page.
38
  pub async fn not_found(
39
  hbs: web::Data<Handlebars<'_>>,
40
+ config: web::Data<Config>,
41
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
42
+ let page_content: String = hbs.render("404", &config.style)?;
43
 
44
  Ok(HttpResponse::Ok()
45
  .content_type("text/html; charset=utf-8")
 
54
  /// ```bash
55
  /// curl "http://127.0.0.1:8080/search?q=sweden&page=1"
56
  /// ```
57
+ ///
58
  /// Or
59
  ///
60
  /// ```bash
 
64
  pub async fn search(
65
  hbs: web::Data<Handlebars<'_>>,
66
  req: HttpRequest,
67
+ config: web::Data<Config>,
68
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
69
  let params = web::Query::<SearchParams>::from_query(req.query_string())?;
70
  match &params.q {
 
74
  .insert_header(("location", "/"))
75
  .finish())
76
  } else {
77
+ let mut results_json: crate::search_results_handler::aggregation_models::SearchResults =
78
  aggregate(query, params.page).await?;
79
+ results_json.add_style(config.style.clone());
80
  let page_content: String = hbs.render("search", &results_json)?;
81
  Ok(HttpResponse::Ok().body(page_content))
82
  }
 
100
  #[get("/about")]
101
  pub async fn about(
102
  hbs: web::Data<Handlebars<'_>>,
103
+ config: web::Data<Config>,
104
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
105
+ let page_content: String = hbs.render("about", &config.style)?;
106
  Ok(HttpResponse::Ok().body(page_content))
107
  }
108
 
 
110
  #[get("/settings")]
111
  pub async fn settings(
112
  hbs: web::Data<Handlebars<'_>>,
113
+ config: web::Data<Config>,
114
  ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
115
+ let page_content: String = hbs.render("settings", &config.style)?;
116
  Ok(HttpResponse::Ok().body(page_content))
117
  }
118
 
websurfx/config.lua ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ port = "8080"
2
+ binding_ip_addr = "127.0.0.1"
3
+ colorscheme = "catppuccin-mocha"
4
+ theme = "simple"