@@ -80,32 +80,39 @@ def scan_code_examples(base_dir):
8080 if os .path .isdir (item_path ) and \
8181 not item_name .startswith ('.' ) and \
8282 item_name not in excluded_dirs :
83-
84- lang_dir = item_name # item_name is now the language directory
85- lang_path = item_path # path to the language directory
83+ lang_dir = item_name
84+ lang_path = item_path
8685
8786 lang_files = []
88- supported_extensions = ('.py' , '.js' , '.java' , '.c' , '.cpp' , '.cs' ,
89- '.go' , '.rs' , '.php' , '.html' , '.ts' , '.sh' )
90-
91- for root , _ , files in os .walk (lang_path ):
92- for filename in sorted (files ):
93- if filename .endswith (supported_extensions ):
94- try :
95- file_info = get_file_info (root , filename )
96- lang_files .append (file_info )
97- except Exception as e :
98- print (f"Error processing { filename } : { e } " )
99- continue
100-
101- if lang_files :
102- languages .append ({
103- "name" : lang_dir .capitalize (),
104- "icon" : get_language_icon (lang_dir ),
105- "files" : lang_files ,
106- "total_size" : sum (f ["size" ] for f in lang_files ),
107- "total_lines" : sum (f ["lines" ] for f in lang_files )
108- })
87+ supported_extensions = ('.py' , '.js' , '.java' , '.c' , '.cpp' , '.cs' ,
88+ '.go' , '.rs' , '.php' , '.html' , '.ts' , '.sh' )
89+
90+ for root , _ , files in os .walk (lang_path ):
91+ for filename in sorted (files ):
92+ if filename .endswith (supported_extensions ):
93+ try :
94+ file_info = get_file_info (root , filename )
95+ lang_files .append (file_info )
96+ except Exception as e :
97+ print (f"Error processing { filename } : { e } " )
98+ continue
99+
100+ # NEW: List all top-level files and folders (not just code files)
101+ items = []
102+ for entry in sorted (os .listdir (lang_path )):
103+ if entry .startswith ('.' ):
104+ continue
105+ items .append (entry )
106+
107+ if lang_files or items :
108+ languages .append ({
109+ "name" : lang_dir .capitalize (),
110+ "icon" : get_language_icon (lang_dir ),
111+ "files" : lang_files , # detailed info for future use
112+ "items" : items , # simple list for frontend
113+ "total_size" : sum (f ["size" ] for f in lang_files ),
114+ "total_lines" : sum (f ["lines" ] for f in lang_files )
115+ })
109116
110117 return languages
111118
@@ -131,14 +138,16 @@ def generate_site_data():
131138 """Generate the complete site data structure"""
132139 base_dir = "../../" # Point to the repository root
133140
141+ languages = scan_code_examples (base_dir )
142+ # Use 'commits' instead of 'recent_activity' for frontend compatibility
134143 return {
135144 "last_updated" : datetime .now ().strftime ('%Y-%m-%d %H:%M:%S' ),
136- "languages" : scan_code_examples ( base_dir ) ,
137- "recent_activity " : get_git_history (),
145+ "languages" : languages ,
146+ "commits " : get_git_history (),
138147 "stats" : {
139- "total_languages" : 0 , # Will be updated after
140- "total_files" : 0 , # Will be updated after
141- "total_lines" : 0 # Will be updated after
148+ "total_languages" : len ( languages ),
149+ "total_files" : sum ( len ( lang [ "files" ]) for lang in languages ),
150+ "total_lines" : sum ( lang [ "total_lines" ] for lang in languages )
142151 }
143152 }
144153
0 commit comments