set icon, update github deployment
This commit is contained in:
parent
b1834ba843
commit
55018afc26
@ -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),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -26,6 +26,8 @@ def invokeDialogueBox(title, message, type):
|
|||||||
input_data = simpledialog.askstring(title, message)
|
input_data = simpledialog.askstring(title, message)
|
||||||
if type == 'password':
|
if type == 'password':
|
||||||
input_data = simpledialog.askstring(title, message, show='*')
|
input_data = simpledialog.askstring(title, message, show='*')
|
||||||
|
if type == 'yesno':
|
||||||
|
input_data = messagebox.askyesno(title, message)
|
||||||
if type == 'message':
|
if type == 'message':
|
||||||
messagebox.showinfo(title, 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_set_origin_url"] = ['git', 'remote', 'set-url', 'origin']
|
||||||
git_commands["git_add_url"] = ['git', 'remote', 'add', 'origin']
|
git_commands["git_add_url"] = ['git', 'remote', 'add', 'origin']
|
||||||
git_commands["git_push"] = ['git', 'push', '-u', 'origin', 'main']
|
git_commands["git_push"] = ['git', 'push', '-u', 'origin', 'main']
|
||||||
|
git_commands["git_clone"] = ['git', 'clone']
|
||||||
|
|
||||||
data_location = f'{settings.BASE_DIR}/deploy/'
|
data_location = f'{settings.BASE_DIR}/deploy/'
|
||||||
deploy_location = settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/ghpages'
|
deploy_location = settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/ghpages'
|
||||||
@ -78,7 +81,12 @@ def github_deploy():
|
|||||||
|
|
||||||
if not os.path.exists(f'{deploy_location}/.git'):
|
if not os.path.exists(f'{deploy_location}/.git'):
|
||||||
try:
|
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)
|
gh_pages_deploy(deploy_location, git_commands)
|
||||||
return {'message': 'Github deployment successful', 'status': status.HTTP_200_OK}
|
return {'message': 'Github deployment successful', 'status': status.HTTP_200_OK}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -95,33 +103,75 @@ def github_deploy():
|
|||||||
|
|
||||||
|
|
||||||
def github_init(deploy_location, git_commands):
|
def github_init(deploy_location, git_commands):
|
||||||
email = invokeDialogueBox('Github Deploy', 'Enter your github email', 'text')
|
user_details_defined = git_check_user_details(deploy_location, git_commands)
|
||||||
name = invokeDialogueBox('Github Deploy', 'Enter your name', 'text')
|
if not user_details_defined:
|
||||||
|
git_set_user_details(deploy_location, git_commands)
|
||||||
username = invokeDialogueBox('Github Deploy', 'Enter your username', 'text')
|
username = invokeDialogueBox('Github Deploy', 'Enter your username', 'text')
|
||||||
password = invokeDialogueBox('Github Deploy', 'Enter your github token', 'password')
|
password = invokeDialogueBox('Github Deploy', 'Enter your github token', 'password')
|
||||||
remote_url = f'https://{username}:{password}@github.com/{username}/{username}.github.io.git'
|
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_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_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_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_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_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)
|
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):
|
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)
|
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_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()
|
origin_url = origin_url_subprocess.stdout.strip()
|
||||||
|
print("Got origin as "+str(origin_url))
|
||||||
parsed_url = urllib.parse.urlparse(origin_url)
|
parsed_url = urllib.parse.urlparse(origin_url)
|
||||||
|
print(parsed_url)
|
||||||
if not '@' in parsed_url.netloc:
|
if not '@' in parsed_url.netloc:
|
||||||
username = invokeDialogueBox('Github Deploy', 'Enter your username', 'text')
|
username = invokeDialogueBox('Github Deploy', 'Enter your username', 'text')
|
||||||
password = invokeDialogueBox('Github Deploy', 'Enter your github token', 'password')
|
password = invokeDialogueBox('Github Deploy', 'Enter your github token', 'password')
|
||||||
netloc = f"{username}:{password}@{parsed_url.hostname}"
|
netloc = f"{username}:{password}@{parsed_url.hostname}"
|
||||||
new_url = urllib.parse.urlunparse(parsed_url._replace(netloc=netloc))
|
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)
|
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_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_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)
|
subprocess.run(git_commands["git_push"], cwd=deploy_location, check=True, text=True, capture_output=True)
|
||||||
|
|||||||
@ -42,6 +42,7 @@ INSTALLED_APPS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
DEPLOY_CONFIG = {
|
DEPLOY_CONFIG = {
|
||||||
|
"VIEWABLE_UI_LOCATION": os.path.join(BASE_DIR, '../frontend/viewable-ui'),
|
||||||
"DEPLOY_LOCATION": os.path.join(BASE_DIR, '../frontend/viewable-ui/dist')
|
"DEPLOY_LOCATION": os.path.join(BASE_DIR, '../frontend/viewable-ui/dist')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
backend/icons/128x128.png
Normal file
BIN
backend/icons/128x128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
backend/icons/256x256.png
Normal file
BIN
backend/icons/256x256.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
backend/icons/64x64.png
Normal file
BIN
backend/icons/64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/data/homepage/media/profile.png" />
|
<link rel="icon" type="image" href="/rangolio.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Rangolio</title>
|
<title>Rangolio</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
BIN
frontend/editable-ui/public/rangolio.png
Normal file
BIN
frontend/editable-ui/public/rangolio.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB |
@ -111,6 +111,7 @@ function BlogList(props) {
|
|||||||
totalItems={featuredBlogData === 'nodata' ? 0 : 1}
|
totalItems={featuredBlogData === 'nodata' ? 0 : 1}
|
||||||
cardType={'longCard'}
|
cardType={'longCard'}
|
||||||
resourceType={'blog'}
|
resourceType={'blog'}
|
||||||
|
showSetFeaturedBlog={false}
|
||||||
textColor={ThemeConfig[GlobalTheme].textColor}
|
textColor={ThemeConfig[GlobalTheme].textColor}
|
||||||
bgColor={ThemeConfig[GlobalTheme].background}
|
bgColor={ThemeConfig[GlobalTheme].background}
|
||||||
borderColor={ThemeConfig[GlobalTheme].borderColor}
|
borderColor={ThemeConfig[GlobalTheme].borderColor}
|
||||||
@ -125,6 +126,7 @@ function BlogList(props) {
|
|||||||
<CardListViewer
|
<CardListViewer
|
||||||
totalItems={categoryData.blogMetadata.length}
|
totalItems={categoryData.blogMetadata.length}
|
||||||
featuredBlog={categoryData.featuredBlog}
|
featuredBlog={categoryData.featuredBlog}
|
||||||
|
showSetFeaturedBlog={true}
|
||||||
updateFeaturedBlog={updateFeaturedBlog}
|
updateFeaturedBlog={updateFeaturedBlog}
|
||||||
cardType={'smallCard'}
|
cardType={'smallCard'}
|
||||||
resourceType={'blog'}
|
resourceType={'blog'}
|
||||||
|
|||||||
@ -141,7 +141,7 @@ function CardListViewer(props) {
|
|||||||
</Link>
|
</Link>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
{
|
{
|
||||||
itemObject.id === props.featuredBlog ?
|
props.showSetFeaturedBlog ?
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<Button
|
<Button
|
||||||
outline
|
outline
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user