blog.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. {% load static %}{% load day_util %}
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8"/>
  6. <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
  7. <meta
  8. name="viewport"
  9. content="width=device-width, initial-scale=1, maximum-scale=2, user-scalable=no"
  10. />
  11. <meta name="apple-mobile-web-app-capable" content="yes"/>
  12. <meta name="robots" content="index,follow"/>
  13. <meta
  14. name="description"
  15. content="{{ article.intro }}"
  16. />
  17. <meta name="keywords" content="{{ article.title }}"/>
  18. <meta name="author" content="CyberSicko"/>
  19. <meta name="theme-color" content="#ffffff"/>
  20. <title>{{ article.title }}-CyberSicko.net</title>
  21. <link rel="preconnect" href="https://fonts.googleapis.com">
  22. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  23. <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@200;300;400;500;600;700;900&display=swap"
  24. rel="stylesheet">
  25. <link
  26. rel="stylesheet"
  27. href="{% static 'semantic.min.css' %}"
  28. type="text/css"
  29. />
  30. <link
  31. rel="stylesheet"
  32. href="{% static 'photoswipe/photoswipe.css' %}"
  33. type="text/css"
  34. />
  35. <link rel="stylesheet" href="{% static 'highlightjs/styles/androidstudio.min.css' %}">
  36. <link rel="stylesheet" href="{% static 'css/fonts.css' %}">
  37. <link rel="shortcut icon" href="{% static 'favicon.ico' %}">
  38. <style>
  39. :root {
  40. --primary: #000000;
  41. --bg-light: #f8f8f8;
  42. --text: #333;
  43. --gray: #666;
  44. --line-height: 1.8;
  45. --max-width: 900px;
  46. --sidebar-width: 300px;
  47. }
  48. body {
  49. color: var(--text);
  50. background: whitesmoke;
  51. line-height: var(--line-height);
  52. }
  53. a {
  54. color: var(--primary);
  55. transition: color .2s;
  56. }
  57. a:hover {
  58. color: darken(var(--primary), 10%);
  59. }
  60. /* 主容器:限制最大宽度并居中 */
  61. .ui.grid.stackable.container {
  62. max-width: var(--max-width);
  63. margin: 1rem auto;
  64. padding: 0 1rem;
  65. }
  66. /* 段落与标题留白 */
  67. p {
  68. margin-bottom: 1rem;
  69. }
  70. h2.ui.header {
  71. margin-top: 2rem;
  72. margin-bottom: 1rem;
  73. }
  74. /* 卡片式内容区 */
  75. .eleven.wide.column {
  76. background: #fff;
  77. padding: 2rem;
  78. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  79. border-radius: 4px;
  80. }
  81. /* 代码块滚动与样式 */
  82. .pre {
  83. overflow-x: auto;
  84. padding: 1rem;
  85. background: #fafafa;
  86. border-left: 3px solid var(--primary);
  87. margin: 1.5rem 0;
  88. }
  89. /* 顶部菜单去掉死板的灰色,增加一点阴影 */
  90. .ui.top.fixed.menu {
  91. background: #fff;
  92. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  93. }
  94. /* 菜单项内边距更舒适 */
  95. .ui.menu .item {
  96. padding: 0.8rem 1.2rem;
  97. font-size: 1.2rem;
  98. }
  99. /* 移动端:展开动画更顺滑 */
  100. .ui.vertical.menu {
  101. transition: max-height .3s ease-out;
  102. overflow: hidden;
  103. }
  104. .ui.vertical.menu.collapsed {
  105. max-height: 0 !important;
  106. }
  107. .ui.vertical.menu.expanded {
  108. max-height: 500px !important;
  109. }
  110. /* 右侧 Archiv/Top 区域在大屏下保持粘性 */
  111. .four.wide.right.floated.column {
  112. position: sticky;
  113. top: 80px; /* 根据你的导航高度微调 */
  114. max-width: var(--sidebar-width);
  115. margin-left: 2rem;
  116. }
  117. /* 调整归档和标签列表间距 */
  118. .ui.list .item {
  119. padding: .5rem 0;
  120. }
  121. </style>
  122. <style type="text/css">
  123. p > a > img {
  124. width: 100%;
  125. height: 100%;
  126. }
  127. blockquote {
  128. margin: 0;
  129. }
  130. blockquote {
  131. padding: 15px;
  132. background: #eee;
  133. }
  134. blockquote ::before {
  135. content: '\201C';
  136. }
  137. blockquote ::after {
  138. content: '\201D';
  139. }
  140. p {
  141. font-size: 1.2em;
  142. }
  143. body {
  144. padding-top: 54px;
  145. -webkit-font-smoothing: antialiased;
  146. -moz-font-smoothing: grayscale;
  147. }
  148. .ui.borderless.menu {
  149. background-color: #f8f8f8;
  150. {#box-shadow: none;#} flex-wrap: wrap;
  151. border: none;
  152. padding-left: 0;
  153. padding-right: 0;
  154. }
  155. .ui.borderless.menu .header.item {
  156. font-size: 1.2rem;
  157. font-weight: 500;
  158. }
  159. .ui.mobile.only.grid .ui.menu .ui.vertical.menu {
  160. display: none;
  161. }
  162. .ui.mobile.only.grid .ui.vertical.menu .dropdown.icon {
  163. float: unset;
  164. }
  165. .ui.mobile.only.grid .ui.vertical.menu .dropdown.icon:before {
  166. content: "\f0d7";
  167. }
  168. .ui.mobile.only.grid .ui.vertical.menu .ui.dropdown.item .menu {
  169. position: static;
  170. width: 100%;
  171. background-color: unset;
  172. border: none;
  173. box-shadow: none;
  174. }
  175. .ui.mobile.only.grid .ui.vertical.menu .ui.dropdown.item .menu {
  176. margin-top: 6px;
  177. }
  178. .ui.container > .ui.message {
  179. background-color: rga(238, 238, 238);
  180. box-shadow: none;
  181. padding: 5rem 4rem;
  182. margin-top: 1rem;
  183. }
  184. .ui.message h1.ui.header {
  185. font-size: 4.5rem;
  186. }
  187. .ui.message p.lead {
  188. font-size: 1.3rem;
  189. color: #333333;
  190. line-height: 1.4;
  191. font-weight: 300;
  192. }
  193. /* 让编辑器生成的表格始终填满可用宽度 */
  194. #article table {
  195. /* 覆盖 inline style */
  196. width: 100% !important;
  197. max-width: 100% !important;
  198. margin: 1rem 0; /* 上下留白,左右不需要居中 */
  199. border-collapse: collapse;
  200. }
  201. /* 去掉默认 cell 间距 */
  202. #article table {
  203. border-spacing: 0;
  204. }
  205. #article_content {
  206. margin-top: 2rem;
  207. }
  208. /* 头部和单元格:更小的内边距和字体 */
  209. #article table th,
  210. #article table td {
  211. padding: 0.4em 0.5em; /* 紧缩内填充 */
  212. font-size: 0.88rem; /* 略微小一点的文字 */
  213. line-height: 1.3; /* 行高也缩小 */
  214. border: 1px solid #ddd; /* 细线框 */
  215. text-align: left;
  216. vertical-align: middle;
  217. }
  218. /* 表头背景:灰黑主题色 */
  219. #article table th {
  220. background-color: #f5f2f0;
  221. font-weight: 600;
  222. }
  223. /* 斑马条纹 */
  224. #article table tr:nth-child(even) td {
  225. background-color: #f7f7f7;
  226. }
  227. /* 悬停高亮 */
  228. #article table tr:hover td {
  229. background-color: #ececec;
  230. }
  231. /* 更紧凑的响应式调整 */
  232. @media (max-width: 600px) {
  233. #article table th,
  234. #article table td {
  235. padding: 0.25em 0.4em;
  236. font-size: 0.8rem;
  237. }
  238. }
  239. .pre {
  240. background-color: antiquewhite;
  241. border-radius: 4px;
  242. }
  243. /* 保证每个图都有左右和上下间隙 */
  244. #article a[data-pswp-width] {
  245. display: inline-block; /* 让 margin 生效 */
  246. }
  247. /* 如果有 img 没包 <a> 的,也同样 */
  248. #article img {
  249. display: inline-block;
  250. margin: 0.5rem;
  251. max-width: 100%;
  252. height: auto;
  253. }
  254. /* 去除一切过渡,避免闪动 */
  255. #article img,
  256. #article a img {
  257. transition: none !important;
  258. }
  259. #article_content{
  260. font-weight: 500;
  261. }
  262. </style>
  263. </head>
  264. <body id="root">
  265. {% if is_login %}
  266. {% csrf_token %}
  267. {% endif %}
  268. <div class="ui tablet computer only padded grid">
  269. <div class="ui top fixed borderless fluid huge menu">
  270. <div class="ui container">
  271. <a href="/" class="header item ">CyberSicko.net</a>
  272. <a href="/" class="item">主页</a>
  273. {% for item in category %}
  274. {# <li class="category_li"><a href="/category/{{ item.name }}?page=1">{{ item.name }}</a></li>#}
  275. <a class="{% if current_category != None and current_category == item.name %}
  276. active
  277. {% else %}
  278. {% endif %} item" href="/category/{{ item.name }}?page=1">{{ item.name }}</a>
  279. {% endfor %}
  280. <div class="right menu">
  281. <a href="/login" class="item"> <i class="icon share square"></i>
  282. Sign in</a>
  283. </div>
  284. </div>
  285. </div>
  286. </div>
  287. <div class="ui mobile only padded grid">
  288. <div class="ui top fixed borderless huge fluid menu">
  289. <a href="/" class="header item ">CyberSicko.net</a>
  290. <div class="right menu">
  291. <div class="item">
  292. <button class="ui icon toggle basic button">
  293. <i class="content icon"></i>
  294. </button>
  295. </div>
  296. </div>
  297. <div class="ui vertical borderless fluid menu">
  298. <a href="/" class="item">主页</a>
  299. {% for item in category %}
  300. {# <li class="category_li"><a href="/category/{{ item.name }}?page=1">{{ item.name }}</a></li>#}
  301. <a class="{% if current_category != None and current_category == item.name %}
  302. active
  303. {% else %}
  304. {% endif %} item" href="/category/{{ item.name }}?page=1">{{ item.name }}</a>
  305. {% endfor %}
  306. <a href="/login" class="item"> <i class="icon share square"></i>
  307. Sign in</a>
  308. </div>
  309. </div>
  310. </div>
  311. <div class="ui grid stackable container">
  312. <div class="row" id="article">
  313. <div style="padding-left: 3rem;padding-right: 3rem" class="eleven wide column">
  314. <h1 class="ui large header">
  315. <div class="content">{{ article.title }}</div>
  316. </h1>
  317. <div class="ui comments" style="margin-top: 0">
  318. <div class="comment">
  319. <a class="avatar">
  320. <img src="/user_avatar/{{ article.user_id }}">
  321. </a>
  322. <div class="content">
  323. <a class="author">{{ article.user__first_name }}{{ article.user__last_name }}</a>
  324. <div class="metadata">
  325. <div class="date">发布于: {{ article.created_time|days_until }}</div> {% if is_login %}
  326. <a style="font-style: italic; color: #0d6678" target="_blank"
  327. href="/management/article/to_edit/{{ article.id }}">编辑</a>
  328. {% endif %}
  329. </div>
  330. <div class="text">hava a nice day.</div>
  331. </div>
  332. </div>
  333. </div>
  334. <div id="article_content">
  335. {% autoescape off %}
  336. {{ article.html_text }}
  337. {% endautoescape %}
  338. </div>
  339. <h3 class="ui dividing header" style="margin-top: 10vh">评论</h3>
  340. <div class="ui comments">
  341. {% if comments|length <= 0 %}
  342. <p style="text-align: center;font-style: italic">还没有评论</p>
  343. {% endif %}
  344. {% for comment in comments %}
  345. <div class="comment">
  346. <a class="avatar">
  347. <img src="{{ comment.avatar | get_avatar }}">
  348. </a>
  349. <div class="content">
  350. <a target="_blank" href="{{ comment.website }}" class="author">{{ comment.nick_name }}</a>
  351. <div class="text">{{ comment.comment }}</div>
  352. <div class="actions">
  353. <a href="mailto:{{ comment.email }}"> <i class="mail icon"></i>联系他</a>
  354. <a>
  355. <i class="time icon"></i>
  356. {{ comment.created_time | days_until }}
  357. </a>
  358. </div>
  359. </div>
  360. </div>
  361. {% endfor %}
  362. </div>
  363. <form method="post" action="/comment/add" id="comment_form" style="margin-top: 10px"
  364. class="ui form">
  365. {% csrf_token %}
  366. <input hidden="hidden" name="article_id" value="{{ article.id }}">
  367. <input hidden="hidden" name="article_title" value="{{ article.title }}">
  368. <h4 class="ui dividing header">发表评论</h4>
  369. <input id="veryCode" type="text" name="veryCode" hidden="hidden">
  370. <div class="field">
  371. <div class="two fields">
  372. <div class="field">
  373. <label>昵称<span style="color: red">*</span></label>
  374. <input id="nick_name" type="text" name="nick_name" placeholder="昵称">
  375. </div>
  376. <div class="field">
  377. <label>Email<span style="color: red">*</span></label>
  378. <input id="email" type="email" name="email" placeholder="Email">
  379. </div>
  380. </div>
  381. </div>
  382. <div class="field">
  383. <div class="two fields">
  384. <div class="twelve wide field">
  385. <label>网站(可不填)</label>
  386. <input id="website" type="url" name="website" placeholder="网站">
  387. </div>
  388. <div class="four wide field">
  389. <label>头像<span style="color: red">*</span></label>
  390. <div class="ui fluid selection dropdown">
  391. <input value="jenny" type="hidden" name="avatar">
  392. <i class="dropdown icon"></i>
  393. <div class="default text">
  394. Jenny Hess
  395. </div>
  396. <div class="menu">
  397. <div class="item" data-value="jenny">
  398. <img class="ui mini avatar image"
  399. src="https://semantic-ui.com/images/avatar/small/jenny.jpg">
  400. Jenny Hess
  401. </div>
  402. <div class="item" data-value="elliot">
  403. <img class="ui mini avatar image"
  404. src="https://semantic-ui.com/images/avatar/small/elliot.jpg">
  405. Elliot Fu
  406. </div>
  407. <div class="item" data-value="stevie">
  408. <img class="ui mini avatar image"
  409. src="https://semantic-ui.com/images/avatar/small/stevie.jpg">
  410. Stevie Feliciano
  411. </div>
  412. <div class="item" data-value="christian">
  413. <img class="ui mini avatar image"
  414. src="https://semantic-ui.com/images/avatar/small/christian.jpg">
  415. Christian
  416. </div>
  417. <div class="item" data-value="matt">
  418. <img class="ui mini avatar image"
  419. src="https://semantic-ui.com/images/avatar/small/matt.jpg">
  420. Matt
  421. </div>
  422. <div class="item" data-value="justen">
  423. <img class="ui mini avatar image"
  424. src="https://semantic-ui.com/images/avatar/small/justen.jpg">
  425. Justen Kitsune
  426. </div>
  427. </div>
  428. </div>
  429. </div>
  430. </div>
  431. </div>
  432. <div class="field">
  433. <textarea name="comment" placeholder="评论"></textarea>
  434. </div>
  435. <div style="color: red">{{ msg }}</div>
  436. <button class="ui blue labeled submit icon button">
  437. <i class="icon edit"></i> 提交
  438. </button>
  439. </form>
  440. <div class="ui hidden divider"></div>
  441. </div>
  442. <div class="four wide right floated column">
  443. <h4 class="ui header">搜索</h4>
  444. <div id="search" class="ui category search">
  445. <div class="ui icon input">
  446. <input class="prompt" type="text" placeholder="搜索">
  447. <i class="search icon"></i>
  448. </div>
  449. </div>
  450. <h4 class="ui header">归档</h4>
  451. <div class="ui list">
  452. {% for record in records %}
  453. <a class="item" href="/date/{{ record.datetime }}?page=1">{{ record.datetime }}
  454. ({{ record.count }})</a>
  455. {% endfor %}
  456. </div>
  457. <h4 class="ui header">Top</h4>
  458. <div class="ui list">
  459. {% for tag in tags %}
  460. <a class="item" href="/tag/{{ tag.name }}?page=1">{{ tag.name }} ({{ tag.count }})</a>
  461. {% endfor %}
  462. </div>
  463. </div>
  464. </div>
  465. </div>
  466. <div class="ui mini test modal">
  467. <div class="header">
  468. 请输入验证码
  469. </div>
  470. <div class="content">
  471. <p id="veryCodeSet"></p>
  472. <div class="ui input">
  473. <input id="veryCodeInput" type="text" placeholder="请输入验证码">
  474. </div>
  475. </div>
  476. <div class="actions">
  477. <a onclick="submitComment()" id="confirmBtn" class="ui positive right labeled icon button">
  478. 确认
  479. <i class="checkmark icon"></i>
  480. </a>
  481. </div>
  482. </div>
  483. <footer style="margin-top: 50px" class="ui secondary segment">
  484. <div class="ui two column stackable grid">
  485. <div class="ten wide column">
  486. <img style="width: 8rem" src="{% static '/img.png' %}">
  487. <p> © 2023 - 2023 cybersicko.net - All Rights Reserved.</p>
  488. </div>
  489. <div class="six wide column">
  490. <div class="ui left aligned container" style="margin-top:10px">
  491. <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=50019002503732"
  492. style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img
  493. src="{% static '/备案图标.png' %}" style="float:left;"/>
  494. <p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;"> 渝公网安备
  495. 50019002503732号</p></a>
  496. <a rel="nofollow"
  497. href="http://beian.miit.gov.cn/publish/query/indexFirst.action"
  498. target="_blank"><p>皖ICP备2023011943号</p></a>
  499. </div>
  500. </div>
  501. </div>
  502. </footer>
  503. <script type="application/javascript" src="{% static 'js/jquery.min.js' %}"></script>
  504. <script type="application/javascript" src="{% static 'semantic.js' %}"></script>
  505. <script src="{% static 'highlightjs/highlight.min.js' %}"></script>
  506. <script type="application/javascript" src="{% static 'photoswipe/photoswipe.umd.min.js' %}"></script>
  507. <script type="application/javascript" src="{% static 'photoswipe/photoswipe-lightbox.umd.min.js' %}"></script>
  508. <script>
  509. restoreComment()
  510. function restoreComment() {
  511. if (localStorage.getItem('nick_name') !== undefined && localStorage.getItem('nick_name') !== '') {
  512. $("#nick_name").val(localStorage.getItem('nick_name'))
  513. }
  514. if (localStorage.getItem('email') !== undefined && localStorage.getItem('email') !== '') {
  515. $("#email").val(localStorage.getItem('email'))
  516. }
  517. if (localStorage.getItem('website') !== undefined && localStorage.getItem('website') !== '') {
  518. $("#website").val(localStorage.getItem('website'))
  519. }
  520. }
  521. function submitComment() {
  522. var veryCodeInput = $("#veryCodeInput").val()
  523. $("#veryCode").attr("value", veryCodeInput)
  524. document.getElementById("comment_form").submit()
  525. }
  526. document.getElementById("comment_form").addEventListener("submit", function (event) {
  527. event.preventDefault(); // 阻止表单提交
  528. // 表单验证逻辑
  529. var veryCode = $('#veryCode').val()
  530. if (veryCode === undefined || veryCode === '') {
  531. getVeryCode()
  532. return
  533. }
  534. var data = $('#comment_form').serializeArray();
  535. localStorage.setItem('nick_name', $('#nick_name').val())
  536. localStorage.setItem('email', $('#email').val())
  537. localStorage.setItem('website', $('#website').val())
  538. return true
  539. // 其他处理逻辑
  540. });
  541. </script>
  542. <script>
  543. function getVeryCode() {
  544. $.ajax('/comment/getVeryCode', {
  545. method: 'get',
  546. contentType: false,
  547. processData: false,
  548. success: function (res) {
  549. $('.mini.modal').modal('show')
  550. $("#veryCodeSet").html("请输入数字: " + res.data)
  551. },
  552. error: function (err) {
  553. }
  554. })
  555. }
  556. $(document).ready(function () {
  557. $(".ui.toggle.button").click(function () {
  558. $(".mobile.only.grid .ui.vertical.menu").toggle(100);
  559. });
  560. $(".ui.dropdown").dropdown();
  561. });
  562. function getClass(width) {
  563. if (width > 35 && width < 150) {
  564. return 'ui small rounded image'
  565. } else if (width > 150 && width < 800) {
  566. return 'ui medium rounded image'
  567. } else if (width > 800) {
  568. return 'ui fluid rounded image'
  569. }
  570. }
  571. $(function () {
  572. // 选中你文章区里的所有图片
  573. $('#article img').each(function () {
  574. const $img = $(this);
  575. const src = $img.attr('src');
  576. const alt = $img.attr('alt') || '';
  577. // 如果 alt 是 “宽,高” 格式
  578. let w, h;
  579. if (/,/.test(alt)) {
  580. [w, h] = alt.split(',').map(x => x.trim());
  581. // 在 img 外包一层 <a>
  582. $img.wrap(`
  583. <a
  584. href="${src}"
  585. data-pswp-width="${w}"
  586. data-pswp-height="${h}"
  587. ></a>
  588. `);
  589. // 再给 img 补属性
  590. $img
  591. .css('display', 'inline-block')
  592. .addClass(getClass(w)) // 你原来的那段 class 逻辑
  593. .attr({
  594. width: w,
  595. height: h,
  596. 'data-magnify': 'gallery',
  597. 'data-src': src,
  598. 'data-href': src
  599. });
  600. } else {
  601. // 没有 alt,就只加个样式,不包 a
  602. $img
  603. .css('display', 'inline-block')
  604. .addClass('ui fluid rounded image');
  605. }
  606. });
  607. // 然后初始化 PhotoSwipeLightbox,gallery 指向包了 a 的容器
  608. const lightbox = new PhotoSwipeLightbox({
  609. gallery: '#article', // 或者 'p' 也行,但 #article 更保险
  610. children: 'a[data-pswp-width]',// 只选那些有宽高 data 的 a
  611. pswpModule: PhotoSwipe
  612. });
  613. lightbox.init();
  614. });
  615. </script>
  616. <script>
  617. hljs.initHighlightingOnLoad();
  618. </script>
  619. </body>
  620. </html>