diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2018-01-25 18:24:11 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2018-01-30 19:19:39 +0300 |
commit | fa9d47f221fff4d75e3c50670aeeac7a3d675f7a (patch) | |
tree | a4011a1da4032cb131f1a53d65569cd8e7c59db9 /app | |
parent | 98dd492766e3455d75fcab47a6abfa100d5c859c (diff) |
Migrate fetching wiki page formatted content to Gitaly
Closes gitaly#958
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project_wiki.rb | 6 | ||||
-rw-r--r-- | app/models/wiki_page.rb | 5 |
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. |