diff options
author | Robert Speicher <robert@gitlab.com> | 2015-08-09 02:03:46 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2015-08-09 02:03:46 +0000 |
commit | 48cf97e8d30baa629133ad378fa712eada6b0f82 (patch) | |
tree | 2ba17b131ddb39a68bf9242e3d5d8ce0bf480249 | |
parent | a71bed53e0aceb10b8e97d490a0d0486a8d47e72 (diff) | |
parent | 9bd074d4cf6b81328921c03c93a385b703da71c9 (diff) | |
download | gitlab-ce-48cf97e8d30baa629133ad378fa712eada6b0f82.tar.gz |
Merge branch 'cache-events' into 'master'
Cache all events
Use CSS to determine if the current user needs to see "Congratulations! Tweet about it" by project creation events and "Create Merge Request" by push events.
Implemented as described here: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/911#note_1559710
Addresses #2054, in part.
cc @dzaporozhets
See merge request !1103
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/views/events/_event.html.haml | 10 | ||||
-rw-r--r-- | app/views/events/event/_created_project.html.haml | 4 | ||||
-rw-r--r-- | app/views/events/event/_push.html.haml | 11 | ||||
-rw-r--r-- | app/views/layouts/_head.html.haml | 4 | ||||
-rw-r--r-- | app/views/layouts/_user_styles.html.haml | 24 |
6 files changed, 40 insertions, 14 deletions
diff --git a/CHANGELOG b/CHANGELOG index 4cb80322846..3a8fcb7b785 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -43,6 +43,7 @@ v 7.14.0 (unreleased) - Fetch code from forks to refs/merge-requests/:id/head when merge request created - Remove satellites - Remove comments and email addresses when publicly exposing ssh keys (Zeger-Jan van de Weg) + - Cache all events v 7.13.3 - Fix bug causing Bitbucket importer to crash when OAuth application had been removed. diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index 5ab5ffc238c..0377760a9b8 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -3,13 +3,11 @@ .event-item-timestamp #{time_ago_with_tooltip(event.created_at)} - - if event.created_project? - = cache [event, current_user] do - = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:'' - = render "events/event/created_project", event: event - - else + = cache event, "v1" do = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:'' - - if event.push? + - if event.created_project? + = render "events/event/created_project", event: event + - elsif event.push? = render "events/event/push", event: event - elsif event.commented? = render "events/event/note", event: event diff --git a/app/views/events/event/_created_project.html.haml b/app/views/events/event/_created_project.html.haml index c2577a24982..8cf36c711b4 100644 --- a/app/views/events/event/_created_project.html.haml +++ b/app/views/events/event/_created_project.html.haml @@ -8,8 +8,8 @@ - else = event.project_name -- if current_user == event.author && !event.project.private? && twitter_sharing_enabled? - .event-body +- if !event.project.private? && twitter_sharing_enabled? + .event-body{"data-user-is" => event.author_id} .event-note .md %p diff --git a/app/views/events/event/_push.html.haml b/app/views/events/event/_push.html.haml index 34a7c00dc43..8bed5cdb9cc 100644 --- a/app/views/events/event/_push.html.haml +++ b/app/views/events/event/_push.html.haml @@ -17,7 +17,7 @@ - few_commits.each do |commit| = render "events/commit", commit: commit, project: project - - create_mr = current_user == event.author && event.new_ref? && create_mr_button?(event.project.default_branch, event.ref_name, event.project) + - create_mr = event.new_ref? && create_mr_button?(event.project.default_branch, event.ref_name, event.project) - if event.commits_count > 1 %li.commits-stat - if event.commits_count > 2 @@ -34,10 +34,11 @@ Compare #{from_label}...#{truncate_sha(event.commit_to)} - if create_mr - or - = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do - create a merge request + %span{"data-user-is" => event.author_id, "data-display" => "inline"} + or + = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do + create a merge request - elsif create_mr - %li.commits-stat + %li.commits-stat{"data-user-is" => event.author_id} = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do Create Merge Request diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 54cddc30b74..397649dacf8 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -27,7 +27,7 @@ = favicon_link_tag 'touch-icon-ipad-retina.png', rel: 'apple-touch-icon', sizes: '152x152' -# Windows 8 pinned site tile - %meta{name: 'msapplication-TileImage', content: image_url('msapplication-tile.png')} + %meta{name: 'msapplication-TileImage', content: image_path('msapplication-tile.png')} %meta{name: 'msapplication-TileColor', content: '#30353E'} = yield :meta_tags @@ -35,3 +35,5 @@ = render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id') = render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id') = render 'layouts/bootlint' if Rails.env.development? + + = render 'layouts/user_styles' diff --git a/app/views/layouts/_user_styles.html.haml b/app/views/layouts/_user_styles.html.haml new file mode 100644 index 00000000000..b76b3cb5510 --- /dev/null +++ b/app/views/layouts/_user_styles.html.haml @@ -0,0 +1,24 @@ +:css + [data-user-is] { + display: none !important; + } + + [data-user-is="#{current_user.try(:id)}"] { + display: block !important; + } + + [data-user-is="#{current_user.try(:id)}"][data-display="inline"] { + display: inline !important; + } + + [data-user-is-not] { + display: block !important; + } + + [data-user-is-not][data-display="inline"] { + display: inline !important; + } + + [data-user-is-not="#{current_user.try(:id)}"] { + display: none !important; + } |