diff --git a/app/assets/stylesheets/base.css.scss b/app/assets/stylesheets/base.css.scss index 6eb4184f..911a7c3b 100644 --- a/app/assets/stylesheets/base.css.scss +++ b/app/assets/stylesheets/base.css.scss @@ -120,4 +120,8 @@ body { #growls.default{ top:64px; right:10px +} + +.links { + padding-bottom: 10px; } \ No newline at end of file diff --git a/app/controllers/ajax/question_controller.rb b/app/controllers/ajax/question_controller.rb index d1da4359..9c62b620 100644 --- a/app/controllers/ajax/question_controller.rb +++ b/app/controllers/ajax/question_controller.rb @@ -48,4 +48,20 @@ class Ajax::QuestionController < ApplicationController @message = "Question asked successfully." @success = true end + + def preview + params.require :md + + @message = "Failed to render markdown." + begin + @markdown = markdown(params[:md], Time.new) + @message = "Successfully rendered markdown." + rescue + @status = :fail + @success = false + return + end + @status = :okay + @success = true + end end diff --git a/app/views/ajax/question/preview.json.jbuilder b/app/views/ajax/question/preview.json.jbuilder new file mode 100644 index 00000000..6bf01010 --- /dev/null +++ b/app/views/ajax/question/preview.json.jbuilder @@ -0,0 +1,2 @@ +json.partial! 'ajax/shared/status' +json.markdown @markdown if @markdown diff --git a/app/views/shared/_links.html.haml b/app/views/shared/_links.html.haml index f2910364..2d3294a9 100644 --- a/app/views/shared/_links.html.haml +++ b/app/views/shared/_links.html.haml @@ -1,4 +1,4 @@ -.centre.text-muted +.centre.text-muted.links © = Date.today.year = APP_CONFIG['site_name'] diff --git a/config/routes.rb b/config/routes.rb index 1e1f1f3e..d4af3769 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -81,6 +81,7 @@ Rails.application.routes.draw do match '/create_group', to: 'group#create', via: :post, as: :create_group match '/destroy_group', to: 'group#destroy', via: :post, as: :destroy_group match '/group_membership', to: 'group#membership', via: :post, as: :group_membership + match '/preview', to: "question#preview", via: :post, as: :preview end match '/public', to: 'public#index', via: :get, as: :public_timeline @@ -89,7 +90,7 @@ Rails.application.routes.draw do match '/notifications(/:type)', to: 'notifications#index', via: :get, as: :notifications, defaults: {type: 'all'} match '/inbox', to: 'inbox#show', via: 'get' - + match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1} match '/@:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile_alt, defaults: {page: 1} match '/@:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer_alt