-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: visuals links and template rendering for index
Change-Id: I92a8baf3b16b1cfbf769b7f56d4878e819712bf9
- Loading branch information
Showing
8 changed files
with
84 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
|
||
from quads.config import Config | ||
|
||
WEB_CONTENT_PATH = Config.get("web_content_path") | ||
EXCLUDE_DIRS = Config.get("web_exclude_dirs") | ||
|
||
|
||
def get_file_paths(web_path: str = WEB_CONTENT_PATH): | ||
file_paths = [] | ||
for root, dirs, files in os.walk(web_path): | ||
dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS] | ||
for file in files: | ||
file_paths.append(file) | ||
return file_paths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
|
||
from flask import Blueprint, abort, render_template | ||
|
||
from quads.web.blueprints.common import WEB_CONTENT_PATH, get_file_paths | ||
|
||
TEMPLATE_DIR = os.path.join(WEB_CONTENT_PATH, "instack") | ||
instack_bp = Blueprint( | ||
"instack", | ||
__name__, | ||
template_folder=TEMPLATE_DIR, | ||
) | ||
|
||
|
||
@instack_bp.route("/<cloud>") | ||
def instack(cloud): | ||
path = os.path.join(WEB_CONTENT_PATH, "instack") | ||
file_paths = get_file_paths(path) | ||
for file in file_paths: | ||
if cloud in file: | ||
return render_template(file) | ||
return abort(404) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
|
||
from flask import Blueprint, abort, render_template | ||
|
||
from quads.web.blueprints.common import WEB_CONTENT_PATH, get_file_paths | ||
|
||
TEMPLATE_DIR = os.path.join(WEB_CONTENT_PATH, "visual") | ||
visual_bp = Blueprint( | ||
"visual", | ||
__name__, | ||
template_folder=TEMPLATE_DIR, | ||
) | ||
|
||
|
||
@visual_bp.route("/") | ||
def index(): | ||
try: | ||
return render_template("index.html") | ||
except Exception as e: | ||
return str(e), 500 | ||
|
||
|
||
@visual_bp.route("/<when>") | ||
def visuals(when): | ||
path = os.path.join(WEB_CONTENT_PATH, "visual") | ||
file_paths = get_file_paths(path) | ||
for file in file_paths: | ||
if when in file: | ||
return render_template(file) | ||
return abort(404) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters