From 374f60216342e3c7f09867faa174416b0afa2b52 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 26 Jan 2015 00:42:58 +0100 Subject: [PATCH] remove mini markdown renderer everywhere was still used for comment emails etc --- app/assets/javascripts/editor.js | 6 +--- app/controllers/tools_controller.rb | 8 ------ app/helpers/application_helper.rb | 28 ------------------- app/views/application/_md_editor.html.erb | 2 +- app/views/blogposts/edit.html.erb | 2 +- app/views/blogposts/new.html.erb | 2 +- app/views/comments/_new.html.erb | 2 +- app/views/comments/edit.html.erb | 2 +- app/views/forumthreads/edit.html.erb | 2 +- app/views/forumthreads/new.html.erb | 2 +- app/views/info/edit.html.erb | 2 +- app/views/info/new.html.erb | 2 +- .../new_post_comment_mail.html.erb | 3 +- .../new_post_comment_mention_mail.html.erb | 3 +- .../new_post_mention_mail.html.erb | 3 +- app/views/threadreplies/_new.html.erb | 2 +- app/views/threadreplies/edit.html.erb | 2 +- app/views/users/edit.html.erb | 2 +- config/routes.rb | 1 - 19 files changed, 16 insertions(+), 60 deletions(-) diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index f5f6da2..4b35aea 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -23,11 +23,7 @@ $(function() { prev.html("(Loading ...)"); 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()}, diff --git a/app/controllers/tools_controller.rb b/app/controllers/tools_controller.rb index ae86f76..b2a8092 100644 --- a/app/controllers/tools_controller.rb +++ b/app/controllers/tools_controller.rb @@ -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 \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0390858..e3a2a25 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) diff --git a/app/views/application/_md_editor.html.erb b/app/views/application/_md_editor.html.erb index 0344485..3a18645 100644 --- a/app/views/application/_md_editor.html.erb +++ b/app/views/application/_md_editor.html.erb @@ -1,4 +1,4 @@ -
"> +
<%= render partial: 'mdhelp' %>
Preview
diff --git a/app/views/blogposts/edit.html.erb b/app/views/blogposts/edit.html.erb index 7eec53f..25da324 100644 --- a/app/views/blogposts/edit.html.erb +++ b/app/views/blogposts/edit.html.erb @@ -3,7 +3,7 @@

Edit post

<%= 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} %>

<%= f.submit "Update Post", class: "btn blue left" %>

<% end %>

<%= button_to "Delete post", @post, method: "delete", data: {confirm: "Delete post & comments forever?"}, class: "btn red right" %>

diff --git a/app/views/blogposts/new.html.erb b/app/views/blogposts/new.html.erb index ed67138..b923002 100644 --- a/app/views/blogposts/new.html.erb +++ b/app/views/blogposts/new.html.erb @@ -3,7 +3,7 @@

New Post

<%= 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} %>

<%= f.submit "Create Post", class: "btn blue left" %>

<% end %> diff --git a/app/views/comments/_new.html.erb b/app/views/comments/_new.html.erb index cc894a4..f4b2785 100644 --- a/app/views/comments/_new.html.erb +++ b/app/views/comments/_new.html.erb @@ -1,5 +1,5 @@

New comment

<%= 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} %>

<%= f.submit class: "btn blue" %>

<% end %> \ No newline at end of file diff --git a/app/views/comments/edit.html.erb b/app/views/comments/edit.html.erb index 16706cc..5416ab6 100644 --- a/app/views/comments/edit.html.erb +++ b/app/views/comments/edit.html.erb @@ -3,7 +3,7 @@

Edit comment

<%= 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} %>

<%= f.submit "Update Comment", class: "btn blue left" %>

<% end %>

<%= button_to "Delete comment", [@comment.blogpost, @comment] , method: "delete", data: {confirm: "Delete comment forever?"}, class: "btn red right" %>

diff --git a/app/views/forumthreads/edit.html.erb b/app/views/forumthreads/edit.html.erb index 863f563..cab2dd8 100644 --- a/app/views/forumthreads/edit.html.erb +++ b/app/views/forumthreads/edit.html.erb @@ -34,7 +34,7 @@
<%= f.text_field :title, placeholder: "Title" %>
- <%= 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.submit "Update thread", class: "btn blue left" %>

