Skip to content

Commit 385ee63

Browse files
committed
Try to add option to remove media
1 parent d42dc26 commit 385ee63

File tree

13 files changed

+40
-10
lines changed

13 files changed

+40
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v1.5.9
2+
- Try to add option to remove media
3+
14
### v1.5.8
25
- Changed Markdown Editor to [EasyMD v2.13.0](https://github.com/ionaru/easy-markdown-editor)
36
- Removed rarely used code styles

config.inc.php.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ $config['default_format'] = 'md'; // default format, you can choose between 'htm
66
$config['yaml_support'] = true; // set to true, if you want enable yaml support
77
$config['yaml_start'] = '---'; // the yaml header should starts as the first sign in a markdown note and is marked by default with '---'
88
$config['yaml_end'] = '---'; // the signs which marks the end of the yaml header
9+
$config['rm_md_media'] = false; // if set to yes, embedded media will be removed
910
?>

localization/de_DE.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ $labels['note_formattxt'] = 'Normaler Text';
1818
$labels['ariallabelnewoptions'] = 'Optionen';
1919
$labels['note_defaultformat'] = 'Standard Format';
2020
$labels['note_yamls'] = 'Aktiviere YAML';
21+
$labels['note_rmedia_md'] = 'Lösche automatisch eingbettete Medien mit Markdown Files';
2122
?>

localization/en_US.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ $labels['note_formattxt'] = 'Pure Text';
1818
$labels['ariallabelnewoptions'] = 'Options';
1919
$labels['note_defaultformat'] = 'Default Format';
2020
$labels['note_yamls'] = 'Enable YAML';
21+
$labels['note_rmedia_md'] = 'Remove automatically embedded Media with Markdown Files';
2122
?>

localization/es_AR.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ $labels['note_formattxt'] = 'Texto Plano';
1818
$labels['ariallabelnewoptions'] = 'Opciones';
1919
$labels['note_defaultformat'] = 'Formato estándar';
2020
$labels['note_yamls'] = 'Activa YAML';
21+
$labels['note_rmedia_md'] = 'Elimina automáticamente los medios incrustados con Markdown Files';
2122
?>

localization/pt_BR.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ $labels['note_formathtml'] = 'HTML';
1616
$labels['note_formatmd'] = 'Remarcar';
1717
$labels['note_formattxt'] = 'Texto puro';
1818
$labels['ariallabelnewoptions'] = 'Opções';
19+
$labels['note_rmedia_md'] = 'Exclua automaticamente a mídia incorporada com arquivos Markdown';
1920
?>

localization/ru_RU.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ $labels['note_formattxt'] = 'Текстовая заметка';
1818
$labels['ariallabelnewoptions'] = 'Параметры';
1919
$labels['note_defaultformat'] = 'Стандартный формат';
2020
$labels['note_yamls'] = 'Активировать YAML';
21+
$labels['note_rmedia_md'] = 'Автоматическое удаление встроенного мультимедиа с помощью файлов Markdown';
2122
?>

notes.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Roundcube Notes Plugin
44
*
5-
* @version 1.5.8
5+
* @version 1.5.9
66
* @author Offerel
77
* @copyright Copyright (c) 2021, Offerel
88
* @license GNU General Public License, version 3
@@ -313,6 +313,17 @@
313313
$file = $notes_path.$_POST["fileid"];
314314

315315
if(file_exists($file)) {
316+
if(substr ($file, -3) == ".md" && boolval($rcmail->config->get('rm_md_media', false))) {
317+
$fcontent = file_get_contents($file);
318+
$mpath = dirname($file);
319+
preg_match_all('/(?:!\[(.*?)\]\((.*?)\))/m', $fcontent, $mediaFiles, PREG_SET_ORDER, 0);
320+
foreach($mediaFiles as $mKey => $mFile) {
321+
if(!unlink($mpath.ltrim($mFile[2],'.'))) {
322+
error_log('PrimitiveNotes: Couldn\'t delete media file. Please check your directory permissions.');
323+
}
324+
}
325+
}
326+
316327
if(!unlink($file)) {
317328
error_log('PrimitiveNotes: Couldn\'t delete note. Please check your directory permissions.');
318329
}

primitivenotes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Roundcube Notes Plugin
33
*
4-
* @version 1.5.8
4+
* @version 1.5.9
55
* @author Offerel
66
* @copyright Copyright (c) 2021, Offerel
77
* @license GNU General Public License, version 3

primitivenotes.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)