totten/hyde

安装: 6

依赖: 0

建议: 0

安全性: 0

星标: 8

关注者: 4

分支: 1

公开问题: 0

类型:drupal-module

dev-master 2018-05-24 14:48 UTC

This package is auto-updated.

Last update: 2024-09-09 13:36:23 UTC


README

Drupal 很好,但我不喜欢在 Web UI 中编辑页面。或者将它们存储在 MySQL 中。或者配置工作流程。这是个问题吗?我还能使用 Drupal 吗?

Hyde 先生是 Jekyll 博士的邪恶版本 -- 它是一个 Drupal 插件,允许您创建 Markdown 文件并将它们存储在 git 仓库中... 但以页面形式显示在 Drupal 网站上。这允许您使用 Drupal 的通用布局引擎(主题和块),同时跟踪 git 中的内容(并使用像 Github PR 或 Gitlab MR 这样的标准工作流程)。

安装模块

$ cd sites/all/modules
$ git clone https://github.com/totten/hyde
$ cd hyde
$ composer install
$ drush en hyde

注意:通过 composer require totten/hyde 安装应该是没有问题的,但我还没有在 D7+Composer 上做足够的实验来证实这一点。

初始化内容根目录

$ cd <drupal-private-data-folder>
$ mkdir hyde
$ cd hyde

当然,这个文件夹可能应该是 git 仓库。您可以在这里初始化一个新的仓库(git init)或克隆一个现有的仓库。

提示:如果您想将内容存储在其他文件夹中,可以通过调用 drush vset hyde_path /path/to/doc/root 或编辑 settings.php 来覆盖 hyde_path 的值。

添加新页面

$ echo "Hello __world__" > hello-world.md
$ drush cc all
$ curl https://example.org/hello-world
$ git add hello-world.md
$ git commit

Markdown 元数据

在 Jekyll 语法中,Markdown 文件可以以 YAML 元数据开始。在这个例子中,我们使用一些额外的元数据设置了 HTML 页面的 title

---
title: "The future of old school content"
---
# Old is the new new
Because sometimes you like to write content in a simple way.

# Git is the new CMS
Because sometimes you like to write content in a simple way.

支持的字段

  • title:主 HTML 页面标题

问题/限制/FIXMEs

如果真的关心这个问题,可能会有几种做法。现在,我正试图快速完成这项工作,所以我不太关心。

  • 添加管理 hyde_path 的管理表单
  • 测试/实现页面缓存支持。
  • 重新设计为 Drupal 实体。如果文件可写,允许通过 CLI 或 GUI 编辑 body。如果文件不可写,则不进行编辑。
  • 为元数据添加更多选项
    • 设置权限
    • 更改布局
  • 只想确保只有 CLI 用户可以操作 Markdown 文件?只需适当地设置文件权限即可。

编码风格

这个仓库是我喝了一些啤酒后 15 分钟内写的糟糕代码的安全空间。