diff options
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/admin/projects_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/admin/users_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 77 | ||||
-rw-r--r-- | app/helpers/commits_helper.rb | 24 | ||||
-rw-r--r-- | app/helpers/dashboard_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/keys_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/profile_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/team_members_helper.rb | 2 |
10 files changed, 117 insertions, 0 deletions
diff --git a/app/helpers/admin/projects_helper.rb b/app/helpers/admin/projects_helper.rb new file mode 100644 index 00000000000..348fb1f1a7b --- /dev/null +++ b/app/helpers/admin/projects_helper.rb @@ -0,0 +1,2 @@ +module Admin::ProjectsHelper +end diff --git a/app/helpers/admin/users_helper.rb b/app/helpers/admin/users_helper.rb new file mode 100644 index 00000000000..5995c2aa82d --- /dev/null +++ b/app/helpers/admin/users_helper.rb @@ -0,0 +1,2 @@ +module Admin::UsersHelper +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 00000000000..89a906f0472 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,77 @@ +require 'digest/md5' +module ApplicationHelper + def gravatar_icon(user_email) + "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email)}?s=40&d=identicon" + end + + def commit_name(project, commit) + if project.commit.id == commit.id + "master" + else + commit.id + end + end + + def admin_namespace? + controller.class.name.split("::").first=="Admin" + end + + def projects_namespace? + !current_page?(root_url) && + controller.controller_name != "keys" && + !admin_namespace? + end + + def last_commit(project) + if project.repo_exists? + time_ago_in_words(project.commit.committed_date) + " ago" + else + "Never" + end + end + + def search_autocomplete_source + projects = current_user.projects.map{ |p| { :label => p.name, :url => project_path(p) } } + default_nav = [ + { :label => "Keys", :url => keys_path }, + { :label => "Projects", :url => projects_path }, + { :label => "Admin", :url => admin_root_path } + ] + + project_nav = [] + + if @project && !@project.new_record? + project_nav = [ + { :label => "#{@project.code} / Issues", :url => project_issues_path(@project) }, + { :label => "#{@project.code} / Wall", :url => wall_project_path(@project) }, + { :label => "#{@project.code} / Tree", :url => tree_project_path(@project) }, + { :label => "#{@project.code} / Commits", :url => project_commits_path(@project) }, + { :label => "#{@project.code} / Team", :url => team_project_path(@project) } + ] + end + + [projects, default_nav, project_nav].flatten.to_json + end + + def handle_file_type(file_name, mime_type) + if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/ + :ruby + elsif file_name =~ /\.py$/ + :python + elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/ + $1[1..-1].to_sym + elsif file_name =~ /\.js$/ + :javascript + elsif file_name =~ /\.sh$/ + :bash + elsif file_name =~ /\.coffee$/ + :coffeescript + elsif file_name =~ /\.yml$/ + :yaml + elsif file_name =~ /\.md$/ + :minid + else + :text + end + end +end diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb new file mode 100644 index 00000000000..f1b546684f0 --- /dev/null +++ b/app/helpers/commits_helper.rb @@ -0,0 +1,24 @@ +module CommitsHelper + def diff_line(line, line_new = 0, line_old = 0) + full_line = html_escape(line.gsub(/\n/, '')) + color = if line[0] == "+" + full_line = "<span class=\"old_line\"> </span><span class=\"new_line\">#{line_new}</span> " + full_line + "#DFD" + elsif line[0] == "-" + full_line = "<span class=\"old_line\">#{line_old}</span><span class=\"new_line\"> </span> " + full_line + "#FDD" + else + full_line = "<span class=\"old_line\">#{line_old}</span><span class=\"new_line\">#{line_new}</span> " + full_line + "none" + end + + raw "<div style=\"white-space:pre;background:#{color};\">#{full_line}</div>" + end + + def more_commits_link + offset = params[:offset] || 0 + limit = params[:limit] || 100 + link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit), + :remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link" + end +end diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb new file mode 100644 index 00000000000..a94ddfc2e33 --- /dev/null +++ b/app/helpers/dashboard_helper.rb @@ -0,0 +1,2 @@ +module DashboardHelper +end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb new file mode 100644 index 00000000000..bfb9d25e564 --- /dev/null +++ b/app/helpers/issues_helper.rb @@ -0,0 +1,2 @@ +module IssuesHelper +end diff --git a/app/helpers/keys_helper.rb b/app/helpers/keys_helper.rb new file mode 100644 index 00000000000..d1a77931a92 --- /dev/null +++ b/app/helpers/keys_helper.rb @@ -0,0 +1,2 @@ +module KeysHelper +end diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb new file mode 100644 index 00000000000..5a0d6b31f8c --- /dev/null +++ b/app/helpers/profile_helper.rb @@ -0,0 +1,2 @@ +module ProfileHelper +end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb new file mode 100644 index 00000000000..db5c5ce1a76 --- /dev/null +++ b/app/helpers/projects_helper.rb @@ -0,0 +1,2 @@ +module ProjectsHelper +end diff --git a/app/helpers/team_members_helper.rb b/app/helpers/team_members_helper.rb new file mode 100644 index 00000000000..6b8a38f84fe --- /dev/null +++ b/app/helpers/team_members_helper.rb @@ -0,0 +1,2 @@ +module TeamMembersHelper +end |