assets.ml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. (*
  2. * _ _ ____ _
  3. * _| || |_/ ___| ___ _ __ _ __ ___ | |
  4. * |_ .. _\___ \ / _ \ '_ \| '_ \ / _ \| |
  5. * |_ _|___) | __/ |_) | |_) | (_) |_|
  6. * |_||_| |____/ \___| .__/| .__/ \___/(_)
  7. * |_| |_|
  8. *
  9. * Personal Social Web.
  10. *
  11. * Copyright (C) The #Seppo contributors. All rights reserved.
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation, either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. *)
  26. let ( let* ) = Result.bind
  27. let ( >>= ) = Result.bind
  28. (** Assets packed into the binary and to be unpacked and used as they are *)
  29. module Const = struct
  30. (** Unpack the web application assets from the executable. *)
  31. let delete_restore_marker = "delete-me-to-restore-missing"
  32. let mutabl =
  33. [
  34. "app/var/lib/me-avatar.jpg";
  35. "app/var/lib/me-banner.jpg";
  36. Cfg.Urlcleaner.fn;
  37. ]
  38. let f_cdb (Mapcdb.Cdb v) = v
  39. let all =
  40. [
  41. ".htaccess";
  42. (*
  43. ".well-known/nodeinfo/.htaccess"; (* dot dir missing *)
  44. ".well-known/nodeinfo/README.txt"; (* dot dir missing *)
  45. ".well-known/nodeinfo/index.json"; (* dot dir missing *)
  46. Webfinger.Server.target; (* dot dir missing *)
  47. *)
  48. "README.txt";
  49. "activitypub/blocked/0.jsa";
  50. "activitypub/blocked/0.xml";
  51. "activitypub/blocked/index.jsa";
  52. "activitypub/blocked/index.xml";
  53. "activitypub/liked/0.jsa";
  54. "activitypub/liked/0.xml";
  55. "activitypub/liked/index.jsa";
  56. "activitypub/liked/index.xml";
  57. "activitypub/notify/0.jsa";
  58. "activitypub/notify/0.xml";
  59. Ap.Followers.Atom.target;
  60. Ap.Followers.Json.target;
  61. "activitypub/outbox/0.jsa";
  62. "activitypub/outbox/0.xml";
  63. "activitypub/outbox/index.jsa";
  64. "activitypub/outbox/index.xml";
  65. "activitypub/subscribed/0.jsa";
  66. "activitypub/subscribed/0.xml";
  67. "activitypub/subscribed/index.jsa";
  68. "activitypub/subscribed/index.xml";
  69. "activitypub/index.html";
  70. "activitypub/README.txt";
  71. "app/.htaccess";
  72. "app/README.txt";
  73. "app/etc/ban.s";
  74. "app/etc/profile.s";
  75. "app/i-must-be-403.svg";
  76. "app/var/README.txt";
  77. Ap.Note.ibc_dir ^ "cur/README.txt";
  78. Ap.Note.ibc_dir ^ "new/README.txt";
  79. Ap.Note.ibc_dir ^ "tmp/README.txt";
  80. Tag.cdb |> f_cdb;
  81. "app/var/db/blocked.cdb";
  82. Ap.Followers.cdb |> f_cdb;
  83. Ap.Following.cdb |> f_cdb;
  84. "app/var/db/o/d/README.txt";
  85. "app/var/db/o/m/README.txt";
  86. "app/var/db/o/p/README.txt";
  87. "app/var/db/o/t/README.txt";
  88. Storage.fn_id_cdb |> f_cdb;
  89. Storage.fn_url_cdb |> f_cdb;
  90. "app/var/log/seppo.log.0";
  91. "app/var/log/seppo.log";
  92. Ban.fn;
  93. "app/var/run/README.txt";
  94. "app/var/spool/job/cur/README.txt";
  95. "app/var/spool/job/err/README.txt";
  96. "app/var/spool/job/new/README.txt";
  97. "app/var/spool/job/run/README.txt";
  98. "app/var/spool/job/tmp/README.txt";
  99. "app/var/spool/job/wait/README.txt";
  100. "contrib/etc/apache2/sites-available/000-default.conf";
  101. "contrib/etc/lighttpd/conf-available/50-seppo.conf";
  102. "contrib/harden.sh";
  103. "contrib/README.txt";
  104. delete_restore_marker;
  105. "favicon.ico";
  106. "index.html";
  107. "me-avatar.jpg";
  108. (* "nodeinfo/2.1.json"; *)
  109. "o/d/README.txt";
  110. "o/p/index.xml";
  111. "o/t/index.json";
  112. "robots.txt";
  113. "seppo.pub.pem";
  114. "themes/current/404.html";
  115. "themes/current/actor.css";
  116. "themes/current/actor.js";
  117. "themes/current/actor.xsl";
  118. "themes/current/awesomplete.css";
  119. "themes/current/awesomplete.js";
  120. "themes/current/backoffice.js";
  121. "themes/current/backoffice.xsl";
  122. "themes/current/changepasswordform.xsl";
  123. "themes/current/configform.xsl";
  124. "themes/current/do=tools.xsl";
  125. "themes/current/feed-icon.svg";
  126. "themes/current/linkform.js";
  127. "themes/current/linkform.xsl";
  128. "themes/current/loginform.xsl";
  129. (* "themes/current/notify.css"; *)
  130. "themes/current/notify.js";
  131. "themes/current/notify.xsl";
  132. "themes/current/posts.css";
  133. "themes/current/posts.js";
  134. "themes/current/posts.xsl";
  135. "themes/current/README.txt";
  136. "themes/current/replies.css";
  137. "themes/current/replies.xsl";
  138. "themes/current/style.css";
  139. (* "themes/current/subscribed.js"; *)
  140. "themes/current/subscribed.xsl";
  141. "themes/current/tick.mp3";
  142. "themes/current/util.xsl";
  143. "themes/current/valid-atom.svg";
  144. ]
  145. @ mutabl
  146. (* how to deal with IO erros? Let them fly! *)
  147. let restore_if_nonex perm candidates =
  148. if not (File.exists delete_restore_marker)
  149. then candidates |> List.filter_map (File.restore_static ~perm)
  150. else []
  151. end
  152. (** Generated assets with local dependencies *)
  153. module Gen = struct
  154. let make x =
  155. Result.bind
  156. Webfinger.Server.(make target)
  157. (fun _ -> Ok x)
  158. (* ready to be used in the handler. *)
  159. let make_cgi x =
  160. match make x with
  161. | Error msg ->
  162. Logr.err (fun m -> m "%s %s" E.e1003 msg);
  163. Http.s500
  164. | Ok _ as o -> o
  165. end