Skip to content

Commit

Permalink
formattign and links
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsdroff committed Dec 12, 2024
1 parent 80a4f20 commit fd1efac
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions scripts/generate_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,11 @@ def clean_date(x):
with open(os.path.join(output_dir, "index.html"), "w") as f:
f.write(header_template.format(title="UNLOCODE Directory"))
f.write("<h1>UNLOCODE Directory</h1>")
f.write("<p>The United Nations Code for Trade and Transport Locations is commonly more known as UN/LOCODE. Although managed and maintained by the UNECE, it is the product of a wide collaboration in the framework of the joint trade facilitation effort undertaken within the United Nations.</p>")
f.write("<p>Initiated within the UNECE Working Party on Trade Facilitation, UN/LOCODE is based on a code structure set up by UN/ECLAC and a list of locations originating in UN/ESCAP, developed in UNCTAD in co-operation with transport organisations like IATA and the ICS and with active contributions from national governments and commercial bodies. Its first issue in 1981 provided codes to represent the names of some 8.000 locations in the world.</p>")
f.write("<p>Currently, UN/LOCODE includes over 103,034 locations in 249 countries and territories. It is used by most major shipping companies, by freight forwarders and in the manufacturing industry around the world. It is also applied by national governments and in trade related activities, such as statistics where it is used by the European Union, by the UPU for certain postal services, etc </p>")
# Add the hyperlink for UNECE Recommendation No. 16 at the end
f.write("<p>The United Nations Code for Trade and Transport Locations is commonly more known as UN/LOCODE...</p>")
f.write('<p>If you are interested in the full text of the formal basis for UN/LOCODE, this can be consulted at ')
f.write(
'<a href="https://unece.org/trade/uncefact/unlocode/recommendation-16">UNECE Recommendation No. 16</a>.</p>')
f.write("The cut-off dates of UN/LOCODE releases are 31 March and 30 September.")
f.write('<a href="https://unece.org/trade/uncefact/unlocode/recommendation-16">UNECE Recommendation No. 16</a>.</p>')

f.write("The 2024-1 release of UN/LOCODE")
f.write("<p>The 2024-1 release of UN/LOCODE</p>")
f.write("<ul>")
f.write('<li><a href="countries.html">Country Codes</a></li>')
f.write('<li><a href="subdivisions.html">Subdivision Codes</a></li>')
Expand All @@ -103,7 +98,13 @@ def clean_date(x):
with open(os.path.join(output_dir, "countries.html"), "w") as f:
f.write(header_template.format(title="Country Codes"))
f.write("<h1>Country Codes</h1>")
f.write(country_df.to_html(index=False))

# Loop through the country codes and generate the links to UNLOCODE country pages
for country_code in sorted(country_df["Country Code"].unique()):
country_file = f"{country_code}.html"
# Update the link to point to the correct location in the UNLOCODE directory
f.write(f'<li><a href="https://uncefact.github.io/tools-methods/unlocode/{country_code}.html">{country_code}</a></li>')

f.write(footer_template)

# Generate Subdivision Codes Page
Expand Down Expand Up @@ -169,9 +170,8 @@ def clean_date(x):
if pd.notna(code) else code
)

# Now, write the country data to the HTML file
cf.write(country_data.to_html(index=False, escape=False, classes="unlocode-table"))
cf.write(footer_template) # Footer for the country-specific page
cf.write(footer_template)

f.write("</ul>")
f.write(footer_template) # Footer for the UNLOCODE directory page
f.write(footer_template)

0 comments on commit fd1efac

Please sign in to comment.