Skip to content

Commit 42102a1

Browse files
committed
Use nested layout
1 parent 419e70c commit 42102a1

File tree

4 files changed

+74
-92
lines changed

4 files changed

+74
-92
lines changed

app/views/layouts/_anno_and_alert.html.erb

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<title><%= page_title yield(:title) %></title>
6-
<%= stylesheet_link_tag "application", media: "all" %>
7-
<%= javascript_include_tag "application" %>
8-
<%= csrf_meta_tags %>
9-
<script>
10-
MathJax = ({
11-
tex: {
12-
inlineMath: [ ['$','$'], ['\\(','\\)'] ],
13-
processEscapes: true
14-
}
15-
});
16-
</script>
17-
<%= mathjax_tag :component => 'tex-svg-full.js' %>
1+
<% content_for :icon do %>
182
<link rel="shortcut icon" href="/images/favicon.ico">
19-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
20-
<style>
21-
#page-content{ padding-left: 40px; padding-right: 40px; padding-bottom: 40px; }
22-
.page-header{ margin: 10px 0 15px; }
23-
</style>
24-
</head>
3+
<% end %>
254

26-
<body>
5+
<% content_for :navbar do %>
276
<div style="background-color:#003365">
287
<nav class="navbar navbar-inverse navbar-embossed" role="navigation" style="background-color:#003365">
298
<div class="container-fluid">
@@ -59,11 +38,6 @@ MathJax = ({
5938
</div>
6039
</nav><!-- /navbar -->
6140
</div>
41+
<% end %>
6242

63-
<div class="container-fluid" id="page-content">
64-
<%= render 'layouts/anno_and_alert', :alert => alert, :notice => notice %>
65-
<%= yield %>
66-
</div>
67-
68-
</body>
69-
</html>
43+
<%= render template: "layouts/base" %>

app/views/layouts/base.erb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title><%= page_title yield(:title) %></title>
6+
<%= stylesheet_link_tag "application", media: "all" %>
7+
<%= javascript_include_tag "application" %>
8+
<%= csrf_meta_tags %>
9+
<script>
10+
MathJax = ({
11+
tex: {
12+
inlineMath: [ ['$','$'], ['\\(','\\)'] ],
13+
processEscapes: true
14+
}
15+
});
16+
</script>
17+
<%= mathjax_tag :component => 'tex-svg-full.js' %>
18+
<%= yield :icon %>
19+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
20+
<style>
21+
#page-content{ padding-left: 40px; padding-right: 40px; padding-bottom: 40px; }
22+
.page-header{ margin: 10px 0 15px; }
23+
</style>
24+
</head>
25+
26+
<body>
27+
<%= yield :navbar %>
28+
29+
<div class="container-fluid" id="page-content">
30+
<% if not @annos.empty? %>
31+
<div class="alert alert-info alert-dismissible" role="alert">
32+
<button type="button" class="close" data-dismiss="alert">
33+
<span aria-hidden="true">&times;</span>
34+
<span class="sr-only">Close</span>
35+
</button>
36+
<% @annos.each_with_index do |anno, index| %>
37+
<strong><%= raw anno.title %></strong> <%= raw anno.body %><% if index != @annos.size - 1 %><br><% end %>
38+
<% end %>
39+
</div>
40+
<% end %>
41+
<% if notice %>
42+
<div class="alert alert-success alert-dismissible" role="alert">
43+
<button type="button" class="close" data-dismiss="alert">
44+
<span aria-hidden="true">&times;</span>
45+
<span class="sr-only">Close</span>
46+
</button>
47+
<strong>Oh Geez! </strong> <%= notice %>
48+
</div>
49+
<% end %>
50+
<% if alert %>
51+
<div class="alert alert-danger alert-dismissible" role="alert">
52+
<button type="button" class="close" data-dismiss="alert">
53+
<span aria-hidden="true">&times;</span>
54+
<span class="sr-only">Close</span>
55+
</button>
56+
<strong>Oh No! </strong> <%= alert %>
57+
</div>
58+
<% end %>
59+
<%= yield %>
60+
</div>
61+
62+
</body>
63+
</html>

app/views/layouts/contest.html.erb

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<title><%= page_title yield(:title) %></title>
6-
<%= stylesheet_link_tag "application", media: "all" %>
7-
<%= javascript_include_tag "application" %>
8-
<%= csrf_meta_tags %>
9-
<script>
10-
MathJax = ({
11-
tex: {
12-
inlineMath: [ ['$','$'], ['\\(','\\)'] ],
13-
processEscapes: true
14-
}
15-
});
16-
</script>
17-
<%= mathjax_tag :component => 'tex-svg-full.js' %>
1+
<% content_for :icon do %>
182
<link rel="shortcut icon" href="/images/favicon_co.ico">
19-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
20-
<style>
21-
#page-content{ padding-left: 40px; padding-right: 40px; padding-bottom: 40px; }
22-
.page-header{ margin: 10px 0 15px; }
23-
</style>
24-
</head>
3+
<% end %>
254

26-
<body>
5+
<% content_for :navbar do %>
276
<div style="background-color:#32CD32">
287
<nav class="navbar navbar-inverse navbar-embossed" role="navigation" style="background-color:#32CD32">
298
<div class="container-fluid">
@@ -45,7 +24,7 @@ MathJax = ({
4524
<% if current_user %>
4625
<li><%= link_to(current_user.username, user_path(current_user)) %></li>
4726
<li><%= link_to('Sign out', destroy_user_session_path, :method => :delete) %></li>
48-
<% else %>
27+
<% else %>
4928
<li><%= link_to('Sign in', new_session_path(:user)) %> </li>
5029
<% unless Rails.configuration.x.settings.dig(:disable_registration) %>
5130
<li><%= link_to('Sign up', new_registration_path(:user)) %></li>
@@ -56,11 +35,6 @@ MathJax = ({
5635
</div>
5736
</nav><!-- /navbar -->
5837
</div>
38+
<% end %>
5939

60-
<div class="container-fluid" id="page-content">
61-
<%= render 'layouts/anno_and_alert', :alert => alert, :notice => notice %>
62-
<%= yield %>
63-
</div>
64-
65-
</body>
66-
</html>
40+
<%= render template: "layouts/base" %>

0 commit comments

Comments
 (0)