diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-15 20:20:18 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-15 20:20:18 +0000 |
commit | 889d50089d4d98db83ba5617b526da50107be661 (patch) | |
tree | d9bed99952fddce716e6d7acf189603358bb2021 /app/helpers | |
parent | a5849ee044837be589e9aae554cf99a394b9b9af (diff) | |
download | redmine-889d50089d4d98db83ba5617b526da50107be661.tar.gz redmine-889d50089d4d98db83ba5617b526da50107be661.zip |
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
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/repositories_helper.rb | 8 |
1 files changed, 8 insertions, 0 deletions
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) |