You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

help_controller.rb 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # redMine - project management software
  2. # Copyright (C) 2006 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class HelpController < ApplicationController
  18. skip_before_filter :check_if_login_required
  19. before_filter :load_help_config
  20. # displays help page for the requested controller/action
  21. def index
  22. # select help page to display
  23. if @params[:ctrl] and @help_config['pages'][@params[:ctrl]]
  24. if @params[:page] and @help_config['pages'][@params[:ctrl]][@params[:page]]
  25. template = @help_config['pages'][@params[:ctrl]][@params[:page]]
  26. else
  27. template = @help_config['pages'][@params[:ctrl]]['index']
  28. end
  29. end
  30. # choose language according to available help translations
  31. lang = (@help_config['langs'].include? current_language.to_s) ? current_language.to_s : @help_config['langs'].first
  32. if template
  33. redirect_to "/manual/#{lang}/#{template}"
  34. else
  35. redirect_to "/manual/#{lang}/"
  36. end
  37. end
  38. private
  39. def load_help_config
  40. @help_config = YAML::load(File.open("#{RAILS_ROOT}/config/help.yml"))
  41. end
  42. end