Skip to content

Commit

Permalink
Merge pull request #20 from RFnexus/master
Browse files Browse the repository at this point in the history
Full Micron markdown and field support, dark mode
  • Loading branch information
liamcottle authored Dec 10, 2024
2 parents e346c02 + 81eff5c commit a6ebf73
Show file tree
Hide file tree
Showing 19 changed files with 1,182 additions and 532 deletions.
34 changes: 32 additions & 2 deletions meshchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,23 @@ def convert_nomadnet_string_data_to_map(self, path_data: str | None):
else:
print(f"unhandled field: {field}")
return data
def convert_nomadnet_field_data_to_map(self, field_data):
data = {}
if field_data is not None or "{}":
try:
json_data = field_data
if isinstance(json_data, dict):
# add the prefixed keys to the result dictionary
data = {f"field_{key}": value for key, value in json_data.items()}
else:
return None
except Exception as e:
print(f"skipping invalid field data: {e}")

return data




# handle data received from websocket client
async def on_websocket_data_received(self, client, data):
Expand Down Expand Up @@ -1675,7 +1692,9 @@ def on_file_download_progress(progress):
# get data from websocket client
destination_hash = data["nomadnet_page_download"]["destination_hash"]
page_path = data["nomadnet_page_download"]["page_path"]

field_data = data["nomadnet_page_download"]["field_data"]

combined_data = {}
# parse data from page path
# example: hash:/page/index.mu`field1=123|field2=456
page_data = None
Expand All @@ -1685,9 +1704,20 @@ def on_file_download_progress(progress):
page_path_to_download = page_path_parts[0]
page_data = self.convert_nomadnet_string_data_to_map(page_path_parts[1])

# Field data
field_data = self.convert_nomadnet_field_data_to_map(field_data)

# Combine page data and field data
if page_data is not None:
combined_data.update(page_data)
if field_data is not None:
combined_data.update(field_data)


# convert destination hash to bytes
destination_hash = bytes.fromhex(destination_hash)


