Skip to content

Commit

Permalink
Update to release v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Jan 12, 2015
1 parent 11d0aa0 commit 3535ddf
Show file tree
Hide file tree
Showing 19 changed files with 86 additions and 88 deletions.
9 changes: 9 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
version 1.3.0
=============
*Date:* 12-Jan-2015

- Revamp to use new Krajee base Module and TranslationTrait.
- Change message file category name to begin with `kv` prefix.
- Code formatting updates as per Yii2 coding style.
- Set release to stable

version 1.2.0
=============
*Date:* 16-Dec-2014
Expand Down
27 changes: 15 additions & 12 deletions Markdown.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

/**
* @package yii2-markdown
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-markdown
* @version 1.2.0
* @version 1.3.0
*/

namespace kartik\markdown;
Expand All @@ -21,12 +22,6 @@
*/
class Markdown
{

/**
* @var MarkdownExtra
*/
protected static $markdown;

// SmartyPantsTypographer does nothing at all
const SMARTYPANTS_ATTR_DO_NOTHING = 0;
// "--" for em-dashes; no en-dash support
Expand All @@ -36,15 +31,21 @@ class Markdown
// "--" for em-dashes; "---" for en-dashes
const SMARTYPANTS_ATTR_SHORT_EM_DASH_LONG_EN = 3;

/**
* @var MarkdownExtra $markdown
*/
protected static $markdown;

/**
* Converts markdown into HTML
*
* @param string $content
* @param array $config . Options to configure MarkdownExtra and smarty
* @param array $config . Options to configure MarkdownExtra and smarty
* - markdown: array for MarkdownExtra configuration parameters
* - smarty: array for SmartyPantsTypographer configuration parameters
* - custom: array for Custom configuration parameters
* @param int $smartyMode the SmartyPantsTypographer processing mode
* @param int $smartyMode the SmartyPantsTypographer processing mode
*
* @return string
* @throws InvalidConfigException if module not set
*/
Expand Down Expand Up @@ -76,7 +77,8 @@ public static function convert($content, $config = [], $smartyMode = self::SMART
* Converts markdown into HTML
*
* @param string $content
* @param array $config
* @param array $config
*
* @return string
*/
public static function process($content, $config = [])
Expand All @@ -94,7 +96,8 @@ public static function process($content, $config = [])
* Custom conversion of patterns
*
* @param string $content
* @param array $config . List of key value pairs to find and replace
* @param array $config . List of key value pairs to find and replace
*
* @return string
*/
public static function customProcess($content, $config = [])
Expand Down
85 changes: 43 additions & 42 deletions MarkdownEditor.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

/**
* @package yii2-markdown
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-markdown
* @version 1.2.0
* @version 1.3.0
*/

namespace kartik\markdown;
Expand Down Expand Up @@ -430,27 +431,27 @@ public function generateMessages()
$this->footerMessage = $this->getFooterMessage();
}
if (!isset($this->emptyPreview)) {
$this->emptyPreview = '<p class="help-block text-center">' . Yii::t('markdown', 'No content to display') . '</p>';
$this->emptyPreview = '<p class="help-block text-center">' . Yii::t('kvmarkdown', 'No content to display') . '</p>';
}
$exportAlert = 'Your {type} file will be generated and downloaded as {filename}.';
$popupAlert = Yii::t('markdown', 'Disable any popup blockers in your browser to ensure proper download.');
$popupAlert = Yii::t('kvmarkdown', 'Disable any popup blockers in your browser to ensure proper download.');
if (empty($this->exportFileName)) {
$this->exportFileName = Yii::t('markdown', 'markdown-export');
$this->exportFileName = Yii::t('kvmarkdown', 'markdown-export');
}
if (!isset($this->exportTextAlert)) {
$this->exportTextAlert = Yii::t('markdown', $exportAlert, [
'type' => Yii::t('markdown', 'TEXT'),
$this->exportTextAlert = Yii::t('kvmarkdown', $exportAlert, [
'type' => Yii::t('kvmarkdown', 'TEXT'),
'filename' => $this->exportFileName . '.txt',
]) . "\n\n" . $popupAlert;
}
if (!isset($this->exportHtmlAlert)) {
$this->exportHtmlAlert = Yii::t('markdown', $exportAlert, [
'type' => Yii::t('markdown', 'HTML'),
$this->exportHtmlAlert = Yii::t('kvmarkdown', $exportAlert, [
'type' => Yii::t('kvmarkdown', 'HTML'),
'filename' => $this->exportFileName . '.htm',
]) . "\n\n" . $popupAlert;
}
if (!isset($this->exportHeader)) {
$this->exportHeader = "> - - -\n> " . Yii::t('markdown', "Markdown Export{line} *Generated {date} by {class}", [
$this->exportHeader = "> - - -\n> " . Yii::t('kvmarkdown', "Markdown Export{line} *Generated {date} by {class}", [
'line' => "\n> ===============\n>",
'date' => date("d-M-Y H:i"),
'class' => "\\kartik\\markdown\\MarkdownEditor*\n> - - -\n\n"
Expand All @@ -466,7 +467,7 @@ public function generateMessages()
);
}
if (!isset($this->previewProgress)) {
$this->previewProgress = '<div class="kv-loading">' . Yii::t('markdown', 'Loading Preview') . ' &hellip;</div>';
$this->previewProgress = '<div class="kv-loading">' . Yii::t('kvmarkdown', 'Loading Preview') . ' &hellip;</div>';
}
}

Expand All @@ -476,15 +477,15 @@ public function generateMessages()
protected function getFooterMessage()
{
$bullet = '<i class="glyphicon glyphicon-arrow-right"></i>';
$link1 = '<a href="http://michelf.ca/projects/php-markdown/extra/" target="_blank">' . Yii::t('markdown', 'PHP Markdown Extra') . '</a>';
$link2 = '<a href="http://michelf.ca/projects/php-smartypants/typographer/" target="_blank">' . Yii::t('markdown', 'PHP SmartyPants Typographer') . '</a>';
$link = $this->_module->smartyPants ? $link1 . ' ' . Yii::t('markdown', 'and') . ' ' . $link2 : $link1;
$msg1 = Yii::t('markdown', '{bullet} You may use {link} syntax.', [
$link1 = '<a href="http://michelf.ca/projects/php-markdown/extra/" target="_blank">' . Yii::t('kvmarkdown', 'PHP Markdown Extra') . '</a>';
$link2 = '<a href="http://michelf.ca/projects/php-smartypants/typographer/" target="_blank">' . Yii::t('kvmarkdown', 'PHP SmartyPants Typographer') . '</a>';
$link = $this->_module->smartyPants ? $link1 . ' ' . Yii::t('kvmarkdown', 'and') . ' ' . $link2 : $link1;
$msg1 = Yii::t('kvmarkdown', '{bullet} You may use {link} syntax.', [
'bullet' => $bullet,
'link' => $link
]);
$keys = '<kbd>' . Yii::t('markdown', 'CTRL-Z') . '</kbd> / <kbd>' . Yii::t('markdown', 'CTRL-Y') . '</kbd>';
$msg2 = Yii::t('markdown', '{bullet} To undo / redo, press {keys}. You can also undo most button actions by clicking it again.', [
$keys = '<kbd>' . Yii::t('kvmarkdown', 'CTRL-Z') . '</kbd> / <kbd>' . Yii::t('kvmarkdown', 'CTRL-Y') . '</kbd>';
$msg2 = Yii::t('kvmarkdown', '{bullet} To undo / redo, press {keys}. You can also undo most button actions by clicking it again.', [
'bullet' => $bullet,
'keys' => $keys
]);
Expand All @@ -510,7 +511,7 @@ protected function registerAssets()
'url' => Url::toRoute($this->_module->previewAction),
'export1' => '#' . $this->getButtonId(self::BTN_EXPORT_1),
'export2' => '#' . $this->getButtonId(self::BTN_EXPORT_2),
'nullMsg' => Yii::t('markdown', $this->emptyPreview),
'nullMsg' => Yii::t('kvmarkdown', $this->emptyPreview),
'height' => $this->height,
'exportText' => $this->exportTextAlert,
'exportHtml' => $this->exportHtmlAlert,
Expand Down Expand Up @@ -538,22 +539,22 @@ protected function setDefaultHeader()

$heading = function ($n) {
return [
'label' => Yii::t('markdown', 'Heading {n}', ['n' => $n]),
'label' => Yii::t('kvmarkdown', 'Heading {n}', ['n' => $n]),
'options' => [
'class' => 'kv-heading-' . $n,
'title' => Yii::t('markdown', 'Heading {n} Style', ['n' => $n])
'title' => Yii::t('kvmarkdown', 'Heading {n} Style', ['n' => $n])
]
];
};

$this->toolbar = [
[
'buttons' => [
self::BTN_BOLD => ['icon' => 'bold', 'title' => Yii::t('markdown', 'Bold')],
self::BTN_ITALIC => ['icon' => 'italic', 'title' => Yii::t('markdown', 'Italic')],
self::BTN_PARAGRAPH => ['icon' => 'font', 'title' => Yii::t('markdown', 'Paragraph')],
self::BTN_NEW_LINE => ['icon' => 'text-height', 'title' => Yii::t('markdown', 'Append Line Break')],
self::BTN_HEADING => ['icon' => 'header', 'title' => Yii::t('markdown', 'Heading'), 'items' => [
self::BTN_BOLD => ['icon' => 'bold', 'title' => Yii::t('kvmarkdown', 'Bold')],
self::BTN_ITALIC => ['icon' => 'italic', 'title' => Yii::t('kvmarkdown', 'Italic')],
self::BTN_PARAGRAPH => ['icon' => 'font', 'title' => Yii::t('kvmarkdown', 'Paragraph')],
self::BTN_NEW_LINE => ['icon' => 'text-height', 'title' => Yii::t('kvmarkdown', 'Append Line Break')],
self::BTN_HEADING => ['icon' => 'header', 'title' => Yii::t('kvmarkdown', 'Heading'), 'items' => [
self::BTN_H1 => $heading(1),
self::BTN_H2 => $heading(2),
self::BTN_H3 => $heading(3),
Expand All @@ -565,43 +566,43 @@ protected function setDefaultHeader()
],
[
'buttons' => [
self::BTN_LINK => ['icon' => 'link', 'title' => Yii::t('markdown', 'URL/Link')],
self::BTN_IMAGE => ['icon' => 'picture', 'title' => Yii::t('markdown', 'Image')],
self::BTN_LINK => ['icon' => 'link', 'title' => Yii::t('kvmarkdown', 'URL/Link')],
self::BTN_IMAGE => ['icon' => 'picture', 'title' => Yii::t('kvmarkdown', 'Image')],
],
],
[
'buttons' => [
self::BTN_INDENT_L => ['icon' => 'indent-left', 'title' => Yii::t('markdown', 'Indent Text')],
self::BTN_INDENT_R => ['icon' => 'indent-right', 'title' => Yii::t('markdown', 'Unindent Text')],
self::BTN_INDENT_L => ['icon' => 'indent-left', 'title' => Yii::t('kvmarkdown', 'Indent Text')],
self::BTN_INDENT_R => ['icon' => 'indent-right', 'title' => Yii::t('kvmarkdown', 'Unindent Text')],
],
],
[
'buttons' => [
self::BTN_UL => ['icon' => 'list', 'title' => Yii::t('markdown', 'Bulleted List')],
self::BTN_OL => ['icon' => 'list-alt', 'title' => Yii::t('markdown', 'Numbered List')],
self::BTN_DL => ['icon' => 'th-list', 'title' => Yii::t('markdown', 'Definition List')],
self::BTN_UL => ['icon' => 'list', 'title' => Yii::t('kvmarkdown', 'Bulleted List')],
self::BTN_OL => ['icon' => 'list-alt', 'title' => Yii::t('kvmarkdown', 'Numbered List')],
self::BTN_DL => ['icon' => 'th-list', 'title' => Yii::t('kvmarkdown', 'Definition List')],
],
],
[
'buttons' => [
self::BTN_FOOTNOTE => ['icon' => 'edit', 'title' => Yii::t('markdown', 'Footnote')],
self::BTN_QUOTE => ['icon' => 'comment', 'title' => Yii::t('markdown', 'Block Quote')],
self::BTN_FOOTNOTE => ['icon' => 'edit', 'title' => Yii::t('kvmarkdown', 'Footnote')],
self::BTN_QUOTE => ['icon' => 'comment', 'title' => Yii::t('kvmarkdown', 'Block Quote')],
],
],
[
'buttons' => [
self::BTN_CODE => ['label' => self::ICON_CODE, 'title' => Yii::t('markdown', 'Inline Code'), 'encodeLabel' => false],
self::BTN_CODE_BLOCK => ['icon' => 'sound-stereo', 'title' => Yii::t('markdown', 'Code Block')],
self::BTN_CODE => ['label' => self::ICON_CODE, 'title' => Yii::t('kvmarkdown', 'Inline Code'), 'encodeLabel' => false],
self::BTN_CODE_BLOCK => ['icon' => 'sound-stereo', 'title' => Yii::t('kvmarkdown', 'Code Block')],
],
],
[
'buttons' => [
self::BTN_HR => ['label' => self::ICON_HR, 'title' => Yii::t('markdown', 'Horizontal Line'), 'encodeLabel' => false],
self::BTN_HR => ['label' => self::ICON_HR, 'title' => Yii::t('kvmarkdown', 'Horizontal Line'), 'encodeLabel' => false],
],
],
[
'buttons' => [
self::BTN_MAXIMIZE => ['icon' => 'fullscreen', 'title' => Yii::t('markdown', 'Toggle full screen'), 'data-enabled' => true]
self::BTN_MAXIMIZE => ['icon' => 'fullscreen', 'title' => Yii::t('kvmarkdown', 'Toggle full screen'), 'data-enabled' => true]
],
'options' => ['class' => 'pull-right']
],
Expand All @@ -620,15 +621,15 @@ protected function setDefaultFooter()
$this->footerButtons = [
[
'buttons' => [
self::BTN_EXPORT => ['icon' => 'floppy-disk', 'label' => Yii::t('markdown', 'Export'), 'title' => Yii::t('markdown', 'Export content'), 'class' => 'btn btn-sm btn-primary', 'data-enabled' => true, 'items' => [
self::BTN_EXPORT_1 => ['icon' => 'floppy-save', 'label' => Yii::t('markdown', 'Text'), 'options' => ['title' => Yii::t('markdown', 'Save as text')]],
self::BTN_EXPORT_2 => ['icon' => 'floppy-saved', 'label' => Yii::t('markdown', 'HTML'), 'options' => ['title' => Yii::t('markdown', 'Save as HTML')]],
self::BTN_EXPORT => ['icon' => 'floppy-disk', 'label' => Yii::t('kvmarkdown', 'Export'), 'title' => Yii::t('kvmarkdown', 'Export content'), 'class' => 'btn btn-sm btn-primary', 'data-enabled' => true, 'items' => [
self::BTN_EXPORT_1 => ['icon' => 'floppy-save', 'label' => Yii::t('kvmarkdown', 'Text'), 'options' => ['title' => Yii::t('kvmarkdown', 'Save as text')]],
self::BTN_EXPORT_2 => ['icon' => 'floppy-saved', 'label' => Yii::t('kvmarkdown', 'HTML'), 'options' => ['title' => Yii::t('kvmarkdown', 'Save as HTML')]],
]],
]
],
[
'buttons' => [
self::BTN_PREVIEW => ['icon' => 'search', 'label' => Yii::t('markdown', 'Preview'), 'title' => Yii::t('markdown', 'Preview formatted text')],
self::BTN_PREVIEW => ['icon' => 'search', 'label' => Yii::t('kvmarkdown', 'Preview'), 'title' => Yii::t('kvmarkdown', 'Preview formatted text')],
]
],
];
Expand Down
5 changes: 3 additions & 2 deletions MarkdownEditorAsset.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

/**
* @package yii2-markdown
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-markdown
* @version 1.2.0
* @version 1.3.0
*/

namespace kartik\markdown;
Expand Down
24 changes: 5 additions & 19 deletions Module.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

/**
* @package yii2-markdown
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-markdown
* @version 1.2.0
* @version 1.3.0
*/

namespace kartik\markdown;
Expand All @@ -16,9 +17,8 @@
* @author Kartik Visweswaran <[email protected]>
* @since 1.0
*/
class Module extends \yii\base\Module
class Module extends \kartik\base\Module
{

/**
* @var string the controller action route used
* for markdown editor preview
Expand Down Expand Up @@ -46,24 +46,10 @@ class Module extends \yii\base\Module
*/
public $smartyPants = true;

/**
* @var array the the internalization configuration for
* this module
*/
public $i18n = [];

public function init()
{
$this->_msgCat = 'kvmarkdown';
parent::init();
Yii::setAlias('@markdown', dirname(__FILE__));
if (empty($this->i18n)) {
$this->i18n = [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@markdown/messages',
'forceTranslation' => true
];
}
Yii::$app->i18n->translations['markdown'] = $this->i18n;
}

}
2 changes: 1 addition & 1 deletion assets/css/kv-markdown.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014
* @package yii2-markdown
* @version 1.2.0
* @version 1.3.0
*
* Markdown editor styling using Bootstrap 3.0 theme
* Built for Yii Framework 2.0
Expand Down
2 changes: 1 addition & 1 deletion assets/css/kv-markdown.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions assets/js/kv-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
* Krajee.com
* Licensed under BSD-3 License.
* Refer attached LICENSE.md for details.
* Version: 1.2.0
* Build date: 6 September 2014
* Version: 1.3.0
*/
String.prototype.trimRight = function (charlist) {
if (charlist === undefined) {
Expand Down
Loading

0 comments on commit 3535ddf

Please sign in to comment.