-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
139 lines (114 loc) · 3.45 KB
/
home.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
namespace DivineComedy;
require_once 'vendor/autoload.php';
// phpcs:disable Generic.Files.LineLength.TooLong
?><!DOCTYPE html>
<html>
<!--
Divine Comedy link shortener - dvncmd.tk
Copyright © 2012-2018 by Ricordisamoa
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The license file can be found at COPYING.txt (in this directory).
-->
<head>
<meta charset="utf-8">
<title>Divine Comedy link shortener - dvncmd.tk</title>
<base target="_blank">
<link href="//fonts.googleapis.com/css?family=IM+Fell+DW+Pica:400,400italic" rel="stylesheet" type="text/css">
<link href="/common.css" rel="stylesheet" type="text/css">
<link href="//upload.wikimedia.org/wikipedia/commons/thumb/e/e5/Dante_icon.png/32px-Dante_icon.png" rel="shortcut icon" type="image/png">
<?php
// phpcs:ignore MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals
$view = new DivineComedyView( $_GET );
if ( !$view->isViewMode() ) {
?><script src="/form.js" type="text/javascript"></script><?php
}
?>
</head>
<body>
<?php
/**
* Show an error message to the user.
*
* @param \Exception $err The exception object from which the message is retrieved
*/
function reportError( \Exception $err ) : void {
echo 'Error: ' . htmlspecialchars( $err->getMessage() );
}
$error = null;
if ( $view->isViewMode() ) {
try {
$view->parseQuery();
echo $view->getLanglinkFlags();
} catch ( DivineComedyException $err ) {
$error = $err;
}
}
?>
<header>
<h1><?php
echo $view->getHeading();
?></h1>
<h2>link shortener</h2>
</header>
<?php
if ( $error !== null ) {
reportError( $error );
} elseif ( $view->isViewMode() ) {
try {
echo $view->getBody();
} catch ( DivineComedyException $err ) {
reportError( $err );
}
} else {
?>
<section>
<h2>Type a Divine Comedy Reference</h2>
<form id="linkgen">
<table>
<tr>
<td>
<label for="input-cantica">Cantica:</label><br>
<select id="input-cantica"><?php
foreach ( array_keys( Cantica::$names ) as $i => $code ) {
echo '<option value="' . $code . '"' . ( $i == 0 ? ' selected' : '' ) .
'>' . Cantica::$names[$code] . '</option>';
}
?></select>
</td>
<td>
<label for="input-canto">Canto:</label><br>
<input type="number" id="input-canto" min="1" max="34" value="1">
</td>
<td>
<label for="input-lines">Lines:</label><br>
<input type="text" id="input-lines" placeholder="1-6" pattern="^\d+(\-\d+)?$">
</td>
<td>
<label for="input-lang">Language code:</label><br>
<input type="text" id="input-lang" value="it">
</td>
</tr>
</table>
</form>
</section>
<section>
<h2>Get a Universal Link</h2>
<a id="link-main" target="_blank">http://dvncmd.tk/<span id="link-lang"></span><span id="link-cantica"></span><span id="link-canto"></span>,<span id="link-lines"></span></a>
</section>
<?php
}
?>
<a href="https://github.com/ricordisamoa/dvncmd">
<img style="position: fixed; top: 0; right: 0; border: 0;" src="//s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub"></a>
</body>
</html>