Add ODT note export, add more metadata to HTML export

master
Skylar Ittner 5 년 전
부모 061834572a
커밋 3ff8a9389a

@ -70,9 +70,29 @@ switch ($VARS['action']) {
if (!$note->hasReadAccess(new User($_SESSION['uid']))) {
die($Strings->get("invalid parameters", false));
}
header("Content-Type: text/markdown; charset=UTF-8");
header("Content-disposition: attachment; filename=\"" . $note->getCleanTitle() . "_" . $note->getModified() . ".md\"");
echo $note->getText();
if (empty($VARS['type'])) {
$VARS['type'] = "markdown";
}
switch ($VARS['type']) {
case "html":
header("Content-Type: text/html; charset=UTF-8");
header("Content-disposition: attachment; filename=\"" . $note->getCleanTitle() . "_" . $note->getModified() . ".html\"");
echo $note->getHTML(false);
break;
case "odt":
if (PANDOC_BIN != "") {
header("Content-Type: application/vnd.oasis.opendocument.text");
header("Content-disposition: attachment; filename=\"" . $note->getCleanTitle() . "_" . $note->getModified() . ".odt\"");
$pandoc = new Pandoc\Pandoc();
echo $pandoc->convert($note->getText(), "markdown_github", "odt");
break;
}
default:
header("Content-Type: text/markdown; charset=UTF-8");
header("Content-disposition: attachment; filename=\"" . $note->getCleanTitle() . "_" . $note->getModified() . ".md\"");
echo $note->getText();
}
break;
case "favoritenote":
if (empty($VARS['noteid'])) {

@ -8,7 +8,8 @@
"erusev/parsedown": "^1.7",
"leblanc-simon/parsedown-checkbox": "^0.0.2",
"erusev/parsedown-extra": "^0.7.1",
"vanilla/htmlawed": "v2.2.4.1"
"vanilla/htmlawed": "v2.2.4.1",
"ryakad/pandoc-php": "^1.0"
},
"license": "MPL-2.0",
"authors": [

28
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "b50c578394552657e0fcab936a4b1a01",
"content-hash": "cd5ba5d882b72c49f91fbc1a6bd97095",
"packages": [
{
"name": "catfan/medoo",
@ -431,6 +431,32 @@
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "ryakad/pandoc-php",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/ryakad/pandoc-php.git",
"reference": "0cfdf959408e4c481db942b26785d94b9fe46672"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ryakad/pandoc-php/zipball/0cfdf959408e4c481db942b26785d94b9fe46672",
"reference": "0cfdf959408e4c481db942b26785d94b9fe46672",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-0": {
"Pandoc": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"time": "2015-01-07T05:07:16+00:00"
},
{
"name": "vanilla/htmlawed",
"version": "v2.2.4.1",

@ -4,7 +4,6 @@
"Note": "Note",
"Edit": "Edit",
"Delete": "Delete",
"Download": "Download",
"Note deleted": "Note deleted",
"Favorite": "Favorite",
"Set color": "Set color",
@ -14,5 +13,13 @@
"Close": "Close",
"Refresh": "Refresh",
"Make a List": "Make a List",
"More": "More"
"More": "More",
"More Options": "More Options",
"Download": "Download",
"Text": "Text",
"HTML": "HTML",
"Office": "Office",
"Download (Text)": "Download (Text)",
"Download (HTML)": "Download (HTML)",
"Download (Office)": "Download (Office)"
}

@ -125,7 +125,12 @@ class Note {
$document = "<!DOCTYPE html>\n"
. "<meta charset=\"UTF-8\">\n"
. "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n"
. "<title>" . $this->getCleanTitle() . " (" . $note->getModified() . ")</title>\n"
. "<meta name=\"author\" content=\"" . htmlentities($this->getOwner()->getName()) . "\">\n"
. "<meta name=\"generator\" content=\"" . SITE_TITLE . "\">\n"
. "<link rel=\"schema.dcterms\" href=\"http://purl.org/dc/terms/\">\n"
. "<meta name=\"dcterms.modified\" content=\"" . date("Y-m-d", strtotime($this->getModified())) . "\">\n"
. "\n"
. "<title>" . $this->getCleanTitle() . "</title>\n"
. "\n"
. $safehtml;
return $document;

@ -135,12 +135,35 @@ foreach ($colors as $c) {
</a>
</span>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="moreoptionsbtn_<?php echo $note->getID(); ?>">
<!--<h4 class="dropdown-header"><?php $Strings->get("More Options"); ?></h4>-->
<a class="dropdown-item" href="./action.php?action=deletenote&noteid=<?php echo $note->getID(); ?>">
<i class="fas fa-trash"></i> <?php $Strings->get('Delete'); ?>
</a>
<a class="dropdown-item" href="./action.php?action=downloadnote&noteid=<?php echo $note->getID(); ?>">
<i class="fas fa-download"></i> <?php $Strings->get('Download'); ?>
<i class="fas fa-trash fa-fw"></i> <?php $Strings->get('Delete'); ?>
</a>
<div class="dropdown-divider"></div>
<h4 class="dropdown-header"><i class="fas fa-cloud-download-alt fa-fw"></i> <?php $Strings->get('Download'); ?></h4>
<div class="dropdown-item d-flex justify-content-between">
<a class="p-2" href="./action.php?action=downloadnote&noteid=<?php echo $note->getID(); ?>&type=markdown">
<i class="fas fa-align-left"></i> <?php $Strings->get('Text'); ?>
</a>
<a class="p-2" href="./action.php?action=downloadnote&noteid=<?php echo $note->getID(); ?>&type=html">
<i class="fab fa-html5"></i> <?php $Strings->get('HTML'); ?>
</a>
<?php
// Additional export formats
if (PANDOC_BIN != "") {
?>
<a class="p-2" href="./action.php?action=downloadnote&noteid=<?php echo $note->getID(); ?>&type=odt">
<i class="fas fa-file-alt"></i> <?php $Strings->get('Office'); ?>
</a>
<?php
} else {
// Fillin' space
?>
<span class="px-4">&nbsp;</span>
<?php
}
?>
</div>
</div>
</div>
</div>

@ -20,6 +20,9 @@ define("DB_CHARSET", "utf8");
// Name of the app.
define("SITE_TITLE", "NotePost");
// Location of the pandoc binary. Enables exporting notes as ODT.
// Leave as an empty string to hide/disable this feature in the GUI.
define("PANDOC_BIN", "/usr/bin/pandoc");
// URL of the AccountHub API endpoint
define("PORTAL_API", "http://localhost/accounthub/api.php");

@ -28,11 +28,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
.dropdown-menu {
z-index: 9999999;
transform: translate3d(-100px, -85px, 0px) !important;
transform: translate3d(-180px, -125px, 0px) !important;
}
.dropdown-item {
.dropdown-item, .dropdown-item a, .dropdown-item a:hover {
color: #212121 !important;
text-decoration: none;
}
.parsedown-task-list-close {

불러오는 중...
취소
저장