xref: /plugin/combo/action/autofrontmatter.php (revision 04fd306c7c155fa133ebb3669986875d65988276)
1<?php
2
3use ComboStrap\ExceptionCompile;
4use ComboStrap\LogUtility;
5use ComboStrap\MarkupPath;
6
7/**
8 * Copyright (c) 2021. ComboStrap, Inc. and its affiliates. All Rights Reserved.
9 *
10 * This source code is licensed under the GPL license found in the
11 * COPYING  file in the root directory of this source tree.
12 *
13 * @license  GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html)
14 * @author   ComboStrap <support@combostrap.com>
15 *
16 *
17 * @deprecated - the frontmatter is no more used to enter metadata.
18 */
19class action_plugin_combo_autofrontmatter extends DokuWiki_Action_Plugin
20{
21
22
23    public function register(Doku_Event_Handler $controller)
24    {
25        /**
26         * Called when new page is created
27         * In order to set its content
28         * https://www.dokuwiki.org/devel:event:common_pagetpl_load
29         */
30        if (false) {
31            $controller->register_hook('COMMON_PAGETPL_LOAD', 'BEFORE', $this, 'handle_new_page', array());
32        }
33    }
34
35    public function handle_new_page(Doku_Event $event, $param){
36
37        try {
38            $page = MarkupPath::createPageFromExecutingId();
39        } catch (ExceptionCompile $e) {
40            LogUtility::msg("Unable to handle a new page because the global id is unknown");
41        }
42        $canonical = $page->getCanonicalOrDefault();
43        $event->data["tpl"] = <<<EOF
44---json
45{
46    "canonical":"{$canonical}",
47    "title":"A [[https://combostrap.com/frontmatter|frontmatter]] title shown on the Search Engine Result Pages",
48    "description":"A [[https://combostrap.com/frontmatter|frontmatter]] description shown on the Search Engine Result Pages"
49}
50---
51EOF;
52
53
54    }
55}
56
57
58
59