Skip to content

Commit 3ae19f1

Browse files
committed
Added ability to download documents as md or html
1 parent f4b2a30 commit 3ae19f1

12 files changed

+78
-13
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Maxdown is a simple markdown editor, using the [codemirror](http://codemirror.ne
1111
- [Open new issue](https://github.com/opoloo/maxdown/issues/new)
1212
- ~~[Official website](#)~~ (coming soon)
1313

14-
![current version](https://img.shields.io/badge/current_version-0.3.10-brightgreen.svg)
15-
![latest update](https://img.shields.io/badge/latest_update-2._September_2015-brightgreen.svg)
14+
![current version](https://img.shields.io/badge/current_version-0.3.11-brightgreen.svg)
15+
![latest update](https://img.shields.io/badge/latest_update-3._September_2015-brightgreen.svg)
1616
![status](https://img.shields.io/badge/status-stable--alpha-yellow.svg)
1717

1818
## Features

assets/javascripts/application.coffee

+17-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ cache =
315315

316316

317317
maxdown =
318-
version: '0.3.10 (2. September 2015)'
318+
version: '0.3.11 (3. September 2015)'
319319
cm: ''
320320
autosave_interval_id: null
321321
autosave_interval: 5000
@@ -502,6 +502,9 @@ maxdown =
502502
@current_doc = null
503503
# Disable Export Button
504504
$('.btn-export').addClass('inactive')
505+
$.post('delete-file.php',
506+
doc_id: id
507+
)
505508
localStorage.removeItem id
506509
@load_documents()
507510
console.log "Deleted document (Doc-ID: " + id + ")"
@@ -578,8 +581,21 @@ maxdown =
578581
generate_preview: ->
579582
@calculate_doc_info()
580583
doc = JSON.parse(localStorage.getItem(@current_doc))
584+
@save_docs_local(doc)
581585
$('.preview').html(markdown.toHTML(doc.content))
582586
$('.preview a').attr('target', '_blank')
587+
$('.btn-download-md span, .btn-download-html span').html(doc.title)
588+
$('.btn-download-md').attr('download', doc.title + '.md')
589+
$('.btn-download-html').attr('download', doc.title + '.html')
590+
$('.btn-download-md').attr('href', 'documents/' + doc.id + '.md')
591+
$('.btn-download-html').attr('href', 'documents/' + doc.id + '.html')
592+
593+
save_docs_local: (doc) ->
594+
$.post('write-file.php',
595+
doc_id: doc.id
596+
doc_content_md: doc.content
597+
doc_content_html: markdown.toHTML(doc.content)
598+
)
583599

584600
calculate_doc_info: ->
585601
doc = JSON.parse(localStorage.getItem(@current_doc))

assets/javascripts/application.js

+18-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/stylesheets/application.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/stylesheets/application.scss

+9-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ body {
9393
top: 0;
9494
right: 0;
9595
background-color: $color-alpha;
96-
display: none;
96+
// display: none;
9797
color: #fff;
9898
&.active {
9999
.main-nav-toggle {
@@ -350,6 +350,14 @@ body {
350350
border-bottom: 1px solid #ddd;
351351
margin-bottom: 1em;
352352
}
353+
ul {
354+
padding-left: 1em;
355+
li {
356+
&+li {
357+
margin-top: 0.5em;
358+
}
359+
}
360+
}
353361
&+.box {
354362
margin-top: 2em;
355363
}

changelog.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Changelog
22

3-
![current version](https://img.shields.io/badge/current_version-0.3.10-brightgreen.svg)
4-
![latest update](https://img.shields.io/badge/latest_update-2._September_2015-brightgreen.svg)
3+
![current version](https://img.shields.io/badge/current_version-0.3.11-brightgreen.svg)
4+
![latest update](https://img.shields.io/badge/latest_update-3._September_2015-brightgreen.svg)
55
![status](https://img.shields.io/badge/status-stable--alpha-yellow.svg)
66

77

8+
- v0.3.11 (3. September 2015)
9+
- Added ability to download documents as .md or .html
810
- v0.3.10 (2. September 2015)
911
- Changed headlines styling in sidebar
1012
- Increased width of editor area

delete-file.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
$doc_id = $_POST['doc_id'];
3+
4+
unlink('documents/'.$doc_id.'.md');
5+
unlink('documents/'.$doc_id.'.html');
6+
?>

documents/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory will contain all md and html versions of the users documents.

0 commit comments

Comments
 (0)