Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
24f04c0a
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
24f04c0a
编写于
10月 21, 2011
作者:
G
gitlabhq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
recent radio button
上级
977fe730
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
55 addition
and
22 deletion
+55
-22
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+16
-18
app/models/note.rb
app/models/note.rb
+1
-0
app/models/project.rb
app/models/project.rb
+28
-0
app/views/projects/show.html.haml
app/views/projects/show.html.haml
+5
-2
app/views/projects/wall.html.haml
app/views/projects/wall.html.haml
+4
-1
spec/requests/projects_spec.rb
spec/requests/projects_spec.rb
+1
-1
未找到文件。
app/controllers/projects_controller.rb
浏览文件 @
24f04c0a
...
...
@@ -60,24 +60,21 @@ class ProjectsController < ApplicationController
end
def
show
if
@project
.
repo_exists?
@date
=
case
params
[
:view
]
when
"week"
then
Date
.
today
-
7
.
days
else
Date
.
today
end
.
at_beginning_of_day
@heads
=
@project
.
repo
.
heads
@commits
=
@heads
.
map
do
|
h
|
@project
.
repo
.
log
(
h
.
name
,
nil
,
:since
=>
@date
)
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
@commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
return
render
"projects/empty"
unless
@project
.
repo_exists?
@date
=
case
params
[
:view
]
when
"week"
then
Date
.
today
-
7
.
days
when
"day"
then
Date
.
today
else
nil
end
if
@date
@date
=
@date
.
at_beginning_of_day
@commits
=
@project
.
commits_since
(
@date
)
@messages
=
project
.
notes
.
since
(
@date
).
order
(
"created_at DESC"
)
else
return
render
"projects/empty"
else
@commits
=
@project
.
fresh_commits
@messages
=
project
.
notes
.
fresh
.
limit
(
10
)
end
end
...
...
@@ -89,11 +86,12 @@ class ProjectsController < ApplicationController
@date
=
case
params
[
:view
]
when
"week"
then
Date
.
today
-
7
.
days
when
"all"
then
nil
else
Date
.
today
when
"day"
then
Date
.
today
else
nil
end
@notes
=
@project
.
common_notes
.
order
(
"created_at DESC"
)
@notes
=
@
notes
.
since
(
@date
.
at_beginning_of_day
)
if
@date
@notes
=
@
date
?
@notes
.
since
(
@date
.
at_beginning_of_day
)
:
@notes
.
fresh
.
limit
(
10
)
@note
=
Note
.
new
end
...
...
app/models/note.rb
浏览文件 @
24f04c0a
...
...
@@ -24,6 +24,7 @@ class Note < ActiveRecord::Base
scope
:last_week
,
where
(
"created_at >= :date"
,
:date
=>
(
Date
.
today
-
7
.
days
))
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
:date
=>
(
day
))
}
scope
:fresh
,
order
(
"created_at DESC"
)
mount_uploader
:attachment
,
AttachmentUploader
end
...
...
app/models/project.rb
浏览文件 @
24f04c0a
...
...
@@ -126,6 +126,34 @@ class Project < ActiveRecord::Base
end
end
def
heads
@heads
||=
repo
.
heads
end
def
fresh_commits
commits
=
heads
.
map
do
|
h
|
repo
.
commits
(
h
.
name
,
10
)
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
[
0
..
10
]
end
def
commits_since
(
date
)
commits
=
heads
.
map
do
|
h
|
repo
.
log
(
h
.
name
,
nil
,
:since
=>
date
)
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
end
def
tree
(
fcommit
,
path
=
nil
)
fcommit
=
commit
if
fcommit
==
:head
tree
=
fcommit
.
tree
...
...
app/views/projects/show.html.haml
浏览文件 @
24f04c0a
%div
%h2
.left
Recent h
istory
%h2
.left
H
istory
.right
=
form_tag
project_path
(
@project
),
:method
=>
:get
do
.span-2
=
radio_button_tag
:view
,
"day"
,
(
params
[
:view
]
||
"day"
)
==
"day"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"day_view"
=
radio_button_tag
:view
,
"recent"
,
(
params
[
:view
]
||
"recent"
)
==
"recent"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"recent_view"
=
label_tag
"recent_view"
,
"Recent"
.span-2
=
radio_button_tag
:view
,
"day"
,
params
[
:view
]
==
"day"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"day_view"
=
label_tag
"day_view"
,
"Today"
.span-2
=
radio_button_tag
:view
,
"week"
,
params
[
:view
]
==
"week"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"week_view"
...
...
app/views/projects/wall.html.haml
浏览文件 @
24f04c0a
...
...
@@ -4,7 +4,10 @@
.right
=
form_tag
wall_project_path
(
@project
),
:method
=>
:get
do
.span-2
=
radio_button_tag
:view
,
"day"
,
(
params
[
:view
]
||
"day"
)
==
"day"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"day_view"
=
radio_button_tag
:view
,
"recent"
,
(
params
[
:view
]
||
"recent"
)
==
"recent"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"recent_view"
=
label_tag
"recent_view"
,
"Recent"
.span-2
=
radio_button_tag
:view
,
"day"
,
params
[
:view
]
==
"day"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"day_view"
=
label_tag
"day_view"
,
"Today"
.span-2
=
radio_button_tag
:view
,
"week"
,
params
[
:view
]
==
"week"
,
:onclick
=>
"this.form.submit()"
,
:id
=>
"week_view"
...
...
spec/requests/projects_spec.rb
浏览文件 @
24f04c0a
...
...
@@ -73,7 +73,7 @@ describe "Projects" do
end
it
"should beahave like dashboard"
do
page
.
should
have_content
(
"
Recent h
istory"
)
page
.
should
have_content
(
"
H
istory"
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录