Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release new version #332

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ body:
I made sure I checked
我确认我已经检查过了
options:
- label: I am using Keep version `4.1.3` or later. (使用 Keep `4.1.3` 或更高版本)
- label: I am using Keep version `4.1.4` or later. (使用 Keep `4.1.4` 或更高版本)
required: true
- label: I have already read the [Troubleshooting page of Hexo](https://hexo.io/docs/troubleshooting) and [Keep documents](https://keep-docs.xpoet.cn). (已阅读 [Hexo 故障处理页面](https://hexo.io/docs/troubleshooting) 和 [Keep 文档](https://keep-docs.xpoet.cn))
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ body:
I made sure I checked
我确认我已经检查过了
options:
- label: I am using Keep version `4.1.3` or later. (使用 Keep `4.1.3` 或更高版本)
- label: I am using Keep version `4.1.4` or later. (使用 Keep `4.1.4` 或更高版本)
required: true
- label: I have already read the [Troubleshooting page of Hexo](https://hexo.io/docs/troubleshooting) and [Keep documents](https://keep-docs.xpoet.cn). (已阅读 [Hexo 故障处理页面](https://hexo.io/docs/troubleshooting) 和 [Keep 文档](https://keep-docs.xpoet.cn))
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/other.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ body:
I made sure I checked
我确认我已经检查过了
options:
- label: I am using Keep version `4.1.3` or later. (使用 Keep `4.1.3` 或更高版本)
- label: I am using Keep version `4.1.4` or later. (使用 Keep `4.1.4` 或更高版本)
required: true
- label: I have already read the [Troubleshooting page of Hexo](https://hexo.io/docs/troubleshooting) and [Keep documents](https://keep-docs.xpoet.cn). (已阅读 [Hexo 故障处理页面](https://hexo.io/docs/troubleshooting) 和 [Keep 文档](https://keep-docs.xpoet.cn))
required: true
Expand Down
3 changes: 3 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ comment:
404:
page_not_found: Page Not Found
go_home: Take me home
encryption:
excerpt: 🔒 The post has been encrypted, please enter the password to view it.
input_password: Please enter password ...
3 changes: 3 additions & 0 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ comment:
404:
page_not_found: 页面找不到
go_home: 前往首页
encryption:
excerpt: 🔒 文章已加密,请在输入密码后查看。
input_password: 请输入密码...
3 changes: 3 additions & 0 deletions languages/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ comment:
404:
page_not_found: 頁面缺失
go_home: 前往首頁
encryption:
excerpt: 🔒 文章已加密,請在輸入密碼後查看。
input_password: 請輸入密碼...
6 changes: 3 additions & 3 deletions layout/_page/home.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
</h3>

<div class="home-post-content keep-markdown-body">
<% if (post.excerpt) { %>
<%- post.excerpt %>
<% if (post?.password) { %>
<%= __('encryption.excerpt') %>
<% } else { %>
<%- truncate(strip_html(post.content), { length: 128 }) %>
<%- post?.excerpt || truncate(strip_html(post.content), { length: 128 }) %>
<% } %>
</div>

Expand Down
17 changes: 15 additions & 2 deletions layout/_page/post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const post_avatar = page?.avatar || theme?.base_info?.avatar
const is_code_block_unshrink = page?.code_block_shrink === false
%>
<div class="fade-in-down-animation">
<div class="post-page-container border-box">
<div class="post-page-container border-box<%= page?.password ? ' encrypt' : '' %>">
<div class="post-content-container border-box">
<% if (page?.post_cover || page?.home_cover) { %>
<div class="post-content-top border-box"
Expand Down Expand Up @@ -61,8 +61,21 @@ const is_code_block_unshrink = page?.code_block_shrink === false
</div>
<% } %>

<%- page.content %>
<% if (page?.password) { %>
<div class="post-encrypt-box border-box"
data-secret="<%= page.secretKey %>"
data-iv="<%= page.iv %>"
data-ep="<%= page.encryptedPassword %>"
data-content="<%= page.encryptedContent %>"
>
<input type="password" class="password-input border-box" placeholder="<%- __('encryption.input_password') %>">
</div>
<div class="post"></div>
<% } else { %>
<%- page.content %>
<% } %>
</div>

<% if (
(
theme?.post?.copyright_info === true
Expand Down
10 changes: 9 additions & 1 deletion layout/_partial/post/post-tools.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<div class="post-tools-container border-box">
<ul class="tools-list border-box">
<ul class="post-tools-list border-box">
<!-- PC encrypt again -->
<% if (page?.password) { %>
<li class="tools-item flex-center post-lock">
<i class="fa-solid fa-lock"></i>
<i class="fa-solid fa-lock-open"></i>
</li>
<% } %>

<!-- PC TOC show toggle -->
<% if (page?.toc !== false && theme?.toc?.enable === true) { %>
<li class="tools-item flex-center toggle-show-toc">
Expand Down
3 changes: 1 addition & 2 deletions layout/_partial/toc.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<div class="post-toc-wrap border-box">
<div class="post-toc border-box">
<!-- use hexo-blog-encrypt -->
<%- toc(
page?.encrypt === true ? page.origin : page.content,
page.content,
{
class: 'nav',
list_number: theme?.toc?.number || false
Expand Down
30 changes: 30 additions & 0 deletions scripts/filters/encrypt-handle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* global hexo */

'use strict'

const crypto = require('crypto')

function encrypt(text, key, iv) {
const algorithm = 'aes-256-cbc'
const cipher = crypto.createCipheriv(algorithm, Buffer.from(key, 'hex'), Buffer.from(iv, 'hex'))
let encrypted = cipher.update(text, 'utf8', 'hex')
encrypted += cipher.final('hex')
return encrypted
}

hexo.extend.filter.register(
'after_post_render',
function (data) {
let { password } = data
password = String(password).trim()
if (password) {
const secretKey = crypto.randomBytes(32).toString('hex') // 256-bit
const iv = crypto.randomBytes(16).toString('hex') // 128-bit
data.secretKey = secretKey
data.iv = iv
data.encryptedPassword = encrypt(password, secretKey, iv)
data.encryptedContent = encrypt(data.content, secretKey, iv)
}
},
1
)
14 changes: 8 additions & 6 deletions source/css/common/code-block/code-theme.styl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ if (hexo-config('code_block') && hexo-config('code_block.highlight_theme') == 'o
$highlight-aqua = #458383
$highlight-blue = #6e95bd
$highlight-purple = #b18bb7
$highlight-deletion = #ff9999
$highlight-addition = #ccff99
$highlight-deletion = #f39090
$highlight-addition = #7ccf26
$shrink-line-foreground = $dark-text-color-4
$shrink-line-background-1 = rgba(40, 40, 40, 0.9)
$shrink-line-background-2 = rgba(40, 40, 40, 0.6)
Expand All @@ -48,8 +48,8 @@ if (hexo-config('code_block') && hexo-config('code_block.highlight_theme') == 'o
$dark-highlight-aqua = darken($highlight-aqua, 2%)
$dark-highlight-blue = darken($highlight-blue, 2%)
$dark-highlight-purple = darken($highlight-purple, 2%)
$dark-highlight-deletion = darken($highlight-deletion, 2%)
$dark-highlight-addition = darken($highlight-addition, 2%)
$dark-highlight-deletion = darken($highlight-deletion, 20%)
$dark-highlight-addition = darken($highlight-addition, 20%)
$dark-shrink-line-foreground = $dark-text-color-4
$dark-shrink-line-background-1 = rgba(40, 40, 40, 0.9)
$dark-shrink-line-background-2 = rgba(40, 40, 40, 0.6)
Expand Down Expand Up @@ -90,8 +90,8 @@ else {
$dark-highlight-aqua = #8abeb7
$dark-highlight-blue = #81a2be
$dark-highlight-purple = #b294bb
$dark-highlight-deletion = #008000
$dark-highlight-addition = #800000
$dark-highlight-addition = darken($highlight-addition, 80%)
$dark-highlight-deletion = darken($highlight-deletion, 75%)
$dark-shrink-line-foreground = $dark-text-color-4
$dark-shrink-line-background-1 = rgba(38, 38, 38, 0.9)
$dark-shrink-line-background-2 = rgba(52, 52, 52, 0.6)
Expand All @@ -114,6 +114,8 @@ code-theme(mode) {
--highlight-aqua mode == 'light' ? $highlight-aqua : $dark-highlight-aqua
--highlight-blue mode == 'light' ? $highlight-blue : $dark-highlight-blue
--highlight-purple mode == 'light' ? $highlight-purple : $dark-highlight-purple
--highlight-deletion mode == 'light' ? $highlight-deletion : $dark-highlight-deletion
--highlight-addition mode == 'light' ? $highlight-addition : $dark-highlight-addition
--highlight-gutter-color mode == 'light' ? $highlight-gutter-color : $dark-highlight-gutter-color
--highlight-gutter-bg-color mode == 'light' ? $highlight-gutter-bg-color : $dark-highlight-gutter-bg-color
--mac-toolbar-background-color mode == 'light' ? $mac-toolbar-background-color : $dark-mac-toolbar-background-color
Expand Down
2 changes: 2 additions & 0 deletions source/css/common/code-block/highlight.styl
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ pre {


pre .deletion {
color var(--highlight-foreground)
background var(--highlight-deletion)
}


pre .addition {
color var(--highlight-foreground)
background var(--highlight-addition)
}

Expand Down
3 changes: 2 additions & 1 deletion source/css/common/markdown.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.keep-markdown-body {
.keep-markdown-body
.keep-markdown-body > .post {
font-size 1rem

blockquote {
Expand Down
70 changes: 41 additions & 29 deletions source/css/layout/_page/post.styl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ $spacer-padding = 2rem
}


&.encrypt {
.post-aging-tips {
display none !important
}
}


+keep-tablet() {
.pc-post-toc {
display none !important
Expand Down Expand Up @@ -266,6 +273,40 @@ $spacer-padding = 2rem
}


.post-encrypt-box {
margin-left $avatar-width + 0.8rem
padding 1rem 0

.password-input {
width 20rem
margin 0
padding 0.8rem 1.2rem
color var(--text-color-3)
font-weight 400 !important
font-size 1.2rem
letter-spacing 2px
background none
border none
border-bottom 0.2rem solid var(--border-color)
outline none

&.error {
border 0.2rem solid var(--keep-danger-color)
}

&::placeholder {
color var(--text-color-4)
font-size 1.1rem
letter-spacing 1px
}

&:hover
&:focus {
background var(--background-color-2)
}
}
}

if (hexo-config('post') && hexo-config('post.copyright_info') == true) {
border-bottom 2px dashed var(--border-color)
}
Expand Down Expand Up @@ -402,33 +443,4 @@ $spacer-padding = 2rem
max-height calc(100vh - calc(var(--header-shrink-height) + var(--component-gap)))
}
}


.hbe-container {

.hbe-input-field {
color var(--text-color-3) !important
background var(--background-color-3) !important
}


.hbe-input-label {
&::before {
display none !important
}

&::after {
background var(--text-color-4) !important
}

.hbe-input-label-content {
color var(--text-color-4) !important
}
}


.hbe-button {
margin-top 2rem
}
}
}
11 changes: 6 additions & 5 deletions source/css/layout/_partial/archive-list.styl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $post-title-font-size = 1.2rem
$post-date-font-size = 1rem
$post-date-width = 3.6rem
$post-item-padding = 1.2rem
$timeline-circle-width = 0.6rem
$timeline-circle-size = 0.5rem

.archive-list-container {

Expand Down Expand Up @@ -68,10 +68,10 @@ $timeline-circle-width = 0.6rem
left 0
z-index $z-index-2
box-sizing border-box
width $timeline-circle-width * 0.8
height $timeline-circle-width * 2
width $timeline-circle-size
height $timeline-circle-size
background var(--text-color-5)
border-radius 0.2rem
border-radius 50%
content ''
transition-t("height", "0", "0.2", "ease")
}
Expand All @@ -81,7 +81,8 @@ $timeline-circle-width = 0.6rem
&:hover {
.starting-point {
&::before {
height $timeline-circle-width * 2.4
width $timeline-circle-size * 1.2
height $timeline-circle-size * 1.2
background var(--text-color-4)
}
}
Expand Down
29 changes: 27 additions & 2 deletions source/css/layout/_partial/post/post-tools.styl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $post-tool-button-width = 2.5rem
.post-tools-container {
padding-top var(--component-gap)

.tools-list {
.post-tools-list {

li {
position relative
Expand Down Expand Up @@ -33,7 +33,7 @@ $post-tool-button-width = 2.5rem
background var(--primary-color)

i {
color var(--background-color-1)
color var(--background-color-1) !important
}
}

Expand Down Expand Up @@ -70,6 +70,31 @@ $post-tool-button-width = 2.5rem
}
}
}

&.post-lock {
cursor default

.fa-lock-open {
display none
color var(--keep-success-color)
}

.fa-lock {
color var(--keep-warning-color)
}

&.decrypt {
cursor pointer

.fa-lock-open {
display block
}

.fa-lock {
display none
}
}
}
}
}
}
4 changes: 4 additions & 0 deletions source/js/lazyload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* global KEEP */

KEEP.initLazyLoad = () => {
if (KEEP?.theme_config?.lazyload?.enable !== true) {
return
}

const imgs = document.querySelectorAll('img')
let now = Date.now()
let needLoad = true
Expand Down
Loading
Loading