# handle successful page download
def on_page_download_success(page_content):
asyncio.run(client.send_str(json.dumps({
Expand Down Expand Up @@ -1727,7 +1757,7 @@ def on_page_download_progress(progress):
# todo: handle page download progress

# download the page
downloader = NomadnetPageDownloader(destination_hash, page_path_to_download, page_data, on_page_download_success, on_page_download_failure, on_page_download_progress)
downloader = NomadnetPageDownloader(destination_hash, page_path_to_download, combined_data, on_page_download_success, on_page_download_failure, on_page_download_progress)
await downloader.download()

# unhandled type
Expand Down
109 changes: 71 additions & 38 deletions src/frontend/components/App.vue

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/frontend/components/SidebarLink.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<template>
<RouterLink :to="to" v-slot="{ href, route, navigate, isActive, isExactActive }" custom>
<a :href="href" @click="handleNavigate($event, navigate)" type="button" :class="[ isExactActive ? 'bg-blue-100 text-blue-800 group:text-blue-800' : 'hover:bg-gray-100']" class="w-full text-gray-800 group flex gap-x-3 rounded-r-full p-2 mr-2 text-sm leading-6 font-semibold focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600">
<a
:href="href"
@click="handleNavigate($event, navigate)"
type="button"
:class="[
isExactActive
? 'bg-blue-100 text-blue-800 group:text-blue-800 dark:bg-zinc-800 dark:text-blue-300'
: 'hover:bg-gray-100 dark:hover:bg-zinc-700'
]"
class="w-full text-gray-800 dark:text-zinc-200 group flex gap-x-3 rounded-r-full p-2 mr-2 text-sm leading-6 font-semibold focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 dark:focus-visible:outline-zinc-500"
>
<span class="my-auto">
<slot name="icon"></slot>
</span>
Expand All @@ -11,6 +21,7 @@
</RouterLink>
</template>


<script>
export default {
name: 'SidebarLink',
Expand Down
63 changes: 36 additions & 27 deletions src/frontend/components/about/AboutPage.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<template>
<div class="flex flex-col flex-1 overflow-hidden min-w-full sm:min-w-[500px]">
<div class="flex flex-col flex-1 overflow-hidden min-w-full sm:min-w-[500px] dark:bg-zinc-950">
<div class="overflow-y-auto space-y-2 p-2">

<!-- app info -->
<div v-if="appInfo" class="bg-white rounded shadow">
<div class="flex border-b border-gray-300 text-gray-700 p-2 font-semibold">App Info</div>
<div class="divide-y text-gray-900">
<div v-if="appInfo" class="bg-white dark:bg-zinc-900 rounded shadow">
<div class="flex border-b border-gray-300 dark:border-zinc-700 text-gray-700 dark:text-zinc-200 p-2 font-semibold">App Info</div>
<div class="divide-y divide-gray-200 dark:divide-zinc-800 text-gray-900 dark:text-zinc-200">

<!-- version -->
<div class="flex p-1">
<div class="mr-auto">
<div>Versions</div>
<div class="text-sm text-gray-700">MeshChat v{{ appInfo.version }} • RNS v{{ appInfo.rns_version }} • LXMF v{{ appInfo.lxmf_version }}</div>
<div class="text-sm text-gray-700 dark:text-zinc-400">
MeshChat v{{ appInfo.version }} • RNS v{{ appInfo.rns_version }} • LXMF v{{ appInfo.lxmf_version }}
</div>
</div>
<div class="hidden sm:block mx-2 my-auto">
<a target="_blank" href="https://github.com/liamcottle/reticulum-meshchat/releases" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500">
<a target="_blank"
href="https://github.com/liamcottle/reticulum-meshchat/releases"
type="button"
class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 dark:bg-zinc-700 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 dark:hover:bg-zinc-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500 dark:focus-visible:outline-zinc-600">
Check for Updates
</a>
</div>
Expand All @@ -24,10 +29,12 @@
<div class="flex p-1">
<div class="mr-auto">
<div>Reticulum Config Path</div>
<div class="text-sm text-gray-700 break-all">{{ appInfo.reticulum_config_path }}</div>
<div class="text-sm text-gray-700 dark:text-zinc-400 break-all">{{ appInfo.reticulum_config_path }}</div>
</div>
<div v-if="isElectron" class="mx-2 my-auto">
<button @click="showReticulumConfigFile" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500">
<button @click="showReticulumConfigFile"
type="button"
class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 dark:bg-zinc-700 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 dark:hover:bg-zinc-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500 dark:focus-visible:outline-zinc-600">
Show in Folder
</button>
</div>
Expand All @@ -37,10 +44,12 @@
<div class="flex p-1">
<div class="mr-auto">
<div>Database Path</div>
<div class="text-sm text-gray-700 break-all">{{ appInfo.database_path }}</div>
<div class="text-sm text-gray-700 dark:text-zinc-400 break-all">{{ appInfo.database_path }}</div>
</div>
<div v-if="isElectron" class="mx-2 my-auto">
<button @click="showDatabaseFile" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500">
<button @click="showDatabaseFile"
type="button"
class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 dark:bg-zinc-700 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 dark:hover:bg-zinc-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500 dark:focus-visible:outline-zinc-600">
Show in Folder
</button>
</div>
Expand All @@ -49,57 +58,57 @@
<!-- database file size -->
<div class="p-1">
<div>Database File Size</div>
<div class="text-sm text-gray-700">{{ formatBytes(appInfo.database_file_size) }}</div>
<div class="text-sm text-gray-700 dark:text-zinc-400">{{ formatBytes(appInfo.database_file_size) }}</div>
</div>

</div>
</div>

<!-- reticulum status -->
<div v-if="appInfo" class="bg-white rounded shadow">
<div class="flex border-b border-gray-300 text-gray-700 p-2 font-semibold">Reticulum Status</div>
<div class="divide-y text-gray-900">
<div v-if="appInfo" class="bg-white dark:bg-zinc-900 rounded shadow">
<div class="flex border-b border-gray-300 dark:border-zinc-700 text-gray-700 dark:text-zinc-200 p-2 font-semibold">Reticulum Status</div>
<div class="divide-y divide-gray-200 dark:divide-zinc-800 text-gray-900 dark:text-zinc-200">

<!-- instance mode -->
<div class="p-1">
<div>Instance Mode</div>
<div class="text-sm text-gray-700">
<span v-if="appInfo.is_connected_to_shared_instance" class="text-orange-600">Connected to Shared Instance</span>
<span v-else class="text-green-600">Running as Standalone Instance</span>
<div class="text-sm text-gray-700 dark:text-zinc-400">
<span v-if="appInfo.is_connected_to_shared_instance" class="text-orange-600 dark:text-orange-400">Connected to Shared Instance</span>
<span v-else class="text-green-600 dark:text-green-400">Running as Standalone Instance</span>
</div>
</div>

<!-- transport mode -->
<div class="p-1">
<div>Transport Mode</div>
<div class="text-sm text-gray-700">
<span v-if="appInfo.is_transport_enabled" class="text-green-600">Transport Enabled</span>
<span v-else class="text-orange-600">Transport Disabled</span>
<div class="text-sm text-gray-700 dark:text-zinc-400">
<span v-if="appInfo.is_transport_enabled" class="text-green-600 dark:text-green-400">Transport Enabled</span>
<span v-else class="text-orange-600 dark:text-orange-400">Transport Disabled</span>
</div>
</div>

</div>
</div>

<!-- my addresses -->
<div v-if="config" class="bg-white rounded shadow">
<div class="flex border-b border-gray-300 text-gray-700 p-2 font-semibold">My Addresses</div>
<div class="divide-y text-gray-900">
<div v-if="config" class="bg-white dark:bg-zinc-900 rounded shadow">
<div class="flex border-b border-gray-300 dark:border-zinc-700 text-gray-700 dark:text-zinc-200 p-2 font-semibold">My Addresses</div>
<div class="divide-y divide-gray-200 dark:divide-zinc-800 text-gray-900 dark:text-zinc-200">
<div class="p-1">
<div>Identity Hash</div>
<div class="text-sm text-gray-700">{{ config.identity_hash }}</div>
<div class="text-sm text-gray-700 dark:text-zinc-400">{{ config.identity_hash }}</div>
</div>
<div class="p-1">
<div>LXMF Address</div>
<div class="text-sm text-gray-700">{{ config.lxmf_address_hash }}</div>
<div class="text-sm text-gray-700 dark:text-zinc-400">{{ config.lxmf_address_hash }}</div>
</div>
<div class="p-1">
<div>LXMF Propagation Node Address</div>
<div class="text-sm text-gray-700">{{ config.lxmf_local_propagation_node_address_hash }}</div>
<div class="text-sm text-gray-700 dark:text-zinc-400">{{ config.lxmf_local_propagation_node_address_hash }}</div>
</div>
<div class="p-1">
<div>Audio Call Address</div>
<div class="text-sm text-gray-700">{{ config.audio_call_address_hash }}</div>
<div class="text-sm text-gray-700 dark:text-zinc-400">{{ config.audio_call_address_hash }}</div>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit a6ebf73

Please sign in to comment.