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.

146 lines
6.3 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(BlogAPI + "/is_uploaded?id={{ page.url }}&sign=" + postContentSign, function (data) {
  45. if (data == "yes") {
  46. $.get(BlogAPI + "/get_summary?id={{ page.url }}&sign=" + postContentSign, function (data2) {
  47. outputContainer.textContent = data2;
  48. });
  49. } else {
  50. $.post(BlogAPI + "/upload_blog?id={{ page.url }}", postContent, function (data) {
  51. $.get(BlogAPI + "/get_summary?id={{ page.url }}&sign=" + postContentSign);
  52. const evSource = new EventSource(BlogAPI + "/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. {% 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 %}
  74. {% if page.tags %}
  75. <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>
  76. {% endif %}
  77. <br />
  78. <br />
  79. <p id="suggest-container"></p>
  80. <script>
  81. var blogurl = "{{ page.url }}";
  82. var suggest = $("#suggest-container")[0];
  83. suggest.innerHTML = "Loading...";
  84. $.get(BlogAPI + "/suggest?id=" + blogurl + "&update=" + lastUpdated.valueOf(), function (data) {
  85. if (data.length) {
  86. getSearchJSON(function (search) {
  87. suggest.innerHTML = '<b>推荐文章</b><hr style="margin: 0 0 5px"/>';
  88. const searchMap = new Map(search.map(item => [item.url, item]));
  89. const merged = data.map(suggestObj => {
  90. const searchObj = searchMap.get(suggestObj.id);
  91. return searchObj ? { ...searchObj } : null;
  92. });
  93. merged.forEach(element => {
  94. if (element) {
  95. suggest.innerHTML += "<a href=" + element.url + ">" + element.title + "</a> - " + element.date + "<br />";
  96. }
  97. });
  98. });
  99. } else {
  100. suggest.innerHTML = "暂无推荐文章……";
  101. }
  102. });
  103. </script>
  104. <div class="pagination">
  105. {% if page.previous.url %}
  106. <span class="prev">
  107. <a href="{{ site.baseurl }}{{ page.previous.url }}">
  108. 上一篇:{{ page.previous.title }}
  109. </a>
  110. </span>
  111. {% endif %}
  112. <br />
  113. {% if page.next.url %}
  114. <span class="next">
  115. <a href="{{ site.baseurl }}{{ page.next.url }}">
  116. 下一篇:{{ page.next.title }}
  117. </a>
  118. </span>
  119. {% endif %}
  120. </div>
  121. <!--[if !IE]> -->
  122. <link rel="stylesheet" href="/assets/css/gitalk.css">
  123. <script src="/assets/js/gitalk.min.js"></script>
  124. <div id="gitalk-container"></div>
  125. <script>
  126. var gitalk = new Gitalk({
  127. clientID: (window.location.host != "mabbs.github.io")?'098934a2556425f19d6e':'36557aec4c3cb04f7ac6',
  128. clientSecret: (window.location.host != "mabbs.github.io")?'0bd44eed8425e5437ce43c4ba9b2791fbc04581d':'ac32993299751cb5a9ba81cf2b171cca65879cdb',
  129. repo: 'mabbs.github.io',
  130. owner: 'Mabbs',
  131. admin: ['Mabbs'],
  132. id: '{{ page.id }}', // Ensure uniqueness and length less than 50
  133. distractionFreeMode: false, // Facebook-like distraction free mode
  134. proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
  135. })
  136. gitalk.render('gitalk-container')
  137. </script>
  138. <!-- <![endif]-->

Powered by TurnKey Linux.