Skip to content

adds support for custom stylesheets #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion phablytics/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

# Reports


@dataclass
class ReportConfig:
name: str
Expand Down Expand Up @@ -123,6 +122,11 @@ class ReportConfig:
),
]

# Web UI

CUSTOM_STATIC_DIR = None

CUSTOM_STYLESHEETS = []

##
# Import Local Settings if `local_settings.py` exists in CWD
Expand Down
11 changes: 10 additions & 1 deletion phablytics/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import uuid

# Third Party (PyPI) Imports
from flask import Flask
from flask import (
Flask,
send_from_directory,
)
from werkzeug.routing import BaseConverter

# Phablytics Imports
from phablytics.settings import CUSTOM_STATIC_DIR
from phablytics.web.explore import explore_page
from phablytics.web.help import help_page
from phablytics.web.home import home_page
Expand Down Expand Up @@ -56,3 +60,8 @@ def __init__(self, url_map, *items):
@application.errorhandler(404)
def page_not_found(e):
return _r('404.html')


@application.route('/custom_static/<path:filename>')
def custom_static(filename):
return send_from_directory(CUSTOM_STATIC_DIR, filename)
4 changes: 4 additions & 0 deletions phablytics/web/templates/fragments/css/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" integrity="sha512-mSYUmp1HYZDFaVKK//63EcZq4iFWFjxSL+Z3T/aCt4IO9Cejm03q3NKKYN6pFQzY0SBOr8h+eCIAZHPXcpZaNw==" crossorigin="anonymous" />

<link rel="stylesheet" href="/static/style.css" />

{% for custom_stylesheet in custom_stylesheets %}
<link rel="stylesheet" href="{{ url_for('custom_static', filename=custom_stylesheet) }}" />
{% endfor %}
3 changes: 3 additions & 0 deletions phablytics/web/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from phablytics.constants import GITHUB_URL
from phablytics.settings import (
ADMIN_USERNAME,
CUSTOM_STYLESHEETS,
PHABRICATOR_INSTANCE_BASE_URL,
)
from phablytics.web.constants import (
Expand Down Expand Up @@ -48,6 +49,8 @@ def get_context_data():
page_title = SITE_NAME

context_data = {
# customizations
'custom_stylesheets': CUSTOM_STYLESHEETS,
# page meta
'nav_links': nav_links,
'breadcrumbs': breadcrumbs,
Expand Down