xref: /plugin/dev/www/index.php (revision f57a6a5c44ae91ca3f48acd858a81e992d4131f5)
1<?php
2require __DIR__ . '/../vendor/autoload.php';
3
4$WIZ = new dokuwiki\plugin\dev\www\PluginWizard();
5try {
6    $archive = $WIZ->handle();
7    if ($archive) {
8        header('Content-Type: application/zip');
9        header('Content-Disposition: attachment; filename="plugin.zip"');
10        echo $archive;
11        exit;
12    }
13} catch (Exception $ignored) {
14    // errors should only happen when the frontend validation is ignored
15}
16
17header('Content-Type: text/html; charset=utf-8');
18?>
19<html lang="en">
20<head>
21    <title>DokuWiki Plugin Wizard</title>
22    <script type="text/javascript">
23        const ACTION_EVENTS = <?php echo json_encode($WIZ->getEvents()); ?>;
24    </script>
25
26    <link rel="stylesheet" href="style.css"/>
27    <link rel="stylesheet" href="awesomplete.css"
28    /
29</head>
30<body>
31<main>
32    <h1>DokuWiki Plugin Wizard</h1>
33
34
35    <div class="intro">
36        <p>
37            This wizard generates a <a href="https://www.dokuwiki.org/devel:plugins">DokuWiki plugin</a>
38            skeleton to help you get started with coding your plugin.
39            Before using it, you should familiarize your self with how plugins in DokuWiki work
40            and determine what components your plugin will need.
41        </p>
42
43        <p>
44            To use it, fill in the general plugin info and add plugin components. Once you're
45            done, click "create" and download your plugin skeleton.
46        </p>
47
48        <p>
49            Alternatively you can also use the <a href="https://www.dokuwiki.org/plugin:dev">dev plugin</a>.
50            This plugin will also come in handy when editing and extending your plugin later.
51        </p>
52    </div>
53
54    <noscript>
55        <div class="nojs">
56            Sorry, this wizard needs JavaScript to do its magic. It will not work with your
57            current setup.
58        </div>
59    </noscript>
60
61
62    <form action="index.php" method="post" id="ajax__plugin_wiz">
63
64        <section>
65            <div id="plugin_info">
66                <h2>Plugin Information</h2>
67
68                <label>
69                    <span>Plugin base name:</span>
70                    <input type="text" name="base" required="required" pattern="^[a-z0-9]+$"
71                           placeholder="yourplugin">
72                    <small>(lowercase, no special chars)</small>
73                </label>
74
75                <label>
76                    <span>A short description of what the plugin does:</span>
77                    <input type="text" name="desc" required="required"
78                           placeholder="A plugin to flurb the blarg">
79                </label>
80
81                <label>
82                    <span>Your name:</span>
83                    <input type="text" name="author" required="required" placeholder="Jane Doe">
84                </label>
85
86                <label>
87                    <span>Your E-Mail address:</span>
88                    <input type="text" name="mail" required="required" placeholder="jane@example.com">
89                </label>
90
91                <label>
92                    <span>URL for the plugin:</span>
93                    <input type="text" name="url" placeholder="https://www.dokuwiki.org/plugin:yourplugin">
94                    <small>(leave empty for default dokuwiki.org location)</small>
95                </label>
96
97                <label>
98                    <input type="checkbox" name="use_lang" value="1"/>
99                    <span>Use localization</span>
100                </label>
101
102                <label>
103                    <input type="checkbox" name="use_conf" value="1"/>
104                    <span>Use configuration</span>
105                </label>
106
107                <label>
108                    <input type="checkbox" name="use_tests" value="1"/>
109                    <span>Use unit tests</span>
110                </label>
111            </div>
112
113            <div id="plugin_components">
114                <h2>Add Plugin Components</h2>
115
116                <label>
117                    <span>Type:</span>
118                    <select>
119                        <?php foreach ($WIZ->getPluginTypes() as $type): ?>
120                            <option value="<?php echo $type ?>"><?php echo ucfirst($type) ?></option>
121                        <?php endforeach; ?>
122                    </select>
123                </label>
124
125                <label>
126                    <span>Add as a Sub-Component:</span>
127                    <input type="text" value="" pattern="^[a-z0-9]+$" placeholder="subcomponent"/>
128                    <small>(leave empty to add top level)</small>
129                </label>
130
131                <button type="button">Add Component</button>
132
133                <ul id="output"></ul>
134
135            </div>
136        </section>
137
138        <button type="submit" name="plugin_wiz_create">Create and Download<br>Plugin Skeleton</button>
139
140    </form>
141
142</main>
143<script src="awesomplete.min.js"></script>
144<script src="script.js"></script>
145</body>
146</html>
147