index.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <!-- HTML Meta Tags -->
  5. <title>Welcome to My Blog</title>
  6. <meta name="description" content="A personal blog hosted on WebStick!">
  7. <meta name="viewport" content="width=device-width, initial-scale=1" >
  8. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  9. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" />
  10. <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>
  11. <script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
  12. <style>
  13. .imgwrapper{
  14. max-height: 200px;
  15. overflow: hidden;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <br>
  21. <div class="ui text container">
  22. <h2 class="ui header">
  23. WebStick Blog
  24. <div class="sub header">Welcome to this new personal blog of mine!</div>
  25. </h2>
  26. <div class="ui divider"></div>
  27. <a class="ui basic icon button" href="../" title="Back to Home"><i class="home icon"></i></a>
  28. <a class="ui basic icon button" href="../" title="Share"><i class="green share alternate icon"></i></a>
  29. <a class="ui basic button adminOnly"><i class="blue add icon"></i> New Post</a>
  30. <br><br>
  31. <div class="posttable">
  32. <div class="ui message">
  33. <h4 class="ui header">
  34. <i class="blue question icon"></i>
  35. <div class="content">
  36. No Post
  37. <div class="sub header">It seems this is a brand new blog site!</div>
  38. </div>
  39. </h4>
  40. </div>
  41. <div class="ui basic segment postObject">
  42. <h4 class="ui header">
  43. <i class="blue map marker alternate icon"></i>
  44. <div class="content">
  45. 11 Sep 2023
  46. </div>
  47. </h4>
  48. <div class="ui divider"></div>
  49. <div class="adminOnly" style="position: absolute; top: 0.4em; right: 0.4em;">
  50. <a class="ui basic mini icon button" title="Edit Post"><i class="edit icon"></i></a>
  51. <button class="ui basic mini icon button" title="Remove Post"><i class="red trash icon"></i></button>
  52. </div>
  53. <div class="postContent">
  54. </div>
  55. <div class="ui divider"></div>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="ui text container center aligned">
  60. <div class="ui divider"></div>
  61. <small>Proudly powered by <a href="https://hackaday.io/project/192618-instant-webstick-esp8266-web-server-nas">WebStick</a></small>
  62. </div>
  63. </div>
  64. <script>
  65. //Check the user has logged in
  66. $.get("", function(data){
  67. if (data == false){
  68. //User cannot use admin function. Hide the buttons.
  69. $(".adminOnly").hide();
  70. }
  71. });
  72. //Load the list of post from the server side
  73. function loadPostFromServer(){
  74. }
  75. //Load a markdown file from URL and render it to target element
  76. function loadMarkdownToHTML(markdownURL, targetElement){
  77. fetch(markdownURL).then( r => r.text() ).then( text =>{
  78. var converter = new showdown.Converter();
  79. let targetHTML = converter.makeHtml(text);
  80. console.log(targetHTML);
  81. $(targetElement).html(targetHTML);
  82. });
  83. }
  84. loadMarkdownToHTML("../../README.md", $(".postContent"));
  85. loadPostFromServer();
  86. </script>
  87. </body>
  88. </html>