index.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <html>
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta name="theme-color" content="#ff9224">
  7. <script src="../../../script/jquery.min.js"></script>
  8. <link rel="stylesheet" href="../../../script/semantic/semantic.min.css">
  9. <script src="../../../script/semantic/semantic.min.js"></script>
  10. <link rel="stylesheet" href="blog.css">
  11. <title>{{blog_title}}</title>
  12. <style>
  13. </style>
  14. </head>
  15. <body>
  16. <div class="ui padded attached black inverted segment">
  17. <br><br>
  18. <div class="ui container" >
  19. <h1 class="ui header" style="color: white;">
  20. {{blog_title}}
  21. <div class="sub header" style="color: white;">{{blog_subtitle}}</div>
  22. </h1>
  23. </div>
  24. <br><br>
  25. </div>
  26. <br>
  27. <div class="ui narrow container relaxed stackable grid">
  28. <div class="sixteen wide column" id="postlist">
  29. <!-- Post List -->
  30. <div class="ui segment post">
  31. <div class="ui teal ribbon label"> owo</div>
  32. <h2 class="ui header">
  33. <a href="" style="color: inherit;">No Posts</a>
  34. <div class="sub header">
  35. There are no post in this blog
  36. </div>
  37. </h2>
  38. <p>
  39. The posts.json index file is not found on this server or there is no post listed in the index file. <br>
  40. That is all we know.
  41. </p>
  42. </div>
  43. </div>
  44. </div>
  45. <!-- footer -->
  46. <div class="ui container">
  47. <div class="ui divider"></div>
  48. {{footer}}
  49. </div>
  50. <script>
  51. loadPostList(0, 20);
  52. function loadPostList(startIndex=0, renderPostNumber = 20){
  53. $.getJSON("posts.json", function(posts){
  54. if (posts.error != undefined || posts.length == 0){
  55. //Error occured
  56. }else{
  57. $("#postlist").html(``);
  58. posts.reverse(); //From latested to oldest
  59. posts.forEach(post => {
  60. //Generate tag index
  61. var tags = post.summary[2];
  62. var tagsHTML = ``;
  63. for (var i = 0; i < tags.length; i++){
  64. tags[i] = `<a class="section">${tags[i]}</a>`;
  65. }
  66. tagsHTML = tags.join(`<span class="divider">,</span>`);
  67. //Generate contents
  68. let tmp = document.createElement("DIV");
  69. tmp.innerHTML = post.summary[1];
  70. let strippedContent = tmp.textContent || tmp.innerText || "";
  71. $("#postlist").append(`<div class="ui segment post">
  72. <div class="ui blue ribbon label"> 2021-05-30</div>
  73. <h2 class="ui header">
  74. <a href="./posts/${post.name}.html" style="color: inherit;">${post.summary[0]}</a>
  75. <div class="sub header">
  76. <div class="ui breadcrumb">
  77. ${tagsHTML}
  78. </div>
  79. </div>
  80. </h2>
  81. <p>
  82. ${strippedContent}
  83. </p>
  84. <a href="./posts/${post.name}.html">Read More</a>
  85. </div>`);
  86. });
  87. }
  88. });
  89. }
  90. </script>
  91. </body>
  92. </html>