summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2008-10-11 22:11:49 -0700
committerAdam Jacob <adam@hjksolutions.com>2008-10-11 22:11:49 -0700
commit6b7e37ea4c1f0af99e51711a807b3b9873d6653a (patch)
treecece4277dd93d06c6805e9f9df51f1dfecda9626
parent19c1e859c180ade6d2cdee66bbed9bf530e04faa (diff)
downloadchef-6b7e37ea4c1f0af99e51711a807b3b9873d6653a.tar.gz
Updating to no longer use UV - pure ruby syntax gem instead
-rw-r--r--chef-server/Rakefile1
-rw-r--r--chef-server/lib/helpers/cookbooks_helper.rb30
-rw-r--r--chef-server/lib/init.rb1
-rw-r--r--chef-server/lib/views/cookbooks/_attribute_file.html.haml2
-rw-r--r--chef-server/lib/views/cookbooks/_syntax_highlight.html.haml2
-rw-r--r--chef-server/lib/views/cookbooks/show.html.haml33
6 files changed, 54 insertions, 15 deletions
diff --git a/chef-server/Rakefile b/chef-server/Rakefile
index 5ac7b0b3a8..7dfdab5137 100644
--- a/chef-server/Rakefile
+++ b/chef-server/Rakefile
@@ -29,6 +29,7 @@ spec = Gem::Specification.new do |s|
s.add_dependency "haml"
s.add_dependency "ruby-openid"
s.add_dependency "json"
+ s.add_dependency "syntax"
s.bindir = "bin"
s.executables = %w( chef-indexer chef-server )
diff --git a/chef-server/lib/helpers/cookbooks_helper.rb b/chef-server/lib/helpers/cookbooks_helper.rb
new file mode 100644
index 0000000000..995f2eb601
--- /dev/null
+++ b/chef-server/lib/helpers/cookbooks_helper.rb
@@ -0,0 +1,30 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+module Merb
+ module CookbooksHelper
+ def syntax_highlight(code)
+ converter = Syntax::Convertors::HTML.for_syntax "ruby"
+ if File.exists?(code)
+ converter.convert(File.read(code))
+ else
+ converter.convert(code)
+ end
+ end
+ end
+end
diff --git a/chef-server/lib/init.rb b/chef-server/lib/init.rb
index 23576dd774..4386361ca9 100644
--- a/chef-server/lib/init.rb
+++ b/chef-server/lib/init.rb
@@ -117,6 +117,7 @@ Merb.push_path(:helper, File.join(File.dirname(__FILE__), "helpers"))
Merb.push_path(:public, File.join(File.dirname(__FILE__), "public"))
require 'merb-haml'
+require 'syntax/convertors/html'
#
diff --git a/chef-server/lib/views/cookbooks/_attribute_file.html.haml b/chef-server/lib/views/cookbooks/_attribute_file.html.haml
index af859d5ff3..eb91921bf0 100644
--- a/chef-server/lib/views/cookbooks/_attribute_file.html.haml
+++ b/chef-server/lib/views/cookbooks/_attribute_file.html.haml
@@ -1,2 +1,2 @@
%h3= name
-= ::Uv.parse(contents, "xhtml", "ruby", true, "twilight") \ No newline at end of file
+%pre= contents \ No newline at end of file
diff --git a/chef-server/lib/views/cookbooks/_syntax_highlight.html.haml b/chef-server/lib/views/cookbooks/_syntax_highlight.html.haml
new file mode 100644
index 0000000000..1f769d05f1
--- /dev/null
+++ b/chef-server/lib/views/cookbooks/_syntax_highlight.html.haml
@@ -0,0 +1,2 @@
+%h3= name
+%div.ruby= syntax_highlight(contents) \ No newline at end of file
diff --git a/chef-server/lib/views/cookbooks/show.html.haml b/chef-server/lib/views/cookbooks/show.html.haml
index 1b6557e012..1c409a3327 100644
--- a/chef-server/lib/views/cookbooks/show.html.haml
+++ b/chef-server/lib/views/cookbooks/show.html.haml
@@ -1,24 +1,29 @@
%h1= "Cookbook #{h @cookbook.name}"
.cookbook
+- if @cookbook.lib_files.length > 0
+ %h2 Library Files
+ - @cookbook.lib_files.each do |f|
+ = partial(:syntax_highlight, :name => File.basename(f), :contents => f)
+
- if @cookbook.attribute_files.length > 0
%h2 Attribute Files
- - @cookbook.attribute_files.each do |af|
- = partial(:attribute_file, :name => File.basename(af), :contents => File.read(af))
+ - @cookbook.attribute_files.each do |f|
+ = partial(:syntax_highlight, :name => File.basename(f), :contents => f)
- if @cookbook.definition_files.length > 0
- - @cookbook.definition_files.each do |df|
- %h2 Definition Files
- %h3= File.basename(df)
- = ::Uv.parse(File.read(df), "xhtml", "ruby", true, "twilight")
+ %h2 Definition Files
+ - @cookbook.definition_files.each do |f|
+ = partial(:syntax_highlight, :name => File.basename(f), :contents => f)
- if @cookbook.recipe_files.length > 0
- - @cookbook.recipe_files.each do |rf|
- %h2 Recipe Files
- %h3= File.basename(rf)
- = ::Uv.parse(File.read(rf), "xhtml", "ruby", true, "twilight")
+ %h2 Recipe Files
+ - @cookbook.recipe_files.each do |f|
+ = partial(:syntax_highlight, :name => File.basename(f), :contents => f)
- if @cookbook.template_files.length > 0
- - @cookbook.template_files.each do |tf|
- %h2 Template Files
- %h3= File.basename(tf)
- = ::Uv.parse(File.read(tf), "xhtml", "html_rails", true, "twilight")
+ %h2 Template Files
+ - @cookbook.template_files.each do |f|
+ %h3= name
+ %div= syntax_highlight(contents)
+ = partial(:syntax_highlight, :name => File.basename(f), :contents => f)
+ \ No newline at end of file