From a00da671a68e9012f0ad53f1e7227811df254e2b Mon Sep 17 00:00:00 2001 From: mutoo Date: Wed, 11 Dec 2013 17:08:47 +0800 Subject: [PATCH 1/3] correct a spelling mistakes --- LaTex/latex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LaTex/latex.js b/LaTex/latex.js index 3ed80fe..bafc138 100644 --- a/LaTex/latex.js +++ b/LaTex/latex.js @@ -1,6 +1,6 @@ (function() { var $ = document.querySelectorAll.bind(document); - var latex = $('code.lang-laTex, code.lang-latex, code.lang-tex'); + var latex = $('code.lang-LaTex, code.lang-latex, code.lang-tex'); for (var i = 0, l = latex.length; i < l; i++) { var node = latex[i]; var latex_image = document.createElement("img"); From b017155214738cb3e367974b1a0c909b791cb566 Mon Sep 17 00:00:00 2001 From: mutoo Date: Wed, 11 Dec 2013 23:34:53 +0800 Subject: [PATCH 2/3] add GoogleAnalytics Plugin --- GoogleAnalytics/Plugin.php | 68 ++++++++++++++++++++++++++++++++++++++ LaTex/latex.js | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 GoogleAnalytics/Plugin.php diff --git a/GoogleAnalytics/Plugin.php b/GoogleAnalytics/Plugin.php new file mode 100644 index 0000000..e52556f --- /dev/null +++ b/GoogleAnalytics/Plugin.php @@ -0,0 +1,68 @@ +footer = array('GoogleAnalytics_Plugin', 'render'); + } + + /** + * 禁用插件方法,如果禁用失败,直接抛出异常 + * + * @static + * @access public + * @return void + * @throws Typecho_Plugin_Exception + */ + public static function deactivate(){} + + /** + * 获取插件配置面板 + * + * @access public + * @param Typecho_Widget_Helper_Form $form 配置面板 + * @return void + */ + public static function config(Typecho_Widget_Helper_Form $form) + { + /** 分类名称 */ + $account = new Typecho_Widget_Helper_Form_Element_Text('account', NULL, 'UA-XXXXXXX-X', _t('Google Analytics 帐号')); + $form->addInput($account); + } + + /** + * 个人用户的配置面板 + * + * @access public + * @param Typecho_Widget_Helper_Form $form + * @return void + */ + public static function personalConfig(Typecho_Widget_Helper_Form $form){} + + /** + * 插件实现方法 + * + * @access public + * @return void + */ + public static function render() + { + $account = Typecho_Widget::widget('Widget_Options')->plugin('GoogleAnalytics')->account; + echo ""; + } +} \ No newline at end of file diff --git a/LaTex/latex.js b/LaTex/latex.js index bafc138..a9ecf44 100644 --- a/LaTex/latex.js +++ b/LaTex/latex.js @@ -5,7 +5,7 @@ var node = latex[i]; var latex_image = document.createElement("img"); latex_image.src = "http://latex.codecogs.com/png.latex?"+ node.innerHTML; - + // replace with image var parent = node.parentNode; parent.insertBefore(latex_image, node); parent.removeChild(node); From 7c3892302e6d5f5a50a153265dc0331235dd3c50 Mon Sep 17 00:00:00 2001 From: mutoo Date: Thu, 12 Dec 2013 11:34:39 +0800 Subject: [PATCH 3/3] upgrade LaTex Plugin: customize ```mark enabled --- GoogleAnalytics/Plugin.php | 2 +- LaTex/Plugin.php | 9 +++++++-- LaTex/latex.js | 40 ++++++++++++++++++++++++++------------ ZenCoding/zen_textarea.js | 2 +- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/GoogleAnalytics/Plugin.php b/GoogleAnalytics/Plugin.php index e52556f..a5da974 100644 --- a/GoogleAnalytics/Plugin.php +++ b/GoogleAnalytics/Plugin.php @@ -41,7 +41,7 @@ class GoogleAnalytics_Plugin implements Typecho_Plugin_Interface public static function config(Typecho_Widget_Helper_Form $form) { /** 分类名称 */ - $account = new Typecho_Widget_Helper_Form_Element_Text('account', NULL, 'UA-XXXXXXX-X', _t('Google Analytics 帐号')); + $account = new Typecho_Widget_Helper_Form_Element_Text('account', NULL, 'UA-XXXXXXX-X', _t('Google Analytics 帐号'), _t('此帐号可在 GA 管理平台查询;格式为 UA-XXXXXXX-X 。')); $form->addInput($account); } diff --git a/LaTex/Plugin.php b/LaTex/Plugin.php index 961d832..0170ed7 100644 --- a/LaTex/Plugin.php +++ b/LaTex/Plugin.php @@ -4,7 +4,7 @@ * * @package LaTex * @author mutoo - * @version 1.0.0 + * @version 1.1.0 * @link http://blog.mutoo.im/LaTex.html */ class LaTex_Plugin implements Typecho_Plugin_Interface @@ -39,7 +39,10 @@ class LaTex_Plugin implements Typecho_Plugin_Interface * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ - public static function config(Typecho_Widget_Helper_Form $form){} + public static function config(Typecho_Widget_Helper_Form $form){ + $mark = new Typecho_Widget_Helper_Form_Element_Text('mark', NULL, 'latex', _t('自定义标记'), _t('在 Markdown 语法环境下使用以下代码进行公式转换:
```自定义标记
公式
```
')); + $form->addInput($mark); + } /** * 个人用户的配置面板 @@ -60,5 +63,7 @@ class LaTex_Plugin implements Typecho_Plugin_Interface public static function footer() { $jsUrl = Helper::options()->pluginUrl . '/LaTex/latex.js'; echo ''; + $mark = Typecho_Widget::widget('Widget_Options')->plugin('LaTex')->mark; + echo ''; } } diff --git a/LaTex/latex.js b/LaTex/latex.js index a9ecf44..79b227d 100644 --- a/LaTex/latex.js +++ b/LaTex/latex.js @@ -1,13 +1,29 @@ -(function() { - var $ = document.querySelectorAll.bind(document); - var latex = $('code.lang-LaTex, code.lang-latex, code.lang-tex'); - for (var i = 0, l = latex.length; i < l; i++) { - var node = latex[i]; - var latex_image = document.createElement("img"); - latex_image.src = "http://latex.codecogs.com/png.latex?"+ node.innerHTML; - // replace with image - var parent = node.parentNode; - parent.insertBefore(latex_image, node); - parent.removeChild(node); +(function(global) { + var previousLatex = global.latex; + + global.latex = { + parse: function(mark) { + if (!mark) { + return; + } + + var $ = document.querySelectorAll.bind(document); + var nodes = $('code.lang-' + mark); + for (var i = 0, l = nodes.length; i < l; i++) { + var node = nodes[i]; + var latex_image = document.createElement("img"); + latex_image.src = "http://latex.codecogs.com/png.latex?" + node.innerHTML; + // replace with image + var parent = node.parentNode; + parent.insertBefore(latex_image, node); + parent.removeChild(node); + } + + }, + noConflict: function() { + global.latex = previousLatex; + return this; + } } -})(); \ No newline at end of file + +})(this); \ No newline at end of file diff --git a/ZenCoding/zen_textarea.js b/ZenCoding/zen_textarea.js index 737ce80..95b99d0 100644 --- a/ZenCoding/zen_textarea.js +++ b/ZenCoding/zen_textarea.js @@ -2250,7 +2250,7 @@ var zen_editor = (function(){ * @include "editor.js" * @include "../../aptana/lib/html_matcher.js" * @include "../../aptana/lib/zen_coding.js" - */ + */ /** * Search for abbreviation in editor from current caret position