Skip to content

Commit b656aa6

Browse files
redirect to cyphal gh-page (#41)
Co-authored-by: Pavel Kirienko <[email protected]>
1 parent 6b424ab commit b656aa6

File tree

4 files changed

+8
-26
lines changed

4 files changed

+8
-26
lines changed

app/view/specification.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,14 @@
1-
#
2-
# Copyright (C) 2019 UAVCAN Development Team <[email protected]>.
1+
# Copyright (C) OpenCyphal <[email protected]>.
32
# Author: Pavel Kirienko <[email protected]>
4-
#
53

6-
import os
7-
import re
8-
import glob
4+
from flask import redirect
95
from .. import app
10-
from flask import send_file, redirect, abort
116

7+
_SPECIFICATION_URI = "https://opencyphal.github.io/specification/Cyphal_Specification.pdf"
128

13-
_SPECIFICATION_DIRECTORY_PATH = os.path.join(app.root_path, '..', 'specification')
149

15-
_CYPHAL_SPECIFICATION_GLOB = 'Cyphal_Specification*.pdf'
16-
17-
@app.route('/specification/')
18-
def _latest_specification():
19-
entries = list(glob.glob(os.path.join(_SPECIFICATION_DIRECTORY_PATH, _CYPHAL_SPECIFICATION_GLOB)))
20-
entries.sort(key=lambda t: [int(c) if c.isdigit() else c for c in re.split(r'(\d+)', t)]) # Natural sorting
21-
newest_file = os.path.basename(entries[-1])
22-
app.logger.info('Sorted specifications: %r, newest: %r', entries, newest_file)
23-
return redirect('/specification/' + newest_file)
24-
25-
26-
@app.route('/specification/<path:file_name>')
27-
def _particular_specification(file_name):
28-
try:
29-
return send_file(os.path.join(_SPECIFICATION_DIRECTORY_PATH, file_name),
30-
mimetype='application/pdf')
31-
except FileNotFoundError:
32-
return abort(404)
10+
@app.route("/specification/", defaults={"subpath": ""})
11+
@app.route("/specification/<path:subpath>")
12+
def _latest_specification(subpath: str):
13+
_ = subpath
14+
return redirect(_SPECIFICATION_URI, code=301)
-796 KB
Binary file not shown.
-3.19 MB
Binary file not shown.
-720 KB
Binary file not shown.

0 commit comments

Comments
 (0)