mirror of
https://github.com/typecho/typecho.git
synced 2025-04-14 06:41:53 +02:00
支持在xmlrpc接口中使用原生的markdown语法
This commit is contained in:
parent
7cdc244d95
commit
9122d2ab49
@ -342,6 +342,7 @@ Typecho_Cookie::set('__typecho_lang', $lang);
|
||||
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'editorSize', 'user' => 0, 'value' => 350)));
|
||||
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'autoSave', 'user' => 0, 'value' => 0)));
|
||||
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'markdown', 'user' => 0, 'value' => 1)));
|
||||
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'xmlrpcMarkdown', 'user' => 0, 'value' => 0)));
|
||||
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsMaxNestingLevels', 'user' => 0, 'value' => 5)));
|
||||
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsPostTimeout', 'user' => 0, 'value' => 24 * 3600 * 30)));
|
||||
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsUrlNofollow', 'user' => 0, 'value' => 1)));
|
||||
|
@ -22,7 +22,7 @@ define('__TYPECHO_MB_SUPPORTED__', function_exists('mb_get_info') && function_ex
|
||||
class Typecho_Common
|
||||
{
|
||||
/** 程序版本 */
|
||||
const VERSION = '1.0/14.10.10';
|
||||
const VERSION = '1.1/17.4.24';
|
||||
|
||||
/**
|
||||
* 允许的属性
|
||||
|
@ -1206,5 +1206,21 @@ Typecho_Date::setTimezoneOffset($options->timezone);
|
||||
$db->query($db->insert('table.options')
|
||||
->rows(array('name' => 'commentsAntiSpam', 'user' => 0, 'value' => 1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级至17.4.24
|
||||
*
|
||||
* @param mixed $db
|
||||
* @param mixed $options
|
||||
* @static
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function v1_1r17_4_24($db, $options)
|
||||
{
|
||||
// 增加markdown
|
||||
$db->query($db->insert('table.options')
|
||||
->rows(array('name' => 'xmlrpcMarkdown', 'user' => 0, 'value' => 0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,12 @@ class Widget_Users_Profile extends Widget_Users_Edit implements Widget_Interface
|
||||
. '<br />' . _t('此功能开启不会影响以前没有使用 Markdown 语法编辑的内容.'));
|
||||
$form->addInput($markdown);
|
||||
|
||||
$xmlrpcMarkdown = new Typecho_Widget_Helper_Form_Element_Radio('xmlrpcMarkdown',
|
||||
array('0' => _t('关闭'), '1' => _t('打开')),
|
||||
$this->options->xmlrpcMarkdown, _t('在 XMLRPC 接口中使用 Markdown 语法'),
|
||||
_t('对于完全支持 <a href="http://daringfireball.net/projects/markdown/">Markdown</a> 语法写作的编辑器, 打开此选项后将避免内容被转换为 HTML.'));
|
||||
$form->addInput($xmlrpcMarkdown);
|
||||
|
||||
/** 自动保存 */
|
||||
$autoSave = new Typecho_Widget_Helper_Form_Element_Radio('autoSave',
|
||||
array('0' => _t('关闭'), '1' => _t('打开')),
|
||||
@ -283,6 +289,7 @@ class Widget_Users_Profile extends Widget_Users_Edit implements Widget_Interface
|
||||
{
|
||||
$settings['autoSave'] = $this->request->autoSave ? 1 : 0;
|
||||
$settings['markdown'] = $this->request->markdown ? 1 : 0;
|
||||
$settings['xmlrpcMarkdown'] = $this->request->xmlrpcMarkdown ? 1 : 0;
|
||||
$defaultAllow = $this->request->getArray('defaultAllow');
|
||||
|
||||
$settings['defaultAllowComment'] = in_array('comment', $defaultAllow) ? 1 : 0;
|
||||
|
@ -61,6 +61,7 @@ class Widget_XmlRpc extends Widget_Abstract_Contents implements Widget_Interface
|
||||
case false !== strpos($agent, 'wp-blackberry'): // 黑莓
|
||||
case false !== strpos($agent, 'wp-andriod'): // andriod
|
||||
case false !== strpos($agent, 'plain-text'): // 这是预留给第三方开发者的接口, 用于强行调用非所见即所得数据
|
||||
case $this->options->xmlrpcMarkdown:
|
||||
$text = $content->text;
|
||||
break;
|
||||
default:
|
||||
@ -69,7 +70,10 @@ class Widget_XmlRpc extends Widget_Abstract_Contents implements Widget_Interface
|
||||
}
|
||||
|
||||
$post = explode('<!--more-->', $text, 2);
|
||||
return array(Typecho_Common::fixHtml($post[0]), isset($post[1]) ? Typecho_Common::fixHtml($post[1]) : NULL);
|
||||
return array(
|
||||
$this->options->xmlrpcMarkdown? $post[0] : Typecho_Common::fixHtml($post[0]),
|
||||
isset($post[1]) ? Typecho_Common::fixHtml($post[1]) : NULL
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1427,6 +1431,7 @@ class Widget_XmlRpc extends Widget_Abstract_Contents implements Widget_Interface
|
||||
|
||||
$input['allowFeed'] = $this->options->defaultAllowFeed;
|
||||
$input['do'] = $publish ? 'publish' : 'save';
|
||||
$input['markdown'] = $this->options->xmlrpcMarkdown;
|
||||
|
||||
/** 调整状态 */
|
||||
if (isset($content["{$type}_status"])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user