Mayx's Home Page https://mabbs.github.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.7 KiB

  1. ---
  2. layout: default
  3. ---
  4. <small>{{ page.date | date: "%-d %B %Y" }} - 字数统计:{% if page.layout == "encrypt" %}God Knows {% else %}{{ page.content | strip_html | strip_newlines | remove: " " | size }} - 阅读大约需要{{ page.content | strip_html | strip_newlines | remove: "" | size | divided_by: 350 | plus: 1 }}分钟{% endif %} - Hits: <span id="{{ page.url }}" class="visitors">Loading...</span></small>
  5. <h1>{{ page.title }}</h1>
  6. <p class="view">by <a href="//github.com/{{ page.author | default: "Mabbs" }}">{{ page.author | default: site.author }}</a></p>
  7. <div id="outdate" style="display:none;">
  8. <hr />
  9. 这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
  10. <br /><br />
  11. </div>
  12. <script>
  13. BirthDay = new Date("{{ page.date | date: "%m/%d/%Y" }} 00:00:00");
  14. today = new Date();
  15. timeold = (today.getTime() - BirthDay.getTime());
  16. secondsold = Math.floor(timeold / 1000);
  17. e_daysold = timeold / (24 * 60 * 60 * 1000);
  18. daysold = Math.floor(e_daysold);
  19. if (daysold > 90) {
  20. document.getElementById("outdate").style.display = "block";
  21. document.getElementById("outime").innerHTML = daysold;
  22. }
  23. </script>
  24. <hr />
  25. {% if page.layout != "encrypt" %}
  26. <!--[if !IE]> -->
  27. <b>AI摘要</b>
  28. <p id="ai-output">正在生成中……</p>
  29. <script>
  30. async function sha(str) {
  31. const encoder = new TextEncoder();
  32. const data = encoder.encode(str);
  33. const hashBuffer = await crypto.subtle.digest("SHA-256", data);
  34. const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
  35. const hashHex = hashArray
  36. .map((b) => b.toString(16).padStart(2, "0"))
  37. .join(""); // convert bytes to hex string
  38. return hashHex;
  39. }
  40. async function ai_gen(){
  41. var postContent = "文章标题:" + {{ page.title | jsonify }} + ";文章内容:" + {{ page.content | strip_html | strip_newlines | jsonify }};
  42. var postContentSign = await sha(postContent);
  43. var outputContainer = document.getElementById("ai-output");
  44. $.get("https://summary.mayx.eu.org/is_uploaded?id={{ page.url }}&sign=" + postContentSign, function (data) {
  45. if (data == "yes") {
  46. $.get("https://summary.mayx.eu.org/get_summary?id={{ page.url }}&sign=" + postContentSign, function (data2) {
  47. outputContainer.textContent = data2;
  48. });
  49. } else {
  50. $.post("https://summary.mayx.eu.org/upload_blog?id={{ page.url }}", postContent, function (data) {
  51. $.get("https://summary.mayx.eu.org/get_summary?id={{ page.url }}&sign=" + postContentSign);
  52. const evSource = new EventSource("https://summary.mayx.eu.org/summary?id={{ page.url }}");
  53. outputContainer.textContent = "";
  54. evSource.onmessage = (event) => {
  55. if (event.data == "[DONE]") {
  56. evSource.close();
  57. return;
  58. } else {
  59. const data = JSON.parse(event.data);
  60. outputContainer.textContent += data.response;
  61. }
  62. }
  63. });
  64. }
  65. });
  66. }
  67. ai_gen();
  68. </script>
  69. <hr />
  70. <!-- <![endif]-->
  71. {% endif %}
  72. {% include toc.html html=content sanitize=true h_max=3 %}
  73. {{content}}
  74. {% if page.tags %}
  75. <small>tags: <em>{{ page.tags | join: "</em> - <em>" }}</em></small>
  76. {% endif %}
  77. <p id="suggest-container"><button onclick="getSuggestBlog('{{ page.url }}')">查看推荐文章</button></p>
  78. <div class="pagination">
  79. {% if page.previous.url %}
  80. <span class="prev">
  81. <a href="{{ site.baseurl }}{{ page.previous.url }}">
  82. 上一篇:{{ page.previous.title }}
  83. </a>
  84. </span>
  85. {% endif %}
  86. <br />
  87. {% if page.next.url %}
  88. <span class="next">
  89. <a href="{{ site.baseurl }}{{ page.next.url }}">
  90. 下一篇:{{ page.next.title }}
  91. </a>
  92. </span>
  93. {% endif %}
  94. </div>
  95. <!--[if !IE]> -->
  96. <link rel="stylesheet" href="/css/gitalk.css">
  97. <script src="/js/gitalk.min.js"></script>
  98. <div id="gitalk-container"></div>
  99. <script>
  100. if (window.location.host != "mabbs.github.io") {
  101. var gitalk = new Gitalk({
  102. clientID: '098934a2556425f19d6e',
  103. clientSecret: '0bd44eed8425e5437ce43c4ba9b2791fbc04581d',
  104. repo: 'mabbs.github.io',
  105. owner: 'Mabbs',
  106. admin: ['Mabbs'],
  107. id: '{{ page.id }}', // Ensure uniqueness and length less than 50
  108. distractionFreeMode: false // Facebook-like distraction free mode
  109. })
  110. }
  111. else {
  112. var gitalk = new Gitalk({
  113. clientID: '36557aec4c3cb04f7ac6',
  114. clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
  115. repo: 'mabbs.github.io',
  116. owner: 'Mabbs',
  117. admin: ['Mabbs'],
  118. id: '{{ page.id }}', // Ensure uniqueness and length less than 50
  119. distractionFreeMode: false // Facebook-like distraction free mode
  120. })
  121. }
  122. gitalk.render('gitalk-container')
  123. </script>
  124. <!-- <![endif]-->

Powered by TurnKey Linux.