From c32477433cbe96b760ae4e71affc0b572e20c3fd Mon Sep 17 00:00:00 2001
From: joyqi
Date: Fri, 18 Oct 2013 22:50:07 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3markdown=E7=BC=96=E8=BE=91?=
=?UTF-8?q?=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin/js/markdown.js | 15 ++++++++++++++-
admin/write-page.php | 3 +++
admin/write-post.php | 3 +++
var/Widget/Abstract/Contents.php | 2 +-
var/Widget/Contents/Page/Edit.php | 5 +++++
var/Widget/Contents/Post/Edit.php | 5 +++++
6 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/admin/js/markdown.js b/admin/js/markdown.js
index 0ebed704..4fdfa31a 100644
--- a/admin/js/markdown.js
+++ b/admin/js/markdown.js
@@ -4128,10 +4128,12 @@ else
// The main dialog box.
dialog = doc.createElement("div");
dialog.className = "wmd-prompt-dialog";
+ /*
dialog.style.padding = "10px;";
dialog.style.position = "fixed";
dialog.style.width = "400px";
dialog.style.zIndex = "1001";
+ */
// The dialog text.
var question = doc.createElement("div");
@@ -4143,22 +4145,26 @@ else
var form = doc.createElement("form"),
style = form.style;
form.onsubmit = function () { return close(false); };
+ /*
style.padding = "0";
style.margin = "0";
style.cssFloat = "left";
style.width = "100%";
style.textAlign = "center";
style.position = "relative";
+ */
dialog.appendChild(form);
// The input text box
input = doc.createElement("input");
input.type = "text";
input.value = defaultInputText;
+ /*
style = input.style;
style.display = "block";
style.width = "80%";
style.marginLeft = style.marginRight = "auto";
+ */
form.appendChild(input);
// The ok button
@@ -4166,26 +4172,30 @@ else
okButton.type = "button";
okButton.onclick = function () { return close(false); };
okButton.value = "OK";
+ /*
style = okButton.style;
style.margin = "10px";
style.display = "inline";
style.width = "7em";
-
+ */
// The cancel button
var cancelButton = doc.createElement("input");
cancelButton.type = "button";
cancelButton.onclick = function () { return close(true); };
cancelButton.value = "Cancel";
+ /*
style = cancelButton.style;
style.margin = "10px";
style.display = "inline";
style.width = "7em";
+ */
form.appendChild(okButton);
form.appendChild(cancelButton);
util.addEvent(doc.body, "keydown", checkEscape);
+ /*
dialog.style.top = "50%";
dialog.style.left = "50%";
dialog.style.display = "block";
@@ -4194,12 +4204,15 @@ else
dialog.style.top = doc.documentElement.scrollTop + 200 + "px";
dialog.style.left = "50%";
}
+ */
doc.body.appendChild(dialog);
// This has to be done AFTER adding the dialog to the form if you
// want it to be centered.
+ /*
dialog.style.marginTop = -(position.getHeight(dialog) / 2) + "px";
dialog.style.marginLeft = -(position.getWidth(dialog) / 2) + "px";
+ */
};
diff --git a/admin/write-page.php b/admin/write-page.php
index 5e03700d..8627643d 100644
--- a/admin/write-page.php
+++ b/admin/write-page.php
@@ -39,6 +39,9 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
+ markdown && (!$page->have() || $page->isMarkdown)): ?>
+
+
diff --git a/admin/write-post.php b/admin/write-post.php
index a4497a63..ef9cc589 100644
--- a/admin/write-post.php
+++ b/admin/write-post.php
@@ -40,6 +40,9 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
+ markdown && (!$post->have() || $post->isMarkdown)): ?>
+
+
diff --git a/var/Widget/Abstract/Contents.php b/var/Widget/Abstract/Contents.php
index 58f33753..cbefb800 100644
--- a/var/Widget/Abstract/Contents.php
+++ b/var/Widget/Abstract/Contents.php
@@ -489,7 +489,7 @@ class Widget_Abstract_Contents extends Widget_Abstract
}
/** 处理Markdown **/
- $value['isMarkdown'] = (0 === strpos('', $value['text']));
+ $value['isMarkdown'] = (0 === strpos($value['text'], ''));
if ($value['isMarkdown']) {
$value['text'] = substr($value['text'], 15);
}
diff --git a/var/Widget/Contents/Page/Edit.php b/var/Widget/Contents/Page/Edit.php
index 4f176eef..2dcf6fa3 100644
--- a/var/Widget/Contents/Page/Edit.php
+++ b/var/Widget/Contents/Page/Edit.php
@@ -64,6 +64,11 @@ class Widget_Contents_Page_Edit extends Widget_Contents_Post_Edit implements Wid
$contents['title'] = $this->request->get('title', _t('未命名页面'));
$contents['created'] = $this->getCreated();
+
+ if ($this->request->markdown && $this->options->markdown) {
+ $contents['text'] = '' . $contents['text'];
+ }
+
$contents = $this->pluginHandle()->write($contents, $this);
if ($this->request->is('do=publish')) {
diff --git a/var/Widget/Contents/Post/Edit.php b/var/Widget/Contents/Post/Edit.php
index 7ccb3a82..7d22011f 100644
--- a/var/Widget/Contents/Post/Edit.php
+++ b/var/Widget/Contents/Post/Edit.php
@@ -556,6 +556,11 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
$contents['title'] = $this->request->get('title', _t('未命名文档'));
$contents['created'] = $this->getCreated();
+
+ if ($this->request->markdown && $this->options->markdown) {
+ $contents['text'] = '' . $contents['text'];
+ }
+
$contents = $this->pluginHandle()->write($contents, $this);
if ($this->request->is('do=publish')) {