theme_icons.js 2.6 KB

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