Commit 093159a8 authored by randx's avatar randx

Styled snippets. Raw button for snippet

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