-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e08daa
commit c35a901
Showing
8 changed files
with
214 additions
and
100 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
|
||
# 更改日志 | ||
|
||
[filename](https://raw.githubusercontent.com/wonder-light/glidea/refs/heads/main/CHANGELOG.md ':include') |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,115 @@ | ||
# dev | ||
|
||
# 主题开发 :id=theme | ||
|
||
> Glidea 采用 Jinja 作为主题的模版引擎 | ||
你可以在这里查看应用的默认主题 [Default Thems](https://github.com/wonder-light/glidea/tree/main/public/default-files.zip) | ||
|
||
基于 Jinja 的语法你可以很快开发出一个心仪的自定义主题 | ||
|
||
🎉 我们为你准备了一个主题开发样板,[快去看看吧](https://github.com/wonder-light/glidea-theme-fog)! | ||
|
||
## 约定 :id=agreement | ||
|
||
我们建议你将主题命名为 **gridea-theme-\<name\>** 以便用户可以更好地搜索,\ | ||
例如 **gridea-theme-notes**,\ | ||
同时我们建议你将主题提交至 Github,并设置 topic,\ | ||
以便用户可以直接点击 topic 即可搜索到你的主题 `grideagridea-theme` | ||
|
||
示例: | ||
|
||
![topic](../../../assets/images/glidea-theme-topic.jpg) | ||
|
||
|
||
## Jinja 基础介绍 :id=Jinja | ||
|
||
这里只列举了你开发主题时最常用的几个语法,当然,如果想了解最全面的语法,可以去查看 [Jinja](https://docs.jinkan.org/docs/jinja2/templates.html) 文档,对 Jinja 的支持情况可以查看 [jinja|dart](https://pub.dev/packages/jinja) 文档 | ||
|
||
示例数据: | ||
|
||
```json | ||
{ | ||
"themeConfig": { | ||
"footerInfo": "Powered by Gridea", | ||
"pageSize": 10, | ||
"showFeatureImage": true, | ||
"siteDescription": "温故而知新", | ||
"siteName": "Gridea", | ||
"themeName": "notes" | ||
}, | ||
"posts": [ | ||
{ | ||
"abstract": "<strong>Gridea</strong> 一个静态博客写作客户端 ", | ||
"content": "<strong>Gridea</strong> 一个静态博客写作客户端 <!-- more -->↵↵👏 欢迎使用 <strong>Gridea</strong> !", | ||
"date": "2019-01-15 08:00:00", | ||
"dateFormat": "2019-01-15", | ||
"feature": "/post-images/hello-gridea.png", | ||
"published": true, | ||
"tags": ["Gridea"], | ||
"fileName": "hello-gridea" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### 标签 :id=tag | ||
|
||
- {{ ... }} 用于把表达式的结果打印到模板上 | ||
``` django | ||
{{% themeConfig.siteName %}} | ||
{{% themeConfig.siteName|e %}} // 对其进行转义 | ||
``` | ||
|
||
|
||
|
||
- {% ... %} 用于执行诸如 for 循环 或赋值的语句 | ||
``` django | ||
{% for item in posts %} | ||
<li> | ||
<a href="{{ item.feature }}">{{ item.content }}</a> | ||
</li> | ||
{% endfor %} | ||
``` | ||
|
||
### 包含 :id=include | ||
|
||
include 语句用于包含一个模板,\ | ||
并在当前命名空间中返回那个文件的内容渲染结果: | ||
|
||
``` django | ||
{% include 'header.html' %} | ||
Body | ||
{% include 'footer.html' %} | ||
``` | ||
|
||
### 条件判断 :id=if | ||
|
||
你可以用 if 和 elif 和 else 来构建多个分支 | ||
|
||
``` django | ||
{% if themeConfig.sick %} | ||
Kenny is sick. | ||
{% elif themeConfig.dead %} | ||
You killed Kenny! You bastard!!! | ||
{% else %} | ||
Kenny looks okay --- so far | ||
{% endif %} | ||
``` | ||
|
||
### 宏 :id=macro | ||
|
||
用于把常用行为作为可重用的函数,取代手动重复的工作\ | ||
这里是一个宏渲染表单元素的小例子: | ||
|
||
``` django | ||
{% macro input(name, value='', type='text', size=20) -%} | ||
<input type="{{ type }}" name="{{ name }}" value="{{ value|e }}" size="{{ size }}"> | ||
{%- endmacro %} | ||
``` | ||
|
||
宏之后可以像函数一样调用: | ||
|
||
``` django | ||
<p>{{ input('username') }}</p> | ||
<p>{{ input('password', type='password') }}</p | ||
``` |
Oops, something went wrong.