Total Pageviews

Sunday 3 November 2024

基于python3的静态博客程序purepress

 

root@racknerd-626f077:~# pip3 install purepress
root@racknerd-626f077:~# purepress -h
Usage: purepress [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  build    Build the site.
  init     Initialize an instance.
root@racknerd-626f077:~# mkdir /usr/local/purepress-site
root@racknerd-626f077:~# cd /usr/local/purepress-site
root@racknerd-626f077:/usr/local/purepress-site# purepress init
Creating folders...OK
Creating default purepress.toml...OK
Createing demo page...OK
Createing demo post...OK
OK! Now you can install a theme and preview the site.
root@racknerd-626f077:/usr/local/purepress-site# ls
pages  posts  purepress.toml  raw  static
root@racknerd-626f077:/usr/local/purepress-site# git clone https://github.com/verilab/purepress-theme-minimal theme

root@racknerd-626f077:/usr/local/purepress-site# purepress build

显示:

Please enter the url root (used as prefix of generated url): /
Creating build folder...OK
Copying raw files...OK
Copying theme static files...OK
Copying static files...OK
Building custom pages...OK
Building posts...OK
Building categories...OK
Building tags...OK
Building archive...OK
Building index...OK
Building feed...OK
Building 404...OK
OK! Now you can find the built site in the "build" folder.
root@racknerd-626f077:/usr/local/purepress-site# cd build

root@racknerd-626f077:/usr/local/purepress-site/build# python3 -m http.server 1234

访问vps-ip:1234,即可看到静态网站的效果。

新建源帖:

root@racknerd-626f077:/usr/local/purepress-site# cd posts

root@racknerd-626f077:/usr/local/purepress-site/posts# nano 2024-11-02-hf.md 

root@racknerd-626f077:/usr/local/purepress-site/posts# cat 2024-11-02-hf.md

显示:

---
title: 快乐的节日
date: 2024-11-02 12:10:00
---
 

此处写正文或html codes.

root@racknerd-626f077:/usr/local/purepress-site/posts# cd ..
root@racknerd-626f077:/usr/local/purepress-site# purepress build

演示网站:

 http://pp.briten.top/

https://zippy-tiramisu-7dc686.netlify.app/

项目地址: 

https://github.com/verilab/purepress

https://github.com/verilab/purepress-theme-minimal 

-----------------------------------------------------------------

上面这个theme不好用,此处用另一个theme:

https://github.com/verilab/purepress-theme-default

root@racknerd-626f077:~# mkdir /usr/local/purepress-site-2
root@racknerd-626f077:~# cd /usr/local/purepress-site-2
root@racknerd-626f077:/usr/local/purepress-site-2# purepress init

 root@racknerd-626f077:/usr/local/purepress-site-2# git clone https://github.com/verilab/purepress-theme-default theme

root@racknerd-626f077:/usr/local/purepress-site-2# purepress build

显示:

Please enter the url root (used as prefix of generated url): /
The url root does not contain a valid server name, "localhost" will be used.
Creating build folder...OK
Copying raw files...OK
Copying theme static files...OK
Copying static files...OK
Building custom pages...OK
Building posts...OK
Building categories...OK
Building tags...OK
Building archive...OK
Building index...OK
Building feed...OK
Building 404...OK
OK! Now you can find the built site in the "build" folder.
root@racknerd-626f077:/usr/local/purepress-site-2# ls
build  pages  posts  purepress.toml  raw  static  theme
root@racknerd-626f077:/usr/local/purepress-site-2# cd build
root@racknerd-626f077:/usr/local/purepress-site-2/build# python3 -m http.server 2346
访问vps-ip:2346,即可看到静态网站的效果。

新建源帖:

root@racknerd-626f077:/usr/local/purepress-site-2# cd posts

root@racknerd-626f077:/usr/local/purepress-site-2/posts# nano 2024-11-02-hf.md 

root@racknerd-626f077:/usr/local/purepress-site-2/posts# cat 2024-11-02-hf.md

显示:

---
title: 快乐的节日
date: 2024-11-02 12:10:00
---
 

此处写正文或html codes.

root@racknerd-626f077:/usr/local/purepress-site-2/posts# cd ..
root@racknerd-626f077:/usr/local/purepress-site-2# purepress build

演示网站:

https://courageous-cheesecake-064de3.netlify.app/

项目地址: 

https://github.com/verilab/purepress

 https://github.com/verilab/purepress-theme-default

-------------------------------------------

注意:最好在virtualenv环境里操作,否则容易遇到错误。 

搭建virtualenv的方法:

pip3 install virtualenv

virtualen dev (此命令会在当前目录下,生成dev目录)

cd dev

source bin/activate (这样就激活了virtualenv环境)


 

 

 

No comments:

Post a Comment