Refactor route and template organisation #28

Merged
glyph merged 16 commits from route_reorganisation into main 2021-11-16 07:43:38 +00:00
Owner

Major Changes

This is a major refactor which aims to group routes and templates into logical categories, as previously discussed in issue #1. It also introduces relative paths for routes so that they can be grouped categorically by mountpoint in src/main.rs.

It's challenging to have precise consistency across the whole codebase (taking into account HTML routes, JSON routes and templates) but I think this is a big step in the right direction and can be refined as we introduce new code.

All tests are passing, though I noticed that we are missing a lot of coverage. I can work on this next.

Perhaps trees are the easiest way to describe the new structure:

Routes

src/routes
├── authentication.rs
├── catchers.rs
├── index.rs
├── mod.rs
├── scuttlebutt.rs
├── settings
│   ├── admin.rs
│   ├── dns.rs
│   ├── menu.rs
│   ├── mod.rs
│   ├── network.rs
│   └── scuttlebutt.rs
└── status
    ├── device.rs
    ├── mod.rs
    └── ping.rs

Templates

templates
├── base.html.tera
├── catchers
│   ├── internal_error.html.tera
│   └── not_found.html.tera
├── device.html.tera
├── help.html.tera
├── home.html.tera
├── login.html.tera
├── nav.html.tera
├── power.html.tera
├── scuttlebutt
│   ├── messages.html.tera
│   ├── peers.html.tera
│   ├── peers_list.html.tera
│   └── profile.html.tera
├── settings
│   ├── admin
│   │   ├── add_admin.html.tera
│   │   ├── change_password.html.tera
│   │   ├── configure_admin.html.tera
│   │   ├── forgot_password.html.tera
│   │   ├── menu.html.tera
│   │   └── reset_password.html.tera
│   ├── menu.html.tera
│   ├── network
│   │   ├── configure_dns.html.tera
│   │   ├── network_add.html.tera
│   │   ├── network_card.html.tera
│   │   ├── network_detail.html.tera
│   │   ├── network_list.html.tera
│   │   ├── network_modify.html.tera
│   │   └── network_usage.html.tera
│   └── scuttlebutt.html.tera
└── snippets
    ├── flash_message.html.tera
    └── noscript.html.tera

Minor Changes

A few small UI changes snuck into this PR; things like updated icons on the /status page, a new 'power' icon in the bottom-right of the home page (replacing the question mark) etc.

