From 889d50089d4d98db83ba5617b526da50107be661 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 15 Aug 2007 20:20:18 +0000 Subject: Added syntax highlightment for repository files (using CodeRay). Supported languages: c, ruby, rhtml, yaml, html, xml. git-svn-id: http://redmine.rubyforge.org/svn/trunk@644 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/repositories_helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index c2d564029..7db748abd 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -15,7 +15,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +require 'coderay' +require 'coderay/helpers/file_type' + module RepositoriesHelper + def syntax_highlight(name, content) + type = CodeRay::FileType[name] + type ? CodeRay.scan(content, type).html : h(content) + end + def repository_field_tags(form, repository) method = repository.class.name.demodulize.underscore + "_field_tags" send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) -- cgit v1.2.3