Commit 093159a8 authored by randx's avatar randx

Styled snippets. Raw button for snippet

parent b96af79b
class SnippetsController < ApplicationController
before_filter :authenticate_user!
before_filter :project
before_filter :snippet, :only => [:show, :edit, :destroy, :update]
before_filter :snippet, :only => [:show, :edit, :destroy, :update, :raw]
layout "project"
# Authorize
......@@ -67,7 +67,17 @@ class SnippetsController < ApplicationController
redirect_to project_snippets_path(@project)
end
def raw
send_data(
@snippet.content,
:type => "text/plain",
:disposition => 'inline',
:filename => @snippet.file_name
)
end
protected
def snippet
@snippet ||= @project.snippets.find(params[:id])
end
......
%tr
%td
%a{:href => project_snippet_path(snippet.project, snippet)}
= truncate(snippet.title, :length => 60)
%span.right.cgray
= snippet.file_name
%strong= truncate(snippet.title, :length => 60)
%td
= snippet.file_name
%td
%span.cgray
- if snippet.expires_at
= snippet.expires_at.to_date.to_s(:short)
- else
Never
......@@ -8,5 +8,14 @@
%br
To add new snippet - click on button.
- unless @snippets.fresh.empty?
%table.zebra-striped.borders= render @snippets.fresh
%table.admin-table
%thead
%tr
%th Title
%th File Name
%th Expires At
= render @snippets.fresh
- if @snippets.fresh.empty?
%tr
%td{:colspan => 3}
%h3.nothing_here_message Nothing here.
......@@ -13,6 +13,8 @@
.view_file_header
%i.icon-file
%strong= @snippet.file_name
%span.options
= link_to "raw", raw_project_snippet_path(@project, @snippet), :class => "btn very_small", :target => "_blank"
.view_file_content
%div{:class => current_user.dark_scheme ? "black" : ""}
= raw @snippet.colorize(options: { linenos: 'True'})
......
......@@ -119,7 +119,12 @@ Gitlab::Application.routes.draw do
end
end
resources :snippets
resources :snippets do
member do
get "raw"
end
end
resources :hooks, :only => [:index, :create, :destroy] do
member do
get :test
......
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