2

我不知道如何让流场在管理员中工作,

我希望显示的示例显示在https://raw.githubusercontent.com/lektor/lektor-assets/master/screenshots/admin.png 然后单击 localhost:5000/admin/root/edit 并获取http: //i.imgur.com/EPCrBRC.png

我觉得我做错了一些简单的事情。但是我尝试过将其缩减为基本的:-

$ cd /tmp/
$ lektor quickstart
Lektor Quickstart
=================

This wizard will generate a new basic project with some sensible defaults for
getting started quickly.  We jsut need to go through a few questions so that
the project is set up correctly for you.

Step 1:
| A project needs a name.  The name is primarily used for the admin UI and
| some other places to refer to your project to not get confused if multiple
| projects exist.  You can change this at any later point.
> Project Name: flow-example

Step 2:
| This is the path where the project will be located.  You can move a
| project around later if you do not like the path.  If you provide a
| relative path it will be relative to the working directory.
> Project Path [/tmp/flow-example]: 

Step 3:
| Do you want to generate a basic blog module?  If you enable this the
| models for a very basic blog will be generated.
> Add Basic Blog [Y/n]: n

Step 4:
| Your name.  This is used in a few places in the default template to refer
| to in the default copyright messages.
> Author Name [Brendan M. Sleight,,,]:   

That's all. Create project? [Y/n] Y
$ cd flow-example/
$ echo "[fields.extra]
> label = Extra
> type = flow
> flow_blocks = text" >>./models/page.ini
$ cat ./models/page.ini 
[model]
name = Page
label = {{ this.title }}

[fields.title]
label = Title
type = string

[fields.body]
label = Body
type = markdown
[fields.extra]
label = Extra
type = flow
flow_blocks = text
$ lektor server
 * Project path: /tmp/flow-example/flow-example.lektorproject
 * Output path: /home/bms/.cache/lektor/builds/76682e6a8f99116f0da91bcf96203e94
Started source info update
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Finished source info update in 0.05 sec
Started build
U index.html
U about/index.html
U projects/index.html
Finished build in 0.12 sec
Started prune
Finished prune in 0.00 sec
```
4

4 回答 4

2

需要仔细阅读文档才能找出使流程块起作用的地方。

  1. 您需要在您的和文件夹flowblocks所在的同一级别创建一个文件夹。contentmodels
  2. 将您的 flowblock 模型文件放在此文件夹中(例如image-paragraph.ini:)
  3. blocks在您的文件夹中创建一个文件templates夹。
  4. 将您的流程块的 HTML 模板放在blocks文件夹中(例如image-paragraph.html:)

目录结构应如下所示:

my-lektor-project
  assets
  content
  flowblocks
    image-paragraph.ini (your model)
  models
  templates
    blocks
      image-paragraph.html (your template for the block)
于 2016-11-20T07:00:53.147 回答
1

目前,管理员对错误配置的反应非常糟糕。通常它只是死于你可以在控制台窗口中看到的错误。很可能流程块本身不存在或有错误。只需打开控制台窗口并查看打印的错误消息。这可能会给出一个迹象。

于 2016-02-28T18:02:24.247 回答
0

最好用一个例子来解释。

首先,创建一个模型,其中包含一个type设置为的字段flow并将其放入models/flow_page.ini.

[model]
name = FlowPage
label = {{ this.title }}

[fields.title]
label = Title
type = string

[fields.body]
label = Body
type = flow

在 中创建一个新模板templates/flow_page.htmlpage.html如果你愿意,你可以复制。

然后将以下流块配置写入flowblocks/colored_text.ini

[block]
name = Text Block
button_label = Text

[fields.text]
label = Text
type = markdown

[fields.color]
label = Class
type = select
choices = red, blue, green
choice_labels = Red, Blue, Green
default = red

现在您需要一个流程块的模板。将其添加到templates/blocks/colored_text.html.

<span style="color: {{ this.color }}">{{ this.text }}</span>

最后,新建一个子页面,FlowPage在model下选择。

现在您可以将我们之前定义的块添加到正文中。

于 2022-01-08T23:23:31.350 回答
0

https://www.getlektor.com/docs/models/flow/

要使用 Flow,您需要定义流块模型。如果您还不熟悉 Flow,您应该先阅读 Flow 简介文档

定义模型

流块模型的工作方式与常规模型几乎完全相同。差异大多是微小的并且具有装饰性。它们存储在 flowblocks/ 文件夹中,并且是与模型一样的 ini 文件。

于 2016-02-28T17:58:48.483 回答