From 093159a8683c381a9f7aa80073ac94c4ed03e108 Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 12 Jun 2012 21:41:46 +0300 Subject: Styled snippets. Raw button for snippet --- app/controllers/snippets_controller.rb | 12 +++++++++++- app/views/snippets/_snippet.html.haml | 12 +++++++++--- app/views/snippets/index.html.haml | 13 +++++++++++-- app/views/snippets/show.html.haml | 2 ++ 4 files changed, 33 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index bfcfda0fc71..3d56bebe2fe 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,7 +1,7 @@ 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 diff --git a/app/views/snippets/_snippet.html.haml b/app/views/snippets/_snippet.html.haml index d6002362a15..0385d753207 100644 --- a/app/views/snippets/_snippet.html.haml +++ b/app/views/snippets/_snippet.html.haml @@ -1,6 +1,12 @@ %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 diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml index 53d6b57f728..a6b07716ccb 100644 --- a/app/views/snippets/index.html.haml +++ b/app/views/snippets/index.html.haml @@ -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. diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index 2720e495011..c934e262488 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -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'}) -- cgit v1.2.3