library.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ---
  2. layout: default
  3. ---
  4. <style type="text/css">
  5. #rulename {
  6. font-size: 1.2em;
  7. }
  8. </style>
  9. <script>
  10. function printLibrary() {
  11. const store = new SteinStore(
  12. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  13. );
  14. var rules = "";
  15. store.read("rules", { limit: 0, offset: 0 }).then(data => {
  16. console.log(data);
  17. rules = data.reverse();
  18. libHTML = "";
  19. for (var i = 0; i < rules.length; i++) {
  20. var title = rules[i]["communityname"];
  21. if (title == null) { title = "Untitled"; }
  22. libHTML += "<h2 id='rulename'>" +
  23. "<a href='/create/?r=" + rules[i]["ruleID"] + "'>" +
  24. title + "</a></h2>\n";
  25. var structure = rules[i]["structure"];
  26. if (structure != null) {
  27. libHTML += "<p>" + structure;
  28. var author = rules[i]["author-text"];
  29. if (author != null) {
  30. libHTML += " (" + author + ")";
  31. }
  32. libHTML += "</p>\n\n";
  33. }
  34. }
  35. document.getElementById("libraryList").innerHTML = libHTML;
  36. });
  37. }
  38. window.onload = function() {
  39. printLibrary();
  40. }
  41. </script>
  42. <article class="post">
  43. <header class="post-header">
  44. <h1 class="post-title">{{ page.title }}</h1>
  45. </header>
  46. <div class="post-content">
  47. {{ content }}
  48. <hr /><br />
  49. <div id="libraryList">
  50. </div>
  51. </div>
  52. </article>