โวลเดอมอร์เป็นตัวสร้างไซต์แบบคงที่อย่างง่ายโดยใช้เทมเพลต 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 คุณสามารถตั้งค่าแอตทริบิวต์ที่เกี่ยวข้องกับโพสต์ได้ที่นี่ ในส่วนเทมเพลตคุณสามารถใช้เทมเพลต jinja2 หรือ markdown ในบล็อก {% markdown %} และ {% endmarkdown %} (คุณสามารถเพิกเฉยต่อบล็อกเหล่านี้ได้หาก layout ถูกกำหนดในส่วนข้อมูลเมตา)
ตามการกำหนดค่าเริ่มต้นของโวลเดอมอร์เทมเพลตฐานทั้งหมดควรอยู่ใน 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 ต่อไปนี้ซึ่งสร้างหน้าแรกของบล็อกของคุณด้วยโพสต์ทั้งหมด paginated ด้วยค่าที่ให้ไว้ใน 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.
สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ templating อ่านเอกสารต่อไปนี้
คุณสามารถเปลี่ยนการตั้งค่าเริ่มต้นโดยแก้ไข settings.yaml 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 แล้วโวลเดอมอร์ยังให้ตัวกรองต่อไปนี้เพื่อใช้ภายในหน้า 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) }}