Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GitLab EE
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
projects.thm.de
GitLab EE
Commits
c3056d5d
Commit
c3056d5d
authored
3 years ago
by
Robert May
Browse files
Options
Downloads
Patches
Plain Diff
Don't try this at home, kids
parent
e5df1467
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/helpers/caching_helper.rb
+43
-0
43 additions, 0 deletions
app/helpers/caching_helper.rb
app/views/projects/show.html.haml
+19
-13
19 additions, 13 deletions
app/views/projects/show.html.haml
with
62 additions
and
13 deletions
app/helpers/caching_helper.rb
0 → 100644
+
43
−
0
View file @
c3056d5d
# frozen_string_literal: true
module
CachingHelper
DEFAULT_EXPIRY
=
1
.
day
def
kit_cache_chunky
(
expires_in:
DEFAULT_EXPIRY
)
@key_blocks
||=
{}
blocks
=
@key_blocks
[
template_root_key
]
=
{}
big_ol_strang
=
capture
do
yield
end
chunks
=
Rails
.
cache
.
fetch_multi
(
*
blocks
.
keys
,
expires_in:
expires_in
)
do
|
missing_key
|
puts
"Cache miss:
#{
missing_key
}
"
capture
do
blocks
[
missing_key
].
call
end
end
chunks
.
each
do
|
key
,
chunk
|
puts
"Rendering chunk:
#{
key
}
"
big_ol_strang
.
gsub!
(
key
,
(
chunk
||
""
))
end
big_ol_strang
.
html_safe
end
def
cache_chunk
(
*
keys
,
&
block
)
key
=
keys
.
map!
{
|
k
|
k
.
try
(
:cache_key
)
||
k
.
to_s
}.
unshift
(
template_root_key
).
join
(
":"
)
@key_blocks
[
template_root_key
][
key
]
=
block
return
key
end
private
def
template_root_key
digest_path_from_template
(
@current_template
)
end
end
This diff is collapsed.
Click to expand it.
app/views/projects/show.html.haml
+
19
−
13
View file @
c3056d5d
...
...
@@ -9,23 +9,29 @@
=
content_for
:invite_members_sidebar
do
=
render
partial:
'projects/invite_members_link'
=
render
partial:
'flash_messages'
,
locals:
{
project:
@project
}
=
kit_cache_chunky
do
=
render
partial:
'flash_messages'
,
locals:
{
project:
@project
}
=
render
"projects/last_push"
=
render
"projects/last_push"
=
render
"home_panel"
=
render
"home_panel"
-
if
can?
(
current_user
,
:download_code
,
@project
)
&&
@project
.
repository_languages
.
present?
=
repository_languages_bar
(
@project
.
repository_languages
)
-
if
can?
(
current_user
,
:download_code
,
@project
)
&&
@project
.
repository_languages
.
present?
=
cache_chunk
(
@project
,
:language_bar
,
expires_in:
1
.
hour
)
do
=
repository_languages_bar
(
@project
.
repository_languages
)
=
render
"archived_notice"
,
project:
@project
=
render_if_exists
"projects/marked_for_deletion_notice"
,
project:
@project
=
render_if_exists
"projects/ancestor_group_marked_for_deletion_notice"
,
project:
@project
=
cache_chunk
(
@project
,
:archive_partials
)
do
=
render
"archived_notice"
,
project:
@project
=
render_if_exists
"projects/marked_for_deletion_notice"
,
project:
@project
=
render_if_exists
"projects/ancestor_group_marked_for_deletion_notice"
,
project:
@project
-
view_path
=
@project
.
default_view
-
show_devops_callout
=
show_auto_devops_callout?
(
@project
)
-
if
show_auto_devops_callout?
(
@project
)
=
render
'shared/auto_devops_callout'
=
cache_chunk
(
@project
,
:auto_devops
,
show_devops_callout
)
do
-
if
show_auto_devops_callout?
(
@project
)
=
render
'shared/auto_devops_callout'
%div
{
class:
project_child_container_class
(
view_path
)
}
=
render
view_path
,
is_project_overview:
true
-
view_path
=
@project
.
default_view
%div
{
class:
project_child_container_class
(
view_path
)
}
=
render
view_path
,
is_project_overview:
true
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment