Skip to content

Commit 9e89857

Browse files
committed
editor minor fix.
1 parent 62bcd9c commit 9e89857

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

TODO

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
- Today
22
* upload attachment and delete immediately bug
3-
* blog article digest layout
4-
* right column recent comments layout
3+
* resume
54

65
- Next
7-
* Editor Tab
8-
* resume
96
* admin panel:
107
* IE compatiablity
118

app/controllers/blog.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
post :create_comment, :map => '/blog/:id/comments' do
5050
content_type :js
51-
halt 403 unless account_login?
51+
halt 401 unless account_login?
5252
blog = Blog.find params[:id]
5353
halt 403 unless blog.commentable?
5454
@comment = blog.comments.create(:account => current_account, :content => params[:blog_comment][:content])

app/views/admin/_attachment.erb

+15
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,18 @@
33
<%= link_to image_tag('btn_delete.png', :title => '删除附件'), url(:admin, :attachment, :id => attachment.id), :method => :delete, :remote => true, :confirm => '是否删除附件' %>
44
<a href="#" onclick="window.parent.$('#blog_content').insertAtCaret('\n![](<%= attachment.file.url %>)\n');return false;"><%= image_tag 'btn_sticky.png', :title => '将图片插入编辑器' %></a>
55
</div>
6+
<script type="text/javascript" charset="utf-8">
7+
$('a[data-remote=true]').on('click', function(e) {
8+
var element = $(this);
9+
if (e.stopped) return;
10+
e.preventDefault(); e.stopped = true;
11+
JSAdapter.sendRequest(element, {
12+
verb: element.data('method') || 'get',
13+
url: element.attr('href')
14+
});
15+
});
16+
$('a[data-confirm]').on('click', function(e) {
17+
var message = $(this).data('confirm');
18+
if (!confirm(message)) { e.preventDefault(); e.stopped = true; }
19+
});
20+
</script>

app/views/admin/_form.erb

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
<%= form.text_area :content %>
2020
<div id="blog_content_preview" class="con text"></div>
2121
<div>
22-
<ul>
23-
<li>编辑器支持Github风格的Markdown格式: [<a href="https://help.github.com/articles/github-flavored-markdown" target="_blank">Github flavored markdown</a>]</li>
24-
<li>Markdown中文帮助: [<a href="http://wowubuntu.com/markdown/" target="_blank">Markdown帮助</a>]</li>
25-
</ul>
22+
[<a href="http://wowubuntu.com/markdown/" target="_blank">Markdown中文帮助</a>]
23+
[<a href="https://help.github.com/articles/github-flavored-markdown" target="_blank">Github风格的Markdown格式</a>]
2624
</div>
2725
</td>
2826
</tr>
@@ -133,15 +131,18 @@
133131

134132
// toggle blog content editor and preview
135133
$('a#show_blog_content_editor').click(function(){
134+
$('a#show_blog_content_editor').addClass('current');
135+
$('a#show_blog_content_preview').removeClass('current');
136136
$('div#blog_content_preview').hide();
137137
$('textarea#blog_content').show();
138138
return false;
139139
});
140140
$('a#show_blog_content_preview').click(function(){
141141
$.post('<%= url(:admin, :blog_preview) %>', {term: $('textarea#blog_content').val()}, function(data){
142-
$('div#blog_content_preview').html(data);
142+
$('a#show_blog_content_editor').removeClass('current');
143+
$('a#show_blog_content_preview').addClass('current');
144+
$('div#blog_content_preview').html(data).show();
143145
$('textarea#blog_content').hide();
144-
$('div#blog_content_preview').show();
145146
});
146147
return false;
147148
});

app/views/blog/show.erb

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% @nav = @blog.category %>
22
<% @title = @blog.title %>
3-
<% @description = @blog.cached_tag_list + ' ' + @blog.content.truncate(200).gsub(/(\r|\n)/, ' ') %>
3+
<% @description = @blog.cached_tag_list.to_s + ' ' + @blog.content.truncate(200).gsub(/(\r|\n)/, ' ') %>
44

