mirror of https://gitlab.com/bashrc2/epicyon
Load default searchable_by from file
parent
7afbb3cfd1
commit
304a187c77
|
@ -46,6 +46,7 @@ from shares import expire_shares
|
||||||
from categories import load_city_hashtags
|
from categories import load_city_hashtags
|
||||||
from categories import update_hashtag_categories
|
from categories import update_hashtag_categories
|
||||||
from languages import load_default_post_languages
|
from languages import load_default_post_languages
|
||||||
|
from utils import load_searchable_by_default
|
||||||
from utils import set_accounts_data_dir
|
from utils import set_accounts_data_dir
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import check_bad_path
|
from utils import check_bad_path
|
||||||
|
@ -703,8 +704,7 @@ def run_daemon(accounts_data_dir: str,
|
||||||
httpd.last_llm_time = None
|
httpd.last_llm_time = None
|
||||||
|
|
||||||
# default "searchable by" for new posts for each account
|
# default "searchable by" for new posts for each account
|
||||||
# TODO load
|
httpd.searchable_by_default = load_searchable_by_default(base_dir)
|
||||||
httpd.searchable_by_default = {}
|
|
||||||
|
|
||||||
# if a custom robots.txt exists then read it
|
# if a custom robots.txt exists then read it
|
||||||
robots_txt_filename = data_dir(base_dir) + '/robots.txt'
|
robots_txt_filename = data_dir(base_dir) + '/robots.txt'
|
||||||
|
|
21
utils.py
21
utils.py
|
@ -5132,3 +5132,24 @@ def account_is_indexable(actor_json: {}) -> bool:
|
||||||
if '#Public' in actor_json['indexable']:
|
if '#Public' in actor_json['indexable']:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def load_searchable_by_default(base_dir: str) -> {}:
|
||||||
|
"""loads the searchable_by states for each account
|
||||||
|
"""
|
||||||
|
result = {}
|
||||||
|
dir_str = data_dir(base_dir)
|
||||||
|
for _, dirs, _ in os.walk(dir_str):
|
||||||
|
for account in dirs:
|
||||||
|
if not is_account_dir(account):
|
||||||
|
continue
|
||||||
|
nickname = account.split('@')[0]
|
||||||
|
filename = os.path.join(dir_str, account) + '/.searchableByDefault'
|
||||||
|
if os.path.isfile(filename):
|
||||||
|
try:
|
||||||
|
with open(filename, 'r', encoding='utf-8') as fp_search:
|
||||||
|
result[nickname] = fp_search.read().strip()
|
||||||
|
except OSError:
|
||||||
|
print('EX: unable to load searchableByDefault ' + filename)
|
||||||
|
break
|
||||||
|
return result
|
||||||
|
|
Loading…
Reference in New Issue