blob: 0622b5e06840005f8744f241e43eda8323d7b551 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import sys
import os
from os import walk
import os.path
from converters.html_to_md import convert_html_to_md
from converters.md_to_gemini import convert_md_to_gemini
from converters.links_to_gemini import convert_links_to_gemini, convert_file_links
import shutil
dir = "input"
if len(sys.argv) > 1:
dir=sys.argv[1]
def wipe_old():
for root, dirs, files in os.walk("output"):
for file in files:
os.remove(os.path.join(root, file))
return "old stuff is gone"
def get_paths(dir):
PathList = []
for thing in os.listdir(dir):
PathList.append(dir + "/" + thing)
try:
PathList += get_paths(dir + "/" + thing)
except:
pass
return PathList
def get_html(PathList):
HtmlList = []
for path in PathList:
if ".html" in path:
HtmlList.append(path)
return HtmlList
if not os.path.isdir("input"):
print("Nothing to do")
exit(1)
PathList = get_paths(dir)
HtmlList = get_html(PathList)
domain = "aaron.place" #Fill in your domain or leave untouched if you dont have one!!!
print(wipe_old())
if not os.path.isdir("output/markdown"):
os.makedirs("output/markdown")
if not os.path.isdir("output/gemini"):
os.makedirs("output/gemini")
if os.path.isfile("input/feed.gmi"):
shutil.copy("input/feed.gmi", "output/gemini/feed.gmi")
print(convert_html_to_md(HtmlList))
print(convert_md_to_gemini())
print(convert_links_to_gemini(domain))
|