Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Commit

Permalink
Release openproject-ce v5.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Dec 2, 2015
2 parents d34b941 + c3fc3ae commit 9b53ca9
Show file tree
Hide file tree
Showing 77 changed files with 1,141 additions and 964 deletions.
1 change: 0 additions & 1 deletion .codeclimate.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ exclude_paths:
- .bundle/**/* - .bundle/**/*
- lib/plugins/rfpdf/**/* - lib/plugins/rfpdf/**/*
- spec_legacy/**/* - spec_legacy/**/*
- lib/redcloth3.rb
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ group :development, :test do
gem 'pry-rescue' gem 'pry-rescue'
gem 'pry-byebug', platforms: [:mri] gem 'pry-byebug', platforms: [:mri]
gem 'pry-doc' gem 'pry-doc'
gem 'parallel_tests' gem 'parallel_tests', '~> 2.1.2'
gem 'rubocop', '~> 0.32' gem 'rubocop', '~> 0.32'
end end


Expand Down Expand Up @@ -230,7 +230,7 @@ platforms :jruby do
end end


group :opf_plugins do group :opf_plugins do
gem 'openproject-translations', git:'https://github.com/opf/openproject-translations.git', tag: 'v5.0.4' gem 'openproject-translations', git:'https://github.com/opf/openproject-translations.git', tag: 'v5.0.5'
end end


# Load Gemfile.local, Gemfile.plugins and plugins' Gemfiles # Load Gemfile.local, Gemfile.plugins and plugins' Gemfiles
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ GIT


GIT GIT
remote: https://github.com/opf/openproject-translations.git remote: https://github.com/opf/openproject-translations.git
revision: 9c87aec9d0cd956a1cfaea2a4d7bbdbadd2997bf revision: 98a560e6eb533bbaacb0146f12fccf61f0452d60
tag: v5.0.4 branch: release/5.0
specs: specs:
openproject-translations (5.0.4) openproject-translations (5.0.5)
crowdin-api (~> 0.4.0) crowdin-api (~> 0.4.0)
mixlib-shellout (~> 2.1.0) mixlib-shellout (~> 2.1.0)
rails (~> 4.2.3) rails (~> 4.2.3)
Expand Down Expand Up @@ -530,7 +530,7 @@ GEM
validate_url validate_url
webfinger (>= 0.0.2) webfinger (>= 0.0.2)
parallel (1.6.1) parallel (1.6.1)
parallel_tests (1.6.1) parallel_tests (2.1.2)
parallel parallel
parser (2.2.2.5) parser (2.2.2.5)
ast (>= 1.1, < 3.0) ast (>= 1.1, < 3.0)
Expand Down Expand Up @@ -858,8 +858,8 @@ DEPENDENCIES
openproject-translations! openproject-translations!
openproject-webhooks! openproject-webhooks!
openproject-xls_export! openproject-xls_export!
parallel_tests
pdf-inspector (~> 1.0.0) pdf-inspector (~> 1.0.0)
parallel_tests (~> 2.1.2)
pg (~> 0.18.3) pg (~> 0.18.3)
poltergeist poltergeist
prototype-rails! prototype-rails!
Expand Down
6 changes: 5 additions & 1 deletion app/assets/stylesheets/_misc_legacy.sass
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
// placed elsewhere. Pleade DO NOT add to this file. Instead MOVE, refactor or // placed elsewhere. Pleade DO NOT add to this file. Instead MOVE, refactor or
// REMOVE with ruthlessness. // REMOVE with ruthlessness.
$version-summary-width: 380px

#watchers #watchers
ul ul
margin: 0 margin: 0
Expand Down Expand Up @@ -192,9 +194,11 @@ div
font-size: 120% font-size: 120%
h2 h2
font-size: 110% font-size: 110%
.generic-table--no-results-container
max-width: calc(100% - #{$version-summary-width})
&#version-summary &#version-summary
float: right float: right
width: 380px width: $version-summary-width
margin-left: 16px margin-left: 16px
margin-bottom: 16px margin-bottom: 16px
background-color: #fff background-color: #fff
Expand Down
50 changes: 19 additions & 31 deletions app/controllers/attachments_controller.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,29 +32,14 @@ class AttachmentsController < ApplicationController
before_filter :file_readable, :read_authorize, except: :destroy before_filter :file_readable, :read_authorize, except: :destroy
before_filter :delete_authorize, only: :destroy before_filter :delete_authorize, only: :destroy


def show
if @attachment.is_diff?
@diff = File.new(@attachment.diskfile, 'rb').read
render action: 'diff'
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
@content = File.new(@attachment.diskfile, 'rb').read
render action: 'file'
else
redirect_to link_to_attachment(@attachment)
end
end

def download def download
if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project) url = @attachment.external_url
@attachment.increment_download
end


# browsers should not try to guess the content-type if url
response.headers['X-Content-Type-Options'] = 'nosniff' redirect_to url.to_s

