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