theme_icons.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * Generate icons.html for the jinja templates of the simple theme.
  3. */
  4. import { argv } from "node:process";
  5. import { dirname, resolve } from "node:path";
  6. import { jinja_svg_sets } from "./tools/jinja_svg_catalog.js";
  7. const HERE = dirname(argv[1]) + "/";
  8. const dest = resolve(HERE, "../../searx/templates/simple/icons.html");
  9. /** @type import("./tools/jinja_svg_catalog.js").JinjaMacro[] */
  10. const searxng_jinja_macros = [
  11. { name: "icon", class: "sxng-icon-set" },
  12. { name: "icon_small", class: "sxng-icon-set-small" },
  13. { name: "icon_big", class: "sxng-icon-set-big" },
  14. ];
  15. const sxng_icon_opts ={
  16. multipass: true,
  17. plugins: [
  18. { name: "removeTitle" },
  19. { name: "removeXMLNS" },
  20. { name: "addAttributesToSVGElement",
  21. params: {
  22. attributes: [
  23. {
  24. "aria-hidden": "true",
  25. }]}}]
  26. };
  27. /** @type import("./tools/jinja_svg_catalog.js").IconSet */
  28. const simple_icons = [
  29. {
  30. base: resolve(HERE, "node_modules/ionicons/dist/svg"),
  31. set: {
  32. "alert": "alert-outline.svg",
  33. "appstore": "apps-outline.svg",
  34. "book": "book-outline.svg",
  35. "close": "close-outline.svg",
  36. "download": "download-outline.svg",
  37. "ellipsis-vertical": "ellipsis-vertical-outline.svg",
  38. "file-tray-full": "file-tray-full-outline.svg",
  39. "film": "film-outline.svg",
  40. "globe": "globe-outline.svg",
  41. "heart": "heart-outline.svg",
  42. "image": "image-outline.svg",
  43. "layers": "layers-outline.svg",
  44. "leecher": "arrow-down.svg",
  45. "location": "location-outline.svg",
  46. "magnet": "magnet-outline.svg",
  47. "musical-notes": "musical-notes-outline.svg",
  48. "navigate-down": "chevron-down-outline.svg",
  49. "navigate-left": "chevron-back-outline.svg",
  50. "navigate-right": "chevron-forward-outline.svg",
  51. "navigate-up": "chevron-up-outline.svg",
  52. "people": "people-outline.svg",
  53. "play": "play-outline.svg",
  54. "radio": "radio-outline.svg",
  55. "save": "save-outline.svg",
  56. "school": "school-outline.svg",
  57. "search": "search-outline.svg",
  58. "seeder": "swap-vertical.svg",
  59. "settings": "settings-outline.svg",
  60. "tv": "tv-outline.svg",
  61. },
  62. svgo_opts: sxng_icon_opts,
  63. },
  64. // some of the ionicons are not suitable for a dark theme, we fixed the svg
  65. // manually in src/svg/ionicons
  66. // - https://github.com/searxng/searxng/pull/4284#issuecomment-2680550342
  67. {
  68. base: resolve(HERE, "src/svg/ionicons"),
  69. set: {
  70. "information-circle": "information-circle-outline.svg",
  71. "newspaper": "newspaper-outline.svg",
  72. },
  73. svgo_opts: sxng_icon_opts,
  74. }
  75. ];
  76. jinja_svg_sets(dest, searxng_jinja_macros, simple_icons);