Start applying new layout to snippets pages
This commit is contained in:
parent
27919e25e8
commit
4a63573b21
6 changed files with 57 additions and 47 deletions
|
@ -1,10 +1,6 @@
|
||||||
class SnippetsController < ApplicationController
|
class SnippetsController < ApplicationController
|
||||||
before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw]
|
before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw]
|
||||||
|
|
||||||
# Allow modify snippet
|
|
||||||
before_filter :authorize_modify_snippet!, only: [:edit, :update]
|
before_filter :authorize_modify_snippet!, only: [:edit, :update]
|
||||||
|
|
||||||
# Allow destroy snippet
|
|
||||||
before_filter :authorize_admin_snippet!, only: [:destroy]
|
before_filter :authorize_admin_snippet!, only: [:destroy]
|
||||||
|
|
||||||
before_filter :set_title
|
before_filter :set_title
|
||||||
|
@ -16,24 +12,24 @@ class SnippetsController < ApplicationController
|
||||||
layout :determine_layout
|
layout :determine_layout
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@snippets = SnippetsFinder.new.execute(current_user, filter: :all).page(params[:page]).per(PER_PAGE)
|
if params[:username].present?
|
||||||
end
|
@user = User.find_by(username: params[:username])
|
||||||
|
|
||||||
def user_index
|
render_404 and return unless @user
|
||||||
@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]).per(PER_PAGE)
|
||||||
|
|
||||||
@snippets = SnippetsFinder.new.execute(current_user, {
|
if @user == current_user
|
||||||
filter: :by_user,
|
render 'current_user_index'
|
||||||
user: @user,
|
else
|
||||||
scope: params[:scope] }).
|
render 'user_index'
|
||||||
page(params[:page]).per(PER_PAGE)
|
end
|
||||||
|
|
||||||
if @user == current_user
|
|
||||||
render 'current_user_index'
|
|
||||||
else
|
else
|
||||||
render 'user_index'
|
@snippets = SnippetsFinder.new.execute(current_user, filter: :all).page(params[:page]).per(PER_PAGE)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -108,6 +104,6 @@ class SnippetsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_layout
|
def determine_layout
|
||||||
current_user ? 'navless' : 'public_users'
|
current_user ? 'snippets' : 'public_users'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
11
app/views/layouts/nav/_snippets.html.haml
Normal file
11
app/views/layouts/nav/_snippets.html.haml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
%ul.nav.nav-sidebar
|
||||||
|
= nav_link(path: user_snippets_path(current_user), html_options: {class: 'home'}) do
|
||||||
|
= link_to user_snippets_path(current_user) do
|
||||||
|
%i.fa.fa-dashboard
|
||||||
|
%span
|
||||||
|
My Snippets
|
||||||
|
= nav_link(path: snippets_path) do
|
||||||
|
= link_to snippets_path, title: 'Discover snippets' do
|
||||||
|
%i.fa.fa-globe
|
||||||
|
%span
|
||||||
|
Discover Snippets
|
6
app/views/layouts/snippets.html.haml
Normal file
6
app/views/layouts/snippets.html.haml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
!!! 5
|
||||||
|
%html{ lang: "en"}
|
||||||
|
= render "layouts/head", title: "Dashboard"
|
||||||
|
%body{class: "#{app_theme} application", :'data-page' => body_data_page }
|
||||||
|
= render "layouts/head_panel", title: link_to("Snippets", snippets_path)
|
||||||
|
= render 'layouts/page', sidebar: 'layouts/nav/snippets'
|
|
@ -8,32 +8,29 @@
|
||||||
|
|
||||||
%p.light
|
%p.light
|
||||||
Share code pastes with others out of git repository
|
Share code pastes with others out of git repository
|
||||||
%hr
|
|
||||||
|
|
||||||
.row
|
%ul.nav.nav-tabs
|
||||||
.col-md-3
|
= nav_tab :scope, nil do
|
||||||
%ul.nav.nav-pills.nav-stacked
|
= link_to user_snippets_path(@user) do
|
||||||
= nav_tab :scope, nil do
|
All
|
||||||
= link_to user_snippets_path(@user) do
|
%span.badge
|
||||||
All
|
= @user.snippets.count
|
||||||
%span.pull-right
|
= nav_tab :scope, 'are_private' do
|
||||||
= @user.snippets.count
|
= link_to user_snippets_path(@user, scope: 'are_private') do
|
||||||
= nav_tab :scope, 'are_private' do
|
Private
|
||||||
= link_to user_snippets_path(@user, scope: 'are_private') do
|
%span.badge
|
||||||
Private
|
= @user.snippets.are_private.count
|
||||||
%span.pull-right
|
= nav_tab :scope, 'are_internal' do
|
||||||
= @user.snippets.are_private.count
|
= link_to user_snippets_path(@user, scope: 'are_internal') do
|
||||||
= nav_tab :scope, 'are_internal' do
|
Internal
|
||||||
= link_to user_snippets_path(@user, scope: 'are_internal') do
|
%span.badge
|
||||||
Internal
|
= @user.snippets.are_internal.count
|
||||||
%span.pull-right
|
= nav_tab :scope, 'are_public' do
|
||||||
= @user.snippets.are_internal.count
|
= link_to user_snippets_path(@user, scope: 'are_public') do
|
||||||
= nav_tab :scope, 'are_public' do
|
Public
|
||||||
= link_to user_snippets_path(@user, scope: 'are_public') do
|
%span.badge
|
||||||
Public
|
= @user.snippets.are_public.count
|
||||||
%span.pull-right
|
|
||||||
= @user.snippets.are_public.count
|
|
||||||
|
|
||||||
.col-md-9.my-snippets
|
.my-snippets
|
||||||
= render 'snippets'
|
= render 'snippets'
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
Public snippets
|
Public snippets
|
||||||
|
|
||||||
.pull-right
|
.pull-right
|
||||||
|
|
||||||
- if current_user
|
- if current_user
|
||||||
= link_to new_snippet_path, class: "btn btn-new btn-grouped", title: "New Snippet" do
|
= link_to new_snippet_path, class: "btn btn-new btn-grouped", title: "New Snippet" do
|
||||||
Add new snippet
|
Add new snippet
|
||||||
|
|
|
@ -51,7 +51,8 @@ Gitlab::Application.routes.draw do
|
||||||
get 'raw'
|
get 'raw'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
get '/s/:username' => 'snippets#user_index', as: :user_snippets, constraints: { username: /.*/ }
|
|
||||||
|
get '/s/:username' => 'snippets#index', as: :user_snippets, constraints: { username: /.*/ }
|
||||||
|
|
||||||
#
|
#
|
||||||
# Invites
|
# Invites
|
||||||
|
|
Loading…
Reference in a new issue