-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from ppfeufer/django-sri
- Loading branch information
Showing
10 changed files
with
214 additions
and
61 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
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
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
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,42 @@ | ||
""" | ||
Helper functions for static integrity calculations | ||
""" | ||
|
||
# Standard Library | ||
import os | ||
from pathlib import Path | ||
|
||
# Third Party | ||
from sri import Algorithm, calculate_integrity | ||
|
||
# Alliance Auth | ||
from allianceauth.services.hooks import get_extension_logger | ||
|
||
# Alliance Auth (External Libs) | ||
from app_utils.logging import LoggerAddTag | ||
|
||
# AA Sovereignty Timer | ||
# AA Sov Timer | ||
from sovtimer import __title__ | ||
from sovtimer.constants import AA_SOVTIMER_STATIC_DIR | ||
|
||
logger = LoggerAddTag(my_logger=get_extension_logger(__name__), prefix=__title__) | ||
|
||
|
||
def calculate_integrity_hash(relative_file_path: str) -> str: | ||
""" | ||
Calculates the integrity hash for a given static file | ||
:param self: | ||
:type self: | ||
:param relative_file_path: The file path relative to the `aa-sov-timer/sovtimer/static/sovtimer` folder | ||
:type relative_file_path: str | ||
:return: The integrity hash | ||
:rtype: str | ||
""" | ||
|
||
file_path = os.path.join(AA_SOVTIMER_STATIC_DIR, relative_file_path) | ||
integrity_hash = calculate_integrity( | ||
path=Path(file_path), algorithm=Algorithm.SHA512 | ||
) | ||
|
||
return integrity_hash |
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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{% load sovtimer %} | ||
|
||
<link | ||
rel="stylesheet" | ||
href="{% sovtimer_static 'sovtimer/css/aa-sov-timer.min.css' %}" | ||
integrity="sha512-0evKG/A1AxkfyUwC1rKD8g0trmE4d9fZtnGzCXTOW8duZNOGQQ93gxJxGrDFCJjqS+2sXVbwLOqgvM2K3FsbOQ==" | ||
crossorigin="anonymous" | ||
> | ||
{% sovtimer_static "css/aa-sov-timer.min.css" %} |
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
{% load sovtimer %} | ||
|
||
<script | ||
src="{% sovtimer_static 'sovtimer/js/aa-sov-timer.min.js' %}" | ||
integrity="sha512-qAK/BsND1RartZcIii61vL+0Ez/3KYG6gSDL71uPVrV2s2UAoggIYZfC6wA5nV4ZbWdqgBkYEWp8POHZdBmD8w==" | ||
crossorigin="anonymous" | ||
></script> | ||
{% sovtimer_static "js/aa-sov-timer.min.js" %} |
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