<% end %> <%= button_to "Delete thread", @thread, :method => "delete", data: {confirm: "Delete thread & comments forever?"}, class: "btn red right" %> diff --git a/app/views/forumthreads/new.html.erb b/app/views/forumthreads/new.html.erb index fec08e7..021e907 100644 --- a/app/views/forumthreads/new.html.erb +++ b/app/views/forumthreads/new.html.erb @@ -28,7 +28,7 @@
<%= f.text_field :title, placeholder: "Title" %>
- <%= 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 %>

<%= f.submit "Create thread", class: "btn blue left" %>

diff --git a/app/views/info/edit.html.erb b/app/views/info/edit.html.erb index c36f6ca..0135219 100644 --- a/app/views/info/edit.html.erb +++ b/app/views/info/edit.html.erb @@ -3,7 +3,7 @@

Edit Info

<%= 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} %>

<%= f.submit "Update Info", class: "btn blue left" %>

<% end %>

<%= button_to "Delete Info", @info, method: "delete", data: {confirm: "Delete Info forever?"}, class: "btn red right" %>

diff --git a/app/views/info/new.html.erb b/app/views/info/new.html.erb index 00d156f..55abdb7 100644 --- a/app/views/info/new.html.erb +++ b/app/views/info/new.html.erb @@ -3,7 +3,7 @@

New Info

<%= 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} %>

<%= f.submit "Create Info", class: "btn blue left" %>

<% end %> diff --git a/app/views/redstoner_mailer/new_post_comment_mail.html.erb b/app/views/redstoner_mailer/new_post_comment_mail.html.erb index 9728427..b3ab99a 100644 --- a/app/views/redstoner_mailer/new_post_comment_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_comment_mail.html.erb @@ -5,8 +5,7 @@

<%= 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!

- <%# TODO: fix relative links + iframes %> - <%= render_mini_md(@comment.content).html_safe %> + <%= render_md(@comment.content).html_safe %>

<%= link_to "Click here", blogpost_url(@comment.blogpost) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

diff --git a/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb b/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb index a923c0e..a65e4a3 100644 --- a/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb @@ -5,8 +5,7 @@

<%= 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!

- <%# TODO: fix relative links + iframes %> - <%= render_mini_md(@comment.content).html_safe %> + <%= render_md(@comment.content).html_safe %>

<%= link_to "Click here", blogpost_url(@comment.blogpost) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

diff --git a/app/views/redstoner_mailer/new_post_mention_mail.html.erb b/app/views/redstoner_mailer/new_post_mention_mail.html.erb index 9efae11..5119e7c 100644 --- a/app/views/redstoner_mailer/new_post_mention_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_mention_mail.html.erb @@ -5,8 +5,7 @@

<%= 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!

- <%# TODO: fix relative links + iframes %> - <%= render_mini_md(@post.content).html_safe %> + <%= render_md(@post.content).html_safe %>

<%= link_to "Click here", blogpost_url(@post), style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

diff --git a/app/views/threadreplies/_new.html.erb b/app/views/threadreplies/_new.html.erb index 93f227d..b0c4b5e 100644 --- a/app/views/threadreplies/_new.html.erb +++ b/app/views/threadreplies/_new.html.erb @@ -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} %>

<%= f.submit "Reply#{ ' (Locked)' if reply.thread.locked? }", class: "btn blue" %>

<% end %> \ No newline at end of file diff --git a/app/views/threadreplies/edit.html.erb b/app/views/threadreplies/edit.html.erb index d45c2b7..645c64d 100644 --- a/app/views/threadreplies/edit.html.erb +++ b/app/views/threadreplies/edit.html.erb @@ -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

Edit reply

<%= 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} %>

<%= f.submit "Reply", class: "btn blue left" %>

<% end %>

<%= button_to "Delete reply", [@reply.thread, @reply], method: "delete", data: {confirm: "Delete reply forever?"}, class: "btn red right" %>

diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 0a47b64..b2d1bd5 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -67,7 +67,7 @@ About you - <%= 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 ..."}} %> diff --git a/config/routes.rb b/config/routes.rb index 4128402..de9eb27 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,7 +37,6 @@ Redstoner::Application.routes.draw do resources :tools do collection do post 'render_markdown' - post 'render_mini_markdown' end end