1
0
forked from HPR/hpr_hub

Support for WYSIWYG upload server side

This commit is contained in:
2024-12-24 17:25:14 +01:00
parent a553beafd5
commit c60905e5de
5 changed files with 12704 additions and 107 deletions

View File

@@ -1,5 +1,9 @@
<?php
# request.php > request_confirm.php > upload.php > upload_confirm.php
## Recent Change
# Support for WYSIWYG https://github.com/slab/quill BSD-3-Clause license
require "/home/hpr/php/include.php";
if ( $_SERVER['REQUEST_METHOD'] !== 'GET' and empty($_SERVER["REMOTE_ADDR"]) and count($_GET) !== 1 ) {
@@ -100,20 +104,23 @@ if ( !file_exists( $image_url )) {
// Main
$body="give";
// $body="give";
//$body="index_full";
include 'header.html';
?>
<body>
<link href="quill.snow.css" rel="stylesheet">
<script src="quill.js"></script>
<main id="maincontent">
<hr />
<?php
if ( $ep_num == 9999 ) {
echo "<h1>Uploading to the Reserve Queue.</h1>\n";
echo "<h2>Uploading to the Reserve Queue.</h2>\n";
}
else {
echo "<h1>Uploading hpr${ep_num} for release on ${ep_date}</h1>\n";
echo "<h2>Uploading hpr${ep_num} for release on ${ep_date}</h2>\n";
}
?>
<p>
@@ -162,8 +169,12 @@ include 'header.html';
</tr>
<tr>
<td style="vertical-align:top;">Profile: (<a href="<?php echo "${baseurl}about.html#Profile"; ?>" target="_blank">?</a>)</td>
<!-- TODO https://xing.github.io/wysihtml5/ -->
<td><textarea name="host_profile" maxlength="2000" rows="10" cols="50" placeholder="Enter some text about yourself with links to your blog or other online presence."><?php echo htmlspecialchars($profile) ?></textarea></td>
<td>
<noscript>
<textarea name="host_profile" maxlength="2000" rows="10" cols="50" placeholder="Enter some text about yourself with links to your blog or other online presence."><?php echo htmlspecialchars($profile) ?></textarea>
</noscript>
<div id="editor_profile" name="host_profile"></div>
</td>
</tr>
</table>
<h2>Please fill in some information about this episode</h2>
@@ -176,12 +187,6 @@ include 'header.html';
<td><strong>Summary(*) (<a href="<?php echo "${baseurl}about.html#Short_Summary"; ?>" target="_blank">?</a>):</strong></td>
<td><input required type="text" name="summary" size="70" maxlength="100" placeholder="This is a short 100 character summary of what your show is about."></td>
</tr>
<tr>
<td style="vertical-align:top;"><strong>Theme: (<a href="<?php echo "${baseurl}about.html#Theme"; ?>" target="_blank">?</a>)</strong></td>
<td>
Please <strong>do not</strong> add a theme to your show: <small>See <a href="https://lists.hackerpublicradio.com/pipermail/hpr/2021-November/004328.html">Policy Decision</a> for more information.</small><br />
</td>
</tr>
<tr>
<td><strong>Explicit: (<a href="<?php echo "${baseurl}about.html#Explicit"; ?>" target="_blank">?</a>)</strong></td>
<td>
@@ -208,22 +213,29 @@ include 'header.html';
</tr>
<tr>
<td><strong>Notes(*) (<a href="<?php echo "${baseurl}about.html#show_notes"; ?>" target="_blank">?</a>):</strong></td>
<td><textarea required name="notes" maxlength="40000" rows="20" cols="70" placeholder="Please add your show notes here." ></textarea></td>
</tr>
<tr>
<td>Format: (<a href="<?php echo "${baseurl}about.html#shownotes_format"; ?>" target="_blank">?</a>)</td>
<td>
<small>What format if any did you just use in the show notes above ?</small><br />
<select name="shownotes_format">
<option value="plain_text" selected>Plain text</option>
<option value="html5">HTML5 (Preferred)</option>
<option value="Markdown_GitHub">Markdown (GitHub flavoured)</option>
<option value="Markdown_Pandoc">Markdown (Pandoc flavoured)</option>
<option value="restructured_text">RestructuredText</option>
<option value="txt2tags">txt2tags</option>
</select>
<noscript>
<textarea required name="notes" maxlength="40000" rows="20" cols="70" placeholder="Please add your show notes here." ></textarea>
</noscript>
<div id="editor_notes" name="notes"></div>
</td>
</tr>
<noscript>
<tr>
<td>Format: (<a href="<?php echo "${baseurl}about.html#shownotes_format"; ?>" target="_blank">?</a>)</td>
<td>
<small>What format if any did you just use in the show notes above ?</small><br />
<select name="shownotes_format">
<option value="plain_text" selected>Plain text</option>
<option value="html5">HTML5 (Preferred)</option>
<option value="Markdown_GitHub">Markdown (GitHub flavoured)</option>
<option value="Markdown_Pandoc">Markdown (Pandoc flavoured)</option>
<option value="restructured_text">RestructuredText</option>
<option value="txt2tags">txt2tags</option>
</select>
</td>
</tr>
</noscript>
<tr>
<td>Series: (<a href="<?php echo "${baseurl}about.html#series"; ?>" target="_blank">?</a>)</td>
<td>
@@ -259,24 +271,14 @@ include 'header.html';
Please avoid services that require login or downloading via a browser.<br />
<input type="url" size="30" name="url" placeholder="https://example.com/hpr9999.flac">
</p>
<p>
<strong>3. Upload via an alternative method</strong>:
If you wish to send a show using another method then please discuss it with the HPR Volunteer at admin@hackerpublicradio.org.
</p>
<p>
<strong>4. Reserve a slot</strong>:
Leave upload option 1 and 2 empty if you have received prior approval for a reservation from the Community via the <a href="/mailman/listinfo/hpr_hackerpublicradio.org">HPR Mailing List</a> to either:
</p>
<ul>
<li>Reserve the show now and upload media later.</li>
<li>Send physical media by the postal service or deliver in person.<br />
<em>Make sure you plan in enough time to deliver your media.</em></li>
</ul>
</td>
</tr>
</table>
<?php echo "<input type=\"hidden\" name=\"hostid\" value=\"$hostid\">"; ?>
<?php echo "<input type=\"hidden\" name=\"key\" value=\"$key\">"; ?>
<script>
document.write(`<?php echo "<input type=\"hidden\" name=\"shownotes_format\" value=\"html5\">"; ?>`);
</script>
<br />
<input type="submit" name="submit_edit" value="Submit"> This will take a <strong>long time</strong>, leave the browser running. You will get an email once the upload is complete.
<?php
@@ -290,10 +292,49 @@ include 'header.html';
?>
<div id="progressbar">
<div></div>
</div>
<script>
const toolbarOptions = [
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
['bold', 'italic', 'underline', 'strike'], // toggled buttons
['blockquote', 'code-block'],
['link', 'image'],
['clean'] // remove formatting button
];
const quill_profile = new Quill('#editor_profile', {
modules: {
toolbar: toolbarOptions
},
placeholder: 'Enter your personal profile here...',
theme: 'snow'
});
const form_profile = document.querySelector("form");
quill_profile.root.innerHTML = `<?php echo $profile ?>` .replace(/(<ul>|<ol>|<\/li>)(?:[\s]+)(<li>|<\/ul>|<\/ol>)/g, '$1$2');
form_profile.addEventListener("formdata", (event) => {
event.formData.append("host_profile", quill_profile.root.innerHTML);
});
const quill = new Quill('#editor_notes', {
modules: {
toolbar: toolbarOptions
},
placeholder: 'Enter your show notes here...',
theme: 'snow'
});
const form = document.querySelector("form");
form.addEventListener("formdata", (event) => {
event.formData.append("notes", quill.root.innerHTML);
});
</script>
</form>
</main>
<?php
include 'footer.html';
?>