remove mini markdown renderer everywhere

was still used for comment emails etc
This commit is contained in:
jomo
2015-01-26 00:42:58 +01:00
parent f0c0c1c20e
commit 374f602163
19 changed files with 16 additions and 60 deletions

View File

@@ -23,11 +23,7 @@ $(function() {
prev.html("<i>(Loading ...)</i>");
prev.show();
editor.hide();
if (target.parent().parent().hasClass('mini')) {
var url = '/tools/render_mini_markdown';
} else {
var url = '/tools/render_markdown';
}
var url = '/tools/render_markdown';
$.ajax(url, {
type: 'post',
data: {text: editor.val()},

View File

@@ -8,12 +8,4 @@ class ToolsController < ApplicationController
end
end
def render_mini_markdown
if current_user
render text: render_mini_md(params[:text])
else
render text: "Error: You are not logged in!"
end
end
end

View File

@@ -69,34 +69,6 @@ module ApplicationHelper
render_youtube(md.render(content))
end
def render_mini_md(content)
renderer = Redcarpet::Render::HTML.new({
filter_html: true,
no_images: true,
no_styles: true,
safe_links_only: true,
with_toc_data: false,
hard_wrap: false,
link_attributes: {rel: "nofollow"}
})
md = Redcarpet::Markdown.new(renderer, {
no_intra_emphasis: true,
tables: false,
fenced_code_blocks: false,
autolink: true,
strikethrough: true,
lax_spacing: false,
disable_indented_code_blocks: true,
space_after_headers: true,
superscript: true,
underline: true,
highlight: true,
footnotes: false
})
md.render(content.gsub(/([\r\n]+\s*?){3,}/, "\n\n").gsub(/^\s*#/, "\\#"))
end
private
def render_youtube(content)

View File

@@ -1,4 +1,4 @@
<div class="md_editor <%= "mini" if mini %>">
<div class="md_editor">
<%= render partial: 'mdhelp' %>
<div class="field_container">
<div class="preview-button btn dark">Preview</div>

View File

@@ -3,7 +3,7 @@
<h1>Edit post</h1>
<%= form_for @post do |f|%>
<%= f.text_field :title %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content} %>
<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>

View File

@@ -3,7 +3,7 @@
<h1>New Post</h1>
<%= form_for @post do |f|%>
<%= f.text_field :title, placeholder: "Title" %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content} %>
<p><%= f.submit "Create Post", class: "btn blue left" %></p>
<div class="clear"></div>
<% end %>

View File

@@ -1,5 +1,5 @@
<h3>New comment</h3>
<%= form_for [@post, @comment] do |f| %>
<%= render partial: "md_editor", locals: {name: "comment[content]", content: @comment.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "comment[content]", content: @comment.content} %>
<p><%= f.submit class: "btn blue" %></p>
<% end %>

View File

@@ -3,7 +3,7 @@
<h1>Edit comment</h1>
<%= form_for [@comment.blogpost, @comment] do |f| %>
<%= render partial: "md_editor", locals: {name: "comment[content]", content: @comment.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "comment[content]", content: @comment.content} %>
<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>

View File

@@ -34,7 +34,7 @@
<div class="table-cell full-width">
<%= f.text_field :title, placeholder: "Title" %>
</div>
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content} %>
<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" %>

View File

@@ -28,7 +28,7 @@
<div class="table-cell full-width">
<%= f.text_field :title, placeholder: "Title" %>
</div>
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content} %>
<%= f.hidden_field :forum_id %>
<p><%= f.submit "Create thread", class: "btn blue left" %></p>
<div class="clear"></div>

View File

@@ -3,7 +3,7 @@
<h1>Edit Info</h1>
<%= form_for @info do |f|%>
<%= f.text_field :title%>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content} %>
<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>

View File

@@ -3,7 +3,7 @@
<h1>New Info</h1>
<%= form_for @info, url: info_index_path do |f|%>
<%= f.text_field :title, placeholder: "Title" %>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content} %>
<p><%= f.submit "Create Info", class: "btn blue left" %></p>
<div class="clear"></div>
<% end %>

View File

@@ -5,8 +5,7 @@
<p><%= link_to @comment.author.name, user_url(@comment.author), style: "text-decoration: none; color: #4096EE;" %> has replied to '<%= @comment.blogpost.title %>' on the Redstoner blog!</p>
<blockquote>
<%# TODO: fix relative links + iframes %>
<%= render_mini_md(@comment.content).html_safe %>
<%= render_md(@comment.content).html_safe %>
</blockquote>
<p><%= link_to "Click here", blogpost_url(@comment.blogpost) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.</p>

View File

@@ -5,8 +5,7 @@
<p><%= link_to @comment.author.name, user_url(@comment.author), style: "text-decoration: none; color: #4096EE;" %> has mentioned you in '<%= @comment.blogpost.title %>' on the Redstoner blog!</p>
<blockquote>
<%# TODO: fix relative links + iframes %>
<%= render_mini_md(@comment.content).html_safe %>
<%= render_md(@comment.content).html_safe %>
</blockquote>
<p><%= link_to "Click here", blogpost_url(@comment.blogpost) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.</p>

View File

@@ -5,8 +5,7 @@
<p><%= link_to @post.author.name, user_url(@post.author), style: "text-decoration: none; color: #4096EE;" %> has mentioned you in '<%= @post.title %>' on the Redstoner blog!</p>
<blockquote>
<%# TODO: fix relative links + iframes %>
<%= render_mini_md(@post.content).html_safe %>
<%= render_md(@post.content).html_safe %>
</blockquote>
<p><%= link_to "Click here", blogpost_url(@post), style: "text-decoration: none; color: #4096EE;" %> to view the blog post.</p>

View File

@@ -1,4 +1,4 @@
<%= form_for [reply.thread, reply] do |f| %>
<%= render partial: "md_editor", locals: {name: "threadreply[content]", content: reply.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "threadreply[content]", content: reply.content} %>
<p><%= f.submit "Reply#{ ' (Locked)' if reply.thread.locked? }", class: "btn blue" %></p>
<% end %>

View File

@@ -3,7 +3,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: "md_editor", locals: {name: "threadreply[content]", content: @reply.content, mini: false} %>
<%= render partial: "md_editor", locals: {name: "threadreply[content]", content: @reply.content} %>
<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>

View File

@@ -67,7 +67,7 @@
<tr>
<td>About you</td>
<td>
<%= render partial: "md_editor", locals: {name: "user[about]", content: @user.about, mini: false, options: {disabled: !can_edit?, placeholder: "Tell us something about you ..."}} %>
<%= render partial: "md_editor", locals: {name: "user[about]", content: @user.about, options: {disabled: !can_edit?, placeholder: "Tell us something about you ..."}} %>
</td>
</tr>
</tbody>

View File

@@ -37,7 +37,6 @@ Redstoner::Application.routes.draw do
resources :tools do
collection do
post 'render_markdown'
post 'render_mini_markdown'
end
end