linux中国归档站-Linuxcat

想了很久也没有想出来该怎么写开头2333333
在我看到这篇文章后,我便想要将Linux中国的文章保留下来并渲染成我喜欢的主题,于是就有了linuxcat.top

Linuxcat

Linuxcat使用Hexo的fluid主题渲染,预计将至少提供50年的正常访问

过程

渲染Linuxcat的过程极其烦人,windows的最大打开文件数使我无法再windows上进行渲染

User interface objects support only one handle per object. Processes cannot inherit or duplicate handles to user objects. Processes in one session cannot reference a user handle in another session.
There is a theoretical limit of 65,536 user handles per session. However, the maximum number of user handles that can be opened per session is usually lower, since it is affected by available memory. There is also a default per-process limit of user handles. To change this limit, set the following registry value:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\USERProcessHandleQuota
This value can be set to a number between 200 and 18,000.

Linuxcat使用149kf渲染大约用了15分钟,加上传文件和删删改改耗费了近一天的时间。(Linuxcat完整的索引文件高达200M)
当然这个域名上我还解析了一堆乱起八糟的东西()

修改数据

头图和大图

1
2
3
4
# 开启bash扩展功能globstar,使得**能匹配任意级目录下的文件
shopt -s globstar
sed 's|largepic|banner_img|g' -i **/*.md
sed 's|pic|index_img|g' -i **/*.md

如果没有头图:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import re

def replace_content(dir_path):
for root, dirs, files in os.walk(dir_path):
for file in files:
if file.endswith('.md'):
file_path = os.path.join(root, file)

with open(file_path, 'r+', encoding='utf-8') as f:
content = f.read()

# 查找并提取 banner_img 后面的内容
match_banner = re.search(r'banner_img:\s*(.*)', content, re.IGNORECASE | re.MULTILINE)
if match_banner:
banner_img = match_banner.group(1).strip() # 去除两边空白字符

# 查找并替换 index_img 后面的内容
match_index = re.search(r'index_img:\s*(.*)', content, re.IGNORECASE | re.MULTILINE)
if match_index and 'islctt: false' in content:
new_content = re.sub(r'index_img:\s*.*?\n', f'index_img: {banner_img}\n', content, flags=re.IGNORECASE | re.MULTILINE)

# 替换文件内容
f.seek(0)
f.truncate()
f.write(new_content)

# 调用函数,指定要遍历的目录
replace_content('_posts')

如果渲染是出现Error: EMFILE, too many open files报错,执行

1
ulimit -n 10000

如果还报错就把这个数改大点

有趣的发现

在渲染Linux中国数据集的过程中,由于Linux中国文章时间跨度极大,不难发现一些有趣的东西

人工智能

打开标签 - AI - Linuxcat,Linux中国共编写了347篇与AI相关的文章,最早的一篇在2016年
2017年共3篇,2018年5篇,2019年共4篇,2020年共10篇,2021年共34篇,2022年共81篇,2023年共187篇
2024年1月共22篇(约为2023年平均篇数的141.2%)
由此可以看出,人工智能的发展并不是突然暴起的,而是循序渐进的,若按照2023年的增速,2024年Linux中国可能会有超过300篇有关AI的文章

参考资料

User Objects - Win32 apps | Microsoft Learn
Home · Linux-CN/archive Wiki (github.com)

在此感谢Linux中国的全体贡献者,感谢他们创作/翻译了这么多优质的内容,感谢他们为中文开源社区做出的贡献


linux中国归档站-Linuxcat
https://mmeiblog.cn/linuxcn.html
作者
mei
发布于
2024年2月25日
许可协议