BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ffda8a1a
Commit
ffda8a1a
authored
May 08, 2016
by
Long Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user routings refactor
parent
5f60841d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
64 additions
and
32 deletions
+64
-32
snippets_controller.rb
app/controllers/snippets_controller.rb
+20
-2
_snippet_blob.html.haml
app/views/search/results/_snippet_blob.html.haml
+1
-1
_snippet_title.html.haml
app/views/search/results/_snippet_title.html.haml
+1
-1
_snippet.html.haml
app/views/shared/snippets/_snippet.html.haml
+1
-1
index.html.haml
app/views/snippets/index.html.haml
+13
-0
calendar.html.haml
app/views/users/calendar.html.haml
+1
-1
show.html.haml
app/views/users/show.html.haml
+6
-6
routes.rb
config/routes.rb
+17
-20
routing_spec.rb
spec/routing/routing_spec.rb
+4
-0
No files found.
app/controllers/snippets_controller.rb
View file @
ffda8a1a
...
...
@@ -10,11 +10,29 @@ class SnippetsController < ApplicationController
# Allow destroy snippet
before_action
:authorize_admin_snippet!
,
only:
[
:destroy
]
skip_before_action
:authenticate_user!
,
only:
[
:show
,
:raw
]
skip_before_action
:authenticate_user!
,
only:
[
:
index
,
:
show
,
:raw
]
layout
'snippets'
respond_to
:html
def
index
if
params
[
:username
].
present?
@user
=
User
.
find_by
(
username:
params
[
:username
])
render_404
and
return
unless
@user
@snippets
=
SnippetsFinder
.
new
.
execute
(
current_user
,
{
filter: :by_user
,
user:
@user
,
scope:
params
[
:scope
]
}).
page
(
params
[
:page
])
render
'index'
else
redirect_to
(
current_user
?
dashboard_snippets_path
:
explore_snippets_path
)
end
end
def
new
@snippet
=
PersonalSnippet
.
new
end
...
...
@@ -43,7 +61,7 @@ class SnippetsController < ApplicationController
@snippet
.
destroy
redirect_to
dashboard_
snippets_path
redirect_to
snippets_path
end
def
raw
...
...
app/views/search/results/_snippet_blob.html.haml
View file @
ffda8a1a
...
...
@@ -6,7 +6,7 @@
%span
=
snippet
.
title
by
=
link_to
user_snippets
_path
(
snippet
.
author
)
do
=
link_to
snippets_user
_path
(
snippet
.
author
)
do
=
image_tag
avatar_icon
(
snippet
.
author_email
),
class:
"avatar avatar-inline s16"
,
alt:
''
=
snippet
.
author_name
%span
.light
#{
time_ago_with_tooltip
(
snippet
.
created_at
)
}
...
...
app/views/search/results/_snippet_title.html.haml
View file @
ffda8a1a
...
...
@@ -17,7 +17,7 @@
=
"#
#{
snippet_title
.
id
}
"
%span
by
=
link_to
user_snippets
_path
(
snippet_title
.
author
)
do
=
link_to
snippets_user
_path
(
snippet_title
.
author
)
do
=
image_tag
avatar_icon
(
snippet_title
.
author_email
),
class:
"avatar avatar-inline s16"
,
alt:
''
=
snippet_title
.
author_name
%span
.light
#{
time_ago_with_tooltip
(
snippet_title
.
created_at
)
}
app/views/shared/snippets/_snippet.html.haml
View file @
ffda8a1a
...
...
@@ -16,6 +16,6 @@
=
link_to
snippet
.
project
.
name_with_namespace
,
namespace_project_path
(
snippet
.
project
.
namespace
,
snippet
.
project
)
.snippet-info
=
link_to
user_snippets
_path
(
snippet
.
author
)
do
=
link_to
snippets_user
_path
(
snippet
.
author
)
do
=
snippet
.
author_name
authored
#{
time_ago_with_tooltip
(
snippet
.
created_at
)
}
app/views/snippets/index.html.haml
0 → 100644
View file @
ffda8a1a
-
page_title
"By
#{
@user
.
name
}
"
,
"Snippets"
%ol
.breadcrumb
%li
=
link_to
snippets_path
do
Snippets
%li
=
@user
.
name
.pull-right.hidden-xs
=
link_to
user_path
(
@user
)
do
#{
@user
.
name
}
profile page
=
render
'snippets'
app/views/users/calendar.html.haml
View file @
ffda8a1a
...
...
@@ -4,7 +4,7 @@
#{
@timestamps
.
to_json
}
,
#{
@starting_year
}
,
#{
@starting_month
}
,
'
#{
user_calendar_activities
_path
}
'
'
#{
calendar_activities_user
_path
}
'
);
.calendar-hint
Summary of issues, merge requests, and push events
app/views/users/show.html.haml
View file @
ffda8a1a
...
...
@@ -70,19 +70,19 @@
%ul
.nav-links.center.user-profile-nav
%li
.js-activity-tab
=
link_to
user_calendar_activities
_path
,
data:
{
target:
'div#activity'
,
action:
'activity'
,
toggle:
'tab'
}
do
=
link_to
calendar_activities_user
_path
,
data:
{
target:
'div#activity'
,
action:
'activity'
,
toggle:
'tab'
}
do
Activity
%li
.js-groups-tab
=
link_to
user_groups
_path
,
data:
{
target:
'div#groups'
,
action:
'groups'
,
toggle:
'tab'
}
do
=
link_to
groups_user
_path
,
data:
{
target:
'div#groups'
,
action:
'groups'
,
toggle:
'tab'
}
do
Groups
%li
.js-contributed-tab
=
link_to
user_contributed_projects
_path
,
data:
{
target:
'div#contributed'
,
action:
'contributed'
,
toggle:
'tab'
}
do
=
link_to
contributed_projects_user
_path
,
data:
{
target:
'div#contributed'
,
action:
'contributed'
,
toggle:
'tab'
}
do
Contributed projects
%li
.projects-tab
=
link_to
user_projects
_path
,
data:
{
target:
'div#projects'
,
action:
'projects'
,
toggle:
'tab'
}
do
=
link_to
projects_user
_path
,
data:
{
target:
'div#projects'
,
action:
'projects'
,
toggle:
'tab'
}
do
Personal projects
%li
.snippets-tab
=
link_to
user_snippets
_path
,
data:
{
target:
'div#snippets'
,
action:
'snippets'
,
toggle:
'tab'
}
do
=
link_to
snippets_user
_path
,
data:
{
target:
'div#snippets'
,
action:
'snippets'
,
toggle:
'tab'
}
do
Snippets
%div
{
class:
container_class
}
...
...
@@ -90,7 +90,7 @@
#activity
.tab-pane
.gray-content-block.calender-block.white.second-block.hidden-xs
%div
{
class:
container_class
}
.user-calendar
{
data:
{
href:
user_calenda
r_path
}}
.user-calendar
{
data:
{
href:
calendar_use
r_path
}}
%h4
.center.light
%i
.fa.fa-spinner.fa-spin
.user-calendar-activities
...
...
config/routes.rb
View file @
ffda8a1a
...
...
@@ -91,6 +91,9 @@ Rails.application.routes.draw do
end
end
get
'/s/:username'
,
to:
redirect
(
'/u/:username/snippets'
),
constraints:
{
username:
/[a-zA-Z.0-9_\-]+(?<!\.atom)/
}
#
# Invites
#
...
...
@@ -340,26 +343,20 @@ Rails.application.routes.draw do
end
end
get
'u/:username/calendar'
=>
'users#calendar'
,
as: :user_calendar
,
constraints:
{
username:
/.*/
}
get
'u/:username/calendar_activities'
=>
'users#calendar_activities'
,
as: :user_calendar_activities
,
constraints:
{
username:
/.*/
}
get
'u/:username/groups'
=>
'users#groups'
,
as: :user_groups
,
constraints:
{
username:
/.*/
}
get
'u/:username/projects'
=>
'users#projects'
,
as: :user_projects
,
constraints:
{
username:
/.*/
}
get
'u/:username/contributed'
=>
'users#contributed'
,
as: :user_contributed_projects
,
constraints:
{
username:
/.*/
}
get
'u/:username/snippets'
=>
'users#snippets'
,
as: :user_snippets
,
constraints:
{
username:
/.*/
}
get
'/u/:username'
=>
'users#show'
,
as: :user
,
constraints:
{
username:
/[a-zA-Z.0-9_\-]+(?<!\.atom)/
}
resources
(
:users
,
path:
'u'
,
param: :username
,
constraints:
{
username:
/[a-zA-Z.0-9_\-]+(?<!\.atom)/
},
only: :show
)
do
member
do
get
:calendar
,
as: :calendar
get
:calendar_activities
,
as: :calendar_activities
get
:groups
,
as: :groups
get
:projects
,
as: :projects
get
:contributed
,
as: :contributed_projects
get
:snippets
,
as: :snippets
end
end
#
# Dashboard Area
...
...
spec/routing/routing_spec.rb
View file @
ffda8a1a
...
...
@@ -31,6 +31,10 @@ describe SnippetsController, "routing" do
expect
(
get
(
"/snippets/1/raw"
)).
to
route_to
(
'snippets#raw'
,
id:
'1'
)
end
it
"to #index"
do
expect
(
get
(
"/snippets"
)).
to
route_to
(
'snippets#index'
)
end
it
"to #create"
do
expect
(
post
(
"/snippets"
)).
to
route_to
(
'snippets#create'
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment