aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorVictor Häggqvist <[email protected]>2014-06-22 13:40:55 +0200
committerVictor Häggqvist <[email protected]>2014-06-22 13:40:55 +0200
commit61a021a728e3dfa7b452b1884188780e6dcae01e (patch)
tree63e1a1d6dc15228e9e1cf346811881f8e32c08f4 /core
init
Diffstat (limited to 'core')
-rw-r--r--core/components/parsedown/docs/changelog.txt5
-rw-r--r--core/components/parsedown/docs/license.txt21
-rw-r--r--core/components/parsedown/docs/readme.txt18
-rw-r--r--core/components/parsedown/elements/snippets/snippet.parsedown.php50
-rw-r--r--core/components/parsedown/model/parsedown/parsedownmodx.class.php81
5 files changed, 175 insertions, 0 deletions
diff --git a/core/components/parsedown/docs/changelog.txt b/core/components/parsedown/docs/changelog.txt
new file mode 100644
index 0000000..baea53b
--- /dev/null
+++ b/core/components/parsedown/docs/changelog.txt
@@ -0,0 +1,5 @@
+Changelog for Parsedown integration into MODx Revolution.
+
+Parsedown 0.1.0
+====================================
+- MODx snippet wrapper for Parsedown
diff --git a/core/components/parsedown/docs/license.txt b/core/components/parsedown/docs/license.txt
new file mode 100644
index 0000000..5e0fc21
--- /dev/null
+++ b/core/components/parsedown/docs/license.txt
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Victor Häggqvist
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/core/components/parsedown/docs/readme.txt b/core/components/parsedown/docs/readme.txt
new file mode 100644
index 0000000..cacddd1
--- /dev/null
+++ b/core/components/parsedown/docs/readme.txt
@@ -0,0 +1,18 @@
+--------------------
+Extra: Parsedown
+--------------------
+Version: 0.1.0
+Created: 2014-06-21
+Since: 2014-06-21
+Author: Victor Häggqvist <[email protected]>
+Source: https://github.com/victorhaggqvist/parsedown-modx
+License: MIT
+Creadits: Emanuil Rusev (https://github.com/erusev) Creator of Parsedown (https://github.com/erusev/parsedown)
+
+This Extra provides a snippet [[Parsedown]] which is a wrapper for Parsedown (https://github.com/erusev/parsedown) packaged for easy use in MODx.
+
+Parsedown (PHP lib) is a parser for Markdown with support for GFM (GitHub Flavored Markdown)
+
+USAGE
+
+[[*content:Parsedown]]
diff --git a/core/components/parsedown/elements/snippets/snippet.parsedown.php b/core/components/parsedown/elements/snippets/snippet.parsedown.php
new file mode 100644
index 0000000..7c363bb
--- /dev/null
+++ b/core/components/parsedown/elements/snippets/snippet.parsedown.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Parsedown
+ *
+ * @author Victor Häggqvist <[email protected]>
+ * @copyright Copyright 2014, Victor Häggqvist
+ *
+ * DESCRIPTION
+ *
+ * This snippet is Parsedown (https://github.com/erusev/parsedown) packaged for easy use in MODx.
+ * Parsedown is a parser for Markdown in PHP with support for GFM (GitHub Flavored Markdown)
+ *
+ * USAGE
+ *
+ * [[*content:Parsedown]]
+ *
+ * PHP version 5
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014 Victor Häggqvist
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+$corePath = $modx->getOption('parsedown.core_path', null, $modx->getOption('core_path').'components/parsedown/');
+
+require $corePath.'model/vendor/erusev/parsedown/Parsedown.php';
+
+$parsedownmodx = $modx->getService('parsedownmodx', 'ParsedownMODx', $corePath.'model/parsedown/', $scriptProperties);
+if (!($parsedownmodx instanceof ParsedownMODx)) return '';
+
+$html = $parsedownmodx->parseText($input);
+
+return $html;
diff --git a/core/components/parsedown/model/parsedown/parsedownmodx.class.php b/core/components/parsedown/model/parsedown/parsedownmodx.class.php
new file mode 100644
index 0000000..2c04b1c
--- /dev/null
+++ b/core/components/parsedown/model/parsedown/parsedownmodx.class.php
@@ -0,0 +1,81 @@
+<?php
+
+/**
+ * ParsedownMODx - A MODx Parsedown wrapper
+ *
+ * PHP version 5
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014 Victor Häggqvist
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * @author Victor Häggqvist <[email protected]>
+ * @copyright Copyright 2014, Victor Häggqvist
+ * @package parsedown
+ * @subpackage core
+ */
+
+class ParsedownMODx {
+
+ /**
+ * A modX instance
+ * @var modX (Object)
+ */
+ public $modx;
+
+ /**
+ * Array of config stuff
+ * @var array
+ */
+ public $config = array();
+
+ /**
+ * Parsedown instance
+ * @var Parsedown (Object)
+ */
+ private $parsedown;
+
+ function __construct(modX &$modx,array $config = array()) {
+ $this->modx = &$modx;
+
+ $basePath = $this->modx->getOption('parsedownmodx.core_path', $config,$this->modx->getOption('core_path').'components/parsedownmodx/');
+ $assetsUrl = $this->modx->getOption('parsedownmodx.assets_url', $config,$this->modx->getOption('assets_url').'components/parsedownmodx/');
+ $this->config = array_merge(array(
+ 'basePath' => $basePath,
+ 'corePath' => $basePath,
+ 'modelPath' => $basePath.'model/',
+ 'processorsPath' => $basePath.'processors/',
+ 'templatesPath' => $basePath.'templates/',
+ 'chunksPath' => $basePath.'elements/chunks/',
+ 'jsUrl' => $assetsUrl.'js/',
+ 'cssUrl' => $assetsUrl.'css/',
+ 'assetsUrl' => $assetsUrl,
+ 'connectorUrl' => $assetsUrl.'connector.php',
+ ), $config);
+
+ $this->parsedown = new Parsedown();
+ }
+
+ public function parseText($text) {
+ return $this->parsedown->text($text);
+ }
+}
+?>