重力-蓝图 


重力-蓝图


蓝图是有关资源(信息源)的元数据信息。它有两个目的-

  • 首先是资源身份本身。
  • 其次是关于表格。

此完整信息将保存在每个插件或主题中存在的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

以下几个属性是可选的,一些用于提供您的身份和资源。

Sr.No. Properties & Description
1

name*

Mention the name of the resource.

2

version*

Specifies the version of the resource.

3

description*

Gives brief description about the resource. It should not exceed more than 200 characters.

4

icon*

Specifies an icons library for developing a new theme or plugin.

5

author.name*

Specifies the name of the developer.

6

author.email (optional)

Specifies the email address of the developer.

7

author.url (optional)

Specifies the URL homepage of developer.

8

homepage (optional)

Specifies the allocated Url for homepage for your resource.

9

docs (optional)

Specifies the documentation link which you have written for your resource.

10

demo (optional)

Specifies the link of demo resource.

11

guide (optional)

Specifies the link of how to guide or tutorials for your resource.

12

keywords (optional)

Specifies the list of keywords that are related to your resource.

13

bugs (optional)

Specifies the Url where issues or bugs can be reported.

14

license (optional)

Specifies your resource license i.e. MIT, GPL etc.

15

dependencies (optional)

Specifies the name of the dependencies that are required for plugins or themes.

以下是登录插件蓝图的示例-

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文件。可以通过Admin插件(由Forms元数据定义)来配置此资源的一部分。

以下是“存档插件” 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

这些是插件的默认设置。要在不使用Admin插件的情况下配置它们,用户必须将该文件复制到/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

选项为根元素“已启用”,“ 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文件中看到的那样,表单验证已设置为strict。如果将验证设置为严格,则必须为所有选项添加蓝图表单,否则在保存时会弹出错误。当您只想将两个字段自定义为管理界面时,可以将form.validation设置为松散。

下表简要说明了与上述表单元素有关的字段。

Sr.No. Field & Description
1

Type

Indicates the field type.

2

Size

Specifies the size of the field.

3

Label

Specifies label to the field.

4

Validate

It validates the type of the field and the minimum length entered in the field.

5

Default

Sets default fields.

6

Options

Specifies the list of options.

7

Classes

Specifies the class for the field.

管理员中可用的表单字段

有许多内置的表单字段可供插件和主题使用,也可以创建自己的表单字段。下表列出了可用的表单字段-

常见表格栏位

Sr.No. Field & Description
1

Checkbox

Displays single checkbox.

2

Checkboxes

Displays a list of checkboxes.

3

Date

Contains date field.

4

Datetime

Contains date and time field.

5

Email

Contains an email address field with validation.

6

Password

Contains a password field which displays in dot format.

7

Hidden

Contains hidden input field.

8

Radio

Allows selecting only one option from the list.

9

Select

This field contains few options.

10

Spacer

Adds title, text or horizontal line to the form.

11

Text

Contains normal text field.

12

Textarea

Contains multiline text inputs.

特殊表格栏位

Sr.No. Field & Description
1

Array

Adds multiple key value rows.

2

Ignore

Unused fields are removed.

3

Columns

Divides the form into multiple columns.

4

Column

Displays a single column.

5

Dateformat

Sets the date and time format.

6

Display

Displays text value without any input value.

7

Frontmatter

The page is displayed in raw format.

8

List

Displays a list of items without a key.

9

Markdown

Displays the markdown editor.

10

Pages

Displays the list of pages.

11

Section

The setting page is divided into sections and each section has a title.

12

Selectize

It is used to select boxes.

13

Tabs

Settings are divided into list of tabs.

14

Tab

The tabs field uses to provide a tab.

15

Taxonomy

It is a select preconfigured to select the taxonomy.

16

Toggle

It represents the toggle effect that specifies on or off type of input.

0



error: 内容受到保护 !!