14
14
# This is to store the paths to the thumbnails of the profile pictures
15
15
image_cache = {}
16
16
17
- def generate_basic_html (s ):
18
- with open (Path (__file__ ).resolve ().parent / '../css/html_readable_style.css' , 'r' ) as f :
19
- css = f .read ()
17
+ with open (Path (__file__ ).resolve ().parent / '../css/html_readable_style.css' , 'r' ) as f :
18
+ readable_css = f .read ()
19
+ with open (Path (__file__ ).resolve ().parent / '../css/html_4chan_style.css' , 'r' ) as css_f :
20
+ _4chan_css = css_f .read ()
21
+ with open (Path (__file__ ).resolve ().parent / '../css/html_cai_style.css' , 'r' ) as f :
22
+ cai_css = f .read ()
20
23
24
+ def generate_basic_html (s ):
21
25
s = '\n ' .join ([f'<p>{ line } </p>' for line in s .split ('\n ' )])
22
- s = f'<style>{ css } </style><div class="container">{ s } </div>'
26
+ s = f'<style>{ readable_css } </style><div class="container">{ s } </div>'
23
27
return s
24
28
25
29
def process_post (post , c ):
@@ -37,9 +41,6 @@ def process_post(post, c):
37
41
return src
38
42
39
43
def generate_4chan_html (f ):
40
- with open (Path (__file__ ).resolve ().parent / '../css/html_4chan_style.css' , 'r' ) as css_f :
41
- css = css_f .read ()
42
-
43
44
posts = []
44
45
post = ''
45
46
c = - 2
@@ -66,7 +67,7 @@ def generate_4chan_html(f):
66
67
posts [i ] = f'<div class="reply">{ posts [i ]} </div>\n '
67
68
68
69
output = ''
69
- output += f'<style>{ css } </style><div id="parent"><div id="container">'
70
+ output += f'<style>{ _4chan_css } </style><div id="parent"><div id="container">'
70
71
for post in posts :
71
72
output += post
72
73
output += '</div></div>'
@@ -101,10 +102,7 @@ def load_html_image(paths):
101
102
return ''
102
103
103
104
def generate_chat_html (history , name1 , name2 , character ):
104
- with open (Path (__file__ ).resolve ().parent / '../css/html_cai_style.css' , 'r' ) as f :
105
- css = f .read ()
106
-
107
- output = f'<style>{ css } </style><div class="chat" id="chat">'
105
+ output = f'<style>{ cai_css } </style><div class="chat" id="chat">'
108
106
109
107
img_bot = load_html_image ([f"characters/{ character } .{ ext } " for ext in ['png' , 'jpg' , 'jpeg' ]] + ["img_bot.png" ,"img_bot.jpg" ,"img_bot.jpeg" ])
110
108
img_me = load_html_image (["img_me.png" , "img_me.jpg" , "img_me.jpeg" ])
0 commit comments