2013-02-15 01:10:53 +08:00
|
|
|
class EducationController < ApplicationController
|
|
|
|
|
|
|
|
before_filter :ensure_logged_in
|
|
|
|
|
|
|
|
def show
|
|
|
|
raise Discourse::InvalidAccess.new unless params[:id] =~ /^[a-z0-9\-\_]+$/
|
2013-03-29 11:50:07 +08:00
|
|
|
raise Discourse::NotFound.new if I18n.t("education.#{params[:id]}", default: MISSING_KEY) == MISSING_KEY
|
2013-02-26 00:42:20 +08:00
|
|
|
|
2013-04-06 04:47:20 +08:00
|
|
|
|
2013-02-15 01:10:53 +08:00
|
|
|
education_posts_text = I18n.t('education.until_posts', count: SiteSetting.educate_until_posts)
|
|
|
|
|
2013-04-06 04:47:20 +08:00
|
|
|
markdown_content = ""
|
|
|
|
if params[:id] == 'new-topic'
|
|
|
|
markdown_content = SiteContent.content_for(:education_new_topic, education_posts_text: education_posts_text)
|
|
|
|
else
|
|
|
|
markdown_content = SiteContent.content_for(:education_new_reply, education_posts_text: education_posts_text)
|
|
|
|
end
|
|
|
|
|
2013-02-15 01:10:53 +08:00
|
|
|
render text: PrettyText.cook(markdown_content)
|
|
|
|
end
|
|
|
|
|
2013-03-29 11:50:07 +08:00
|
|
|
private
|
|
|
|
MISSING_KEY = '_MISSING_KEY_'.freeze
|
|
|
|
|
2013-02-15 01:10:53 +08:00
|
|
|
end
|