**Major Changes** This is a major refactor which aims to group routes and templates into logical categories, as previously discussed in [issue #1](https://git.coopcloud.tech/PeachCloud/peach-workspace/issues/1). It also introduces relative paths for routes so that they can be grouped categorically by mountpoint in `src/main.rs`. It's challenging to have precise consistency across the whole codebase (taking into account HTML routes, JSON routes and templates) but I think this is a big step in the right direction and can be refined as we introduce new code. All tests are passing, though I noticed that we are missing a lot of coverage. I can work on this next. Perhaps trees are the easiest way to describe the new structure: **Routes** ```bash src/routes ├── authentication.rs ├── catchers.rs ├── index.rs ├── mod.rs ├── scuttlebutt.rs ├── settings │ ├── admin.rs │ ├── dns.rs │ ├── menu.rs │ ├── mod.rs │ ├── network.rs │ └── scuttlebutt.rs └── status ├── device.rs ├── mod.rs └── ping.rs ``` **Templates** ```bash templates ├── base.html.tera ├── catchers │ ├── internal_error.html.tera │ └── not_found.html.tera ├── device.html.tera ├── help.html.tera ├── home.html.tera ├── login.html.tera ├── nav.html.tera ├── power.html.tera ├── scuttlebutt │ ├── messages.html.tera │ ├── peers.html.tera │ ├── peers_list.html.tera │ └── profile.html.tera ├── settings │ ├── admin │ │ ├── add_admin.html.tera │ │ ├── change_password.html.tera │ │ ├── configure_admin.html.tera │ │ ├── forgot_password.html.tera │ │ ├── menu.html.tera │ │ └── reset_password.html.tera │ ├── menu.html.tera │ ├── network │ │ ├── configure_dns.html.tera │ │ ├── network_add.html.tera │ │ ├── network_card.html.tera │ │ ├── network_detail.html.tera │ │ ├── network_list.html.tera │ │ ├── network_modify.html.tera │ │ └── network_usage.html.tera │ └── scuttlebutt.html.tera └── snippets ├── flash_message.html.tera └── noscript.html.tera ``` **Minor Changes** A few small UI changes snuck into this PR; things like updated icons on the `/status` page, a new 'power' icon in the bottom-right of the home page (replacing the question mark) etc.
glyph added 9 commits 2021-11-15 15:44:16 +00:00
glyph added 1 commit 2021-11-15 15:54:08 +00:00
glyph added 5 commits 2021-11-15 18:58:24 +00:00
glyph changed title from WIP: Refactor route and template organisation to Refactor route and template organisation 2021-11-15 19:01:57 +00:00
glyph requested review from notplants 2021-11-15 19:02:13 +00:00
glyph added the
peach-web
label 2021-11-15 19:02:22 +00:00
Author
Owner

@notplants

This is now ready for the review. Apologies for the large number of changes; I got in the zone. Let me know if anything is unclear and we can always hop on a call to walk through it together.

@notplants This is now ready for the review. Apologies for the large number of changes; I got in the zone. Let me know if anything is unclear and we can always hop on a call to walk through it together.
glyph added the
refactor
label 2021-11-15 19:03:39 +00:00
glyph added 1 commit 2021-11-16 06:43:22 +00:00
Owner

@glyph glad you got in the zone, and looks good to me.

The diagram you made makes it pretty easy to parse and understand how it works, as well as the groupings of routes in main.rs.

I could imagine as someone trying to look through the codebase,
I might be confused by the json api routes being grouped separately from the HTML routes -- like if I am looking at the admin page, and trying to figure out where admin related routes are, I actually have to look in two places.

But I can also see why they are separated. So more just a comment on the tradeoff than a request for change. Having json and html routes, which are somewhat separate, is one of the more unconventional things about our app I think. I've sometimes been wondering if there are ways we could streamline that more. Maybe even some way using macros at some point (I think Plume does something like this, making a custom macro for routes, that does just what they need, so they can write simple, legible, minimal code, with less boilerplate).

@glyph glad you got in the zone, and looks good to me. The diagram you made makes it pretty easy to parse and understand how it works, as well as the groupings of routes in main.rs. I could imagine as someone trying to look through the codebase, I might be confused by the json api routes being grouped separately from the HTML routes -- like if I am looking at the admin page, and trying to figure out where admin related routes are, I actually have to look in two places. But I can also see why they are separated. So more just a comment on the tradeoff than a request for change. Having json and html routes, which are somewhat separate, is one of the more unconventional things about our app I think. I've sometimes been wondering if there are ways we could streamline that more. Maybe even some way using macros at some point (I think Plume does something like this, making a custom macro for routes, that does just what they need, so they can write simple, legible, minimal code, with less boilerplate).
Author
Owner

@notplants

Thanks for the review!

Yeah I'd like to figure out a way to better integrate the JSON API. It has always been a secondary concern for me and that reflects in the design. I'd be intersted in learning how other Rocket applications like Plume are handling routes and JSON.

I also had some difficultly deciding on clear separations. For example, separating admin and auth routes.

Hopefully we can continue improving this in waves. Moving through the codebase already feels like a more streamlined experience to me. Let's continue feeling for friction and discomfort when we're navigating; then use those sensations to target refactors and improvements.

@notplants Thanks for the review! Yeah I'd like to figure out a way to better integrate the JSON API. It has always been a secondary concern for me and that reflects in the design. I'd be intersted in learning how other Rocket applications like Plume are handling routes and JSON. I also had some difficultly deciding on clear separations. For example, separating `admin` and `auth` routes. Hopefully we can continue improving this in waves. Moving through the codebase already feels like a more streamlined experience to me. Let's continue feeling for friction and discomfort when we're navigating; then use those sensations to target refactors and improvements.
glyph merged commit dad9ee9392 into main 2021-11-16 07:43:38 +00:00
glyph deleted branch route_reorganisation 2021-11-16 07:43:39 +00:00
Sign in to join this conversation.
No description provided.