55
<% content_for :stylesheets do %>
66
<%= stylesheet_link_tag '/skins/default/github' %>
@@ -17,7 +17,7 @@
1717
<%= link_to @blog.title, blog_url(@blog) %>
1818
<%= link_to '', blog_url(@blog, mime_type = :md), :class => 'markdown', :title => 'Markdown格式原文' %>
1919
<% if account_admin? %>
20-
<%= link_to '', url(:admin, :blog, :id => @blog.id), :method => :delete, :confirm => 'Are you delete', :class => 'del', :title => '删除' %>
20+
<%= link_to '', url(:admin, :blog, :id => @blog.id), :method => :delete, :confirm => '要删除文章吗?', :class => 'del', :title => '删除' %>
2121
<%= link_to '', url(:admin, :edit_blog, :id => @blog.id), :class => 'edit', :title => '编辑' %>
2222
<% end %>
2323
</div>
@@ -29,9 +29,9 @@
2929
<div class="text">
3030
<%= @blog.md_content.html_safe %>
3131
</div>
32-
<div class="info clearfix">
32+
<div class="info clearfix">
3333
<div class="fr">
34-
<span class="author"><%= @blog.account.name %></span>
34+
<span class="author"><%= @blog.account.name %></span>
3535
<span class="time"><%= time_ago_in_words(@blog.created_at) %>发表</span>
3636
<span class="edit"><%= time_ago_in_words(@blog.content_updated_at) %>更新</span>
3737
<span class="views" title="浏览次数"><%= @blog.view_count %></span>
@@ -57,12 +57,12 @@
5757
<div class="relative">
5858
<div style="text-align:right;">[<a href="http://wowubuntu.com/markdown/" target="_blank">评论可以使用Markdown格式</a>]</div>
5959
<% form_for BlogComment.new, url(:blog, :create_comment, :id => @blog.id), :remote => true do |f| %>
60-
<%= f.text_area :content, :class => 'comment' %>
61-
<div id="comment-error-info"></div>
62-
<%= f.submit '', :class => 'comment_btn' %>
60+
<%= f.text_area :content, :class => 'comment' %>
61+
<div id="comment-error-info"></div>
62+
<%= f.submit '', :class => 'comment_btn' %>
6363
<% end %>
6464
<div class="box" style="<%= "display:none;" if account_login? %>">
65-
<button class="close" onclick=""></button>
65+
<button class="close"></button>
6666
<p>我想知道与谁交流思想,请用微博登录留言。</p>
6767
<button class="sina_btn"></button>
6868
</div><!-- box -->
@@ -95,7 +95,7 @@
9595
$('button.sina_btn').click(function(){
9696
var width=Math.round((window.screen.width-800)/2);
9797
var height=Math.round((window.screen.height-600)/2);
98-
window.open('<%= url(:weibo_login) %>/?quick_login=1', 'weibo_third_part_authentication', 'height=300px, width=400px, top='+height+',left='+width+', scrollbars=no, resizable=no, status=no, resizable=no, menubar=no')
98+
window.open('<%= url(:weibo_login) %>/?quick_login=1', 'weibo_third_part_authentication', 'height=300px, width=400px, top='+height+',left='+width+', scrollbars=no, resizable=no, status=no, resizable=no, menubar=no');
9999
});
100100

101101
// validate empty comment

models/blog.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ def user_tags
2525
def user_tags=(tags)
2626
unless tags.blank?
2727
# filter illegal characters
28-
user_tags_list = tags.split(/\s*,\s*/).uniq.collect {|t| t.downcase}.select {|t| t =~ /^(?!_)(?!.*?_$)[\+#a-zA-Z0-9_\s\u4e00-\u9fa5]+$/}.join(",")
29-
self.tag_list = user_tags_list
28+
self.tag_list = tags.split(/\s*,\s*/).uniq.collect {|t| t.downcase}.select {|t| t =~ /^(?!_)(?!.*?_$)[\+#a-zA-Z0-9_\s\u4e00-\u9fa5]+$/}.join(",")
3029
end
3130
end
3231

0 commit comments

Comments
 (0)