summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2018-01-25 16:24:11 +0100
committerAhmad Sherif <me@ahmadsherif.com>2018-01-30 17:19:39 +0100
commitfa9d47f221fff4d75e3c50670aeeac7a3d675f7a (patch)
treea4011a1da4032cb131f1a53d65569cd8e7c59db9 /app/models
parent98dd492766e3455d75fcab47a6abfa100d5c859c (diff)
downloadgitlab-ce-fa9d47f221fff4d75e3c50670aeeac7a3d675f7a.tar.gz
Migrate fetching wiki page formatted content to Gitalyfeature/migrate-wiki-page-formatted-data-to-gitaly
Closes gitaly#958
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project_wiki.rb6
-rw-r--r--app/models/wiki_page.rb5
2 files changed, 10 insertions, 1 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index a0af749a93f..459d1673125 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -124,6 +124,12 @@ class ProjectWiki
update_project_activity
end
+ def page_formatted_data(page)
+ page_title, page_dir = page_title_and_dir(page.title)
+
+ wiki.page_formatted_data(title: page_title, dir: page_dir, version: page.version)
+ end
+
def page_title_and_dir(title)
title_array = title.split("/")
title = title_array.pop
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index bdfef677ef3..e6254183baf 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -107,7 +107,10 @@ class WikiPage
# The processed/formatted content of this page.
def formatted_content
- @attributes[:formatted_content] ||= @page&.formatted_data
+ # Assuming @page exists, nil formatted_data means we didn't load it
+ # before hand (i.e. page was fetched by Gitaly), so we fetch it separately.
+ # If the page was fetched by Gollum, formatted_data would've been a String.
+ @attributes[:formatted_content] ||= @page&.formatted_data || @wiki.page_formatted_data(@page)
end
# The markup format for the page.