Commit 0712e785 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Snippet restyle

parent ca4e2ad1
......@@ -28,6 +28,7 @@ class Snippet < ActiveRecord::Base
scope :fresh, order("created_at DESC")
scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current])
scope :expired, where(["expires_at IS NOT NULL AND expires_at < ?", Time.current])
def self.content_types
[
......
%div
.ui-box.width-100p
%h3
= @snippet.new_record? ? "New snippet" : "Edit snippet ##{@snippet.id}"
= form_for [@project, @snippet] do |f|
.data.no-padding
= form_for [@project, @snippet] do |f|
%div
%span.entity-info
- if @snippet.new_record?
= link_to project_snippets_path(@project) do
.entity-button
Back
%i
- else
= link_to project_snippet_path(@project, @snippet) do
.entity-button
Back
%i
%h2= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
%hr
%table.no-borders
-if @snippet.errors.any?
%tr
%td Errors
%td
%td{:colspan => 2}
#error_explanation
- @snippet.errors.full_messages.each do |msg|
%span= msg
......@@ -22,7 +31,7 @@
%td= f.text_field :file_name, :placeholder => "example.rb"
%tr
%td= f.label "Lifetime"
%td= f.select :expires_at, lifetime_select_options
%td= f.select :expires_at, lifetime_select_options, {}, :style => "width:200px;"
%tr
%td{:colspan => 2}
= f.label :content, "Code"
......@@ -30,7 +39,15 @@
%br
= f.text_area :content
.buttons
.merge-tabs
= f.submit 'Save', :class => "grey-button"
- if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user
.right= link_to 'Destroy', [@project, @snippet], :confirm => 'Are you sure?', :method => :delete, :class => "grey-button delete-snippet negative", :id => "destroy_snippet_#{@snippet.id}"
- unless @snippet.new_record?
.right= link_to 'Destroy', [@project, @snippet], :confirm => 'Are you sure?', :method => :delete, :class => "red-button delete-snippet", :id => "destroy_snippet_#{@snippet.id}"
:javascript
$(function(){
$('select#snippet_expires_at').chosen();
});
- unless snippet.expired?
%tr{ :id => dom_id(snippet), :class => "snippet", :url => project_snippet_path(@project, snippet) }
%td
= image_tag gravatar_icon(snippet.author.email), :class => "left", :width => 40, :style => "padding:0 5px;"
%span
%strong= html_escape snippet.title
%br
%br
%div.author
%strong= truncate snippet.author.name, :lenght => 20
%cite.cgray
= time_ago_in_words(snippet.updated_at)
%a.update-item{:href => project_snippet_path(snippet.project, snippet)}
= image_tag gravatar_icon(snippet.author_email), :class => "left", :width => 40
%span.update-title
= truncate(snippet.title, :length => 60)
%span.update-author
%strong= snippet.author_name
authored
= time_ago_in_words(snippet.created_at)
ago
.right.action-links
- if can?(current_user, :admin_snippet, @project) || snippet.author == current_user
= link_to 'Edit', edit_project_snippet_path(@project, snippet), :class => "cgray"
- if can?(current_user, :admin_snippet, @project) || snippet.author == current_user
= link_to 'Destroy', [@project, snippet], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-snippet negative", :id => "destroy_snippet_#{snippet.id}"
.right
%span.tag.commit= snippet.file_name
......@@ -4,9 +4,7 @@
- if can? current_user, :write_snippet, @project
.right= link_to 'New Snippet', new_project_snippet_path(@project), :class => "grey-button append-bottom-10"
%table#snippets-table
- unless @snippets.fresh.empty?
%div{ :class => "update-data ui-box ui-box-small ui-box-big" }
.data
= render @snippets.fresh
:javascript
$('.delete-snippet').live('ajax:success', function() {
$(this).closest('tr').fadeOut(); });
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