diff --git a/.gitignore b/.gitignore index 95242ce7..e6c74964 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ node_modules package-lock.json lms/public/frontend lms/www/lms.html +lms/www/_lms.html frappe-ui \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index bead43a6..9bd26413 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,7 +7,7 @@ "dev": "vite", "serve": "vite preview", "build": "vite build --base=/assets/lms/frontend/ && yarn copy-html-entry && yarn copy-colors-json", - "copy-html-entry": "cp ../lms/public/frontend/index.html ../lms/www/lms.html", + "copy-html-entry": "cp ../lms/public/frontend/index.html ../lms/www/_lms.html", "copy-colors-json": "cp node_modules/frappe-ui/tailwind/colors.json src/utils/frappe-ui-colors.json" }, "dependencies": { diff --git a/frontend/src/components/AssessmentPlugin.vue b/frontend/src/components/AssessmentPlugin.vue index 75e747c5..53b51392 100644 --- a/frontend/src/components/AssessmentPlugin.vue +++ b/frontend/src/components/AssessmentPlugin.vue @@ -65,6 +65,7 @@ import { Dialog, FormControl } from 'frappe-ui' import { nextTick, onMounted, ref } from 'vue' import { useRoute } from 'vue-router' import { Link } from 'frappe-ui/frappe' +import { getLmsRoute } from '@/utils/basePath' const show = ref(false) const quiz = ref(null) @@ -94,7 +95,10 @@ const addAssessment = () => { } const redirectToForm = () => { - if (props.type == 'quiz') window.open('/lms/quizzes?new=true', '_blank') - else window.open('/lms/assignments?new=true', '_blank') + if (props.type == 'quiz') { + window.open(getLmsRoute('quizzes?new=true'), '_blank') + } else { + window.open(getLmsRoute('assignments?new=true'), '_blank') + } } diff --git a/frontend/src/pages/Batch.vue b/frontend/src/pages/Batch.vue index ad5c47bb..3bd57614 100644 --- a/frontend/src/pages/Batch.vue +++ b/frontend/src/pages/Batch.vue @@ -248,6 +248,7 @@ import DateRange from '@/components/Common/DateRange.vue' import BulkCertificates from '@/components/Modals/BulkCertificates.vue' import BatchFeedback from '@/components/BatchFeedback.vue' import dayjs from 'dayjs/esm' +import { getLmsRoute } from '@/utils/basePath' const user = inject('$user') const showAnnouncementModal = ref(false) @@ -357,7 +358,9 @@ const isStudent = computed(() => { }) const redirectToLogin = () => { - window.location.href = `/login?redirect-to=/lms/batches/${props.batchName}` + window.location.href = `/login?redirect-to=${getLmsRoute( + `batches/${props.batchName}` + )}` } const openAnnouncementModal = () => { diff --git a/frontend/src/pages/Billing.vue b/frontend/src/pages/Billing.vue index 00a98a94..02f9ce11 100644 --- a/frontend/src/pages/Billing.vue +++ b/frontend/src/pages/Billing.vue @@ -207,14 +207,18 @@ :text="access.data.message" :buttonLabel="type == 'course' ? 'Checkout Course' : 'Checkout Batch'" :buttonLink=" - type == 'course' ? `/lms/courses/${name}` : `/lms/batches/${name}` + type == 'course' + ? getLmsRoute(`courses/${name}`) + : getLmsRoute(`batches/${name}`) " />
{{ _(" Please evaluate and grade it.") }}
{{ _("Visit the following link to view your ") }} - {{ _("Batch Details") }} + {{ _("Batch Details") }}
{{ _("If you have any questions or require assistance, feel free to contact us.") }} @@ -32,4 +32,3 @@
{{ _("Best Regards") }}
- diff --git a/lms/templates/emails/batch_start_reminder.html b/lms/templates/emails/batch_start_reminder.html index de240de6..95443e6a 100644 --- a/lms/templates/emails/batch_start_reminder.html +++ b/lms/templates/emails/batch_start_reminder.html @@ -20,7 +20,7 @@- 👉 {{ _("Visit your batch") }} + 👉 {{ _("Visit your batch") }}
diff --git a/lms/templates/emails/live_class_reminder.html b/lms/templates/emails/live_class_reminder.html index cd1db5ef..20865d7a 100644 --- a/lms/templates/emails/live_class_reminder.html +++ b/lms/templates/emails/live_class_reminder.html @@ -17,7 +17,7 @@
- 👉 {{ _("Visit your batch") }} + 👉 {{ _("Visit your batch") }}
@@ -26,4 +26,4 @@
{{ _("Best Regards") }} -
\ No newline at end of file + diff --git a/lms/www/lms.py b/lms/www/_lms.py similarity index 88% rename from lms/www/lms.py rename to lms/www/_lms.py index fcda12cd..10a9b796 100644 --- a/lms/www/lms.py +++ b/lms/www/_lms.py @@ -5,6 +5,9 @@ from bs4 import BeautifulSoup from frappe import _ from frappe.utils.telemetry import capture +from lms.hooks import lms_path +from lms.lms.utils import get_lms_route + no_cache = 1 @@ -32,6 +35,7 @@ def get_boot(): "read_only_mode": frappe.flags.read_only, "csrf_token": frappe.sessions.get_csrf_token(), "site_name": frappe.local.site, + "lms_path": lms_path, } ) @@ -85,7 +89,7 @@ def get_meta_from_document(app_path): return { "title": _("Course List"), "keywords": "All Courses, Courses, Learn", - "link": "/courses", + "link": get_lms_route("courses"), } if re.match(r"^courses/.*$", app_path): @@ -94,7 +98,7 @@ def get_meta_from_document(app_path): "title": _("New Course"), "image": frappe.db.get_single_value("Website Settings", "banner_image"), "keywords": "New Course, Create Course", - "link": "/lms/courses/new/edit", + "link": get_lms_route("courses/new/edit"), } course_name = app_path.split("/")[1] course = frappe.db.get_value( @@ -113,14 +117,14 @@ def get_meta_from_document(app_path): "image": course.image, "description": course.description, "keywords": course.tags, - "link": f"/courses/{course_name}", + "link": get_lms_route(f"courses/{course_name}"), } if app_path == "batches": return { "title": _("Batches"), "keywords": "All Batches, Batches, Learn", - "link": "/batches", + "link": get_lms_route("batches"), } if re.match(r"^batches/details/.*$", app_path): batch_name = app_path.split("/")[2] @@ -140,7 +144,7 @@ def get_meta_from_document(app_path): "image": batch.meta_image, "description": batch.batch_details, "keywords": f"{batch.category} {batch.medium}", - "link": f"/batches/details/{batch_name}", + "link": get_lms_route(f"batches/details/{batch_name}"), } if re.match(r"^batches/.*$", app_path): @@ -149,7 +153,7 @@ def get_meta_from_document(app_path): return { "title": _("New Batch"), "keywords": "New Batch, Create Batch", - "link": "/lms/batches/new/edit", + "link": get_lms_route("batches/new/edit"), } batch = frappe.db.get_value( "LMS Batch", @@ -167,14 +171,14 @@ def get_meta_from_document(app_path): "image": batch.meta_image, "description": batch.batch_details, "keywords": f"{batch.category} {batch.medium}", - "link": f"/batches/{batch_name}", + "link": get_lms_route(f"batches/{batch_name}"), } if app_path == "job-openings": return { "title": _("Job Openings"), "keywords": "Job Openings, Jobs, Vacancies", - "link": "/job-openings", + "link": get_lms_route("job-openings"), } if re.match(r"^job-openings/.*$", app_path): @@ -195,14 +199,14 @@ def get_meta_from_document(app_path): "image": job_opening.company_logo, "description": job_opening.description, "keywords": "Job Openings, Jobs, Vacancies", - "link": f"/job-openings/{job_opening_name}", + "link": get_lms_route(f"job-openings/{job_opening_name}"), } if app_path == "statistics": return { "title": _("Statistics"), "keywords": "Enrollment Count, Completion, Signups", - "link": "/statistics", + "link": get_lms_route("statistics"), } if re.match(r"^user/.*$", app_path): @@ -225,7 +229,7 @@ def get_meta_from_document(app_path): "image": user.user_image, "description": user.bio, "keywords": f"{user.full_name}, {user.bio}", - "link": f"/user/{username}", + "link": get_lms_route(f"user/{username}"), } if re.match(r"^badges/.*/.*$", app_path): @@ -242,14 +246,14 @@ def get_meta_from_document(app_path): "image": badge.image, "description": badge.description, "keywords": f"{badge.title}, {badge.description}", - "link": f"/badges/{badgeName}/{email}", + "link": get_lms_route(f"badges/{badgeName}/{email}"), } if app_path == "quizzes": return { "title": _("Quizzes"), "keywords": "Quizzes, interactive quizzes, online quizzes", - "link": "/quizzes", + "link": get_lms_route("quizzes"), } if re.match(r"^quizzes/[^/]+$", app_path): @@ -264,14 +268,14 @@ def get_meta_from_document(app_path): return { "title": quiz.title, "keywords": quiz.title, - "link": f"/quizzes/{quiz_name}", + "link": get_lms_route(f"quizzes/{quiz_name}"), } if app_path == "assignments": return { "title": _("Assignments"), "keywords": "Assignments, interactive assignments, online assignments", - "link": "/assignments", + "link": get_lms_route("assignments"), } if re.match(r"^assignments/[^/]+$", app_path): @@ -286,21 +290,21 @@ def get_meta_from_document(app_path): return { "title": assignment.title, "keywords": assignment.title, - "link": f"/assignments/{assignment_name}", + "link": get_lms_route(f"assignments/{assignment_name}"), } if app_path == "programs": return { "title": _("Programs"), "keywords": "All Programs, Programs, Learn", - "link": "/programs", + "link": get_lms_route("programs"), } if app_path == "certified-participants": return { "title": _("Certified Participants"), "keywords": "All Certified Participants, Certified Participants, Learn, Certification", - "link": "/certified-participants", + "link": get_lms_route("certified-participants"), } return {}