summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-07-10 23:12:38 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-07-10 23:12:38 +0300
commitf88a2617e65ecc037d3f885965efcee39745163d (patch)
tree135d118cb7a5d9020ad411b0ce7d645aa88220c1 /app/helpers
parent1a2bacfb4b4b8f4d79df0335b4daf1d2cfa16d88 (diff)
downloadgitlab-ce-f88a2617e65ecc037d3f885965efcee39745163d.tar.gz
Tree ajax log. progress bar & refactoring
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/helpers/tree_helper.rb27
2 files changed, 31 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 2697fff433e..3f15fd9237f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -134,4 +134,8 @@ module ApplicationHelper
end
active ? "current" : nil
end
+
+ def hexdigest(string)
+ Digest::SHA1.hexdigest string
+ end
end
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
new file mode 100644
index 00000000000..ed3053d8af5
--- /dev/null
+++ b/app/helpers/tree_helper.rb
@@ -0,0 +1,27 @@
+module TreeHelper
+ def tree_icon(content)
+ if content.is_a?(Grit::Blob)
+ if content.text?
+ image_tag "file_txt.png"
+ elsif content.image?
+ image_tag "file_img.png"
+ else
+ image_tag "file_bin.png"
+ end
+ else
+ image_tag "file_dir.png"
+ end
+ end
+
+ def tree_hex_class(content)
+ "file_#{hexdigest(content.name)}"
+ end
+
+ def tree_full_path(content)
+ if params[:path]
+ File.join(params[:path], content.name)
+ else
+ content.name
+ end
+ end
+end