footer.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. const html = require('choo/html');
  2. const Component = require('choo/component');
  3. class Footer extends Component {
  4. constructor(name, state) {
  5. super(name);
  6. this.state = state;
  7. }
  8. update() {
  9. return false;
  10. }
  11. createElement() {
  12. const translate = this.state.translate;
  13. // Add additional links from configuration if available
  14. var links = [];
  15. if (this.state != undefined && this.state.WEB_UI != undefined) {
  16. const WEB_UI = this.state.WEB_UI;
  17. if (WEB_UI.FOOTER_DONATE_URL != '') {
  18. links.push(html`
  19. <li class="m-2">
  20. <a href="${WEB_UI.FOOTER_DONATE_URL}" target="_blank">
  21. ${translate('footerLinkDonate')}
  22. </a>
  23. </li>
  24. `);
  25. }
  26. if (WEB_UI.FOOTER_CLI_URL != '') {
  27. links.push(html`
  28. <li class="m-2">
  29. <a href="${WEB_UI.FOOTER_CLI_URL}" target="_blank">
  30. ${translate('footerLinkCli')}
  31. </a>
  32. </li>
  33. `);
  34. }
  35. if (WEB_UI.FOOTER_DMCA_URL != '') {
  36. links.push(html`
  37. <li class="m-2">
  38. <a href="${WEB_UI.FOOTER_DMCA_URL}" target="_blank">
  39. ${translate('footerLinkDmca')}
  40. </a>
  41. </li>
  42. `);
  43. }
  44. if (WEB_UI.FOOTER_SOURCE_URL != '') {
  45. links.push(html`
  46. <li class="m-2">
  47. <a href="${WEB_UI.FOOTER_SOURCE_URL}" target="_blank">
  48. ${translate('footerLinkSource')}
  49. </a>
  50. </li>
  51. `);
  52. }
  53. } else {
  54. links.push(html`
  55. <li class="m-2">
  56. <a href="https://gitlab.com/timvisee/send" target="_blank">
  57. ${translate('footerLinkSource')}
  58. </a>
  59. </li>
  60. `);
  61. }
  62. // Defining a custom footer
  63. var footer = [];
  64. if (this.state != undefined && this.state.WEB_UI != undefined) {
  65. const WEB_UI = this.state.WEB_UI;
  66. if (WEB_UI.CUSTOM_FOOTER_URL != '' && WEB_UI.CUSTOM_FOOTER_TEXT != '') {
  67. footer.push(html`
  68. <li class="m-2">
  69. <a href="${WEB_UI.CUSTOM_FOOTER_URL}" target="_blank">
  70. ${WEB_UI.CUSTOM_FOOTER_TEXT}
  71. </a>
  72. </li>
  73. `);
  74. }
  75. else if (WEB_UI.CUSTOM_FOOTER_URL != '') {
  76. footer.push(html`
  77. <li class="m-2">
  78. <a href="${WEB_UI.CUSTOM_FOOTER_URL}" target="_blank">
  79. ${WEB_UI.CUSTOM_FOOTER_URL}
  80. </a>
  81. </li>
  82. `);
  83. }
  84. else if (WEB_UI.CUSTOM_FOOTER_TEXT != '') {
  85. footer.push(html`
  86. <li class="m-2">
  87. ${WEB_UI.CUSTOM_FOOTER_TEXT}
  88. </li>
  89. `)
  90. }
  91. else {
  92. footer.push(html`
  93. <li class="m-2">
  94. ${translate('footerText')}
  95. </li>
  96. `);
  97. }
  98. }
  99. return html`
  100. <footer
  101. class="flex flex-col md:flex-row items-start w-full flex-none self-start p-6 md:p-8 font-medium text-xs text-grey-60 dark:text-grey-40 md:items-center justify-between"
  102. >
  103. <ul
  104. class="flex flex-col md:flex-row items-start md:items-center md:justify-start"
  105. >
  106. ${footer}
  107. </ul>
  108. <ul
  109. class="flex flex-col md:flex-row items-start md:items-center md:justify-end"
  110. >
  111. ${links}
  112. </ul>
  113. </footer>
  114. `;
  115. }
  116. }
  117. module.exports = Footer;