/
_header.html.erb
311 lines (296 loc) · 13.1 KB
/
_header.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<% logo_path = SiteSetting['SiteLogoPath'] %>
<% mobile_logo_path = SiteSetting['MobileLogoPath'] %>
<% sticky_header = user_preference('sticky_header', community: false) == 'true' %>
<header class="header is-small has-margin-0<%=' is-dark' if SiteSetting['SiteHeaderIsDark'] %><%= ' sticky' if sticky_header %>">
<div class="container header--container">
<div class="header--brand">
<% if mobile_logo_path.present? %>
<a href="/" class="header--site-name __mobile-only" aria-label="Home"><img alt src="<%= mobile_logo_path %>" /></a>
<% if logo_path.present? %>
<a href="/" class="header--site-name __desktop-only" aria-label="Home"><img alt src="<%= logo_path %>" /></a>
<% else %>
<a href="/" class="header--site-name __desktop-only" aria-label="Home"><%= SiteSetting['SiteName'] %></a>
<% end %>
<% else %>
<% if logo_path.present? %>
<a href="/" class="header--site-name" aria-label="Home"><img alt src="<%= logo_path %>" /></a>
<% else %>
<a href="/" class="header--site-name" aria-label="Home"><%= SiteSetting['SiteName'] %></a>
<% end %>
<% end %>
</div>
<nav class="header--menu">
<% unless @community.is_fake %>
<%= link_to users_path, class: 'header--item', title: 'Open users list' do %>
<i class="fas fa-fw fa-users"></i> Users
<% end %>
<%= link_to search_path, class: 'header--item',
data: { 'header-slide' => '#search-slide' },
title: 'Show search' do %>
<i class="fas fa-fw fa-search"></i> Search
<% end %>
<% end %>
<div class='header--separator'></div>
<% if user_signed_in? %>
<% unless @community.is_fake %>
<% if current_user.is_moderator %>
<%= link_to (@open_flags > 0) ? flag_queue_path : moderator_path,
class: 'header--item',
title: 'Open moderator dashboard' do %>
<i class="fas fa-fw fa-wrench"></i> Mod
<% if @open_flags > 0 %>
<span class="header--alert"><%= @open_flags %></span>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% unless @community.is_fake %>
<%= link_to help_center_path, class: 'header--item', title: 'Open Help Center' do %>
<i class="fas fa-fw fa-question-circle"></i> Help
<% end %>
<%= link_to dashboard_path, class: 'header--item', title: 'Open dashboard' do %>
<i class="fas fa-fw fa-th"></i>
<% end %>
<% end %>
<% if user_signed_in? %>
<a href="#" class="header--item inbox-toggle is-visible-on-mobile"
data-header-slide="#js-inbox"
title='Open notifications'
>
<% unread = current_user.unread_count %>
<% if unread > 0 %>
<span class="header--alert inbox-count"><%= unread %></span>
<% end %>
<i class='fas fa-fw fa-inbox'></i>
</a>
<%= link_to user_path(current_user), class: 'header--item is-complex is-visible-on-mobile',
title: 'Manage profile' do %>
<img alt="user avatar" src="<%= avatar_url(current_user, 40) %>" class="header--item-image avatar-40">
<span class="<%= SiteSetting['SiteHeaderIsDark'] ? 'has-color-white' : 'has-color-tertiary-600' %>"><%= current_user.reputation %></span>
<% end %>
<% end %>
<a href="#"
class="header--item is-visible-on-mobile"
aria-label="Show Communities"
data-header-slide="#communities-slide"
title="Show Communities"
>
<i class="far fa-fw fa-caret-square-down"></i>
</a>
<% unless user_signed_in? %>
<div class="header--item">
<% if devise_sign_in_enabled? %>
<%= link_to 'Sign Up', new_user_registration_path, class: 'button is-muted is-filled' %>
<%= link_to 'Sign In', new_user_session_path, class: 'button is-muted is-outlined' %>
<% end %>
<% if sso_sign_in_enabled? %>
<%= link_to 'SSO Sign In', new_saml_user_session_path, class: 'button is-muted is-outlined' %>
<% end %>
</div>
<% end %>
<% unless @community.is_fake %>
<a class="header--item is-mobile-menu is-complex" aria-label="Menu" href="#" data-header-slide="#js-mobile-menu">
<span class="header--menu-bars">
<span></span>
<span></span>
<span></span>
</span>
</a>
<% end %>
</nav>
</div>
</header>
<div class="header-slide" id="communities-slide">
<% if user_signed_in? %>
<% if devise_sign_in_enabled? %>
<%= link_to 'Sign Out', destroy_user_session_path, method: :delete, class: 'button is-muted has-float-right', role: 'button' %>
<% else %>
<%= link_to 'Sign Out', destroy_saml_user_session_path, method: :delete, class: 'button is-muted has-float-right', role: 'button' %>
<% end %>
<% end %>
<h3 class="h-m-t-1">Communities</h3>
<div class="community-header-list">
<% logo_paths = SiteSetting.all_communities('SiteLogoPath') %>
<% Community.where(hidden: false).each do |c| %>
<div class="community-header-list-entry">
<% logo_setting = logo_paths[c.id] %>
<%= link_to "//#{c.host}" do %>
<% if logo_setting.present? %>
<div class="img">
<img src="<%= logo_setting %>" alt="<%= c.name %>" class="community-header-list-image">
</div>
<% end %>
<div class="label">
<%= c.name %>
</div>
<% end %>
</div>
<% end %>
</div>
</div>
<div class="header-slide is-large" id="search-slide">
<div class="grid has-padding-bottom-2">
<div class="grid--cell is-6 is-12-sm">
<span>tag:snake</span> <span class="has-color-tertiary-600">search within a tag</span>
</div>
<div class="grid--cell is-6 is-12-sm">
<span>answers:0</span> <span class="has-color-tertiary-600">unanswered questions</span>
</div>
<div class="grid--cell is-6 is-12-sm">
<span>user:xxxx</span> <span class="has-color-tertiary-600">search by author id</span>
</div>
<div class="grid--cell is-6 is-12-sm">
<span>score:0.5</span> <span class="has-color-tertiary-600">posts with 0.5+ score</span>
</div>
<div class="grid--cell is-6 is-12-sm">
<span>"snake oil"</span> <span class="has-color-tertiary-600">exact phrase</span>
</div>
<div class="grid--cell is-6 is-12-sm">
<span>votes:4</span> <span class="has-color-tertiary-600">posts with 4+ votes</span>
</div>
<div class="grid--cell is-6 is-12-sm">
<span>created:<1w</span> <span class="has-color-tertiary-600">created < 1 week ago</span>
</div>
<div class="grid--cell is-6 is-12-sm">
<span>post_type:xxxx</span> <span class="has-color-tertiary-600">type of post</span>
</div>
</div>
<%= form_tag search_path, method: :get, role: 'search' do %>
<div class="grid is-nowrap">
<%= search_field_tag :search, params[:search], class: 'form-element' %>
<div class="h-m-1">
<%= button_tag type: :submit, class: 'button is-filled is-outlined', name: nil do %>
<i class="fa fa-search"></i>
<% end %>
</div>
</div>
<% end %>
<div class="has-padding-top-2 has-padding-right-1 has-float-right">
<a href="<%= help_path('search') %>">Search help</a>
</div>
</div>
<div class="header-slide inbox h-p-0" id="js-inbox">
<div class="h-p-2 h-bg-tertiary-050 h-fw-bold">Notifications</div>
<div class="h-p-2 h-bg-tertiary-050 h-fw-bold">
<a class="no-unread js-read-all-notifs" href="#"><i class="fas fa-envelope-open"></i> Mark all as read</a>
<a href="/users/me/notifications" class="button is-muted is-small">See all your notifications »</a>
</div>
<div class="inbox--container h-p-2"></div>
</div>
<% unless @community.is_fake %>
<div class="header-slide mobile-menu" id="js-mobile-menu">
<div class="menu">
<%= link_to 'Users', users_path, class: 'menu--item' %>
<%= link_to 'Search', search_path, class: 'menu--item' %>
<div class='header-slide--separator'></div>
<%= link_to 'Help', help_center_path, class: 'menu--item' %>
<%= link_to 'Dashboard', dashboard_path, class: 'menu--item' %>
<% if user_signed_in? %>
<% if current_user.is_admin || current_user.is_moderator %>
<%= link_to (@open_flags > 0) ? flag_queue_path : moderator_path, class: 'menu--item' do %>
Mod
<% if @open_flags > 0 %>
<span class="badge is-status"><%= @open_flags %></span>
<% end %>
<% end %>
<% end %>
<% if devise_sign_in_enabled? %>
<%= link_to 'Sign Out', destroy_user_session_path, method: :delete, class: 'menu--item', role: 'button' %>
<% else %>
<%= link_to 'Sign Out', destroy_saml_user_session_path, method: :delete, class: 'menu--item', role: 'button' %>
<% end %>
<% else %>
<% if sso_sign_in_enabled? %>
<%= link_to 'SSO Sign In', new_saml_user_session_path, class: 'menu--item' %>
<% end %>
<% if devise_sign_in_enabled? %>
<%= link_to 'Sign In', new_user_session_path, class: 'menu--item' %>
<%= link_to 'Sign Up', new_user_registration_path, class: 'menu--item' %>
<% end %>
<% end %>
</div>
</div>
<% end %>
<% unless @community.is_fake %>
<% if expandable? %>
<% current_cat = current_category %>
<% header_class = current_cat.color_code.present? ? current_cat.color_code : SiteSetting['SiteCategoryHeaderDefaultColor'] %>
<% else %>
<% header_class = SiteSetting['SiteCategoryHeaderDefaultColor'] %>
<% end %>
<header class="category-header is-<%= header_class %>">
<div class="category-header--tabs">
<div class="container category-header--tabs-container">
<% @header_categories.each do |cat| %>
<% next unless (current_user&.trust_level || 0) >= (cat.min_view_trust_level || -1) %>
<%= link_to category_path(cat), class: "category-header--tab #{active?(cat) ? 'is-active' : ''}" do %>
<%= cat.name %>
<% if user_signed_in? && cat.new_posts_for?(current_user) %>
<span class="badge is-status" title="unread activity in category"></span>
<% end %>
<% end %>
<% end %>
</div>
</div>
<% if expandable? %>
<div class="container category-header--container">
<% if (current_cat&.min_view_trust_level || -1) > 0 %>
<i class="fas fa-lock-open h-m-r-2" title="The access to this category is restricted, but you are exempt."></i>
<% end %>
<div class="category-header--name">
<%= current_cat.name %>
</div>
<div class="category-header--nav">
<%= link_to 'Posts', category_path(current_cat),
class: "category-header--nav-item #{active?(current_cat) && !['tags', 'suggested_edit'].include?(controller_name) ? 'is-active' : ''}" %>
<%= link_to 'Tags', category_tags_path(current_cat),
class: "category-header--nav-item #{active?(current_cat) && controller_name == 'tags' ? 'is-active' : ''}" %>
<%= link_to suggested_edits_queue_path(current_cat),
class: "category-header--nav-item #{active?(current_cat) && controller_name == 'suggested_edit' ? 'is-active' : ''}" do %>
Edits
<% if pending_suggestions? && check_your_privilege('edit_posts') %>
<span class="badge is-status" title="Suggested edits pending"></span>
<% end %>
<% end %>
<div class="category-header--nav-separator"></div>
<%= link_to category_post_types_path(current_cat.id),
class: 'category-header--nav-item is-button' do %>
<%= current_cat.button_text.present? ? current_cat.button_text : 'Create Post' %>
<% end %>
</div>
</div>
<% end %>
</header>
<% end %>
<% if Rails.env.development? %>
<div class="notice is-danger is-banner has-padding-2 notice__dev-mode has-color-red-900">
<div class="container">
<p>This site is in development mode!</p>
</div>
</div>
<% end %>
<% if read_only? %>
<div class="notice is-warning is-filled is-banner has-padding-2 has-color-yellow-900 has-font-size-caption">
<div class="container">
<p>This site is in read-only mode.</p>
</div>
</div>
<% end %>
<% if user_signed_in? && session[:impersonator_id].present? %>
<div class="notice is-info is-banner is-filled has-padding-2">
<div class="container">
<p class="has-font-size-caption">
You are impersonating <%= current_user.username %>.
<%= link_to 'Stop impersonating', stop_impersonating_path, class: 'is-underlined' %>
</p>
</div>
</div>
<% end %>
<% if RequestContext.redis.exists? 'banner_text' %>
<div class="notice is-filled <%= RequestContext.redis.get('banner_class') || 'is-warning' %> has-padding-2 is-banner">
<div class="container">
<%= RequestContext.redis.get 'banner_text' %>
</div>
</div>
<% end %>