Skip to content

Commit

Permalink
Merge pull request #584 from IN-CORE/release-1.19.0
Browse files Browse the repository at this point in the history
Release 1.19.0
  • Loading branch information
longshuicy authored Jun 11, 2024
2 parents 0cf327a + a41de0a commit 63a3886
Show file tree
Hide file tree
Showing 95 changed files with 5,399 additions and 2,292 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.19.0] - 2024-06-12

### Changed
- Rename Social Vulnerability Analysis to Social Vulnerability Index Analysis [#556](https://github.com/IN-CORE/pyincore/issues/556)
- Join dataset has an option for only keeping the table dataset fields [#299](https://github.com/IN-CORE/pyincore/issues/299)
- Update Non-structural Building Damage to support flood [#562](https://github.com/IN-CORE/pyincore/issues/562)
- Update flood input to non-structural building damage for combined wind-wave-surge building [#566](https://github.com/IN-CORE/pyincore/issues/566)
- Rename transportation recovery analysis to traffic flow recovery analysis [#558](https://github.com/IN-CORE/pyincore/issues/558)
- Rename Monte Carlo Failure Probability to Monte Carlo Limit State Probability [#557](https://github.com/IN-CORE/pyincore/issues/557)
- Rename Housing Recovery to Housing Valuation Recovery Analysis [#560](https://github.com/IN-CORE/pyincore/issues/560)
- Rename Building Portfolio Analysis to Building Cluster Recovery Analysis [#559](https://github.com/IN-CORE/pyincore/issues/559)
- Rename nonstructural building damage [#537](https://github.com/IN-CORE/pyincore/issues/537)
- Rename building damage to building structural damage [#561](https://github.com/IN-CORE/pyincore/issues/561)

### Added
- Gas Facility Damage Analysis [#568](https://github.com/IN-CORE/pyincore/issues/568)
- Copyrights to transportation recovery analysis [#579](https://github.com/IN-CORE/pyincore/issues/579)
- Buyout Model Analyses [#539](https://github.com/IN-CORE/pyincore/issues/539)
- Google Analytics to the documentation site [#547](https://github.com/IN-CORE/pyincore/issues/547)

### Fixed
- Permission error in clearing cache process [#563](https://github.com/IN-CORE/pyincore/issues/563)
- Out of index error in dfr3 service's property conversion when the rule is not found [#555](https://github.com/IN-CORE/pyincore/issues/555)


## [1.18.1] - 2024-04-30

Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@ COPY requirements.txt .

ENV PATH "$MAMBA_ROOT_PREFIX/bin:$PATH"
RUN micromamba install -y -n base -c conda-forge \
beautifulsoup4 \
sphinx sphinx_rtd_theme \
-f requirements.txt

# copy code and generate documentation
COPY . ./
RUN sphinx-build -v -b html docs/source docs/build

# Run the insert_ga_to_header.py script to insert Google Analytics code
RUN python /src/docs/source/insert_ga_to_header.py

# ----------------------------------------------------------------------
# Building actual container
# ----------------------------------------------------------------------
FROM nginx

COPY --from=builder /src/docs/build/ /usr/share/nginx/html/doc/pyincore/
COPY config /usr/share/nginx/html/doc/pyincore/config
3 changes: 3 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"GA_KEY": "Test-Google-Analytics-Key-Replace-Me"
}
31 changes: 31 additions & 0 deletions config/googleAnalytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// analytics.js
(function() {
// Fetch the runtime configuration
fetch('config/config.json')
.then(response => {
if (!response.ok) {
throw new Error('Configuration file not found');
}
return response.json();
})
.then(config => {
if (!config.GA_KEY) {
throw new Error('GA_KEY is missing in the configuration');
}

// Create the script tag for Google Tag Manager
const scriptTag = document.createElement('script');
scriptTag.async = true;
scriptTag.src = `https://www.googletagmanager.com/gtag/js?id=${config.GA_KEY}`;
document.head.appendChild(scriptTag);

// Initialize Google Analytics
window.dataLayer = window.dataLayer || [];

function gtag() { dataLayer.push(arguments); }

gtag('js', new Date());
gtag('config', config.GA_KEY);
})
.catch(error => console.warn('GA setup skipped:', error.message));
})();
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
author = ''

# The short X.Y version
version = '1.18'
version = '1.19'
# The full version, including alpha/beta/rc tags
release = '1.18.1'
release = '1.19.0'

# -- General configuration ---------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ To **update** pyIncore run the following command:
:name: mastertoc

mod_top
refs
refs

46 changes: 46 additions & 0 deletions docs/source/insert_ga_to_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
from bs4 import BeautifulSoup

# Directory containing the built HTML files
build_dir = "docs/build"

# Google Analytics code snippet to insert into the HTML files
ga_code = f"""
<script>
// Fetch and execute the analytics script
fetch('config/googleAnalytics.js')
.then(response => response.text())
.then(scriptContent => {{
const scriptTag = document.createElement('script');
scriptTag.textContent = scriptContent;
document.head.appendChild(scriptTag);
}})
.catch(error => console.error('Failed to load analytics script:', error));
</script>
"""

# Loop through each HTML file in the build directory
for filename in os.listdir(build_dir):
if filename.endswith(".html"):
filepath = os.path.join(build_dir, filename)
print(f"Processing file: {filepath}")

# Read the content of the HTML file
with open(filepath, "r", encoding="utf-8") as file:
html_content = file.read()

# Parse HTML content using BeautifulSoup
soup = BeautifulSoup(html_content, "html.parser")

# Find the <head> tag and insert the Google Analytics code before it
head_tag = soup.find("head")
if head_tag:
print(f"Found <head> tag in {filename}:")
print("Inserting Google Analytics code...")
head_tag.insert(0, BeautifulSoup(ga_code, "html.parser"))

# Write the modified HTML content back to the file
with open(filepath, "w", encoding="utf-8") as file:
file.write(str(soup))

print("Google Analytics code insertion completed.")
Loading

0 comments on commit 63a3886

Please sign in to comment.