forked from samdark/yiifeed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented notifications for new suggestions and comments, new edito…
…r, code highlighting, rollbar handler for errors
- Loading branch information
Showing
61 changed files
with
962 additions
and
947 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ phpunit.phar | |
/config/key.php | ||
/config/db.php | ||
/config/authclients.php | ||
/config/rollbar.php | ||
|
||
# rbac items | ||
/rbac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
|
||
namespace app\assets; | ||
|
||
|
||
use yii\web\AssetBundle; | ||
|
||
/** | ||
* CodeMirrorAsset groups assets for code editing areas | ||
*/ | ||
class CodeMirrorAsset extends AssetBundle | ||
{ | ||
public $sourcePath = '@bower/codemirror'; | ||
|
||
public $js = [ | ||
'lib/codemirror.js', | ||
|
||
// langs to highlight in markdown blocks | ||
'mode/shell/shell.js', | ||
'mode/clike/clike.js', | ||
'mode/css/css.js', | ||
'mode/javascript/javascript.js', | ||
'mode/php/php.js', | ||
'mode/sass/sass.js', | ||
'mode/sql/sql.js', | ||
'mode/twig/twig.js', | ||
'mode/xml/xml.js', | ||
'mode/yaml/yaml.js', | ||
'mode/htmlmixed/htmlmixed.js', | ||
|
||
// markdown and gfm | ||
'mode/meta.js', | ||
'mode/markdown/markdown.js', | ||
'addon/mode/overlay.js', | ||
'mode/gfm/gfm.js', | ||
'addon/edit/continuelist.js', | ||
|
||
|
||
// code editing goods | ||
'addon/fold/xml-fold.js', | ||
'addon/edit/matchbrackets.js', | ||
'addon/edit/closebrackets.js', | ||
'addon/edit/closetag.js', | ||
|
||
// for controls | ||
'addon/display/panel.js', | ||
]; | ||
|
||
public $css = [ | ||
'lib/codemirror.css', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace app\assets; | ||
|
||
use yii\web\AssetBundle; | ||
|
||
class CodeMirrorButtonsAsset extends AssetBundle | ||
{ | ||
public $sourcePath = '@bower/codemirror-buttons'; | ||
|
||
public $js = [ | ||
'buttons.js', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace app\assets; | ||
|
||
use yii\web\AssetBundle; | ||
|
||
/** | ||
* MarkdownEditorAsset groups assets for markdown editor | ||
*/ | ||
class MarkdownEditorAsset extends AssetBundle | ||
{ | ||
public $sourcePath = '@app/assets/markdown'; | ||
public $js = [ | ||
'editor.js', | ||
]; | ||
public $depends = [ | ||
'yii\web\JqueryAsset', | ||
'app\assets\CodeMirrorAsset', | ||
'app\assets\CodeMirrorButtonsAsset', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
jQuery(function ($) { | ||
CodeMirror.findModeByName('php').mime = 'text/x-php'; | ||
}); | ||
|
||
function initEditor(el) { | ||
el = $(el)[0]; | ||
var editor = CodeMirror.fromTextArea(el, { | ||
mode: 'gfm', | ||
theme: 'default', | ||
extraKeys: { | ||
"Enter": 'newlineAndIndentContinueMarkdownList', | ||
}, | ||
lineWrapping: true, | ||
lineNumbers: false, | ||
matchBrackets: true, | ||
autoCloseBrackets: true, | ||
autoCloseTags: true, | ||
buttons: [ | ||
{ | ||
hotkey: 'Ctrl-B', | ||
class: 'bold btn btn-default', | ||
label: '<i class="glyphicon glyphicon-bold"></i>', | ||
callback: function (cm) { | ||
var selection = cm.getSelection(); | ||
cm.replaceSelection('**' + selection + '**'); | ||
if (!selection) { | ||
var cursorPos = cm.getCursor(); | ||
cm.setCursor(cursorPos.line, cursorPos.ch - 2); | ||
} | ||
} | ||
}, | ||
{ | ||
hotkey: 'Ctrl-I', | ||
class: 'italic btn btn-default', | ||
label: '<i class="glyphicon glyphicon-italic"></i>', | ||
callback: function (cm) { | ||
var selection = cm.getSelection(); | ||
cm.replaceSelection('*' + selection + '*'); | ||
if (!selection) { | ||
var cursorPos = cm.getCursor(); | ||
cm.setCursor(cursorPos.line, cursorPos.ch - 1); | ||
} | ||
} | ||
}, | ||
{ | ||
class: 'block-code btn btn-default', | ||
label: 'CODE', | ||
callback: function (cm) { | ||
var language = prompt('Language') || ''; | ||
|
||
var selection = cm.getSelection(); | ||
cm.replaceSelection("```" + language + "\n" + selection + "\n```\n"); | ||
if (!selection) { | ||
var cursorPos = cm.getCursor(); | ||
cm.setCursor(cursorPos.line - 2, 0); | ||
} | ||
} | ||
}, | ||
{ | ||
class: 'quote btn btn-default', | ||
label: '<i class="glyphicon glyphicon-menu-right"></i>', | ||
callback: function (cm) { | ||
cm.replaceSelection("> " + cm.getSelection()); | ||
} | ||
}, | ||
{ | ||
class: 'ul btn btn-default', | ||
label: 'UL', | ||
callback: function (cm) { | ||
cm.replaceSelection("- " + cm.getSelection()); | ||
} | ||
}, | ||
{ | ||
class: 'ol btn btn-default', | ||
label: 'OL', | ||
callback: function (cm) { | ||
cm.replaceSelection("1. " + cm.getSelection()); | ||
} | ||
}, | ||
{ | ||
class: 'a btn btn-default', | ||
label: '<i class="glyphicon glyphicon-link"></i>', | ||
callback: function (cm) { | ||
var selection = cm.getSelection(); | ||
var text = ''; | ||
var link = ''; | ||
|
||
if (selection.match(/^https?:\/\//)) { | ||
link = selection; | ||
} else { | ||
text = selection; | ||
} | ||
cm.replaceSelection('[' + text + '](' + link + ')'); | ||
|
||
var cursorPos = cm.getCursor(); | ||
if (!selection) { | ||
cm.setCursor(cursorPos.line, cursorPos.ch - 3); | ||
} else if (link) { | ||
cm.setCursor(cursorPos.line, cursorPos.ch - (3 + link.length)); | ||
} else { | ||
cm.setCursor(cursorPos.line, cursorPos.ch - 1); | ||
} | ||
} | ||
}, | ||
{ | ||
class: 'img btn btn-default', | ||
label: '<i class="glyphicon glyphicon-picture"></i>', | ||
callback: function (cm) { | ||
var url = prompt('Add image url') || ''; | ||
|
||
var selection = cm.getSelection(); | ||
cm.replaceSelection('<img src="' + url + '"' + selection + ' />'); | ||
|
||
} | ||
}, | ||
{ | ||
class: 'img btn btn-default', | ||
label: '<i class="glyphicon glyphicon-resize-small"></i>', | ||
callback: function (cm) { | ||
$('.CodeMirror').css('height', 'auto'); | ||
} | ||
}, | ||
] | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.