Pages

Thursday, 8 June 2017

基于perl的静态网站生成器:App-PFT

登录linux vps,
通常linux vps都自带了perl环境。而且存在可执行文件cpan, /usr/bin/cpan.

运行cpan App::PFT
会显示:
...
Installing /usr/local/bin/pft-init
Installing /usr/local/bin/pft-edit
Installing /usr/local/bin/pft-pub
Installing /usr/local/bin/pft
Installing /usr/local/bin/pft-make
Installing /usr/local/bin/pft-ls
Installing /usr/local/bin/pft-clean
Installing /usr/local/bin/pft-show
Installing /usr/local/bin/pft-grab

Appending installation info to /usr/local/lib/x86_64-linux-gnu/perl/5.22.1/perllocal.pod

这样App-PFT就安装成功了。

cd /usr/local
mkdir app-pft-site
cd app-pft-site

root@AR:/usr/local/app-pft-site# pft-init
root@AR:/usr/local/app-pft-site# ls
content  inject  pft.yaml  templates
root@AR:/usr/local/app-pft-site# pft-make
(此即生成/更新静态网站的根目录的命令)
root@AR:/usr/local/app-pft-site# ls
build  content  inject  pft.yaml  templates
(生成了build目录)
root@AR:/usr/local/app-pft-site#  cd build
root@AR:/usr/local/app-pft-site/build# ls
index.html  pages
root@AR:/usr/local/app-pft-site/build#
(可见/usr/local/app-pft-site/build就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/app-pft-site/build# cd ..
root@AR:/usr/local/app-pft-site# ls
build  content  inject  pft.yaml  templates
root@AR:/usr/local/app-pft-site# cd content
root@AR:/usr/local/app-pft-site/content# ls
attachments  blog  pages  pics  tags
root@AR:/usr/local/app-pft-site/content# cd pages
root@AR:/usr/local/app-pft-site/content/pages# ls
welcome
root@AR:/usr/local/app-pft-site/content/pages# cp welcome test-1
root@AR:/usr/local/app-pft-site/content/pages# nano test-1
root@AR:/usr/local/app-pft-site/content/pages# cat test-1
---
Author: root
Date: 2017-06-08
Options:
  hide: 0
  template: ~
Slug: test-1
Tags: misc
Title: 测试1
---

这是测试1.

看看如何?

root@AR:/usr/local/app-pft-site/content/pages# cd ../..
root@AR:/usr/local/app-pft-site# pft-make

在上面新建源页面/源帖时,还可这样做:
root@AR:/usr/local/app-pft-site# nano pft.yaml
(把editor的值改为'nano %s' )
root@AR:/usr/local/app-pft-site# pft-edit -P test-4
(把Title的值改为中文标题。在第二个“---"的下面,空一行,写内容。保存文件。这样, 新建源页面成功)
root@AR:/usr/local/app-pft-site# pft-edit -B how-is-it
(把Title的值改为中文标题。在第二个“---"的下面,空一行,写内容。保存文件。这样, 新建源帖成功)
root@AR:/usr/local/app-pft-site# pft-make


演示网站:http://pft-site.smt.biz.st/ (搭建在我的openvz vps上)
http://pft-site2.smt.biz.st,(搭建在我的kvm vps上)
http://pft-site.smt.biz.st/blog/2017-06.html (全部帖子)
项目地址:
AnnoCPAN, Annotated CPAN documentation
    http://annocpan.org/dist/App-PFT
Search CPAN
    http://search.cpan.org/dist/App-PFT/ 
https://github.com/dacav/App-PFT
https://github.com/dacav/App-PFT/issues/2
https://github.com/dacav/App-PFT/issues/3
(相关帖子:http://briteming.blogspot.com/2014/06/linux-vpsperl5140.html,
升级linux vps自带的perl的版本到5.22.1版)


注:
如果运行cpan App::PFT后,
没有显示:
...
Installing /usr/local/bin/pft-init
Installing /usr/local/bin/pft-edit
Installing /usr/local/bin/pft-pub
Installing /usr/local/bin/pft
Installing /usr/local/bin/pft-make
Installing /usr/local/bin/pft-ls
Installing /usr/local/bin/pft-clean
Installing /usr/local/bin/pft-show
Installing /usr/local/bin/pft-grab


解决办法: cpan -f -i App::PFT

No comments:

Post a Comment