re-initialize and make some changes. repository got to around 2 gigabytes and needed to be more efficient

This commit is contained in:
soap
2023-09-29 12:56:26 -05:00
commit 234e4592fa
1441 changed files with 476627 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import os
import re
def remove_age_gate(file_path):
with open(file_path, 'r') as file:
content = file.read()
new_content = re.sub(
r'<script id="age_check_preload" src="https:\/\/diyhrt\.wiki\/age-check\.js">.*?<\/script>', '', content, flags=re.DOTALL)
with open(file_path, 'w') as file:
file.write(new_content)
directory_path = 'diyhrt.wiki'
for filename in os.listdir(directory_path):
file_path = os.path.join(directory_path, filename)
if os.path.isfile(file_path):
remove_age_gate(file_path)
+36
View File
@@ -0,0 +1,36 @@
https://diyhrt.cafe/index.php/Special:MyTalk
https://diyhrt.cafe/index.php/Special:MyContributions
https://diyhrt.cafe/index.php?title=Special:CreateAccount&returnto=Special%3AAllPages
https://diyhrt.cafe/index.php?title=Special:UserLogin&returnto=Special%3AAllPages
https://diyhrt.cafe/index.php/Main_Page
https://diyhrt.cafe/index.php/Archives
https://diyhrt.cafe/index.php/Bicalutamide
https://diyhrt.cafe/index.php/Clomifene
https://diyhrt.cafe/index.php/Commentary_and_Fact_Check_of_Dr._Will_Powers%E2%80%99s_Transgender_Care_Presentation@TransfemScience
https://diyhrt.cafe/index.php/Cyproterone_Acetate
https://diyhrt.cafe/index.php/Domperidone
https://diyhrt.cafe/index.php/Donate
https://diyhrt.cafe/index.php/Dutasteride
https://diyhrt.cafe/index.php/EUAibolit_Updates
https://diyhrt.cafe/index.php/Estradiol_Gel
https://diyhrt.cafe/index.php/Estradiol_Injections
https://diyhrt.cafe/index.php/Estradiol_Patches
https://diyhrt.cafe/index.php/Estradiol_Pills
https://diyhrt.cafe/index.php/Finasteride
https://diyhrt.cafe/index.php/Gonadotropin-Releasing_Hormone_Agonists
https://diyhrt.cafe/index.php/Hydroxyprogesterone_Caproate_Injections
https://diyhrt.cafe/index.php/Main_Page/sandbox
https://diyhrt.cafe/index.php/Pioglitazone
https://diyhrt.cafe/index.php/Progesterone_Capsules
https://diyhrt.cafe/index.php/Progesterone_Gel
https://diyhrt.cafe/index.php/Progesterone_Injections
https://diyhrt.cafe/index.php/Raloxifene
https://diyhrt.cafe/index.php/Resources
https://diyhrt.cafe/index.php/Sandbox
https://diyhrt.cafe/index.php/Spironolactone
https://diyhrt.cafe/index.php/Tamoxifen
https://diyhrt.cafe/index.php/Special:AllPages
https://diyhrt.cafe/index.php/Project:About
https://diyhrt.cafe/index.php/Special:SpecialPages
https://diyhrt.cafe/index.php/Project:Privacy_policy
https://diyhrt.cafe/index.php/Project:General_disclaimer
+27
View File
@@ -0,0 +1,27 @@
import sys
def remove_trailing_spaces(line):
return line.rstrip()
def remove_duplicate_lines(file_path):
lines_seen = set()
output_lines = []
with open(file_path, 'r') as file:
for line in file:
cleaned_line = remove_trailing_spaces(line)
if cleaned_line.startswith("https://diyhrt.cafe") and cleaned_line not in lines_seen:
lines_seen.add(cleaned_line)
output_lines.append(line)
with open(file_path, 'w') as file:
file.writelines(output_lines)
# Usage example
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Please provide the file path as an argument.")
else:
file_path = sys.argv[1]
remove_duplicate_lines(file_path)
+29
View File
@@ -0,0 +1,29 @@
from bs4 import BeautifulSoup
from urllib.request import Request, urlopen
import re
import sys
from urllib.parse import urljoin
if len(sys.argv) < 2:
print("Please provide a URL.")
sys.exit(1)
url = sys.argv[1]
headers = {'User-Agent': 'Mozilla/5.0'}
req = Request(url, headers=headers)
html_page = urlopen(req)
soup = BeautifulSoup(html_page, "html.parser")
links = []
for link in soup.findAll('a'):
href = link.get('href')
if href:
full_url = urljoin(url, href)
links.append(full_url)
formatted_links = '\n'.join(links)
print(formatted_links)
+58
View File
@@ -0,0 +1,58 @@
import os
import argparse
# May need to do "pip install mako"
from mako.template import Template
INDEX_TEMPLATE = r"""
<html>
<head>
<style>
body {
background-color: black;
color: white;
font-size: 25px;
}
a {
color: white;
}
</style>
</head>
<body>
<h2>${header}</h2>
<p>
% for name in names:
<a href="${name}">${name}</a><br>
% endfor
</p>
</body>
</html>
"""
EXCLUDED = ['index.html']
def generate_index(directory):
fnames = [fname for fname in sorted(os.listdir(directory)) if fname not in EXCLUDED]
header = os.path.basename(directory)
index_content = Template(INDEX_TEMPLATE).render(names=fnames, header=header)
with open(os.path.join(directory, 'index.html'), 'w') as index_file:
index_file.write(index_content)
# subdirectories = [subdir for subdir in fnames if os.path.isdir(os.path.join(directory, subdir))]
# for subdir in subdirectories:
# generate_index(os.path.join(directory, subdir))
def main():
parser = argparse.ArgumentParser()
parser.add_argument("directory")
args = parser.parse_args()
generate_index(args.directory)
if __name__ == '__main__':
main()
+57
View File
@@ -0,0 +1,57 @@
import markdown
import bleach
import sys
if len(sys.argv) != 3:
print("usage: python script.py <input markdown file> <output html file>")
sys.exit(1)
input_markdown_file = sys.argv[1]
output_html_file = sys.argv[2]
with open(input_markdown_file, 'r') as f:
text = f.read()
# converts the markdown to html
html = markdown.markdown(text)
# makes links that begin with https:// clickable
html_with_links = bleach.linkify(html)
# defines a template that should be at the beginning of the html
start_template = '''<!DOCTYPE html>
<html lang="en">
<!-- this file is automatically updated when README.md is updated, please don't modify it -->
<head>
<title>readme</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="/favicon.png">
<style>
body {
background-color: black;
color: white;
font-size: 20px;
font-family: sans-serif;
}
a {
color: white;
}
</style>
</head>
<body>
'''
# defines a template that should be at the end
end_template = '''
</body>
</html>
'''
# combines them
final_html = start_template + html_with_links + end_template
with open(output_html_file, 'w') as f:
f.write(final_html)