Skip to content

Commit

Permalink
Run multiple world at same time (#246)
Browse files Browse the repository at this point in the history
* use the same ico with eventyay-talk

* update base path for webapp using basePath from config file

* update route to run multiple world at ssame time

* fix upload avatar, default theme

* correct link when click to logo

* fix code style/lint/black/flake8

---------

Co-authored-by: odkhang <[email protected]>
  • Loading branch information
lcduong and odkhang authored Oct 12, 2024
1 parent d14de63 commit 4c2cd45
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 236 deletions.
1 change: 0 additions & 1 deletion server/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def _clear_db():


@pytest.fixture(autouse=True)
@pytest.mark.django_db
async def clear_database(request):
if "django_db" not in request.keywords: # pragma: no cover
return
Expand Down
3 changes: 1 addition & 2 deletions server/venueless/control/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class WorldAdminToken(AdminBase, DetailView):
success_url = "/control/worlds/"

def get(self, request, *args, **kwargs):
base_path = settings.BASE_PATH
world = self.get_object()
jwt_config = world.config["JWT_secrets"][0]
secret = jwt_config["secret"]
Expand All @@ -205,7 +204,7 @@ def get(self, request, *args, **kwargs):
action_type="world.adminaccess",
data={},
)
return redirect(f"https://{world.domain}{base_path}/#token={token}")
return redirect(f"https://{world.domain}#token={token}")


class FormsetMixin:
Expand Down
4 changes: 2 additions & 2 deletions server/venueless/storage/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from . import views

urlpatterns = [
path("upload/", views.UploadView.as_view(), name="upload"),
path("<str:world_id>/upload/", views.UploadView.as_view(), name="upload"),
path(
"schedule_import/",
"<str:world_id>/schedule_import/",
views.ScheduleImportView.as_view(),
name="schedule_import",
),
Expand Down
5 changes: 2 additions & 3 deletions server/venueless/storage/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import re
from io import BytesIO

from asgiref.sync import async_to_sync
Expand Down Expand Up @@ -34,8 +33,8 @@ def dispatch(self, request, *args, **kwargs):

@cached_property
def world(self):
world_domain = re.sub(r":\d+$", "", self.request.get_host())
return get_object_or_404(World, domain=world_domain)
world_id = self.kwargs.get("world_id", None)
return get_object_or_404(World, id=world_id)

@cached_property
def user(self):
Expand Down
11 changes: 7 additions & 4 deletions webapp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ if (ENV_DEVELOPMENT || !window.venueless) {
const hostname = window.location.hostname
const wsProtocol = window.location.protocol === 'https:' ? 'wss' : 'ws'
const httpProtocol = window.location.protocol
// Extract the world name from the URL path
const pathSegments = window.location.pathname.split('/')
const worldName = pathSegments.length > 2 ? pathSegments[2] : 'sample'
config = {
api: {
base: `${httpProtocol}//${hostname}:8443/api/v1/worlds/sample/`,
socket: `${wsProtocol}://${hostname}:8443/ws/world/sample/`,
upload: `${httpProtocol}//${hostname}:8443/storage/upload/`,
scheduleImport: `${httpProtocol}//${hostname}:8443/storage/schedule_import/`,
base: `${httpProtocol}//${hostname}:8443/api/v1/worlds/${worldName}/`,
socket: `${wsProtocol}://${hostname}:8443/ws/world/${worldName}/`,
upload: `${httpProtocol}//${hostname}:8443/storage/${worldName}/upload/`,
scheduleImport: `${httpProtocol}//${hostname}:8443/storage/${worldName}/schedule_import/`,
feedback: `${httpProtocol}//${hostname}:8443/_feedback/`,
},
defaultLocale: 'en',
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/AppBar.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template lang="pug">
.c-app-bar
bunt-icon-button(v-if="showActions", @click="$emit('toggleSidebar')", @touchend.native="$emit('toggleSidebar')") menu
router-link.logo(to="/", :class="{anonymous: isAnonymous}")
router-link.logo(:to="{name: 'home'}", :class="{anonymous: isAnonymous}")
img(:src="theme.logo.url", :alt="world.title")
.user(v-if="showUser")
p(v-if="isAnonymous") {{ $t('AppBar:user-anonymous') }}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/RoomsSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template lang="pug">
transition(name="sidebar")
.c-rooms-sidebar(v-show="show && !snapBack", :style="style", role="navigation", @pointerdown="onPointerdown", @pointermove="onPointermove", @pointerup="onPointerup", @pointercancel="onPointercancel")
router-link.logo(to="/", v-if="$mq.above['m']", :class="{'fit-to-width': theme.logo.fitToWidth}")
router-link.logo(:to="{name: 'home'}", v-if="$mq.above['m']", :class="{'fit-to-width': theme.logo.fitToWidth}")
img(:src="theme.logo.url", :alt="world.title")
bunt-icon-button#btn-close-sidebar(v-else, @click="$emit('close')") menu
scrollbars(y)
Expand Down
Loading

0 comments on commit 4c2cd45

Please sign in to comment.