Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
0c14c633
Commit
0c14c633
authored
Jul 21, 2016
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Retrieve rendered HTML from cache in one request
See #19985
parent
89292551
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
20 deletions
+30
-20
CHANGELOG
CHANGELOG
+1
-0
lib/banzai/reference_extractor.rb
lib/banzai/reference_extractor.rb
+5
-4
spec/models/note_spec.rb
spec/models/note_spec.rb
+24
-16
No files found.
CHANGELOG
View file @
0c14c633
...
@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.11.0 (unreleased)
v 8.11.0 (unreleased)
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
- Limit git rev-list output count to one in forced push check
- Limit git rev-list output count to one in forced push check
- Retrieve rendered HTML from cache in one request
v 8.10.0 (unreleased)
v 8.10.0 (unreleased)
- Fix profile activity heatmap to show correct day name (eanplatter)
- Fix profile activity heatmap to show correct day name (eanplatter)
...
...
lib/banzai/reference_extractor.rb
View file @
0c14c633
...
@@ -2,11 +2,11 @@ module Banzai
...
@@ -2,11 +2,11 @@ module Banzai
# Extract possible GFM references from an arbitrary String for further processing.
# Extract possible GFM references from an arbitrary String for further processing.
class
ReferenceExtractor
class
ReferenceExtractor
def
initialize
def
initialize
@texts
=
[]
@texts
_and_contexts
=
[]
end
end
def
analyze
(
text
,
context
=
{})
def
analyze
(
text
,
context
=
{})
@texts
<<
Renderer
.
render
(
text
,
context
)
@texts
_and_contexts
<<
{
text:
text
,
context:
context
}
end
end
def
references
(
type
,
project
,
current_user
=
nil
)
def
references
(
type
,
project
,
current_user
=
nil
)
...
@@ -21,9 +21,10 @@ module Banzai
...
@@ -21,9 +21,10 @@ module Banzai
def
html_documents
def
html_documents
# This ensures that we don't memoize anything until we have a number of
# This ensures that we don't memoize anything until we have a number of
# text blobs to parse.
# text blobs to parse.
return
[]
if
@texts
.
empty?
return
[]
if
@texts
_and_contexts
.
empty?
@html_documents
||=
@texts
.
map
{
|
html
|
Nokogiri
::
HTML
.
fragment
(
html
)
}
@html_documents
||=
Renderer
.
cache_collection_render
(
@texts_and_contexts
)
.
map
{
|
html
|
Nokogiri
::
HTML
.
fragment
(
html
)
}
end
end
end
end
end
end
spec/models/note_spec.rb
View file @
0c14c633
...
@@ -135,22 +135,30 @@ describe Note, models: true do
...
@@ -135,22 +135,30 @@ describe Note, models: true do
let!
(
:note2
)
{
create
(
:note_on_issue
)
}
let!
(
:note2
)
{
create
(
:note_on_issue
)
}
it
"reads the rendered note body from the cache"
do
it
"reads the rendered note body from the cache"
do
expect
(
Banzai
::
Renderer
).
to
receive
(
:render
).
expect
(
Banzai
::
Renderer
).
to
receive
(
:cache_collection_render
).
with
(
note1
.
note
,
with
([{
text:
note1
.
note
,
context:
{
pipeline: :note
,
pipeline: :note
,
cache_key:
[
note1
,
"note"
],
cache_key:
[
note1
,
"note"
],
project:
note1
.
project
,
project:
note1
.
project
,
author:
note1
.
author
)
author:
note1
.
author
}
expect
(
Banzai
::
Renderer
).
to
receive
(
:render
).
}]).
and_call_original
with
(
note2
.
note
,
expect
(
Banzai
::
Renderer
).
to
receive
(
:cache_collection_render
).
with
([{
text:
note2
.
note
,
context:
{
pipeline: :note
,
pipeline: :note
,
cache_key:
[
note2
,
"note"
],
cache_key:
[
note2
,
"note"
],
project:
note2
.
project
,
project:
note2
.
project
,
author:
note2
.
author
)
author:
note2
.
author
}
}]).
and_call_original
note1
.
all_references
note1
.
all_references
.
users
note2
.
all_references
note2
.
all_references
.
users
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment