| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  | __filename__ = "webapp_welcome_final.py" | 
					
						
							|  |  |  | __author__ = "Bob Mottram" | 
					
						
							|  |  |  | __license__ = "AGPL3+" | 
					
						
							|  |  |  | __version__ = "1.2.0" | 
					
						
							|  |  |  | __maintainer__ = "Bob Mottram" | 
					
						
							|  |  |  | __email__ = "bob@freedombone.net" | 
					
						
							|  |  |  | __status__ = "Production" | 
					
						
							| 
									
										
										
										
											2021-06-26 11:27:14 +00:00
										 |  |  | __module_group__ = "Onboarding" | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | import os | 
					
						
							|  |  |  | from shutil import copyfile | 
					
						
							| 
									
										
										
										
											2021-02-25 19:15:04 +00:00
										 |  |  | from utils import removeHtml | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  | from utils import getConfigParam | 
					
						
							|  |  |  | from webapp_utils import htmlHeaderWithExternalStyle | 
					
						
							|  |  |  | from webapp_utils import htmlFooter | 
					
						
							| 
									
										
										
										
											2021-06-25 14:38:31 +00:00
										 |  |  | from markdown import markdownToHtml | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def htmlWelcomeFinal(baseDir: str, nickname: str, domain: str, | 
					
						
							|  |  |  |                      httpPrefix: str, domainFull: str, | 
					
						
							| 
									
										
										
										
											2021-02-27 10:27:39 +00:00
										 |  |  |                      language: str, translate: {}, | 
					
						
							|  |  |  |                      themeName: str) -> str: | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  |     """Returns the final welcome screen after first login
 | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     # set a custom background for the welcome screen | 
					
						
							|  |  |  |     if os.path.isfile(baseDir + '/accounts/welcome-background-custom.jpg'): | 
					
						
							|  |  |  |         if not os.path.isfile(baseDir + '/accounts/welcome-background.jpg'): | 
					
						
							|  |  |  |             copyfile(baseDir + '/accounts/welcome-background-custom.jpg', | 
					
						
							|  |  |  |                      baseDir + '/accounts/welcome-background.jpg') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     finalText = 'Welcome to Epicyon' | 
					
						
							|  |  |  |     finalFilename = baseDir + '/accounts/welcome_final.md' | 
					
						
							|  |  |  |     if not os.path.isfile(finalFilename): | 
					
						
							| 
									
										
										
										
											2021-02-27 10:27:39 +00:00
										 |  |  |         defaultFilename = None | 
					
						
							|  |  |  |         if themeName: | 
					
						
							|  |  |  |             defaultFilename = \ | 
					
						
							|  |  |  |                 baseDir + '/theme/' + themeName + '/welcome/' + \ | 
					
						
							|  |  |  |                 'final_' + language + '.md' | 
					
						
							|  |  |  |             if not os.path.isfile(defaultFilename): | 
					
						
							|  |  |  |                 defaultFilename = None | 
					
						
							|  |  |  |         if not defaultFilename: | 
					
						
							|  |  |  |             defaultFilename = \ | 
					
						
							|  |  |  |                 baseDir + '/defaultwelcome/final_' + language + '.md' | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  |         if not os.path.isfile(defaultFilename): | 
					
						
							|  |  |  |             defaultFilename = baseDir + '/defaultwelcome/final_en.md' | 
					
						
							|  |  |  |         copyfile(defaultFilename, finalFilename) | 
					
						
							| 
									
										
										
										
											2021-02-25 22:25:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     instanceTitle = \ | 
					
						
							|  |  |  |         getConfigParam(baseDir, 'instanceTitle') | 
					
						
							|  |  |  |     if not instanceTitle: | 
					
						
							|  |  |  |         instanceTitle = 'Epicyon' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  |     if os.path.isfile(finalFilename): | 
					
						
							|  |  |  |         with open(finalFilename, 'r') as finalFile: | 
					
						
							| 
									
										
										
										
											2021-02-25 22:25:01 +00:00
										 |  |  |             finalText = finalFile.read() | 
					
						
							|  |  |  |             finalText = finalText.replace('INSTANCE', instanceTitle) | 
					
						
							|  |  |  |             finalText = markdownToHtml(removeHtml(finalText)) | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     finalForm = '' | 
					
						
							|  |  |  |     cssFilename = baseDir + '/epicyon-welcome.css' | 
					
						
							|  |  |  |     if os.path.isfile(baseDir + '/welcome.css'): | 
					
						
							|  |  |  |         cssFilename = baseDir + '/welcome.css' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     finalForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     finalForm += \ | 
					
						
							| 
									
										
										
										
											2021-07-06 12:50:38 +00:00
										 |  |  |         '<div class="container">' + finalText + '</div>\n' + \ | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  |         '<form enctype="multipart/form-data" method="POST" ' + \ | 
					
						
							|  |  |  |         'accept-charset="UTF-8" ' + \ | 
					
						
							| 
									
										
										
										
											2021-07-06 12:50:38 +00:00
										 |  |  |         'action="/users/' + nickname + '/profiledata">\n' + \ | 
					
						
							|  |  |  |         '<div class="container next">\n' + \ | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  |         '    <button type="submit" class="button" ' + \ | 
					
						
							| 
									
										
										
										
											2021-07-06 12:50:38 +00:00
										 |  |  |         'name="previewAvatar">' + translate['Go Back'] + '</button>\n' + \ | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  |         '    <button type="submit" class="button" ' + \ | 
					
						
							| 
									
										
										
										
											2021-07-06 12:50:38 +00:00
										 |  |  |         'name="welcomeCompleteButton">' + translate['Next'] + '</button>\n' + \ | 
					
						
							|  |  |  |         '</div>\n' | 
					
						
							| 
									
										
										
										
											2021-02-25 16:55:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     finalForm += '</form>\n' | 
					
						
							|  |  |  |     finalForm += htmlFooter() | 
					
						
							|  |  |  |     return finalForm |