library.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ---
  2. layout: default
  3. ---
  4. <script>
  5. function printLibrary(sheet) {
  6. const store = new SteinStore(
  7. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  8. );
  9. var rules = "";
  10. store.read(sheet, { limit: 0, offset: 0 }).then(data => {
  11. rules = data.reverse();
  12. libHTML = "";
  13. for (var i = 0; i < rules.length; i++) {
  14. var title = rules[i]["communityname"];
  15. if (title == null) { title = "Untitled"; }
  16. libHTML += "<div class='library-rule-name'>" +
  17. "<a href='/create/?r=" + rules[i]["ruleID"] + "'>" +
  18. title + "</a></div>\n";
  19. var author = rules[i]["author-text"];
  20. if (author != null) {
  21. libHTML += "<div class='library-rule-author'>" + author + "</div>";
  22. }
  23. var structure = rules[i]["structure"];
  24. if (structure != null) {
  25. libHTML += "<p class='library-rule-structure'>" + structure;
  26. libHTML += "</p>\n\n";
  27. }
  28. }
  29. document.getElementById("librarylist").innerHTML = libHTML;
  30. });
  31. }
  32. // allows for using alt sheets (though rule.html is not equipped)
  33. var source = "";
  34. window.onload = function() {
  35. if ((window.location.href.indexOf("/library/") != -1)) {
  36. source = "rules";
  37. }
  38. printLibrary(source);
  39. }
  40. </script>
  41. <article class="post">
  42. <header class="post-header">
  43. <h1 class="post-title">{{ page.title }}</h1>
  44. </header>
  45. <div class="post-content">
  46. {{ content }}
  47. <div id="librarylist">
  48. </div>
  49. </div>
  50. </article>