diff --git a/action.php b/action.php index ac57152..c8ec748 100644 --- a/action.php +++ b/action.php @@ -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'])) { diff --git a/composer.json b/composer.json index 1c00eec..94b0fb2 100644 --- a/composer.json +++ b/composer.json @@ -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": [ diff --git a/composer.lock b/composer.lock index 10fd048..0d331e7 100644 --- a/composer.lock +++ b/composer.lock @@ -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", diff --git a/langs/en/notes.json b/langs/en/notes.json index 1ddc0b5..a145157 100644 --- a/langs/en/notes.json +++ b/langs/en/notes.json @@ -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)" } diff --git a/lib/Note.lib.php b/lib/Note.lib.php index c7ed319..f6a6931 100644 --- a/lib/Note.lib.php +++ b/lib/Note.lib.php @@ -125,7 +125,12 @@ class Note { $document = "\n" . "\n" . "\n" - . "" . $this->getCleanTitle() . " (" . $note->getModified() . ")\n" + . "getOwner()->getName()) . "\">\n" + . "\n" + . "\n" + . "getModified())) . "\">\n" + . "\n" + . "" . $this->getCleanTitle() . "\n" . "\n" . $safehtml; return $document; diff --git a/pages/home.php b/pages/home.php index 0e7eec8..09b033e 100644 --- a/pages/home.php +++ b/pages/home.php @@ -135,12 +135,35 @@ foreach ($colors as $c) { diff --git a/settings.template.php b/settings.template.php index 3ee374f..020d77b 100644 --- a/settings.template.php +++ b/settings.template.php @@ -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"); diff --git a/static/css/home.css b/static/css/home.css index 7e4023d..9a44e79 100644 --- a/static/css/home.css +++ b/static/css/home.css @@ -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 {