Merge pull request #269 from warpc/195-new_design_for_projects

[Refs #195] Add blane functions. Fixed syntax highlighting. Stub for rpm-specs.
This commit is contained in:
Vladimir Sharshov 2012-03-05 09:07:36 -08:00
commit 9d8eb8a3f2
8 changed files with 152 additions and 8 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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);
});
});

View File

@ -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 @@
<br/>
:javascript
$(document).ready(function() {
var text = $('#code').innerHTML.replace(/&amp;/gi, '&');
CodeMirror.runMode(text, "#{@blob.mime_type}", document.getElementById("output"));
var text = $('#code').text().replace(/&amp;/gi, '&');
CodeMirror.runMode(text, "#{File.extname(@blob.name) == '.spec' ? 'text/x-rpm-spec' : @blob.mime_type}", document.getElementById("output"));
});

View File

@ -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')

View File

@ -9,3 +9,5 @@ en:
enter_commit_message: Commit message
read_write_access: read & write
by: by

View File

@ -9,3 +9,5 @@ ru:
enter_commit_message: Сопровождающее сообщение
read_write_access: чтение и запись
by: ''

View File

@ -9,3 +9,6 @@
@import "codemirror";
@import "codemirror/themes/eclipse";
@import "codemirror/modes/diff";
@import "codemirror/modes/rpm-spec";
@import "codemirror/modes/tiddlywiki";