module BulkUpdateRequestsHelper def script_with_line_breaks(script) escaped_script = AliasAndImplicationImporter.tokenize(script).map do |cmd, arg1, arg2| case cmd when :create_alias arg1_count = Tag.find_by_name(arg1).try(:post_count).to_i arg2_count = Tag.find_by_name(arg2).try(:post_count).to_i "create alias " + link_to(arg1, posts_path(:tags => arg1)) + " (#{arg1_count}) -> " + link_to(arg2, posts_path(:tags => arg2)) + " (#{arg2_count})" when :create_implication arg1_count = Tag.find_by_name(arg1).try(:post_count).to_i arg2_count = Tag.find_by_name(arg2).try(:post_count).to_i "create implication " + link_to(arg1, posts_path(:tags => arg1)) + " (#{arg1_count}) -> " + link_to(arg2, posts_path(:tags => arg2)) + " (#{arg2_count})" when :remove_alias arg1_count = Tag.find_by_name(arg1).try(:post_count).to_i arg2_count = Tag.find_by_name(arg2).try(:post_count).to_i "remove alias " + link_to(arg1, posts_path(:tags => arg1)) + " (#{arg1_count}) -> " + link_to(arg2, posts_path(:tags => arg2)) + " (#{arg2_count})" when :remove_implication arg1_count = Tag.find_by_name(arg1).try(:post_count).to_i arg2_count = Tag.find_by_name(arg2).try(:post_count).to_i "remove implication " + link_to(arg1, posts_path(:tags => arg1)) + " (#{arg1_count}) -> " + link_to(arg2, posts_path(:tags => arg2)) + " (#{arg2_count})" when :mass_update "mass update " + link_to(arg1, posts_path(:tags => arg1)) + " -> " + link_to(arg2, posts_path(:tags => arg2)) end end.join("\n") escaped_script.gsub(/\n/m, "
").html_safe end end