else
send_file @attachment.diskfile, filename: filename_for_content_disposition(@attachment.filename), serve_attachment @attachment
type: @attachment.content_type, end
disposition: @attachment.content_disposition
end end


def destroy def destroy
Expand All @@ -69,16 +54,6 @@ def destroy


private private


def link_to_attachment(attachment)
url = URI.parse attachment.file.download_url

if url.host # check if URL or file path
url.to_s
else
download_attachment_url filename: attachment.filename, id: attachment.id
end
end

def find_project def find_project
@attachment = Attachment.find(params[:id]) @attachment = Attachment.find(params[:id])
# Show 404 if the filename in the url is wrong # Show 404 if the filename in the url is wrong
Expand All @@ -104,4 +79,17 @@ def delete_authorize
def destroy_response_url(container) def destroy_response_url(container)
url_for(container.is_a?(WikiPage) ? [@project, container.wiki] : container) url_for(container.is_a?(WikiPage) ? [@project, container.wiki] : container)
end end

def serve_attachment(attachment)
if attachment.container.is_a?(Version) || attachment.container.is_a?(Project)
attachment.increment_download
end

# browsers should not try to guess the content-type
response.headers['X-Content-Type-Options'] = 'nosniff'

send_file attachment.diskfile, filename: filename_for_content_disposition(attachment.filename),
type: attachment.content_type,
disposition: attachment.content_disposition
end
end end
96 changes: 21 additions & 75 deletions app/controllers/repositories_controller.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ def committers
@users.sort! @users.sort!
if request.post? && params[:committers].is_a?(Hash) if request.post? && params[:committers].is_a?(Hash)
# Build a hash with repository usernames as keys and corresponding user ids as values # Build a hash with repository usernames as keys and corresponding user ids as values
@repository.committer_ids = params[:committers].values @repository.committer_ids = params[:committers].values.inject({}) { |h, c| h[c.first] = c.last; h }
.inject({}) { |h, c|
h[c.first] = c.last
h
}
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to action: 'committers', project_id: @project redirect_to action: 'committers', project_id: @project
end end
Expand Down Expand Up @@ -150,17 +146,10 @@ def show


def changes def changes
@entry = @repository.entry(@path, @rev) @entry = @repository.entry(@path, @rev)

(show_error_not_found; return) unless @entry
unless @entry @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
show_error_not_found
return
end

@changesets = @repository.latest_changesets(@path,
@rev,
Setting.repository_log_display_limit.to_i)
@properties = @repository.properties(@path, @rev) @properties = @repository.properties(@path, @rev)
@changeset = @repository.find_changeset_by_name(@rev) @changeset = @repository.find_changeset_by_name(@rev)
end end


def revisions def revisions
Expand All @@ -170,21 +159,14 @@ def revisions
.per_page(per_page_param) .per_page(per_page_param)


respond_to do |format| respond_to do |format|
format.html do format.html do render layout: false if request.xhr? end
render layout: false if request.xhr? format.atom do render_feed(@changesets, title: "#{@project.name}: #{l(:label_revision_plural)}") end
end
format.atom do
render_feed(@changesets, title: "#{@project.name}: #{l(:label_revision_plural)}")
end
end end
end end


def entry def entry
@entry = @repository.entry(@path, @rev) @entry = @repository.entry(@path, @rev)
unless @entry (show_error_not_found; return) unless @entry
show_error_not_found
return
end


# If the entry is a dir, show the browser # If the entry is a dir, show the browser
if @entry.dir? if @entry.dir?
Expand All @@ -193,12 +175,7 @@ def entry
end end


@content = @repository.cat(@path, @rev) @content = @repository.cat(@path, @rev)

(show_error_not_found; return) unless @content
unless @content
show_error_not_found
return
end

