Skip to content
Snippets Groups Projects
Commit 6b030fd4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

1.1pre1

parent 3a2b2733
No related branches found
No related tags found
No related merge requests found
Showing
with 215 additions and 31 deletions
module SnippetsHelper
end
Loading
Loading
@@ -2,6 +2,9 @@ class Ability
def self.allowed(object, subject)
case subject.class.name
when "Project" then project_abilities(object, subject)
when "Issue" then issue_abilities(object, subject)
when "Note" then note_abilities(object, subject)
when "Snippet" then snippet_abilities(object, subject)
else []
end
end
Loading
Loading
@@ -12,6 +15,7 @@ class Ability
rules << [
:read_project,
:read_issue,
:read_snippet,
:read_team_member,
:read_note
] if project.readers.include?(user)
Loading
Loading
@@ -19,16 +23,35 @@ class Ability
rules << [
:write_project,
:write_issue,
:write_snippet,
:write_note
] if project.writers.include?(user)
 
rules << [
:admin_project,
:admin_issue,
:admin_snippet,
:admin_team_member,
:admin_note
] if project.admins.include?(user)
 
rules.flatten
end
class << self
[:issue, :note, :snippet].each do |name|
define_method "#{name}_abilities" do |user, subject|
if subject.author == user
[
:"read_#{name}",
:"write_#{name}",
:"admin_#{name}"
]
else
subject.respond_to?(:project) ?
project_abilities(user, subject.project) : []
end
end
end
end
end
Loading
Loading
@@ -37,5 +37,6 @@ end
# created_at :datetime
# updated_at :datetime
# closed :boolean default(FALSE), not null
# position :integer default(0)
#
 
Loading
Loading
@@ -22,6 +22,10 @@ class Note < ActiveRecord::Base
 
scope :common, where(:noteable_id => nil)
 
scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days))
scope :since, lambda { |day| where("created_at >= :date", :date => (day)) }
scope :fresh, order("created_at DESC")
mount_uploader :attachment, AttachmentUploader
end
# == Schema Information
Loading
Loading
Loading
Loading
@@ -7,6 +7,7 @@ class Project < ActiveRecord::Base
has_many :users_projects, :dependent => :destroy
has_many :users, :through => :users_projects
has_many :notes, :dependent => :destroy
has_many :snippets, :dependent => :destroy
 
validates :name,
:uniqueness => true,
Loading
Loading
@@ -125,6 +126,34 @@ class Project < ActiveRecord::Base
end
end
 
def heads
@heads ||= repo.heads
end
def fresh_commits
commits = heads.map do |h|
repo.commits(h.name, 10)
end.flatten.uniq { |c| c.id }
commits.sort! do |x, y|
y.committed_date <=> x.committed_date
end
commits[0..10]
end
def commits_since(date)
commits = heads.map do |h|
repo.log(h.name, nil, :since => date)
end.flatten.uniq { |c| c.id }
commits.sort! do |x, y|
y.committed_date <=> x.committed_date
end
commits
end
def tree(fcommit, path = nil)
fcommit = commit if fcommit == :head
tree = fcommit.tree
Loading
Loading
class Snippet < ActiveRecord::Base
include Utils::Colorize
belongs_to :project
belongs_to :author, :class_name => "User"
has_many :notes, :as => :noteable
attr_protected :author, :author_id, :project, :project_id
validates_presence_of :project_id
validates_presence_of :author_id
validates :title,
:presence => true,
:length => { :within => 0..255 }
validates :file_name,
:presence => true,
:length => { :within => 0..255 }
validates :content,
:presence => true,
:length => { :within => 0..10000 }
def self.content_types
[
".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java",
".haml", ".html", ".sass", ".scss", ".xml", ".php", ".erb",
".js", ".sh", ".coffee", ".yml", ".md"
]
end
def colorize
system_colorize(content, file_name)
end
end
# == Schema Information
#
# Table name: snippets
#
# id :integer not null, primary key
# title :string(255)
# content :text
# author_id :integer not null
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# file_name :string(255)
#
Loading
Loading
@@ -5,7 +5,8 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable
 
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :projects_limit
attr_accessible :email, :password, :password_confirmation, :remember_me,
:name, :projects_limit, :skype, :linkedin, :twitter
 
has_many :users_projects, :dependent => :destroy
has_many :projects, :through => :users_projects
Loading
Loading
@@ -58,5 +59,8 @@ end
# name :string(255)
# admin :boolean default(FALSE), not null
# projects_limit :integer
# skype :string
# linkedin :string
# twitter :string
#
 
Loading
Loading
@@ -25,13 +25,26 @@
= f.label :password_confirmation
%br
= f.password_field :password_confirmation
.span-11
.field.prepend-top.append-bottom
.field.prepend-top
= f.check_box :admin
= f.label :admin
.span-11
.field.prepend-top
= f.text_field :projects_limit, :class => "small_input"
= f.label :projects_limit
.field
= f.label :skype
%br
= f.text_field :skype
.field
= f.label :linkedin
%br
= f.text_field :linkedin
.field
= f.label :twitter
%br
= f.text_field :twitter
.clear
%br
.actions
Loading
Loading
Loading
Loading
@@ -14,6 +14,17 @@
%b Projects limit:
= @admin_user.projects_limit
 
