Add markdown preview; fix bug with deleted editor

This commit is contained in:
jomo
2014-05-11 06:43:56 +02:00
parent df030f4d2d
commit 19eb868a50
19 changed files with 135 additions and 39 deletions
+11
View File
@@ -0,0 +1,11 @@
<div class="md_editor <%= "mini" if mini %>">
<%= render partial: 'mdhelp' %>
<div class="field_container">
<div class="preview-button btn dark">Preview</div>
<% options = (defined?(options) && options || {}) %>
<% options[:class] = "#{options[:class]} editor_field" %>
<% options[:placeholder] ||= "Text" %>
<%= text_area_tag name, content, options %>
<div class="preview"><i>(Loading...)</i></div>
</div>
</div>
+1 -2
View File
@@ -1,8 +1,7 @@
<h1>Edit post</h1>
<%= form_for @post do |f|%>
<%= f.text_field :title %>
<%= render partial: "mdhelp" %>
<%= f.text_area :content%>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, mini: false} %>
<p><%= f.submit "Update Post", class: "btn blue left" %></p>
<% end %>
<p><%= button_to "Delete post", @post, method: "delete", data: {confirm: "Delete post & comments forever?"}, class: "btn red right" %></p>
+1 -2
View File
@@ -1,8 +1,7 @@
<h1>New Post</h1>
<%= form_for @post do |f|%>
<%= f.text_field :title, placeholder: "Title" %>
<%= render partial: "mdhelp" %>
<%= f.text_area :content, placeholder: "Text" %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, mini: false} %>
<p><%= f.submit "Create Post", class: "btn blue left" %></p>
<div class="clear"></div>
<% end %>
+1 -2
View File
@@ -1,8 +1,7 @@
<% if current_user %>
<h3>New comment</h3>
<%= form_for [@post, @comment] do |f| %>
<%= render partial: "mdhelp" %>
<%= f.text_area :content, placeholder: "Comment", class: "comment" %>
<%= render partial: "md_editor", locals: {name: "comment[content]", content: @comment.content, mini: true} %>
<p><%= f.submit class: "btn blue" %></p>
<% end %>
<% end %>
+1 -2
View File
@@ -1,8 +1,7 @@
<h1>Edit comment</h1>
<%= form_for [@comment.blogpost, @comment] do |f| %>
<%= render partial: "mdhelp" %>
<%= f.text_area :content, placeholder: "Comment" %>
<%= render partial: "md_editor", locals: {name: "comment[content]", content: @comment.content, mini: true} %>
<p><%= f.submit "Update Comment", class: "btn blue left" %></p>
<% end %>
<p><%= button_to "Delete comment", [@comment.blogpost, @comment] , method: "delete", data: {confirm: "Delete comment forever?"}, class: "btn red right" %></p>
+1 -2
View File
@@ -24,8 +24,7 @@
<% end %>
</table>
<%= f.text_field :title, placeholder: "Title" %>
<%= render partial: "mdhelp" %>
<%= f.text_area :content, placeholder: "Text" %>
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
<p><%= f.submit "Update thread", class: "btn blue left" %></p>
<% end %>
<%= button_to "Delete thread", @thread, :method => "delete", data: {confirm: "Delete thread & comments forever?"}, class: "btn red right" %>
+1 -2
View File
@@ -14,8 +14,7 @@
<% end %>
</table>
<%= f.text_field :title, placeholder: "Title" %>
<%= render partial: "mdhelp" %>
<%= f.text_area :content, placeholder: "Text" %>
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
<%= f.hidden_field :forum_id %>
<p><%= f.submit "Create thread", class: "btn blue left" %></p>
<div class="clear"></div>
+1 -2
View File
@@ -1,8 +1,7 @@
<h1>Edit Info</h1>
<%= form_for @info do |f|%>
<%= f.text_field :title%>
<%= render partial: "mdhelp" %>
<%= f.text_area :content %>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, mini: false} %>
<p><%= f.submit "Update Info", class: "btn blue left" %></p>
<% end %>
<p><%= button_to "Delete Info", @info, method: "delete", data: {confirm: "Delete Info forever?"}, class: "btn red right" %></p>
+1 -2
View File
@@ -1,8 +1,7 @@
<h1>New Info</h1>
<%= form_for @info, url: info_index_path do |f|%>
<%= f.text_field :title, placeholder: "Title" %>
<%= render partial: "mdhelp" %>
<%= f.text_area :content, placeholder: "Text" %>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, mini: false} %>
<p><%= f.submit "Create Info", class: "btn blue left" %></p>
<div class="clear"></div>
<% end %>
+1 -1
View File
@@ -1,4 +1,4 @@
<%= form_for [reply.thread, reply] do |f| %>
<%= f.text_area :content, placeholder: "Text" %>
<%= render partial: "md_editor", locals: {name: "threadreply[content]", content: reply.content, mini: false} %>
<p><%= f.submit "Reply", class: "btn blue" %></p>
<% end %>
+1 -2
View File
@@ -1,8 +1,7 @@
<%= link_to @reply.thread.forum.group, forumgroup_path(@reply.thread.forum.group) %><%= link_to @reply.thread.forum, @reply.thread.forum %><%= link_to @reply.thread %> → Edit reply
<h1>Edit reply</h1>
<%= form_for [@reply.thread, @reply] do |f| %>
<%= render partial: "mdhelp" %>
<%= f.text_area :content, placeholder: "Text" %>
<%= render partial: "md_editor", locals: {name: "threadreply[content]", content: @reply.content, mini: false} %>
<p><%= f.submit "Reply", class: "btn blue left" %></p>
<% end %>
<p><%= button_to "Delete reply", [@reply.thread, @reply], method: "delete", data: {confirm: "Delete reply forever?"}, class: "btn red right" %></p>
+1 -2
View File
@@ -59,8 +59,7 @@
<tr>
<td>About you</td>
<td>
<%= render partial: "mdhelp" %>
<%= f.text_area :about, placeholder: "Tell us something about you...", disabled: !can_edit? %>
<%= render partial: "md_editor", locals: {name: "user[about]", content: @user.about, mini: true, options: {disabled: !can_edit?, placeholder: "Tell us something about you ..."}} %>
</td>
</tr>
</tbody>