if 'raw' == params[:format] || if 'raw' == params[:format] ||
(@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
!is_entry_text_data?(@content, @path) !is_entry_text_data?(@content, @path)
Expand Down Expand Up @@ -226,8 +203,7 @@ def is_entry_text_data?(ent, path)
# http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F # http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F
if ent.respond_to?('is_binary_data?') && ent.is_binary_data? # Ruby 1.8.x and <1.9.2 if ent.respond_to?('is_binary_data?') && ent.is_binary_data? # Ruby 1.8.x and <1.9.2
return false return false
elsif ent.respond_to?(:force_encoding) && elsif ent.respond_to?(:force_encoding) && (ent.dup.force_encoding('UTF-8') != ent.dup.force_encoding('BINARY')) # Ruby 1.9.2
(ent.dup.force_encoding('UTF-8') != ent.dup.force_encoding('BINARY')) # Ruby 1.9.2
# TODO: need to handle edge cases of non-binary content that isn't UTF-8 # TODO: need to handle edge cases of non-binary content that isn't UTF-8
return false return false
end end
Expand All @@ -238,13 +214,9 @@ def is_entry_text_data?(ent, path)


def annotate def annotate
@entry = @repository.entry(@path, @rev) @entry = @repository.entry(@path, @rev)
(show_error_not_found; return) unless @entry


unless @entry @annotate = @repository.scm.annotate(@path, @rev)
show_error_not_found
return
end

@annotate = @repository.scm.annotate(@path, @rev)
@changeset = @repository.find_changeset_by_name(@rev) @changeset = @repository.find_changeset_by_name(@rev)
end end


Expand All @@ -264,12 +236,7 @@ def revision
def diff def diff
if params[:format] == 'diff' if params[:format] == 'diff'
@diff = @repository.diff(@path, @rev, @rev_to) @diff = @repository.diff(@path, @rev, @rev_to)

(show_error_not_found; return) unless @diff
unless @diff
show_error_not_found
return
end

filename = "changeset_r#{@rev}" filename = "changeset_r#{@rev}"
filename << "_r#{@rev_to}" if @rev_to filename << "_r#{@rev_to}" if @rev_to
send_data @diff.join, send_data @diff.join,
Expand All @@ -286,9 +253,7 @@ def diff
User.current.preference.save User.current.preference.save
end end


@cache_key = "repositories/diff/#{@repository.id}/" + @cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")

unless read_fragment(@cache_key) unless read_fragment(@cache_key)
@diff = @repository.diff(@path, @rev, @rev_to) @diff = @repository.diff(@path, @rev, @rev_to)
show_error_not_found unless @diff show_error_not_found unless @diff
Expand Down Expand Up @@ -341,11 +306,7 @@ def update_repository(repo_params)


def find_repository def find_repository
@repository = @project.repository @repository = @project.repository

(render_404; return false) unless @repository
unless @repository
render_404
return false
end


# Prepare checkout instructions # Prepare checkout instructions
# available on all pages (even empty!) # available on all pages (even empty!)
Expand Down Expand Up @@ -383,30 +344,20 @@ def graph_commits_per_month(repository)
@date_to = Date.today @date_to = Date.today
@date_from = @date_to << 11 @date_from = @date_to << 11
@date_from = Date.civil(@date_from.year, @date_from.month, 1) @date_from = Date.civil(@date_from.year, @date_from.month, 1)
commits_by_day = Changeset.where( commits_by_day = Changeset.where(['repository_id = ? AND commit_date BETWEEN ? AND ?', repository.id, @date_from, @date_to]).group(:commit_date).size
['repository_id = ? AND commit_date BETWEEN ? AND ?', repository.id, @date_from, @date_to]
).group(:commit_date).size
commits_by_month = [0] * 12 commits_by_month = [0] * 12
commits_by_day.each do |c| commits_by_day.each do |c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last end
commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last
end


changes_by_day = Change.includes(:changeset) changes_by_day = Change.includes(:changeset)
.where(["#{Changeset.table_name}.repository_id = ? "\ .where(["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
"AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?",
repository.id, @date_from, @date_to])
.references(:changesets) .references(:changesets)
.group(:commit_date) .group(:commit_date)
.size .size
changes_by_month = [0] * 12 changes_by_month = [0] * 12
changes_by_day.each do |c| changes_by_day.each do |c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last end
changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last
end


fields = [] fields = []
12.times do |m| 12.times do |m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1) end
fields << month_name(((Date.today.month - 1 - m) % 12) + 1)
end


graph = SVG::Graph::Bar.new( graph = SVG::Graph::Bar.new(
height: 300, height: 300,
Expand Down Expand Up @@ -435,19 +386,14 @@ def graph_commits_per_month(repository)


def graph_commits_per_author(repository) def graph_commits_per_author(repository)
commits_by_author = Changeset.where(['repository_id = ?', repository.id]).group(:committer).size commits_by_author = Changeset.where(['repository_id = ?', repository.id]).group(:committer).size
commits_by_author.to_a.sort! do |x, y| commits_by_author.to_a.sort! do |x, y| x.last <=> y.last end
x.last <=> y.last
end


changes_by_author = Change.includes(:changeset) changes_by_author = Change.includes(:changeset)
.where(["#{Changeset.table_name}.repository_id = ?", repository.id]) .where(["#{Changeset.table_name}.repository_id = ?", repository.id])
.references(:changesets) .references(:changesets)
.group(:committer) .group(:committer)
.size .size
h = changes_by_author.inject({}) { |o, i| h = changes_by_author.inject({}) { |o, i| o[i.first] = i.last; o }
o[i.first] = i.last
o
}


fields = commits_by_author.map(&:first) fields = commits_by_author.map(&:first)
commits_data = commits_by_author.map(&:last) commits_data = commits_by_author.map(&:last)
Expand Down
Loading

0 comments on commit 9b53ca9

Please sign in to comment.