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.

152 lines
6.6 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 %} <!--[if !IE]> --> - Hits: <span id="{{ page.url }}" class="visitors">Loading...</span> <!-- <![endif]--> </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_to_xmlschema }}");
  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. <b>AI摘要</b>
  27. <p id="ai-output">{% assign ai_cache = site.data.ai-cache[page.url] %}{% if ai_cache %}{{ ai_cache }}{% else %}正在生成中……{% endif %}</p>
  28. {% unless ai_cache %}
  29. <!--[if IE]>
  30. <script>document.getElementById("ai-output").innerHTML="这个文章的AI摘要还没有缓存……IE看不了哦~";</script>
  31. <![endif]-->
  32. <!--[if !IE]> -->
  33. <script>
  34. async function sha(str) {
  35. const encoder = new TextEncoder();
  36. const data = encoder.encode(str);
  37. const hashBuffer = await crypto.subtle.digest("SHA-256", data);
  38. const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
  39. const hashHex = hashArray
  40. .map((b) => b.toString(16).padStart(2, "0"))
  41. .join(""); // convert bytes to hex string
  42. return hashHex;
  43. }
  44. async function ai_gen(){
  45. var postContent = "文章标题:" + {{ page.title | jsonify }} + ";文章内容:" + {{ page.content | strip_html | strip_newlines | jsonify }};
  46. var postContentSign = await sha(postContent);
  47. var outputContainer = document.getElementById("ai-output");
  48. $.get(BlogAPI + "/is_uploaded?id={{ page.url }}&sign=" + postContentSign, function (data) {
  49. if (data == "yes") {
  50. $.get(BlogAPI + "/get_summary?id={{ page.url }}&sign=" + postContentSign, function (data2) {
  51. outputContainer.textContent = data2;
  52. });
  53. } else {
  54. $.post(BlogAPI + "/upload_blog?id={{ page.url }}", postContent, function (data) {
  55. $.get(BlogAPI + "/get_summary?id={{ page.url }}&sign=" + postContentSign);
  56. const evSource = new EventSource(BlogAPI + "/summary?id={{ page.url }}");
  57. outputContainer.textContent = "";
  58. evSource.onmessage = (event) => {
  59. if (event.data == "[DONE]") {
  60. evSource.close();
  61. return;
  62. } else {
  63. const data = JSON.parse(event.data);
  64. outputContainer.textContent += data.response;
  65. }
  66. }
  67. });
  68. }
  69. });
  70. }
  71. ai_gen();
  72. </script>
  73. <!-- <![endif]-->
  74. {% endunless %}
  75. <hr />
  76. {% endif %}
  77. {% include toc.html html=content sanitize=true h_max=3 %}
  78. {% if post.layout == "encrypt" %} {{content}} {% else %} <main class="post-content" role="main">{% include anchor_headings.html html=content beforeHeading=true anchorBody="<svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>" %}</main> {% endif %}
  79. {% if page.tags %}
  80. <small style="display: block">tags: {% for tag in page.tags %}<a href="/search.html?keyword={{ tag | url_encode }}"><em>{{ tag }}</em></a>{% unless forloop.last %} - {% endunless %}{% endfor %} <span style="float: right;"><a href="{% if site.github %}{{ site.github.repository_url }}{% else %}https://gitlab.com/mayx/mayx.gitlab.io{% endif %}/tree/master/{{ page.path }}">查看原始文件</a></span></small>
  81. {% endif %}
  82. <br />
  83. <br />
  84. <!--[if !IE]> -->
  85. <p id="suggest-container"></p>
  86. <script>
  87. var suggest = $("#suggest-container")[0];
  88. suggest.innerHTML = "Loading...";
  89. $.get(BlogAPI + "/suggest?id={{ page.url }}&update=" + lastUpdated.valueOf(), function (data) {
  90. if (data.length) {
  91. getSearchJSON(function (search) {
  92. suggest.innerHTML = '<b>推荐文章</b><hr style="margin: 0 0 5px"/>';
  93. const searchMap = new Map(search.map(item => [item.url, item]));
  94. const merged = data.map(suggestObj => {
  95. const searchObj = searchMap.get(suggestObj.id);
  96. return searchObj ? { ...searchObj } : null;
  97. });
  98. merged.forEach(element => {
  99. if (element) {
  100. suggest.innerHTML += "<a href=" + element.url + ">" + element.title + "</a> - " + element.date + "<br />";
  101. }
  102. });
  103. });
  104. } else {
  105. suggest.innerHTML = "暂无推荐文章……";
  106. }
  107. });
  108. </script>
  109. <!-- <![endif]-->
  110. <div class="pagination">
  111. {% if page.previous.url %}
  112. <span class="prev">
  113. <a href="{{ site.baseurl }}{{ page.previous.url }}">
  114. 上一篇:{{ page.previous.title }}
  115. </a>
  116. </span>
  117. {% endif %}
  118. <br />
  119. {% if page.next.url %}
  120. <span class="next">
  121. <a href="{{ site.baseurl }}{{ page.next.url }}">
  122. 下一篇:{{ page.next.title }}
  123. </a>
  124. </span>
  125. {% endif %}
  126. </div>
  127. <!--[if !IE]> -->
  128. <link rel="stylesheet" href="/assets/css/gitalk.css">
  129. <script src="/assets/js/gitalk.min.js"></script>
  130. <div id="gitalk-container"></div>
  131. <script>
  132. var gitalk = new Gitalk({
  133. clientID: (window.location.host != "mabbs.github.io")?'098934a2556425f19d6e':'36557aec4c3cb04f7ac6',
  134. clientSecret: (window.location.host != "mabbs.github.io")?'0bd44eed8425e5437ce43c4ba9b2791fbc04581d':'ac32993299751cb5a9ba81cf2b171cca65879cdb',
  135. repo: 'mabbs.github.io',
  136. owner: 'Mabbs',
  137. admin: ['Mabbs'],
  138. id: '{{ page.id }}', // Ensure uniqueness and length less than 50
  139. distractionFreeMode: false, // Facebook-like distraction free mode
  140. proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
  141. })
  142. gitalk.render('gitalk-container')
  143. </script>
  144. <!-- <![endif]-->

Powered by TurnKey Linux.