diff --git a/backend/apimanager/publish_methods.py b/backend/apimanager/publish_methods.py
index 5fb2585..daac69e 100644
--- a/backend/apimanager/publish_methods.py
+++ b/backend/apimanager/publish_methods.py
@@ -3,7 +3,10 @@ import os
import shutil
import subprocess
import tkinter as tk
+from rest_framework import status
from tkinter import simpledialog
+from tkinter import messagebox
+import urllib.parse
deployment_methods = {
"server_deploy": {
@@ -23,10 +26,12 @@ def invokeDialogueBox(title, message, type):
input_data = simpledialog.askstring(title, message)
if type == 'password':
input_data = simpledialog.askstring(title, message, show='*')
+ if type == 'message':
+ messagebox.showinfo(title, message)
root.destroy()
-
return input_data
+
def copyData(data_location, deploy_location):
if not os.path.exists(data_location):
print("The source directory does not exist.")
@@ -41,9 +46,14 @@ def copyData(data_location, deploy_location):
except Exception as e:
print(f"Error occurred: {e}")
def server_deploy():
- data_location = f'{settings.BASE_DIR}/deploy/'
- deploy_location = settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/server'
- copyData(data_location, deploy_location)
+ try:
+ data_location = f'{settings.BASE_DIR}/deploy/'
+ deploy_location = settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/server'
+ copyData(data_location, deploy_location)
+ return {'message': 'Server deployment successful', 'status': status.HTTP_200_OK}
+ except Exception as e:
+ print (f"An error occurred: {str(e)}")
+ return {'message': str(e), 'status': status.HTTP_500_INTERNAL_SERVER_ERROR}
def github_deploy():
print("Deploying via github")
@@ -55,6 +65,8 @@ def github_deploy():
git_commands["git_config_name"] = ['git', 'config', '--local', 'user.name']
git_commands["git_commit"] = ['git', 'commit', '-m', 'Update website']
git_commands["git_branch"] = ['git', 'branch', '-m', 'main']
+ git_commands["git_get_origin_url"] = ['git', 'remote', 'get-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_push"] = ['git', 'push', '-u', 'origin', 'main']
@@ -65,42 +77,54 @@ def github_deploy():
copyData(data_location, deploy_location)
if not os.path.exists(f'{deploy_location}/.git'):
- github_init(deploy_location, git_commands)
- gh_pages_deploy(deploy_location, git_commands)
+ try:
+ 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:
+ print (f"An error occurred: {str(e)}")
+ return {'message': str(e), 'status': status.HTTP_500_INTERNAL_SERVER_ERROR}
+
else:
- gh_pages_deploy(deploy_location, git_commands)
+ try:
+ gh_pages_deploy(deploy_location, git_commands)
+ return {'message': 'Github deployment successful', 'status': status.HTTP_200_OK}
+ except Exception as e:
+ print (f"An error occurred: {str(e)}")
+ return {'message': str(e), 'status': status.HTTP_500_INTERNAL_SERVER_ERROR}
+
def github_init(deploy_location, git_commands):
- email = invokeDialogueBox('Github Deploy', 'Enter your github email', 'text')
- name = invokeDialogueBox('Github Deploy', 'Enter your name', 'text')
- 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'
+ email = invokeDialogueBox('Github Deploy', 'Enter your github email', 'text')
+ name = invokeDialogueBox('Github Deploy', 'Enter your name', 'text')
+ 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'
- try:
- 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)
- except subprocess.CalledProcessError as e:
- print (f"Failed to add remote: {e.stderr}")
- except Exception as e:
- print (f"An error occurred: {str(e)}")
+ 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 gh_pages_deploy(deploy_location, git_commands):
- try:
- 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)
- except subprocess.CalledProcessError as e:
- return f"Failed to add remote: {e.stderr}"
- except Exception as e:
- return f"An error occurred: {str(e)}"
+ subprocess.run(git_commands["git_pull"], 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()
+ parsed_url = urllib.parse.urlparse(origin_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)
+ 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)
def create_404_page(deploy_location):
diff --git a/backend/apimanager/publish_views.py b/backend/apimanager/publish_views.py
index 459e577..883c5a2 100644
--- a/backend/apimanager/publish_views.py
+++ b/backend/apimanager/publish_views.py
@@ -34,8 +34,8 @@ class Publish(APIView):
storage = CustomStorage()
self.delete_old_data()
self.create_json(storage)
- self.execute_deploy(deploy_type)
- return Response({"deploy_type": deploy_type}, status=status.HTTP_200_OK)
+ response = self.execute_deploy(deploy_type)
+ return Response(response['message'], response['status'])
def delete_old_data(self):
@@ -152,7 +152,14 @@ class Publish(APIView):
def execute_deploy(self, deploy_type):
+ response = {
+ 'message': 'Something failed',
+ 'status': status.HTTP_500_INTERNAL_SERVER_ERROR
+ }
+
if deploy_type == "server_deploy":
- server_deploy()
+ response = server_deploy()
if deploy_type == "github_deploy":
- github_deploy()
\ No newline at end of file
+ response = github_deploy()
+
+ return response
diff --git a/frontend/editable-ui/src/components/blog-list.jsx b/frontend/editable-ui/src/components/blog-list.jsx
index fd7f95a..87a3731 100755
--- a/frontend/editable-ui/src/components/blog-list.jsx
+++ b/frontend/editable-ui/src/components/blog-list.jsx
@@ -131,6 +131,7 @@ function BlogList(props) {
textColor={ThemeConfig[GlobalTheme].textColor}
bgColor={ThemeConfig[GlobalTheme].background}
borderColor={ThemeConfig[GlobalTheme].borderColor}
+ buttonColor={ThemeConfig[GlobalTheme].buttonColor}
itemObject={item}
/>
diff --git a/frontend/editable-ui/src/components/shared/card-list-viewer.jsx b/frontend/editable-ui/src/components/shared/card-list-viewer.jsx
index 7c1178c..aa24b9c 100755
--- a/frontend/editable-ui/src/components/shared/card-list-viewer.jsx
+++ b/frontend/editable-ui/src/components/shared/card-list-viewer.jsx
@@ -111,7 +111,9 @@ function CardListViewer(props) {
- Open this resource
+
@@ -138,21 +140,26 @@ function CardListViewer(props) {
-
-
-
-
+ {
+ itemObject.id === props.featuredBlog ?
+
+
+
+ : ''
+ }
)
}
diff --git a/frontend/editable-ui/src/index.css b/frontend/editable-ui/src/index.css
index a8c4035..b9e3df9 100755
--- a/frontend/editable-ui/src/index.css
+++ b/frontend/editable-ui/src/index.css
@@ -11,17 +11,8 @@ a {
}
.blogContent a{
- border-radius: 5px;
- padding-left: 5px;
- padding-right: 5px;
- transition-duration: 0.1s;
-}
-
-.blogContent a:hover{
- border-radius: 5px;
- padding-left: 15px;
- padding-right: 15px;
- transition-duration: 0.1s;
+ color: blue !important;
+ text-decoration: underline !important;
}
.blogContent{