%p
%b Skype:
= @admin_user.skype
%p
%b LinkedIn:
= @admin_user.linkedin
%p
%b Twitter:
= @admin_user.twitter
.clear
= link_to 'Edit', edit_admin_user_path(@admin_user)
\|
Loading
Loading
Loading
Loading
@@ -11,12 +11,12 @@
= image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
%p
%strong
= commit.message.length > 60 ? (commit.message[0..59] + "...") : commit.message
= truncate_commit_message(commit)
= link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right"
= link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right"
%span
%span
[ #{commit.author} ]
%span.author
= commit.author
= time_ago_in_words(commit.committed_date)
ago
= more_commits_link if @commits.size > 99
- require "utils"
.file_stats
- @commit.diffs.each do |diff|
- if diff.deleted_file
Loading
Loading
@@ -35,7 +34,7 @@
%strong{:id => "#{diff.b_path}"}= diff.b_path
%br/
.diff_file_content
- if file.mime_type =~ /application|text/ && !Utils.binary?(file.data)
- if file.text?
- lines_arr = diff.diff.lines.to_a
- line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0
- line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0
Loading
Loading
@@ -50,9 +49,9 @@
- else
- line_new += 1
- line_old += 1
- elsif file.mime_type =~ /image/
- elsif file.image?
.diff_file_content_image
%img{:src => "data:image/jpeg;base64,#{Base64.encode64(file.data)}"}
%img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
- else
%p
%center No preview for this file type
%h3
= "[ #{@commit.committer} ] #{truncate @commit.message, :length => 80}"
= "[ #{@commit.committer} ] #{truncate_commit_message(@commit, 80)}"
-#= link_to 'Back', project_commits_path(@project), :class => "button"
%table.round-borders
%tr
Loading
Loading
:plain
-#:plain
$("#side-commit-preview").remove();
var side = $("<div id='side-commit-preview'></div>");
side.html("#{escape_javascript(render "commits/show")}");
$("##{dom_id(@project)}").parent().append(side);
$("##{dom_id(@project)}").addClass("span-14");
:plain
$("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}");
:plain
$("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}");
Loading
Loading
@@ -12,9 +12,9 @@
= f.label :note
%cite (255 symbols only)
%br
= f.text_area :note, :style => "width:97%;height:100px", :size => 255
= f.text_area :note, :size => 255
 
%div
%div.attach_holder
= f.label :attachment
%cite (less than 10 MB)
%br
Loading
Loading
@@ -25,4 +25,4 @@
.clear
%br
= f.submit 'Add note', :class => "lbutton vm"
= f.submit 'Add note', :class => "lbutton vm", :id => "submit_note"
%ul#notes-list
- @notes.each do |note|
- next unless note.author
= render :partial => "notes/show", :locals => {:note => note}
- if controller.action_name == "wall"
%ul#notes-list= render "notes/notes_list"
 
%br
%br
- if can? current_user, :write_note, @project
= render "notes/form"
- else
%ul#notes-list= render "notes/notes_list"
%br
%br
- if can? current_user, :write_note, @project
= render "notes/form"
 
:javascript
$('.delete-note').live('ajax:success', function() {
$(this).closest('li').fadeOut(); });
 
$("#new_note").live("ajax:before", function(){
$("#submit_note").attr("disabled", "disabled");
})
 
$("#new_note").live("ajax:complete", function(){
$("#submit_note").removeAttr("disabled");
})
- if ["issues", "projects"].include?(controller.controller_name)
:javascript
$(function(){
var int =self.setInterval("updatePage()", 20000);
});
- @notes.each do |note|
- next unless note.author
= render :partial => "notes/show", :locals => {:note => note}
%li{:id => dom_id(note)}
%div.note_author
= image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;"
%div.note_content
%div.note_content.left
= simple_format(html_escape(note.note))
- if note.attachment.url
Attachment:
= link_to note.attachment_identifier, note.attachment.url
= link_to note.attachment_identifier, note.attachment.url, :target => "_blank"
%br
%span
%span
[ #{note.author.name} ]
&nbsp;
%span.author= note.author.name
%cite.ago
= time_ago_in_words(note.updated_at)
ago
%br
%br
- if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
= link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative"
.clear
- if @note.valid?
:plain
$("#new_note .errors").remove();
$("#notes-list").append("#{escape_javascript(render(:partial => 'show', :locals => {:note => @note} ))}");
updatePage();
$('#note_note').val("");
- else
:plain
$("#new_note").replaceWith("#{escape_javascript(render('form'))}");
:plain
$("#submit_note").removeAttr("disabled");
Loading
Loading
@@ -6,3 +6,28 @@
%p
%b Email:
= @user.email
%br
= form_for @user, :url => profile_edit_path, :method => :put do |f|
-if @user.errors.any?
#error_explanation
%ul
- @user.errors.full_messages.each do |msg|
%li= msg
.div
= f.label :skype
%br
= f.text_field :skype
.div
= f.label :linkedin
%br
= f.text_field :linkedin
.div
= f.label :twitter
%br
= f.text_field :twitter
.actions
= f.submit 'Save', :class => "lbutton vm"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment