# haumea [![PyPI version](https://badge.fury.io/py/haumea.svg)](https://badge.fury.io/py/haumea)
Small & fast python static site generator (SSG) optimized for external JSON (REST API, GraphQL etc.) data driven contents.
Work in progress...
Haumea requires **Python >=3.6**
## Installation
```bash
$ pip install haumea
```
## Quickstart
You can create a skeleton project with the haumea-quickstart command
```bash
$ haumea-quickstart yourprojectname
```
```bash
yourprojectname
├── content # All content for your website will live inside this directory
│ └── (pages)
├── layouts # Stores .html templates files
│ └── partials
│ └── footer.html
│ └── header.html
│ └── head.html
│ └── _base.html
├── public # Your site will be rendered into this dir
└── static # Stores all the static content: images, CSS, JavaScript, etc.
```
Build & test your website
```bash
$ cd yourprojectname/
# builds your site any time a source file changes ans serves it locally
$ haumea serve
or
$ haumea s
```
Or just build
```bash
$ cd yourprojectname/
# performs build of your site to ./public (by default)
$ haumea build
or
$ haumea b
```
## Documentation
### Directory Structure (sample)
```bash
yourprojectname
├── content
│ └── index.html # Simple page
│ └── about.html # Simple page
│ └── blog # Subdir
│ └── post-1.html # Simple page
│ └── post-2.html # Simple page
│ └── post-3.html # Simple page
│ └── products/ # Subdir
│ └── _product.html # Page bundle (create from a json array of data)
│ └── _product.graphql # graphql query (for json-request-type="graphql")
├── layouts
│ └── partials
│ └── footer.html
│ └── header.html
│ └── head.html
│ └── _base.html
├── public
└── static
```
### Templating tags (layouts dir)
```bash
# render your content into template
{{ _content }}
```
```bash
# basic template include
{% include "partials/header.html" %}
```
```bash
# basic render of menu
{% menu mymainmenu %}
# html output
<ul>
<li><a href="">item 1</a></li>
<li><a href="">item 2</a></li>
<li><a href="">item 3</a></li>
</ul>
```
```bash
# advanced render of menu
{% menu myfootermenu a.item %}
# html output
<a class="item" href="">item 1</a>
<a class="item" href="">item 2</a>
<a class="item" href="">item 3</a>
```
```bash
# advanced render of menu
{% menu mycustommenu nav.menu>div.item>a.link.is-active %}
# html output
<nav class="menu">
<div class="item">
<a class="link is-active" href="">item 1</a>
</div>
<div class="item">
<a class="link" href="">item 2</a>
</div>
<div class="item">
<a class="link" href="">item 3</a>
</div>
</nav>
```
```bash
# custom render of menu
{% for menu in _menus.main %}
<li><a href="{{ menu.page.permalink }}">{{ menu.page._params.title }} - {{ menu.page._json_.fields.regular_price|{:.2f} }}</a></li>
{% endfor %}
```
```bash
# basic render of current timestamp
{% time %}
```
```bash
# render absolute permalink
{% link "about.html" %} # > /about/index.html
{% link "/blog/post-2020.html#more" %} # > /blog/post-2020/#more
{% link "#more" %} # > #more
```
```bash
# render page params
{{ _params.title }}
```
```bash
# render json data
{{ _json_.short_title }}
{{ _json.regular_price|{:.2f} }}
```
### Content config
#### Static page
**page.html**
```bash
---
{
"title":"Welcome home",
"menus":["main", "footer"]
}
---
<div class="main">
Hello World !
</div>
```
#### Single page from JSON or REST API
**page.html**
```bash
---
{
"json-source" : "https://api.buttercms.com/v2/pages/*/sample-page/",
"json-request-type" : "get",
"json-params" : { "locale" : "fr" , "auth_token" : "XXXXXXX" },
"json-root-node" : "data",
"title" : "{{ _json.fields.title }} - {{ _json.fields.product_qty }}",
"menus" : [ "main" ],
"slug" : "test"
}
---
<div class="main">
Hello World !
</div>
```
#### Page bundle from JSON with GraphQL
**\_page.html**
```bash
---
{
"json-source" : "https://graphql.datocms.com/",
"json-request-type" : "graphql",
"json-headers" : {"Authorization":"token xxxxxxx"},
"json-root-node" : "data.allProduits",
"title": "{{ _json.title }}",
"nav-title": "Navigation Title !",
"meta-desc" : "{{ _json.meta_description }}",
"meta-title" : "{{ _json.meta_title }}",
"slug" : "{{ _json.slug }}",
"menus" : [ "products", "footer" ],
"layout" : "layout.html" # Default "_base.html"
}
---
<div class="main">
Hello World !
</div>
```
**\_page.graphql**
```bash
query {
launchesPast(limit: 80) {
mission_name
details
launch_date_local
ships {
name
image
}
}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源分类:Python库 所属语言:Python 资源全名:haumea-0.6.2.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
haumea-0.6.2.tar.gz (20个子文件)
haumea-0.6.2
PKG-INFO 7KB
haumea
quickstart
content
index.html 156B
about.html 134B
layouts
partials
head.html 219B
footer.html 23B
header.html 38B
_base.html 260B
__main__.py 58B
__init__.py 21KB
quickstart.py 2KB
tests.py 0B
setup.cfg 38B
setup.py 992B
haumea.egg-info
PKG-INFO 7KB
requires.txt 9B
SOURCES.txt 525B
entry_points.txt 92B
top_level.txt 7B
dependency_links.txt 1B
README.md 5KB
共 20 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C#ASP.NET大型合同管理系统源码 项目合同源码数据库 SQL2008源码类型 WebForm
- (源码)基于Arduino的温湿度传感器与OLED显示屏显示系统.zip
- Type C PCB封装库 6Pin 24Pin 有公头、有母头分享下载Altium格式
- btstack协议栈-HID Mouse Classic
- (ARM-LINUX)C源码-课程设计.zip
- btstack协议栈实战篇-HID Keyboard Classic
- 自然语言处理大作业Python实现基于词典的分词方法源代码+实验报告(高分项目)
- 基于C++实现的交互界面计算器程序项目源码+详细代码注释(高分项目)
- 数据库期末作业基于Python+mysql的餐厅点餐系统源码+数据库+文档说明(高分项目)
- 打印机输出中心,博艺HP45输出中心 1907版
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功