Commit c0f02aad authored by Long Nguyen's avatar Long Nguyen
Browse files

Add snippet tab under user profile

parent df8fda60
......@@ -26,6 +26,10 @@
# Personal projects
# </a>
# </li>
# <li class="snippets-tab">
# <a data-action="snippets" data-target="#snippets" data-toggle="tab" href="/u/username/snippets">
# </a>
# </li>
# </ul>
#
# <div class="tab-content">
......@@ -41,6 +45,9 @@
# <div class="tab-pane" id="projects">
# Projects content
# </div>
# <div class="tab-pane" id="snippets">
# Snippets content
# </div>
# </div>
#
# <div class="loading-status">
......@@ -100,7 +107,7 @@ class @UserTabs
if action is 'activity'
@loadActivities(source)
if action in ['groups', 'contributed', 'projects']
if action in ['groups', 'contributed', 'projects', 'snippets']
@loadTab(source, action)
loadTab: (source, action) ->
......
......@@ -58,6 +58,19 @@ def contributed
end
end
def snippets
load_snippets
respond_to do |format|
format.html { render 'show' }
format.json do
render json: {
html: view_to_html_string("snippets/_snippets", collection: @snippets)
}
end
end
end
def calendar
calendar = contributions_calendar
@timestamps = calendar.timestamps
......@@ -116,6 +129,15 @@ def load_groups
@groups = JoinedGroupsFinder.new(user).execute(current_user)
end
def load_snippets
@snippets = SnippetsFinder.new.execute(
current_user,
filter: :by_user,
user: user,
scope: params[:scope]
).page(params[:page])
end
def projects_for_current_user
ProjectsFinder.new.execute(current_user)
end
......
......@@ -81,6 +81,9 @@
%li.projects-tab
= link_to user_projects_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
Snippets
%div{ class: container_class }
.tab-content
......@@ -104,6 +107,9 @@
#projects.tab-pane
- # This tab is always loaded via AJAX
#snippets.tab-pane
- # This tab is always loaded via AJAX
.loading-status
= spinner
......
......@@ -89,8 +89,6 @@
end
end
get '/s/:username' => 'snippets#index', as: :user_snippets, constraints: { username: /.*/ }
#
# Invites
#
......@@ -355,6 +353,9 @@
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)/ }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment