diff --git a/backend/apimanager/migrations/0015_alter_userdata_dark_theme_alter_userdata_light_theme.py b/backend/apimanager/migrations/0015_alter_userdata_dark_theme_alter_userdata_light_theme.py new file mode 100644 index 0000000..4c4a4c3 --- /dev/null +++ b/backend/apimanager/migrations/0015_alter_userdata_dark_theme_alter_userdata_light_theme.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.6 on 2024-06-18 15:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('apimanager', '0014_alter_userdata_name'), + ] + + operations = [ + migrations.AlterField( + model_name='userdata', + name='dark_theme', + field=models.CharField(default='{"theme": "Dark Mode","background": "bg-dark","textColor": "text-white","linkBackground": "bg-light","linkTextColor": "text-black","captionColor": "#8a8a8a","fontAwesomeIcon": "faSun","borderColor": "border-light","buttonColor": "light","navBar": {"navBarTheme": "navbar-dark","background": "bg-secondary","buttonColor": "light"},"footer": {"background": "bg-secondary","text": "text-white"}}', max_length=1500), + ), + migrations.AlterField( + model_name='userdata', + name='light_theme', + field=models.CharField(default='{"theme": "Light Mode","background": "bg-light","textColor": "text-black","linkBackground": "bg-dark","linkTextColor": "text-white","captionColor": "#605f5f","fontAwesomeIcon": "faMoon","borderColor": "border-secondary","buttonColor": "dark","navBar": {"navBarTheme": "navbar-light","background": "bg-secondary","buttonColor": "light"},"footer": {"background": "bg-secondary","text": "text-black"}}', max_length=1500), + ), + ] diff --git a/backend/apimanager/publish_methods.py b/backend/apimanager/publish_methods.py index daac69e..36bf484 100644 --- a/backend/apimanager/publish_methods.py +++ b/backend/apimanager/publish_methods.py @@ -26,6 +26,8 @@ def invokeDialogueBox(title, message, type): input_data = simpledialog.askstring(title, message) if type == 'password': input_data = simpledialog.askstring(title, message, show='*') + if type == 'yesno': + input_data = messagebox.askyesno(title, message) if type == 'message': messagebox.showinfo(title, message) @@ -69,6 +71,7 @@ def github_deploy(): git_commands["git_set_origin_url"] = ['git', 'remote', 'set-url', 'origin'] git_commands["git_add_url"] = ['git', 'remote', 'add', 'origin'] git_commands["git_push"] = ['git', 'push', '-u', 'origin', 'main'] + git_commands["git_clone"] = ['git', 'clone'] data_location = f'{settings.BASE_DIR}/deploy/' deploy_location = settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/ghpages' @@ -78,7 +81,12 @@ def github_deploy(): if not os.path.exists(f'{deploy_location}/.git'): try: - github_init(deploy_location, git_commands) + + existingRepo = invokeDialogueBox('Github Deploy', 'Do you have an existing repository with Rangolio on github?', 'yesno') + if (existingRepo): + git_existing_repo_setup(deploy_location, git_commands) + else: + github_init(deploy_location, git_commands) gh_pages_deploy(deploy_location, git_commands) return {'message': 'Github deployment successful', 'status': status.HTTP_200_OK} except Exception as e: @@ -95,33 +103,75 @@ def github_deploy(): def github_init(deploy_location, git_commands): - email = invokeDialogueBox('Github Deploy', 'Enter your github email', 'text') - name = invokeDialogueBox('Github Deploy', 'Enter your name', 'text') + user_details_defined = git_check_user_details(deploy_location, git_commands) + if not user_details_defined: + git_set_user_details(deploy_location, git_commands) username = invokeDialogueBox('Github Deploy', 'Enter your username', 'text') password = invokeDialogueBox('Github Deploy', 'Enter your github token', 'password') remote_url = f'https://{username}:{password}@github.com/{username}/{username}.github.io.git' subprocess.run(git_commands["git_init"], cwd=deploy_location, check=True, text=True, capture_output=True) - subprocess.run((git_commands["git_config_email"]).append(email), cwd=deploy_location, check=True, text=True, capture_output=True) - subprocess.run((git_commands["git_config_name"]).append(name), cwd=deploy_location, check=True, text=True, capture_output=True) subprocess.run(git_commands["git_add"], cwd=deploy_location, check=True, text=True, capture_output=True) subprocess.run(git_commands["git_commit"], cwd=deploy_location, check=True, text=True, capture_output=True) subprocess.run(git_commands["git_branch"], cwd=deploy_location, check=True, text=True, capture_output=True) subprocess.run((git_commands["git_add_url"]).append(remote_url), cwd=deploy_location, check=True, text=True, capture_output=True) subprocess.run(git_commands["git_push"], cwd=deploy_location, check=True, text=True, capture_output=True) +def git_set_user_details(deploy_location, git_commands): + email = invokeDialogueBox('Github Deploy', 'Enter your github email', 'text') + name = invokeDialogueBox('Github Deploy', 'Enter your name', 'text') + subprocess.run(git_commands["git_config_email"] + [email], cwd=deploy_location, check=True, text=True, capture_output=True) + subprocess.run(git_commands["git_config_name"]+ [name], cwd=deploy_location, check=True, text=True, capture_output=True) + +def git_existing_repo_setup(deploy_location, git_commands): + + repo_url = invokeDialogueBox('Github Deploy', 'Enter Repository URL', 'text') + if not repo_url.endswith('.git'): + repo_url = repo_url + '.git' + + dist_folder_name = ((repo_url.split('/')).pop()).removesuffix('.git') + subprocess.run(git_commands["git_clone"] + [repo_url], cwd=settings.DEPLOY_CONFIG["DEPLOY_LOCATION"], check=True, text=True, capture_output=True) + git_update_viewable_ui(deploy_location, dist_folder_name) + +def git_check_user_details( deploy_location, git_commands): + try: + subprocess.run(git_commands["git_config_name"], cwd=deploy_location, check=True, text=True, capture_output=True) + subprocess.run(git_commands["git_config_email"], cwd=deploy_location, check=True, text=True, capture_output=True) + return True + except Exception as e: + return False + + +def git_update_viewable_ui(deploy_location, dist_folder_name, build_frontend=False): + shutil.move(deploy_location, f'{deploy_location}.temp') + if build_frontend: + subprocess.run(["npm", 'run', 'build:ghpages'], cwd=settings.DEPLOY_CONFIG["VIEWABLE_UI_LOCATION"], check=True, text=True, capture_output=True) + shutil.move(f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/{dist_folder_name}', f'{deploy_location}') + shutil.copy(f'{deploy_location}.temp/index.html', deploy_location) + shutil.copy(f'{deploy_location}.temp/404.html', deploy_location) + shutil.copytree(f'{deploy_location}.temp/assets', f'{deploy_location}/assets', dirs_exist_ok=True) + if os.path.exists(f'{deploy_location}.temp/data'): + shutil.copytree(f'{deploy_location}.temp/data', f'{deploy_location}/data', dirs_exist_ok=True) + shutil.rmtree(f'{deploy_location}.temp') def gh_pages_deploy(deploy_location, git_commands): + user_details_defined = git_check_user_details(deploy_location, git_commands) + if not user_details_defined: + git_set_user_details(deploy_location, git_commands) subprocess.run(git_commands["git_pull"], cwd=deploy_location, check=True, text=True, capture_output=True) + print("completed git pull") origin_url_subprocess = subprocess.run(git_commands["git_get_origin_url"], cwd=deploy_location, check=True, text=True, capture_output=True) origin_url = origin_url_subprocess.stdout.strip() + print("Got origin as "+str(origin_url)) parsed_url = urllib.parse.urlparse(origin_url) + print(parsed_url) if not '@' in parsed_url.netloc: username = invokeDialogueBox('Github Deploy', 'Enter your username', 'text') password = invokeDialogueBox('Github Deploy', 'Enter your github token', 'password') netloc = f"{username}:{password}@{parsed_url.hostname}" new_url = urllib.parse.urlunparse(parsed_url._replace(netloc=netloc)) subprocess.run(git_commands["git_set_origin_url"] + [new_url], cwd=deploy_location, check=True, text=True, capture_output=True) + print("Origin URL changed") subprocess.run(git_commands["git_add"], cwd=deploy_location, check=True, text=True, capture_output=True) subprocess.run(git_commands["git_commit"], cwd=deploy_location, check=True, text=True, capture_output=True) subprocess.run(git_commands["git_push"], cwd=deploy_location, check=True, text=True, capture_output=True) diff --git a/backend/backend/settings.py b/backend/backend/settings.py index 2faa78d..4da9fe9 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -42,6 +42,7 @@ INSTALLED_APPS = [ ] DEPLOY_CONFIG = { + "VIEWABLE_UI_LOCATION": os.path.join(BASE_DIR, '../frontend/viewable-ui'), "DEPLOY_LOCATION": os.path.join(BASE_DIR, '../frontend/viewable-ui/dist') } diff --git a/backend/icons/128x128.png b/backend/icons/128x128.png new file mode 100644 index 0000000..2f6b1eb Binary files /dev/null and b/backend/icons/128x128.png differ diff --git a/backend/icons/256x256.png b/backend/icons/256x256.png new file mode 100644 index 0000000..76438cd Binary files /dev/null and b/backend/icons/256x256.png differ diff --git a/backend/icons/64x64.png b/backend/icons/64x64.png new file mode 100644 index 0000000..abda4b5 Binary files /dev/null and b/backend/icons/64x64.png differ diff --git a/frontend/editable-ui/index.html b/frontend/editable-ui/index.html index fb0b53b..3dd4fed 100644 --- a/frontend/editable-ui/index.html +++ b/frontend/editable-ui/index.html @@ -2,7 +2,7 @@ - + Rangolio diff --git a/frontend/editable-ui/public/rangolio.png b/frontend/editable-ui/public/rangolio.png new file mode 100644 index 0000000..abda4b5 Binary files /dev/null and b/frontend/editable-ui/public/rangolio.png differ diff --git a/frontend/editable-ui/public/vite.svg b/frontend/editable-ui/public/vite.svg deleted file mode 100755 index e7b8dfb..0000000 --- a/frontend/editable-ui/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/frontend/editable-ui/src/components/blog-list.jsx b/frontend/editable-ui/src/components/blog-list.jsx index 87a3731..a32d701 100755 --- a/frontend/editable-ui/src/components/blog-list.jsx +++ b/frontend/editable-ui/src/components/blog-list.jsx @@ -111,6 +111,7 @@ function BlogList(props) { totalItems={featuredBlogData === 'nodata' ? 0 : 1} cardType={'longCard'} resourceType={'blog'} + showSetFeaturedBlog={false} textColor={ThemeConfig[GlobalTheme].textColor} bgColor={ThemeConfig[GlobalTheme].background} borderColor={ThemeConfig[GlobalTheme].borderColor} @@ -125,6 +126,7 @@ function BlogList(props) { { - itemObject.id === props.featuredBlog ? + props.showSetFeaturedBlog ?