New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Routing Improvements #1279
Comments
Please allow This will allow us to build redirects from other systems to new pages on pOS. |
That was already fixed about a month ago |
Control over the first level slug, currently we can not control test in website.com/test - it would allow for full dynamic routing and a basic htaccess level of control (at least for routing) |
It throws a 404 for me, so maybe it re-broke? -> https://www.dropbox.com/s/q21aup727xx7bq8 |
Works for me on staging, the latest version of pos-cli doesn't have the editor anymore so I couldn't compare apple for apples. |
Moving this here from ClickUp. I brought this up ages ago, and I still think it's a good idea. One of the messiest experiences I have in pOS is working with The linked doc is a good start to a spec for this. I think this would become a favorite feature for a lot of people. There are some updates I would make to this spec that I think would make it a little more flexible. For instance, I wouldn't:
Instead, I would:
|
Matt issue is the dot in the middle of the path, not in its last part - @onecreative if you had an equivalent of the |
Progress is going well for this one - it seems we should be able to start QA-ing some of the routing improvements at the end of the next week. The first iteration should ensure the new system is in place with full backward compatibility, as well as the possibility to use named parameters, including the possibility of creating a Page to which all requests will be routed. |
All requests? Including assets and media? Is it for a site is down message or something? |
@richxrich assets/media served through CDN of course not. Sometimes you might want to handle routes via JS. The maintenance page is another use case, which would require a bit slightly different treatment because the way this Page |
@Slashek so its for a single file application website? Maybe I'll wait until I see it |
@richxrich yes, it's one of the use cases! @mattwalter91 the possibility of having |
I'm keen for total routing, but transparently. Will we have to have a visual static first slug or is it a behind the scenes thing? Not looking for the PHP methods of
or something in POS where "module" or whatever had in the URL, would mean the entire site would have to run in second level slug
Is it possible to route everything to the "module" file (in this example) and also run the site directly from slug1? i.e.
with "module.liquid" as the route processor (just making up names here) |
@richxrich one will be able to create a slug What I mean by expanding is that currently if you create a page with slug |
@Slashek, I'd like to see this go one step further by introducing For example, instead of having one page with
and
As the child page, the business_member slug would be relative to the parent, making it effectively As a child, the yaml from the parent would also be available for reference purposes. |
I like the idea of the parenthesis making part of the slug optional. (i.e.,
and
The child page would always equate to |
@onecreative : For parent, you are assuming that all sub pages (children) have the same parent / URL structure. Case example, products listed in multiple categories will have different parents / urls. For parent, clientside you could use go back This assumes the page knows it has a parent (a little hacky as well) But I'm guessing you want to do this for breadcrumbs on a page. If the page doesn't know if it has a parent or not:
Example could be cleaned up and you can then loop it in a nice function and build dynamic breadcrumbs based on the URL structure. |
There are a lot of ways to create page relationships. I doubt the parent/child model I explained will meet all of those needs. Its main purpose is to reduce the complexity of pages that would otherwise have multi-page logic in them. Personally, I don't like having a ton of partials that I treat as "pages". |
@richxrich The relationship is defined on the child page's yaml, so the page would definitely know it has a parent. |
Also, @richxrich, the page content is decided by you, not the url. This pattern will work for multi-category product catalogs just as easily as the one I explained. The child page has access to the parent page yaml data, so your logic can use that pattern however you need. In the end, it's just a pattern like we are already successfully using with |
@onecreative Not saying it's a bad idea for some use cases, just we would not use it all because we don't have linear parents and children. |
@richxrich That's cool. No feature will meet every need. I'm curious, though. Can you give me an example parent/child relationship that wouldn't work with it? |
Currently, the page is an all-in-one thing - it's routing, it's a controller, it's also a view. What we are thinking about as part of the new routine is to remove the |
Sounds like a steeper learning curve and less intuitive user experience. |
@Slashek Whatever happens here, it shouldn't steepen the learning curve. Right? This doesn't sound like a good direction. Can you sell me on it? |
Just a note that the new routing engine has been deployed to staging. @onecreative it simplifies the directory structure [ no need for app/views/pages and app/views/partials ], as in the routing file you will be able to say which template you would like to render as which route - it will be easy to get an overview of the application thanks to this. Additionally, when you create modules, it's not clear where "Page" belongs - because the rendering part most of the time should belong to the module, however, the routing usually belongs to the application - but right now it's combined. Later on, it should also allow for easier namespace management, I imagine authorization policies could be easily applied to the whole namespace [ which you probably referred to as |
@Slashek What is the roadmap plan for "where the page belongs" - Are you thinking of pushing things into app or keeping it combined? |
@Slashek I don't see the vision like you do, and I've never seen it in action. I just hope this doesn't make pOS more difficult. It sounds like a move that is driven by SPAs and backend coding conventions. That said, if it makes its setup more logical and enables better control, it will be easier to teach even if it is different. |
@pavelloz Was that aimed at me? |
So "svelte way" is pretty much what we already do - by default
|
|
@Slashek I don't entirely know how it's related, but I keep feeling like we need to solve the lack of 301 management as part of this. Otherwise, I think we could end up getting stuck in a direction that won't be ideal for solving that problem. |
There are a few big nuisances I have when working with PlatformOS:
I firmly believe that the new routing implementation could resolve all of these issues if done correctly. I am all for decoupling routing from page processing. Routes should point to defined
If we utilize YML, then route definition would look very similar to what we have in pages right now.
There is a matter of where to store these routes. We could keep each route in a separate file, or we could have one configuration file, storing routes for the whole application. I prefer the second approach, as I can easily see the entire URL schema in one place and adjust related routes easily. I am having a hard time figuring out how to achieve all that with only file name based routes:
Finally, I believe we can have our cake and eat it too. Moreover, I think we will be forced to do so to keep the current system backward compatible. We could use one routing file, like |
I like and agree with @chrisdanek 's comments. And on the 301 issue I mentioned, I think we should have a special table for 301s that is managed exclusively via graphql. The system will look at the |
I got frustated so created my own endpoints and process to handle everything... but can only do so much without routing |
How would this work with search parameter naming conflicts? For instance: Would the output be |
@onecreative wouldn't that be the same as /test?id=12&id=54 Under a usual HTML server the form data would be id=12,54 but under POS the ID is the last element, in this case 54 (unless you process the headers manually). I'm assuming the same here? |
We could avoid the conflict completely if slugs were not accessed in the same place as search params. |
There isn't a conflict I don't think, same thing happens currently if you have a querystring variable and a form variable with the same name... it takes the later one (in my opinion it should be an array) but hey. |
The engine is stable, will close this card as consider phase 1 done. For further improvements, we'll create a separate issue. |
for example, defining slug
products/:id/reviews/:review_id
should be able to match URLproducts/1/reviews/2
and automatically populatecontext.params.id
with1
andcontext.params.review_id
with 2- As a developer, when I define slug
my_page
it should raise 404 for URL/my_page/something
- As a developer, I should be able to use anywhere in the slug
- As a developer, I would like to point all request to one page
The text was updated successfully, but these errors were encountered: