Keystone-classic: Custom Admin UI routes

Created on 12 Sep 2014  路  11Comments  路  Source: keystonejs/keystone-classic

Is there a way to keep the default Admin UI but change the routes from /keystone to something else ie (/admin)?

discussion enhancement

Most helpful comment

Hello

It's too simple to change the admin path.
I have spend 2 days for that how do i change the admin path and it's just on config to set the admin

keystone.set('admin path' , "admin")
Let me know if you need any help

skype : patelmit69

All 11 comments

Fro my understanding so far a quick answer is no.
But you could route /admin to keystone.View(req, res), but this will again land you in /keystone.

app.get('/admin', routes.views.index);

Hm, we can introduce a new settings option called admin path String that you should set like any other variable inside init().

@JedWatson ? Let me know and can PR that, sounds like a super quick thing.

This isn't simple because the /keystone path is hard-coded in resources that are checked in to the repo (js / css). We need to get a dynamic build on app init happening first for both js and css that can take into account keystone settings, including generating our css from a template.

All of this is on the roadmap, just wanted to explain why it hasn't been done yet.

I added my workaround to https://github.com/frederik/keystone-admin-routes (just a temporary solution since I needed to get this going with subdirectories). Feedback and pull requests are welcome.

@frederik I like your solution, I'm thinking about modifying it a bit so I can swap /keystone to /admin(rather than a subdirectory), I would also need to use an nginx rewrite to then proxy anything from /admin back to /keystone.

Until there is an easy way to decouple the path from the assets, I can't think of a better solution.

I'd been working on a solution for this as well, not sure if it's worth submitting now that @milosdakic submitted his PR. My implantation was a bit different though.

  • treat the Keystone API, the Admin UI routes and the assets used by Admin UI (i.e. css, js plugins, images, fonts, etc.) as separate resources
  • leave the Keystone API routes as-is (i.e. /keystone/api/*)
  • decouple Admin UI assets from the Admin UI routes (i.e. create an Express router to handle routes to all Admin UI assets, mounted as /keystone/assets/ or something along those lines)
  • point all asset the their new location using absolute URIs
  • now we're free to mount the Admin UI router anywhere

I have a working version of this that I'm still testing (successfully so far) on a local dirty branch. If you guys think this may be a viable solution I can package it in a PR and submit it.

@JohnnyEstilles my PR will allow us to do that in stages. Maybe you could take a look and see if my PR could be amended with your changes?

@milosdakic! Like yours, my first attempt was to do it in stages, but ran into a number of issues (including the one mentioned by @JedWatson in your PR). What I describe in my comment above is the minimum number of changes I could come up with to implement this. That said, I still have more testing to do to ensure I haven't inadvertently introduced any bugs.

I will pull your PR and check it out.

I assume this is closed in 0.4.0, no? At least I can modify the admin URI just fine in the current git master. So should be closed unless the intention is to backport this feature to 0.3.x.

AFAIK this has landed in v0.4

Hello

It's too simple to change the admin path.
I have spend 2 days for that how do i change the admin path and it's just on config to set the admin

keystone.set('admin path' , "admin")
Let me know if you need any help

skype : patelmit69

Was this page helpful?
0 / 5 - 0 ratings