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

Snippet restyle

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