11# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
22
33import json
4+ from datetime import datetime , timedelta
45from pathlib import Path
56from subprocess import check_output
67
1415 get_youtube_video_ids ,
1516)
1617
18+ today = datetime .now ()
19+ DEFAULT_CREATION_DATE = (today - timedelta (days = 365 )).strftime ("%Y-%m-%d %H:%M:%S +0000" )
20+ DEFAULT_MODIFIED_DATE = (today - timedelta (days = 40 )).strftime ("%Y-%m-%d %H:%M:%S +0000" )
21+
1722
1823class MetaPlugin (BasePlugin ):
1924 """
@@ -36,6 +41,7 @@ class MetaPlugin(BasePlugin):
3641 ("verbose" , config_options .Type (bool , default = True )), # Enable verbose output for debugging
3742 ("enabled" , config_options .Type (bool , default = True )), # Enable or disable the plugin
3843 ("default_image" , config_options .Type (str , default = None )), # Default image URL if none found in content
44+ ("default_author" , config_options .Type (str , default = None )), # Default GitHub author email if none found
3945 ("add_desc" , config_options .Type (bool , default = True )), # Add meta description tags
4046 ("add_image" , config_options .Type (bool , default = True )), # Add meta image tags
4147 ("add_keywords" , config_options .Type (bool , default = True )), # Add meta keywords tags
@@ -71,18 +77,18 @@ def get_git_info(self, file_path):
7177 """
7278 file_path = str (Path (file_path ).resolve ())
7379
74- # Get the creation date
80+ # Get the creation and last modified dates
7581 args = ["git" , "log" , "--reverse" , "--pretty=format:%ai" , file_path ]
7682 creation_date = check_output (args ).decode ("utf-8" ).split ("\n " )[0 ]
77- git_info = {"creation_date" : creation_date }
78-
79- # Get the last modification date
8083 last_modified_date = check_output (["git" , "log" , "-1" , "--pretty=format:%ai" , file_path ]).decode ("utf-8" )
81- git_info ["last_modified_date" ] = last_modified_date
84+ git_info = {
85+ "creation_date" : creation_date or DEFAULT_CREATION_DATE ,
86+ "last_modified_date" : last_modified_date or DEFAULT_MODIFIED_DATE ,
87+ }
8288
8389 # Get the authors and their contributions count using get_github_usernames_from_file function
8490 if self .config ["add_authors" ]:
85- authors_info = get_github_usernames_from_file (file_path )
91+ authors_info = get_github_usernames_from_file (file_path , default_user = self . config [ "default_author" ] )
8692 git_info ["authors" ] = [
8793 (author , info ["url" ], info ["changes" ], info ["avatar" ]) for author , info in authors_info .items ()
8894 ]
0 commit comments