mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-12-22 13:45:02 +00:00
Add short markdown embed code input box to file pages
This commit is contained in:
parent
b3c3a91faf
commit
e0aeda8b17
4 changed files with 32 additions and 6 deletions
|
@ -3,6 +3,9 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
|
|||
|
||||
## v0.16-dev
|
||||
|
||||
### Added
|
||||
- Added an input box with auto-generated short markdown embed code with copy button
|
||||
|
||||
### Fixed
|
||||
- Fix saving edits to pages with an ampersand in their name (#99)
|
||||
|
||||
|
|
|
@ -5348,7 +5348,7 @@ register_module([
|
|||
}
|
||||
|
||||
$fileInfo = [];
|
||||
$fileInfo["Name"] = str_replace("File/", "", $filepath);
|
||||
$fileInfo["Name"] = str_replace("Files/", "", $filepath);
|
||||
$fileInfo["Type"] = $mime_type;
|
||||
$fileInfo["Size"] = human_filesize(filesize($env->storage_prefix . $filepath));
|
||||
switch($fileTypeDisplay)
|
||||
|
@ -5359,6 +5359,7 @@ register_module([
|
|||
break;
|
||||
}
|
||||
$fileInfo["Uploaded by"] = $pageindex->{$env->page}->lasteditor;
|
||||
$fileInfo["Short markdown embed code"] = "<input type='text' class='short-embed-markdown-code' value='![{$fileInfo["Name"]}]($filepath | right | 350x350)' readonly /> <button class='short-embed-markdown-button'>Copy</button>";
|
||||
|
||||
$preview_html .= "\t\t\t<h2>File Information</h2>
|
||||
<table>";
|
||||
|
@ -5372,6 +5373,17 @@ register_module([
|
|||
}
|
||||
});
|
||||
|
||||
// Add the snippet that copies the embed markdown code to the clipboard
|
||||
page_renderer::AddJSSnippet('window.addEventListener("load", function(event) {
|
||||
console.log("initialising copy driver");
|
||||
let button = document.querySelector(".short-embed-markdown-button");
|
||||
button.addEventListener("click", function(inner_event) {
|
||||
let input = document.querySelector(".short-embed-markdown-code");
|
||||
input.select();
|
||||
button.innerHTML = document.execCommand("copy") ? "Copied!" : "Failed to copy :-(";
|
||||
});
|
||||
});');
|
||||
|
||||
// Register a section on the help page on uploading files
|
||||
add_help_section("28-uploading-files", "Uploading Files", "<p>$settings->sitename supports the uploading of files, though it is up to " . $settings->admindetails_name . ", $settings->sitename's administrator as to whether it is enabled or not (uploads are currently " . (($settings->upload_enabled) ? "enabled" : "disabled") . ").</p>
|
||||
<p>Currently Pepperminty Wiki (the software that $settings->sitename uses) only supports the uploading of images, although more file types should be supported in the future (<a href='//github.com/sbrl/Pepperminty-Wiki/issues'>open an issue on GitHub</a> if you are interested in support for more file types).</p>
|
||||
|
@ -6084,7 +6096,7 @@ register_module([
|
|||
|
||||
register_module([
|
||||
"name" => "Page editor",
|
||||
"version" => "0.17",
|
||||
"version" => "0.17.1",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
|
||||
"id" => "page-edit",
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.",
|
||||
"id": "feature-upload",
|
||||
"lastupdate": 1505512979,
|
||||
"lastupdate": 1513119449,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
@ -163,11 +163,11 @@
|
|||
},
|
||||
{
|
||||
"name": "Page editor",
|
||||
"version": "0.17",
|
||||
"version": "0.17.1",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
|
||||
"id": "page-edit",
|
||||
"lastupdate": 1512908662,
|
||||
"lastupdate": 1512919152,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
|
|
@ -504,7 +504,7 @@ register_module([
|
|||
}
|
||||
|
||||
$fileInfo = [];
|
||||
$fileInfo["Name"] = str_replace("File/", "", $filepath);
|
||||
$fileInfo["Name"] = str_replace("Files/", "", $filepath);
|
||||
$fileInfo["Type"] = $mime_type;
|
||||
$fileInfo["Size"] = human_filesize(filesize($env->storage_prefix . $filepath));
|
||||
switch($fileTypeDisplay)
|
||||
|
@ -515,6 +515,7 @@ register_module([
|
|||
break;
|
||||
}
|
||||
$fileInfo["Uploaded by"] = $pageindex->{$env->page}->lasteditor;
|
||||
$fileInfo["Short markdown embed code"] = "<input type='text' class='short-embed-markdown-code' value='![{$fileInfo["Name"]}]($filepath | right | 350x350)' readonly /> <button class='short-embed-markdown-button'>Copy</button>";
|
||||
|
||||
$preview_html .= "\t\t\t<h2>File Information</h2>
|
||||
<table>";
|
||||
|
@ -528,6 +529,16 @@ register_module([
|
|||
}
|
||||
});
|
||||
|
||||
// Add the snippet that copies the embed markdown code to the clipboard
|
||||
page_renderer::AddJSSnippet('window.addEventListener("load", function(event) {
|
||||
let button = document.querySelector(".short-embed-markdown-button");
|
||||
button.addEventListener("click", function(inner_event) {
|
||||
let input = document.querySelector(".short-embed-markdown-code");
|
||||
input.select();
|
||||
button.innerHTML = document.execCommand("copy") ? "Copied!" : "Failed to copy :-(";
|
||||
});
|
||||
});');
|
||||
|
||||
// Register a section on the help page on uploading files
|
||||
add_help_section("28-uploading-files", "Uploading Files", "<p>$settings->sitename supports the uploading of files, though it is up to " . $settings->admindetails_name . ", $settings->sitename's administrator as to whether it is enabled or not (uploads are currently " . (($settings->upload_enabled) ? "enabled" : "disabled") . ").</p>
|
||||
<p>Currently Pepperminty Wiki (the software that $settings->sitename uses) only supports the uploading of images, although more file types should be supported in the future (<a href='//github.com/sbrl/Pepperminty-Wiki/issues'>open an issue on GitHub</a> if you are interested in support for more file types).</p>
|
||||
|
|
Loading…
Reference in a new issue