Skip to content

Commit 780b125

Browse files
committed
Converted the maintenance page to have its own view and styled it up.
1 parent a68efab commit 780b125

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed

FrontEnd/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ $mobile-breakpoint: 740px;
3030
@import 'styles/keywords';
3131
@import 'styles/layout';
3232
@import 'styles/maintainer_info';
33+
@import 'styles/maintenance';
3334
@import 'styles/markdown';
3435
@import 'styles/matrix';
3536
@import 'styles/modal_panel';

FrontEnd/styles/maintenance.scss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// -------------------------------------------------------------------------
16+
// Site maintenance page, set by HOMEPAGE_INTERSTITIAL in the environment.
17+
// -------------------------------------------------------------------------
18+
19+
body.maintenance {
20+
main {
21+
display: flex;
22+
align-items: center;
23+
min-height: 500px;
24+
text-align: center;
25+
26+
h1 {
27+
padding-top: 50px;
28+
font-size: 30px;
29+
background-position: top center;
30+
background-repeat: no-repeat;
31+
background-size: 40px;
32+
background-image: var(--image-warning);
33+
}
34+
}
35+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import Foundation
16+
import Ink
17+
18+
enum MaintenanceIndex {
19+
20+
struct Model {
21+
22+
var markdown: String
23+
var html: String
24+
25+
init(markdown: String) {
26+
self.markdown = markdown
27+
self.html = MarkdownParser().parse(markdown).html
28+
}
29+
30+
}
31+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import Foundation
16+
import Plot
17+
18+
extension MaintenanceIndex {
19+
20+
class View: PublicPage {
21+
22+
let model: Model
23+
24+
init(path: String, model: Model) {
25+
self.model = model
26+
super.init(path: path)
27+
}
28+
29+
override func bodyClass() -> String? {
30+
"maintenance"
31+
}
32+
33+
override func content() -> Node<HTML.BodyContext> {
34+
.raw(model.html)
35+
}
36+
}
37+
}

Sources/App/routes.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ func routes(_ app: Application) throws {
2424
do { // home page
2525
app.get { req in
2626
if let interstitial = Current.homepageInterstitial() {
27-
return MarkdownPage(path: req.url.path, markdown: interstitial).document()
27+
let model = MaintenanceIndex.Model(markdown: interstitial)
28+
return MaintenanceIndex.View(path: req.url.path, model: model).document()
2829
} else {
2930
let model = try await HomeIndex.Model.query(database: req.db)
3031
return HomeIndex.View(path: req.url.path, model: model).document()

0 commit comments

Comments
 (0)