theme_icons.js 2.6 KB

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