swg-一个静态网站生成器

swg的Python项目详细描述


Simone Margaritelli版权所有evilsocket@gmail.com>;

什么是SWG?

swg是新一代的静态网站生成器,以mako(http://www.makotemplates.org/)模板系统为特色,源于 既有性能又有“web 2.0”的内容和能力。

给定一组文件,每个页面/文章一个,每个作者一个,类别hyerarchy一个,swg将读取配置文件 您从命令行指定并生成一个完整的静态网站,带有标签和类别索引。

安装

要获取最新版本:

pip install swg

创建新网站

要创建新网站,请键入:

swg --create website-folder-name

将在“网站文件夹名称”目录内创建具有基本结构的示例网站。 然后您可以键入:

cd website-folder-name
swg --serve

在本地测试网站。 第一篇文章是关于定制和基本配置的,所以请仔细阅读。

生成您的网站

一旦您进入包含网站定义的目录(其中包含swg.cfg文件),只需运行:

swg --generate

要开始生成网站,可以使用其他选项,请使用

swg --help

以显示完整的列表。

从其他平台导入

现在,可以使用swg wordpress脚本将wordpress xml备份文件转换为 swg格式,要使用它,请考虑以下内容:

swg-wordpress --help
- SWG Wordpress Backup Importer -

Usage: swg-wordpress -i wordpress-backup.xml -u 'http://www.your-site-url.com' <options>


Options:
  -h, --help            show this help message and exit
  -i WPBACKUP, --input=WPBACKUP
                        The Wordpress XML backup file.
  -u SITEURL, --url=SITEURL
                        URL of the destination website.
  -o OUTDIR, --output=OUTDIR
                        Output directory, default is the current working
                        directory.
  -e FILEEXT, --extension=FILEEXT
                        Output file extension, default is txt.
  -I IMGDIR, --images=IMGDIR
                        If specified, it's the path where the importer will
                        try to download images referenced by articles.

例如,假设您有wp.xml文件,希望将其导出到'example site.com'目录,下载 文章引用到“example site.com/images”目录中的图像(导入将正确替换图像url),您可以 将使用命令行:

swg-wordpress -i wp.xml -u http://www.example-site.com -o 'example-site.com' -I 'example-site.com/images'

一切都结束了! 现在您只需创建模板,修复文件'example site.com/db/categories.txt'中的类别hyerarchy,自定义 您自己在“example site.com/db/your nickname.txt”中的描述,并按照下面的示例创建配置文件。

配置文件示例

# DB files extension
dbitem_ext = txt
# URL of the site you are going to generate
siteurl    = http://www.example-site.com
# Site name / description
sitename   = An example site generated by SWG
# Site charset
charset    = utf-8
# Site language
language   = it
# Comma separated site keywords
keywords   = some, html, keywords, here
# Site destination basepath
basepath   =
# Site page files output extension
page_ext   = html
# Generated site output path
outputpath = out
# Items (dirs or files) to copy from datapath to outputpath (eg. static files, css, etc)
copypaths  = css, images, .htaccess
# Command to execute once the generation is finished, for instance an rsync :)
transfer   = rsync -ravz out/* -e ssh user@example-site.com:/var/www/example-site.com/htdocs/
# Enable or disable the pager on categories, index, tags and author pages
pager      = true
# If pager is enabled, this is the maximum number of items per page
items_per_page = 10
# Compress pages (ie. index.html.gz) and create (or update) .htaccess file to serve them as html files
gzip       = true
# Compression level, 0 to 9
compression = 9
# Clean output html with TIDY
tidyfy = true

很不言而喻,不是吗?:)

在本地测试您的网站

从版本1.2.4,swg提供了在本地测试您的网站的可能性,一旦您在包含您的网站定义的目录中 (包含swg.cfg文件),运行以下命令:

swg --serve

这将在http://localhost:8080/上启动网站生成和测试web服务器。

示例项目

作为一个示例站点,请查看我的个人博客github repo,它位于这里https://github.com/evilsocket/evilsocket.net

享受^^

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么Struts 2注释没有LongRangeFieldValidator   java哪个更高效   简单Java加密/解密(错误:意外类型| |必需:找到变量:值)   java谷歌mlkit的条形码扫描仪无法识别任何条形码   java如何捕捉游标窗口错误   java依赖于使用ivy的gradle项目   java是检查谁在使用线程的好方法。interrupted()和不抛出InterruptedException?   java添加。在Eclipse中将文件类化为构建路径   java如何将JFreechart添加到面板?   java数学。当参数名为“e”时,mxparser返回NaN   java使用hadoop文件系统API模拟hadoop fs命令(hadoop fs cat)   图像Java代码打开应用程序并显示图标   使用Java POST请求在Django Tastypie上创建资源,但得到500个错误代码   java SpringBoot显示注销按钮,仅适用于未使用thymeleaf登录的用户   java Android后台服务和活动之间的自动通信   javascript在本地存储中设置键和值,以便在边缘浏览器中加载URL   java通过配置创建重复的springboot控制器