Skip to content

Commit bee6621

Browse files
author
dalj8690
committed
Fixing the script for generating the RSS feeds
1 parent f5283a8 commit bee6621

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

generate_rss.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
# Define the RSS file and folder containing articles
77
docs_folder = "docs"
88
rss_file = os.path.join(docs_folder, "rss.xml") # Adjust path to rss.xml
9+
10+
# Use local time instead of GMT
11+
# current_date = datetime.now().strftime("%a, %d %b %Y %H:%M:%S %z") # Local time with timezone offset
12+
# Get the current timestamp in GMT
913
current_date = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
1014

15+
1116
def create_empty_rss_file(file_path):
1217
"""
1318
Create an empty RSS file with the basic structure if it doesn't exist.
@@ -36,6 +41,7 @@ def is_file_updated(file_path, existing_pub_date):
3641
print(f"File {file_path} has been updated (mod_time: {file_mod_time}, existing_time: {existing_time})")
3742
return updated
3843

44+
3945
def write_rss_feed(file_path, tree, channel):
4046
"""
4147
Write the updated RSS feed to the file with proper formatting using minidom.
@@ -99,10 +105,10 @@ def write_rss_feed(file_path, tree, channel):
99105

100106
# Process each PDF file
101107
for pdf in sorted(pdf_files):
102-
relative_path = os.path.relpath(pdf, docs_folder)
108+
relative_path = os.path.relpath(pdf, start=docs_folder) # This will include docs/ and subfolders
103109
relative_path = relative_path.replace(os.sep, "/") # Normalize to URL format
104-
link = f"https://github.com/damirlj/modern_cpp_tutorials/blob/main/{relative_path}"
105-
110+
link = f"https://github.com/damirlj/modern_cpp_tutorials/blob/main/docs/{relative_path}"
111+
106112
# Check if the item already exists
107113
if link in existing_items:
108114
item = existing_items[link]

0 commit comments

Comments
 (0)