some views for git
This commit is contained in:
parent
17797b956e
commit
5135f048a5
|
@ -11,6 +11,8 @@ class Git::BlobsController < Git::BaseController
|
|||
@commit_hash = @git_repository.repo.log(@treeish, @path).first.id
|
||||
end
|
||||
|
||||
@commit = @git_repository.commits(@treeish, 1).first
|
||||
|
||||
@blob = @tree / @path
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ class Git::TreesController < Git::BaseController
|
|||
@path = params[:path]
|
||||
|
||||
@tree = @git_repository.tree(@treeish)
|
||||
@commit = @git_repository.commits(@treeish, 1).first
|
||||
|
||||
@tree = @tree / @path if @path
|
||||
|
||||
|
|
|
@ -15,11 +15,15 @@ module CommitHelper
|
|||
end
|
||||
|
||||
def format_commit_message(message)
|
||||
h(message).gsub("\n", "<br />")
|
||||
h(message).gsub("\n", "<br />").html_safe
|
||||
end
|
||||
|
||||
def commit_date(date)
|
||||
I18n.localize(date, { :format => "%d %B %Y" })
|
||||
end
|
||||
|
||||
def short_hash_id(id)
|
||||
id[0..19]
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,43 @@
|
|||
module GitHelper
|
||||
|
||||
def render_path
|
||||
# TODO: Looks ugly, rewrite with clear mind.
|
||||
if @path.present?
|
||||
if @treeish == "master"
|
||||
res = "#{link_to @project.name, tree_path(@platform, @repository, @project)} / "
|
||||
else
|
||||
res = "#{link_to @project.name, tree_path(@platform, @repository, @project, @treeish)} / "
|
||||
end
|
||||
|
||||
parts = @path.split("/")
|
||||
|
||||
current_path = parts.first
|
||||
res += parts.length == 1 ? parts.first : link_to(parts.first, tree_path(@platform, @repository, @project, @treeish, current_path)) + " / "
|
||||
|
||||
parts[1..-2].each do |part|
|
||||
current_path = File.join([current_path, part].compact)
|
||||
res += link_to(part, tree_path(@platform, @repository, @project, @treeish, current_path))
|
||||
res += " / "
|
||||
end
|
||||
|
||||
res += parts.last if parts.length > 1
|
||||
else
|
||||
res = "#{link_to @project.name, tree_path(@platform, @repository, @project)} /"
|
||||
end
|
||||
|
||||
res.html_safe
|
||||
end
|
||||
|
||||
def render_line_numbers(n)
|
||||
res = ""
|
||||
1.upto(n) {|i| res += "<span>#{i}</span>\n" }
|
||||
|
||||
res
|
||||
end
|
||||
|
||||
def render_blob(blob)
|
||||
res = ""
|
||||
blob.data.split("\n").collect{|line| "<div>#{line.present? ? h(line) : "<br>"}</div>"}.join
|
||||
end
|
||||
|
||||
end
|
|
@ -8,9 +8,9 @@ class Git::Repository
|
|||
end
|
||||
|
||||
def master
|
||||
commits.first
|
||||
commits(master, 1).first
|
||||
end
|
||||
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
|
|
@ -1,10 +1,39 @@
|
|||
%h2= @blob.name
|
||||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
|
||||
.row
|
||||
= link_to "Raw", raw_commit_path(@platform, @repository, @project, @commit_hash, @path)
|
||||
= link_to "Blame", blame_commit_path(@platform, @repository, @project, @commit_hash, @path)
|
||||
= link_to "History", commits_path(@platform, @repository, @project, @treeish, @path)
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
|
||||
%pre
|
||||
%code
|
||||
= @blob.data
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
= render :partial => "git/commits/commits", :object => [@commit]
|
||||
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
%h3= render_path
|
||||
|
||||
.blob_header
|
||||
.size #{(@blob.size / 1024.0).round(3)} Kb
|
||||
.buttons
|
||||
#{link_to "Raw", raw_commit_path(@platform, @repository, @project, @commit_hash, @path)} #{link_to "Blame", blame_commit_path(@platform, @repository, @project, @commit_hash, @path)} #{link_to "History", commits_path(@platform, @repository, @project, @treeish, @path)}
|
||||
.clear
|
||||
%table.table.blob
|
||||
%tr
|
||||
%td.lines{ :style => "vertical-align: top" }
|
||||
:plain
|
||||
<pre>#{render_line_numbers(@blob.data.split("\n").length)}</pre>
|
||||
%td.blob{ :style => "vertical-align: top" }
|
||||
:plain
|
||||
<pre>#{render_blob(@blob)}</pre>
|
||||
|
||||
- content_for :sidebar, render(:partial => 'git/shared/sidebar')
|
|
@ -1,4 +0,0 @@
|
|||
.commit_row
|
||||
= render :partial => "git/commits/commit_pane", :locals => { :commit => commit }
|
||||
|
||||
.row= link_to commit.message, commit_path(@platform, @repository, @project, commit.id)
|
|
@ -1,7 +0,0 @@
|
|||
= render :partial => "git/commits/committer_pane", :locals => { :commit => commit }
|
||||
|
||||
.row.tree Tree: #{link_to commit.tree.id, tree_path(@platform, @repository, @project, :treeish => commit.tree.id)}
|
||||
|
||||
.row.parents
|
||||
- commit.parents.each do |parent|
|
||||
Parent: #{link_to parent, commit_path(@platform, @repository, @project, parent)}
|
|
@ -0,0 +1,26 @@
|
|||
%ul.list.commits
|
||||
- commits.each do |commit|
|
||||
%li.commit
|
||||
%table
|
||||
%tr
|
||||
%td.committers
|
||||
.author #{commit.author}, #{commit_date(commit.authored_date)}
|
||||
- if commit.committer != commit.author
|
||||
.committer
|
||||
(committed by: #{commit.committer}, #{commit_date(commit.committed_date)})
|
||||
%td.message
|
||||
%p= link_to commit.message, commit_path(@platform, @repository, @project, commit.id)
|
||||
%td.trees
|
||||
.commit
|
||||
Commit:
|
||||
%span{ :style => "float: right;"}
|
||||
#{link_to short_hash_id(commit.id), commit_path(@platform, @repository, @project, commit.id)}
|
||||
.tree
|
||||
Tree:
|
||||
%span{ :style => "float: right;"}
|
||||
#{link_to short_hash_id(commit.tree.id), tree_path(@platform, @repository, @project, :treeish => commit.tree.id)}
|
||||
- commit.parents.each do |parent|
|
||||
.parent
|
||||
Parent:
|
||||
%span{ :style => "float: right;"}
|
||||
#{link_to short_hash_id(parent.id), commit_path(@platform, @repository, @project, parent)}
|
|
@ -1,5 +0,0 @@
|
|||
- if commit.committer != commit.author
|
||||
.row.author Author: #{commit.author}, #{commit_date(commit.authored_date)}
|
||||
.row.committer Committer: #{commit.committer}, #{commit_date(commit.committed_date)}
|
||||
- else
|
||||
.row.author #{commit.author}, #{commit_date(commit.committed_date)}
|
|
@ -1,4 +1,20 @@
|
|||
- if @path.present?
|
||||
%h3 Commits for: #{@path}
|
||||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li.active= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
|
||||
= render :partial => "commit", :collection => @commits
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
= render :partial => "git/commits/commits", :object => @commits
|
||||
|
||||
- content_for :sidebar, render(:partial => 'git/shared/sidebar')
|
||||
|
|
|
@ -1,14 +1,37 @@
|
|||
%h3 Commit: #{@commit.id}
|
||||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li.active= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
|
||||
= render :partial => "commit_pane", :locals => { :commit => @commit}
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
|
||||
#{link_to "raw diff", commit_path(@platform, @repository, @project, @commit.id, :diff)} | #{link_to "patch", commit_path(@platform, @repository, @project, @commit.id, :patch)}
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
= render :partial => "git/commits/commits", :object => [@commit]
|
||||
|
||||
.row.commit_message
|
||||
%code!= format_commit_message(@commit.message)
|
||||
|
||||
.row.commit_stats
|
||||
!= render_commit_stats(@commit.stats)
|
||||
|
||||
- @commit.diffs.each do |diff|
|
||||
!= render_inline_diff(@commit, diff)
|
||||
|
||||
|
||||
-#%h3 Commit: #{@commit.id}
|
||||
-#
|
||||
-#= render :partial => "commit_pane", :locals => { :commit => @commit}
|
||||
-#
|
||||
-##{link_to "raw diff", commit_path(@platform, @repository, @project, @commit.id, :diff)} | #{link_to "patch", commit_path(@platform, @repository, @project, @commit.id, :patch)}
|
||||
-#
|
||||
-#.row.commit_message
|
||||
-# %code!= format_commit_message(@commit.message)
|
||||
-#
|
||||
-#.row.commit_stats
|
||||
-# != render_commit_stats(@commit.stats)
|
||||
-#
|
||||
-#- @commit.diffs.each do |diff|
|
||||
-# != render_inline_diff(@commit, diff)
|
||||
|
|
|
@ -1,34 +1,54 @@
|
|||
.row= link_to "Commits", commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
.row.tags
|
||||
%h3 Tags:
|
||||
%ul
|
||||
- @git_repository.tags.each do |tag|
|
||||
%li= link_to tag.name, tree_path(@platform, @repository, @project, :treeish => tag.name)
|
||||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
|
||||
.row.heads
|
||||
%h3 Heads:
|
||||
%ul
|
||||
- @git_repository.heads.each do |head|
|
||||
%li= link_to head.name, tree_path(@platform, @repository, @project, :treeish => head.name)
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
|
||||
%table
|
||||
%thead
|
||||
%tr
|
||||
%th name
|
||||
%th age
|
||||
%th message
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
= render :partial => "git/commits/commits", :object => [@commit]
|
||||
|
||||
%tbody
|
||||
- if @path.present?
|
||||
%tr
|
||||
%td
|
||||
= link_to "..", tree_path(@platform, @repository, @project, @treeish, File.join([@path, ".."].compact))
|
||||
- @tree.contents.each do |entry|
|
||||
%tr
|
||||
%td
|
||||
- if entry.is_a?(Grit::Blob)
|
||||
= link_to entry.name, blob_path(@platform, @repository, @project, @treeish, File.join([@path, entry.name].compact))
|
||||
- else
|
||||
= link_to "#{entry.name}/", tree_path(@platform, @repository, @project, @treeish, File.join([@path, entry.name].compact))
|
||||
%td==
|
||||
%td==
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
%h3= render_path
|
||||
|
||||
%table.table.git_tree
|
||||
%tr
|
||||
%th.icon
|
||||
%th name
|
||||
%th age
|
||||
%th.last message
|
||||
|
||||
- if @path.present?
|
||||
%tr.odd
|
||||
%td
|
||||
%td.icon
|
||||
= link_to "..", tree_path(@platform, @repository, @project, @treeish, File.join([@path, ".."].compact))
|
||||
%td==
|
||||
%td.last==
|
||||
- (@tree.trees + @tree.blobs).each do |entry|
|
||||
%tr{ :class => cycle("even", "odd")}
|
||||
%td.icon
|
||||
- if entry.is_a?(Grit::Blob)
|
||||
= image_tag("git/icons/text_document_16.png")
|
||||
- else
|
||||
= image_tag("git/icons/folder_16.png")
|
||||
%td.tree_element
|
||||
- if entry.is_a?(Grit::Blob)
|
||||
= link_to entry.name, blob_path(@platform, @repository, @project, @treeish, File.join([@path, entry.name].compact))
|
||||
- else
|
||||
= link_to "#{entry.name}/", tree_path(@platform, @repository, @project, @treeish, File.join([@path, entry.name].compact))
|
||||
%td==
|
||||
%td.last==
|
||||
|
||||
- content_for :sidebar, render(:partial => 'git/shared/sidebar')
|
|
@ -0,0 +1,14 @@
|
|||
.block.notice
|
||||
%h3= t("layout.platforms.current_platform_header")
|
||||
.content
|
||||
%p= link_to @platform.name, platform_path(@platform)
|
||||
|
||||
.block.notice
|
||||
%h3= t("layout.repositories.current_repository_header")
|
||||
.content
|
||||
%p= link_to @repository.name + repository_name_postfix(@platform), platform_repository_path(@platform, @repository)
|
||||
|
||||
.block.notice
|
||||
%h3= t("layout.projects.current_project_header")
|
||||
.content
|
||||
%p= link_to @project.name, platform_repository_path(@platform, @repository) + "#projects"
|
|
@ -8,6 +8,7 @@ stylesheets:
|
|||
- public/stylesheets/web-app-theme/base.css
|
||||
- public/stylesheets/web-app-theme/themes/default/style.css
|
||||
- public/stylesheets/web-app-theme/override.css
|
||||
- public/stylesheets/git/style.css
|
||||
|
||||
sessions:
|
||||
- public/stylesheets/web-app-theme/base.css
|
||||
|
|
|
@ -60,6 +60,7 @@ ru:
|
|||
location: Расположение
|
||||
git_repo_location: Путь к git-репозиторию
|
||||
back_to_the_list: ⇐ К списку проектов репозитория
|
||||
current_project_header: Текущий проект
|
||||
users:
|
||||
list: Список
|
||||
new: Создать
|
||||
|
@ -73,6 +74,10 @@ ru:
|
|||
git:
|
||||
repositories:
|
||||
empty: Пустой репозиторий
|
||||
source: Source
|
||||
commits: Commits
|
||||
tags: Tags
|
||||
branches: Branches
|
||||
|
||||
flash:
|
||||
project:
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 567 B |
Binary file not shown.
After Width: | Height: | Size: 291 B |
|
@ -0,0 +1,120 @@
|
|||
ul.commits {
|
||||
|
||||
}
|
||||
|
||||
li.commit {
|
||||
|
||||
}
|
||||
|
||||
li.commit table tr td {
|
||||
vertical-align: top;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
li.commit .committers {
|
||||
width: 175px;
|
||||
border-right: 1px solid #E2E2E2;
|
||||
}
|
||||
|
||||
li.commit .committers .author {
|
||||
|
||||
}
|
||||
|
||||
li.commit .committers .committer {
|
||||
margin-top: 5px;
|
||||
color: #999999;
|
||||
font-size: 11px;
|
||||
font-weight: normal;
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
li.commit .message {
|
||||
padding-left: 5px;
|
||||
border-right: 1px solid #E2E2E2;
|
||||
width: 575px;
|
||||
}
|
||||
|
||||
li.commit .trees {
|
||||
padding-left: 5px;
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
li.commit .message a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
li.commit .message p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
li.commit .message a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
li.commit .trees div {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
table.git_tree .icon {
|
||||
padding-left: 10px !important;
|
||||
padding-right: 0px !important;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
table.git_tree tree_element a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
table.git_tree ree_element a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
table.git_tree .icon img {
|
||||
top: 1px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
table.blob {
|
||||
line-height: 1.4em;
|
||||
font-family: 'Bitstream Vera Sans Mono','Courier',monospace;
|
||||
border-left: 1px solid #EAEAEA;
|
||||
border-right: 1px solid #EAEAEA;
|
||||
}
|
||||
|
||||
table.blob td {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
table.blob td.lines {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
table.blob td.lines pre {
|
||||
text-align: right;
|
||||
background-color: #ECECEC;
|
||||
border-right: 1px solid #DDDDDD;
|
||||
color: #AAAAAA;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
table.blob td.blob pre {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.blob_header {
|
||||
background-color: #EAEAEA;
|
||||
border-bottom: 1px solid #DDDDDD;
|
||||
font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.blob_header .size {
|
||||
margin-left: 15px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.blob_header .buttons {
|
||||
float: right;
|
||||
margin-right: 15px;
|
||||
}
|
Loading…
Reference in New Issue