-
-
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.
fix: Site does not load when hosted in a subdirectory of the web host…
- Loading branch information
Showing
6 changed files
with
65 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from weewx.reportengine import ReportGenerator | ||
import os.path | ||
import logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
class NextJsBasePathGenerator(ReportGenerator): | ||
def run(self): | ||
html_root = self.skin_dict.get('HTML_ROOT', self.config_dict['StdReport']['HTML_ROOT']) | ||
html_dest_dir = os.path.join(self.config_dict['WEEWX_ROOT'], html_root) | ||
html_subdir = self.skin_dict.get('HTML_SUBDIR', '') | ||
|
||
log.info("Replacing ##METEO_BASE_PATH## with '%s' in all html, js, css and txt files in '%s'...", html_subdir, html_dest_dir) | ||
|
||
for root, dirs, files in os.walk(html_dest_dir): | ||
for file in files: | ||
if file.endswith('.html') or file.endswith('.js') or file.endswith('.css') or file.endswith('.txt'): | ||
filepath = os.path.join(root, file) | ||
log.debug("Processing '%s'...", filepath) | ||
|
||
try: | ||
with open(filepath, 'r') as f: | ||
content = f.read() | ||
|
||
if html_subdir == '': | ||
content = content.replace('/##METEO_BASE_PATH##', '') | ||
else: | ||
content = content.replace('##METEO_BASE_PATH##', html_subdir) | ||
|
||
with open(filepath, 'w') as f: | ||
f.write(content) | ||
except Exception as e: | ||
log.error("Unable to process '%s'. Got exception '%s': %s", filepath, type(e), e) | ||
pass |
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