diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 75a786165..ae67ed104 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -323,3 +323,52 @@ table.tablesorter tr td.centered { header div.user div.avatar img { border: 1px solid #DDDDDD; } + +div.blame_data { + font-size: 80%; +} + +div.blame_data tr.firstrow { + border-top: 1px solid #DDDDDD; +} + + +div.blame_data tr td.commit_info { + padding: 0.5em !important; + vertical-align: top; + width: 210px; + border-right: 1px solid #DDDDDD; +} + +div.blame_data tr td.commit_info .date { + display: block; + float: left; + color: #666666; +} + +div.blame_data tr td.commit_info .message { + width: 210px; + display: block; + float: right; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: 12px; +} + +div.blame_data tr td.lines { + padding: 0 0.5em !important; + width: 1%; + font-size: 12px; + line-height: 1.4em; +} + +div.blame_data tr td.code { + padding: 0 10px !important; + font-size: 12px; +} + +div.blame_data tr td.code pre { + padding: 0; + margin: 0; +} diff --git a/app/helpers/commit_helper.rb b/app/helpers/commit_helper.rb index 238b0a800..26cbc061b 100644 --- a/app/helpers/commit_helper.rb +++ b/app/helpers/commit_helper.rb @@ -41,4 +41,10 @@ module CommitHelper truncate(message, :length => 42, :omission => "...").encode_to_default end + def commit_author_link(author) + name = author.name.encode_to_default + email = author.email + u = User.where(:email => email).first + u.present? ? link_to(name, user_path(u)) : mail_to(email, name) + end end diff --git a/app/views/git/blobs/_blame_table.html.haml b/app/views/git/blobs/_blame_table.html.haml new file mode 100644 index 000000000..79f20113a --- /dev/null +++ b/app/views/git/blobs/_blame_table.html.haml @@ -0,0 +1,41 @@ +%table.table.blame + - index = 1 + - @blame.each do |elem| + %tr.firstrow + %td.commit_info{ :rowspan => elem[1].length, :nowrap => 'nowrap' } + %code + #{link_to shortest_hash_id(elem[0].id), commit_path(@project, elem[0].id)} #{t('layout.by')} + - author = elem[0].author + - committer = elem[0].committer + = commit_author_link(author) + - if author.email != committer.email + (#{commit_author_link(committer)}) + %br + %span.date= commit_date(elem[0].committed_date) + %span.message{:title => elem[0].message.encode_to_default}= short_commit_message(elem[0].message) + + %td.lines + = index + - index += 1 + + %td.code.cm-s-default + %pre + %div= elem[1].first.encode_to_default + + - elem[1][1..-1].each do |line| + %tr + %td.lines + = index + - index += 1 + %td.code.cm-s-default + %pre + %div= line.encode_to_default + +:javascript + $(document).ready(function() { + var $code_rows = $('.code.cm-s-default pre div'); + var mode = "#{File.extname(@blob.name) == '.spec' ? 'text/x-rpm-spec' : @blob.mime_type}" + $code_rows.each(function() { + CodeMirror.runMode($(this).text().replace(/&/gi, '&'), mode, this.parentElement.parentElement); + }); + }); diff --git a/app/views/git/blobs/_show.html.haml b/app/views/git/blobs/_show.html.haml index aba2703b4..f1f07fe2f 100644 --- a/app/views/git/blobs/_show.html.haml +++ b/app/views/git/blobs/_show.html.haml @@ -17,7 +17,8 @@ - if render_way == :text and can? :write, @project and @treeish.in? @project.branches.map(&:name) = raw "#{link_to "Edit", edit_blob_path(@project, @treeish, @path) } | " = raw "#{link_to "Raw", raw_path(@project, @treeish, @path)} | " - =# raw "#{link_to "Blame", blame_path(@project, @treeish, @path)} | " + - if render_way == :text + = raw "#{link_to "Blame", blame_path(@project, @treeish, @path)} | " = link_to "History", commits_path(@project, @treeish, @path) .both .data @@ -34,7 +35,7 @@ - when :text .gutter = render_line_numbers(text.length) - #output.formatted + #output.formatted.cm-s-default %pre#code =#{render_blob(@blob)} :preserve @@ -51,6 +52,6 @@
:javascript $(document).ready(function() { - var text = $('#code').innerHTML.replace(/&/gi, '&'); - CodeMirror.runMode(text, "#{@blob.mime_type}", document.getElementById("output")); + var text = $('#code').text().replace(/&/gi, '&'); + CodeMirror.runMode(text, "#{File.extname(@blob.name) == '.spec' ? 'text/x-rpm-spec' : @blob.mime_type}", document.getElementById("output")); }); diff --git a/app/views/git/blobs/blame.html.haml b/app/views/git/blobs/blame.html.haml index aaf184b15..3ab4ab4d2 100644 --- a/app/views/git/blobs/blame.html.haml +++ b/app/views/git/blobs/blame.html.haml @@ -1,15 +1,55 @@ -.block += render :partial => 'projects/submenu' += render :partial => 'projects/repo_block', :locals => {:project => @project} + +.description + %h3= t("layout.projects.about_subheader") + %p + = @project.description + = link_to t('layout.read_more'), '#' + +%h3= t("layout.projects.last_commit") +- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter| + = render :partial => 'shared/feed_message', :locals => {:presenter => presenter, :item_no => 1} + +.both + +#repo-wrapper + %h3= t("layout.projects.files_in_project") + .files + .l + = render :partial => 'git/shared/whereami' + .both + + - render_way = choose_render_way(@blob) + .file + .top + .l + = @blob.mode + ' | ' + - if (render_way == :text) + - text = @blob.data.split("\n") + = "#{text.length} lines (#{text.select{|s| s.strip.length > 0}.length} sloc) | " + = "#{(@blob.size / 1024.0).round(3)} Kb" + .r + = raw "#{link_to "Normal", blob_path(@project, @treeish, @path) } | " + = raw "#{link_to "Raw", raw_path(@project, @treeish, @path)} | " + =# raw "#{link_to "Blame", blame_path(@project, @treeish, @path)} | " + = link_to "History", commits_path(@project, @treeish, @path) + .both + .blame_data + = render :partial => 'blame_table' + +-#.block = render :partial => "git/shared/navigation" = render :partial => "git/shared/info" -- if @commit +-#- if @commit .block .content .inner = render :partial => "git/commits/commits", :object => [@commit] -.block +-#.block .content .inner %h3= render_path @@ -53,4 +93,4 @@ %pre %div= line.encode_to_default -- content_for :sidebar, render(:partial => 'git/shared/sidebar') +-#- content_for :sidebar, render(:partial => 'git/shared/sidebar') diff --git a/config/locales/layout.en.yml b/config/locales/layout.en.yml index 3aed28b0e..b8779b053 100644 --- a/config/locales/layout.en.yml +++ b/config/locales/layout.en.yml @@ -9,3 +9,5 @@ en: enter_commit_message: Commit message read_write_access: read & write + + by: by diff --git a/config/locales/layout.ru.yml b/config/locales/layout.ru.yml index a0445ddb7..52e4c78eb 100644 --- a/config/locales/layout.ru.yml +++ b/config/locales/layout.ru.yml @@ -9,3 +9,5 @@ ru: enter_commit_message: Сопровождающее сообщение read_write_access: чтение и запись + + by: '' diff --git a/vendor/assets/stylesheets/vendor.scss b/vendor/assets/stylesheets/vendor.scss index 20df69199..b1a585e0a 100644 --- a/vendor/assets/stylesheets/vendor.scss +++ b/vendor/assets/stylesheets/vendor.scss @@ -9,3 +9,6 @@ @import "codemirror"; @import "codemirror/themes/eclipse"; +@import "codemirror/modes/diff"; +@import "codemirror/modes/rpm-spec"; +@import "codemirror/modes/tiddlywiki";