Skip to content
Browse files

プレビューを表示する機能を追加

  • Loading branch information...
1 parent eda7f74 commit 673a7636488e77855c0e11545baa3bb9d11495c9 @yuki-kimoto committed Apr 20, 2012
Showing with 19 additions and 6 deletions.
  1. +4 −3 lib/Ringowiki/Api.pm
  2. +15 −3 templates/main/edit_page.html.ep
View
7 lib/Ringowiki/Api.pm
@@ -2,6 +2,7 @@ package Ringowiki::Api;
use Mojo::Base 'Mojolicious::Controller';
use utf8;
use Text::Diff 'diff';
+use Text::Markdown 'markdown';
use Ringowiki::HTMLFilter;
our $TABLE_INFOS = {
@@ -201,10 +202,10 @@ sub preview {
# HTML filter
my $hf = Ringowiki::HTMLFilter->new;
- # Wiki link to a
- $content = $self->parse_wiki_link($self, $content, $wiki_id);
+ # Prase wiki link
+ $content = $hf->parse_wiki_link($self, $content, $wiki_id);
- # Content to html(Markdown)
+ # Sanitize and Markdown
$content = markdown $hf->sanitize_tag($content);
# Render
View
18 templates/main/edit_page.html.ep
@@ -9,8 +9,11 @@
var data = ringowikiapi.create_form_data('form[name="edit_page"]');
$.post('<%= url_for '/api/preview' %>', data, function (result) {
if (result.success === 1) {
-
- location.href = "<%= url_for('preview', wiki_id => $wiki_id, page_name => $page_name) %>";
+ var page = result.page;
+ $("#preview_header").text("プレビュー");
+ $("#preview_content").html(page.content);
+ $("#preview_area").show();
+ $('html, body').animate({scrollTop: 0}, 0);
}
else {
alert("ページの更新に失敗しました。");
@@ -38,7 +41,16 @@
<%= $title %>
</h1>
-<div id="preview"></div>
+<div id="preview_area" style="display:none">
+ <div id="preview_header"></div>
+ <div id="preview_content"></div>
+</div>
+
+<div id="diff_area" style="display:none">
+ <div id="diff_header"></div>
+ <div id="diff_content"></div>
+</div>
+
<form name="edit_page">
<input type="hidden" name="wiki_id" value="<%= param('wiki_id') %>">

0 comments on commit 673a763

Please sign in to comment.
Something went wrong with that request. Please try again.