Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Braha Stoll <alexbrahastoll@gmail.com>2016-12-26 03:50:36 +0300
committerAlex Braha Stoll <alexbrahastoll@gmail.com>2016-12-31 21:55:50 +0300
commit77fe503a1fd01eaa8b790d1aacc0cdab159f015e (patch)
treeeffb9fd9df625f951944e2fde4be68344998ecdc /app/models/wiki_page.rb
parent645aaf6e3d18007b56e5bbb33c6fda1526bdc716 (diff)
Remove WikiPage.sort_by_directory
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r--app/models/wiki_page.rb24
1 files changed, 2 insertions, 22 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index a84f84c67cd..efb6ff9bf2b 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -17,10 +17,10 @@ class WikiPage
# pages - an array of WikiPage objects.
#
# Returns a hash whose keys are directories and whose values are WikiPage
- # arrays. See WikiPage.sort_by_directory for more info about the ordering.
+ # arrays.
def self.group_by_directory(pages)
return {} if pages.blank?
- pages = sort_by_directory(pages)
+ pages = pages.sort_by { |page| [page.directory, page.slug] }
directories = {}
pages.each do |page|
@@ -206,26 +206,6 @@ class WikiPage
private
- # Sorts an array of pages by directory and file alphabetical order.
- # Pages at the root directory will come first. The next pages will be
- # sorted by their directories. Within directories, pages are sorted by
- # filename alphabetical order. Pages are sorted in such a fashion that
- # nested directories will always follow their parents (e.g. pages in
- # dir_1/nested_dir_1 will follow pages inside dir_1).
- #
- # pages - an array of WikiPage objects.
- #
- # Returns a sorted array of WikiPage objects.
- def self.sort_by_directory(pages)
- pages.sort do |page, next_page|
- if page.directory == next_page.directory
- page.slug <=> next_page.slug
- else
- page.directory <=> next_page.directory
- end
- end
- end
-
def set_attributes
attributes[:slug] = @page.url_path
attributes[:title] = @page.title