- Grav 插件
- Grav - 插件基础
- Grav - 插件教程
- Grav - 事件钩子
- Grav 管理面板
- Grav - 管理员简介
- Grav - 管理员仪表盘
- Grav - 配置系统
- Grav - 站点配置
- Grav - 管理面板页面
- Grav - 页面编辑器选项
- Grav - 页面编辑器高级
- Grav 高级
- Grav - 蓝图
- Grav - 性能和缓存
- Grav - 调试和日志记录
- Grav - CLI
- Grav - GPM
- Grav - 开发
- Grav - 生命周期
- Grav - YAML 语法
- Grav - 表单
- Grav 托管
- Grav - 网络主机
- Grav 故障排除
- Grav - 服务器错误
- Grav - 权限
- Grav 有用资源
- Grav - 面试问题
- Grav - 快速指南
- Grav - 有用资源
- Grav - 讨论
Grav - 蓝图
蓝图是关于资源(信息来源)的元数据信息。它有两个用途:
- 首先是资源本身的身份。
- 其次是关于表单的。
所有这些完整的信息都保存在每个插件或主题中存在的blueprints.yaml文件中。
资源身份
在blueprints.yaml文件中,为每个主题和插件定义了身份。除非蓝图格式正确并完美编译,否则资源将不会添加到 Grav 存储库中。
蓝图示例
name: plugin name
version: 0.6.0
description: Adds an advanced plugin to manage your site
icon: empire
author:
name: Team Grav
email: devs@getGrav.org
url: http://getGrav.org
homepage: https://github.com/getGrav/Grav-plugin-assets
keywords: assets, plugin, manager, panel
bugs: https://github.com/getGrav/Grav-plugin-assets/issues
readme: https://github.com/getGrav/Grav-plugin-assets/blob/develop/README.md
license: MIT
dependencies:
- form
- email
- login
form:
validation: loose
fields:
Basics:
type: section
title: Basics
underline: false
enabled:
type: hidden
label: Plugin status
highlight: 1
default: 0
options:
1: Enabled
0: Disabled
validate:
type: bool
以下一些属性是可选的,有些用于提供您的身份和资源。
| 序号 | 属性和描述 |
|---|---|
| 1 | name* 提及资源的名称。 |
| 2 | version* 指定资源的版本。 |
| 3 | description* 对资源进行简要描述。它不应超过 200 个字符。 |
| 4 | icon* 为开发新主题或插件指定图标库。 |
| 5 | author.name* 指定开发人员的姓名。 |
| 6 | author.email(可选) 指定开发人员的电子邮件地址。 |
| 7 | author.url(可选) 指定开发人员的 URL 主页。 |
| 8 | homepage(可选) 为您的资源指定分配的主页 URL。 |
| 9 | docs(可选) 指定您为资源编写的文档链接。 |
| 10 | demo(可选) 指定演示资源的链接。 |
| 11 | guide(可选) 指定如何引导或教程的链接,以供您的资源使用。 |
| 12 | keywords(可选) 指定与您的资源相关的关键字列表。 |
| 13 | bugs(可选) 指定可以报告问题或错误的 URL。 |
| 14 | license(可选) 指定您的资源许可证,例如 MIT、GPL 等。 |
| 15 | dependencies(可选) 指定插件或主题所需的依赖项的名称。 |
以下是登录插件蓝图的示例:
name: Login version: 0.3.3 description: Enables user authentication and login screen. icon: sign-in author: name: Team Grav email: devs@getGrav.org url: http://getGrav.org keywords: admin, plugin, login homepage: https://github.com/getGrav/Grav-plugin-login keywords: login, authentication, admin, security bugs: https://github.com/Getgrav/Grav-plugin-login/issues license: MIT
表单
如果您希望主题或插件具有可直接从管理界面配置的选项,则可以使用表单填充blueprints.yaml文件。此资源的一部分可以通过管理插件配置,该插件由表单元数据定义。
以下是 Archives 插件的archives.yaml文件的示例。
enabled: true built_in_css: true date_display_format: 'F Y' show_count: true limit: 12 order: by: date dir: desc filter_combinator: and filters: category: blog
这些是插件的默认设置。要无需使用管理插件即可配置它们,用户必须将此文件复制到/user/config/plugins/archives.yaml文件夹中并进行更改。您可以正确提供archives.yaml文件;您可以选择从用户更改管理界面中的设置。
保存更改后,它将自动写入<your_folder_name>/user/config/plugins/archives.yaml。
Archives 插件的blueprint.yaml文件包含如下所示的结构:
name: Archives
version: 1.3.0
description: The **Archives** plugin creates links for pages grouped by month/year
icon: university
author:
name: Team Grav
email: devs@getGrav.org
url: http://getGrav.org
homepage: https://github.com/getGrav/Grav-plugin-archives
demo: http://demo.getGrav.org/blog-skeleton
keywords: archives, plugin, blog, month, year, date, navigation, history
bugs: https://github.com/getGrav/Grav-plugin-archives/issues
license: MIT
form:
validation: strict
fields:
enabled:
type: toggle
label: Plugin status
highlight: 1
default: 1
options:
1: Enabled
0: Disabled
validate:
type: bool
date_display_format:
type: select
size: medium
classes: fancy
label: Date Format
default: 'jS M Y'
options:
'F jS Y': "January 1st 2014"
'l jS of F': "Monday 1st of January"
'D, m M Y': "Mon, 01 Jan 2014"
'd-m-y': "01-01-14"
'jS M Y': "10th Feb 2014"
limit:
type: text
size: x-small
label: Count Limit
validate:
type: number
min: 1
order.dir:
type: toggle
label: Order Direction
highlight: asc
default: desc
options:
asc: Ascending
desc: Descending
以下是archive.yaml中存在的表单元素。
切换
enabled:
type: toggle
label: Plugin status
highlight: 1
default: 1
options:
1: Enabled
0: Disabled
validate:
type: bool
选择
date_display_format:
type: select
size: medium
classes: fancy
label: Date Format
default: 'jS M Y'
options:
'F jS Y': "January 1st 2014"
'l jS of F': "Monday 1st of January"
'D, m M Y': "Mon, 01 Jan 2014"
'd-m-y': "01-01-14"
'jS M Y': "10th Feb 2014"
文本
limit:
type: text
size: x-small
label: Count Limit
validate:
type: number
min: 1
根元素Enabled、date_display_format和limit是选项。此根元素中存在的字段确定类型、大小、标签、默认值和选项。根据字段类型,其他字段可能会发生变化;例如,选择字段需要选项列表。
顺序方向
order.dir:
type: toggle
label: Order Direction
highlight: asc
default: desc
options:
asc: Ascending
desc: Descending
此字段包含嵌套选项。在plugins/admin/themes/Grav/templates/forms/fields中可以使用许多字段类型。正如我们在archive.yaml文件中看到的那样,表单验证设置为严格。当验证设置为严格时,对于所有选项,您都必须添加蓝图表单,否则在保存时会弹出错误。当您只想将两个字段自定义到管理界面时,可以将form.validation设置为宽松。
下表对与上述表单元素相关的字段进行了简要说明。
| 序号 | 字段和描述 |
|---|---|
| 1 | 类型 指示字段类型。 |
| 2 | 大小 指定字段的大小。 |
| 3 | 标签 为字段指定标签。 |
| 4 | 验证 它验证字段的类型以及在字段中输入的最小长度。 |
| 5 | 默认 设置默认字段。 |
| 6 | 选项 指定选项列表。 |
| 7 | 类 为字段指定类。 |
管理中可用的表单字段
有许多内置表单字段可供插件和主题使用,或者可以创建自己的表单字段。下表列出了可用的表单字段:
常用表单字段
| 序号 | 字段和描述 |
|---|---|
| 1 | 复选框 显示单个复选框。 |
| 2 | 复选框 显示复选框列表。 |
| 3 | 日期 包含日期字段。 |
| 4 | 日期时间 包含日期和时间字段。 |
| 5 | 电子邮件 包含带验证的电子邮件地址字段。 |
| 6 | 密码 包含一个密码字段,以点格式显示。 |
| 7 | 隐藏 包含隐藏输入字段。 |
| 8 | 单选按钮 允许从列表中选择一个选项。 |
| 9 | 选择 此字段包含一些选项。 |
| 10 | 间隔符 向表单添加标题、文本或水平线。 |
| 11 | 文本 包含普通文本字段。 |
| 12 | 文本区域 包含多行文本输入。 |
特殊表单字段
| 序号 | 字段和描述 |
|---|---|
| 1 | 数组 添加多个键值行。 |
| 2 | 忽略 未使用字段将被删除。 |
| 3 | 列 将表单分成多列。 |
| 4 | 列 显示单个列。 |
| 5 | 日期格式 设置日期和时间格式。 |
| 6 | 显示 显示文本值,没有任何输入值。 |
| 7 | 前置信息 页面以原始格式显示。 |
| 8 | 列表 显示项目列表,没有键。 |
| 9 | Markdown 显示 Markdown 编辑器。 |
| 10 | 页面 显示页面列表。 |
| 11 | 部分 设置页面被分成多个部分,每个部分都有一个标题。 |
| 12 | Selectize 用于选择框。 |
| 13 | 选项卡 设置分为选项卡列表。 |
| 14 | 选项卡 选项卡字段用于提供选项卡。 |
| 15 | 分类法 它是一个预先配置的选择,用于选择分类法。 |
| 16 | 切换 它表示切换效果,指定开或关类型的输入。 |