Voldemort는 Jinja2 및 Markdown 템플릿을 사용하는 간단한 정적 사이트 생성기입니다.
sudo python setup.py install
또는
sudo easy_install -U voldemort
Usage: voldemort [options]
Options:
-h, --help show this help message and exit
-w WORK_DIR, --work_dir=WORK_DIR
Working Directory
-s, --serve Start the HTTP Server
-p PORT, --port=PORT Port inwhich the HTTPServer should run
-d, --deploy Deploy this website
-u USER, --user=USER Login name for server
-a AT, --at=AT Server address to deploy the site
-t TO, --to=TO Deployment directory
--skip-blog Skip blog posts generation
--skip-pages Skip pages generation
--skip-tags Skip tags generation
--skip-feeds Skip Atom feed generation
--skip-sitemap Skip sitemap generation
예제 디렉토리로 이동하십시오
cd example
그리고 달리기
voldemort
httpserver를 시작하십시오
voldemort --serve -p 8080
브라우저를 열고 웹 사이트를 실제로보십시오.
웹 사이트를 배포하십시오
voldemort --deploy -u foobarnb -a foobarnbaz.com -t /home/foobarnbaz/public_html
게시물에는 주로 2 개의 섹션이 포함됩니다. 구성 섹션 및 템플릿 섹션. 두 가지 내부의 모든 데이터 --- 구성을 정의하고 YAML 데이터로 유효성을 유지합니다. 여기에서 게시물 관련 속성을 설정할 수 있습니다. 템플릿 섹션에서는 {% markdown %} 및 {% endmarkdown %} 블록의 Jinja2 템플릿 또는 마크 다운을 사용할 수 있습니다 (메타 데이터 섹션에 layout 정의되면 이러한 블록을 무시할 수 있음).
Voldemort의 기본 구성에 따라 모든 기본 템플릿은 layout 에 있어야하며 디렉토리를 include . 이것은 어려운 제한이 아니지만 의미를 보존하기위한 유지 유지. 게시물은 posts 이라는 디렉토리로 작성됩니다. 예를 들어, 아래와 같이 디렉토리 구조가 있습니다.
layout/
listing.html
post.html
include/
navigation.html
posts/
voldemort-is-awesome.markdown
index.html
css/
screen.css
pygments.css
그리고 우리는 layout/listing.html 에서 다음과 같은 데이터를 가지고 있습니다
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>foobarnbaz.com - {{ page.title }}</title>
{% include "head-common.html" %}
</head>
<body>
<section class="page-content">
{% block content %}{% endblock %}
</section>
</body>
</html>
포함 include/header.html 있습니다
<meta charset="UTF-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="Sreejith K" />
<link rel="alternate" href="http://feeds2.feedburner.com/foobarnbaz"
title="foobarnbaz.com" type="application/atom+xml" />
<link rel="stylesheet" href="/css/screen.css" type="text/css" />
<link rel="stylesheet" href="/css/pygments.css" type="text/css" />
<link href='/images/layout/favicon.ico' rel='shortcut icon' type='image/ico' />
우리는 모든 게시물로 블로그의 첫 페이지를 생성하는 다음 index.html 작성할 수 있으며, settings.yaml 에 제공된 값 (기본값은 5)으로 페이지를 찍습니다.
---
paginate: true
---
{% extends "listing.html" %}
{% block content %}
{% for post in paginator.posts %}
<article class="excerpt">
<header>
<h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
<time datetime="{{ post.date | date_to_string }}" pubdate="pubdate">
{{ post.date.strftime("%b %d, %Y") }}
</time>
</header>
{% if loop.first %}
{{ post.content }}
<p class="full-post"><a href="{{ post.url }}#comments">comments...</a></p>
{% else %}
<p>{{ post.content }}</p>
<p class="full-post"><a href="{{ post.url }}">full post...</a></p>
{% endif %}
</article>
{% endfor %}
{% endblock %}
그리고 우리의 샘플 포스트 posts/voldemort-is-awesome.markdown ,
---
title: Voldemort
date: '02-10-2011'
time: '10:45'
layout: 'post.html'
---
[Voldemort](https://github.com/semk/voldemort) is an awesome static site generator based in Jinja2 and Markdown templates.
템플릿에 대한 자세한 내용은 다음 문서를 읽으십시오.
settings.yaml 편집하여 기본 설정을 변경할 수 있습니다.
layout_dirs :
- layout # directory inwhich base tempaltes reside
- include # html code that can be included goes here
posts_dir : posts # directory where you write posts
post_url : "%Y/%m/%d" # url to posts. You can alter the order
site_dir : _site # generated site will be in this directory
paginate : 5 # number of pages to be paginated at once
사용자 정의 데이터는 아래와 같이 site 에서만 추가해야합니다.
site :
name : "Pythoned!"
address : "http://foobarnbaz.com"
author_name : "Sreejith Kesavan"
author_email: "[email protected]"
또한 웹 사이트를 선호하는 위치 또는 GitHub 자체에 배포 할 수 있습니다.
deploy :
user : semk
at : github.com
to : semk.github.com
site: User defined variables from settings.yaml. Also includes site.time
Eg: site.name, site.address, site.time
posts: A list of all your posts. All attributes in the YAML section
can be accessed either using . or [].
eg. post['date'], post.date
paginator: You can paginate your posts using this object.
eg: {% for post in paginator.posts %}
Attributes:
posts: list of posts in this paginator
current_page : current page number (None if not)
next_page : next page number (None if not)
previous_page : previous page number (None if not)
post: Info about the post. Only accessible in posts.
Attributes:
content : html content of the post
url : url to this post
id : identifier for the post (url)
next : points to the next post
previous : points to the previous post
tags : points to the tags
and you can access all the attributes in the config section (eg: post.date)
page: Info about a page. Only available in pages other than posts.
Attributes:
content : html content of the post
and you can access all the attributes in the config section (eg: page.title)
tags: Tags for the blog posts. Globally available.
Eg: You can loop like {% for tag in tags %} and access tag.name, tag.url and tag.posts
tag: Available only to the tag template (Default `tag.html`)
Usage: {% for post in tag.posts %}
Jinja2에서 제공하는 내장 필터 외에도 Voldemort는 HTML 페이지 내에서 사용할 필터를 제공합니다.
date: Format datetime objects.
eg. post.date | date("%d-%m-%Y")
date_to_string: Convert date to string.
eg. "27 Jan 2011"
date_to_long_string: Format a date in long format.
eg. "27 January 2011"
date_to_xmlschema: Format a date for use in XML.
eg. "2011-04-24T20:34:46+05:30"
xml_escape: Replace special characters "&", "<" and ">" to
HTML-safe sequences.
cgi_escape: CGI escape a string for use in a URL. Replaces any special
characters with appropriate %XX replacements.
uri_escape: Escape special characters in url.
number_of_words: Return number of words in a string.
excerpt: Split the html data. Eg: {{ post.content | excerpt(70) }}