Is there a way to change the url paths in CKAN? - slug

I want to change mysite.org/organization/someinstitution to mysite.org/institution/someinstitution
In ckan/ckan/config/routing.py the urls are defined like this:
m.connect('organization_read', '/organization/{id}', action='read')
Is there a way to change this using an extension or by any other means?, I don't want to modify the master branch.

Update: The current best way to implement custom organization types is to use ckanext-scheming, as described here. This will automatically register all the appropriate routes for you.
It is not as straight-forward as datasets with the IDatasetForm interface, but you can change the /organization URLs to /institution by changing the routing with the IRoutes interface.
Here is an example that changes /organization to /publisher:
https://github.com/IATI/ckanext-iati/blob/b26d2cd518f3991f3c3c954819a582393d9a7e35/ckanext/iati/plugins.py#L69:L103

Related

How can I get window.location.href in VuePress V2

I'm trying to display a dynamic link to a Quiz from inside my VuePress V2 documentation. Since that game will be hosted on several IP's, i need to dynamically generate that URL.
Game and documentation will always run on the same IP, but different port.
I am looking for something like this in my markup file:
# Quiz
[Click here to start the quiz](<script>document.write(window.location.href.replace('3000','8080')</script>)
I know I can't use script, but i am hoping for one of the following:
Like i can keep the protocol by calling //example.com and keeping the URL by calling /subfolder, maybe there is a way to call :8080// or sth...
I can make use of the fact that Vue Syntax is allowed. There is a way I can implement logic into .md files by writing
I have { 1+1 } hands.
That will convert to
I have 2 hands.
I can write a custom Vue component and in there reference window.location.href.

How do you work with resource ownership with adonis-acl

How do you manage the owner of a resource when using adonis-acl? In my application the typical pattern is that if you own the resource you have full CRUD over it but Admins also have Updated and Delete control over the resource even though they are not the owners.
Ideally I want to manage this control though middleware rather than having to then re-check ACL in my Controllers. Ideally I'm looking for something like
Route
.get('/users')
.middleware(['auth:jwt', 'is:(administrator)' 'can:read_resouce_{SOMEKINDOFID}'])
Currently is seems that the only way I can do this is to setup a permission for every single resource which for my use case seems unnecessary.
Thanks

Laravel - Secure Way to Use SQL ids in JS/Http

I'm making a web app where users can create pages, edit them, and delete them. In developing the prototype, I have a user access a route such as:
localhost:8000/mypage/1
The "1" in the URL refers to the ID in the database, so that the controller can fetch the appropriate associated data and populate the page accordingly.
The obvious problem here is that a user can plug in any number to that URL and edit someone else's page.
One obvious fix would be to add logic that checks whether or not page '1' belongs to the Auth::user(). But this would be an if statement that I have to add to every controller that carries out such function.
When I think about other sites, they never have ID's in the URL, or if they do, they look 'encrypted' in some form. What is the best practice for changing an ID into some uninterpretable string that I frequently see done on other websites?
Thank you for any help.
why don't you just use a middleware that check if the route can be acceded by the user? then you can call it with
$this->middleware('middlewareName');
in the controller that you need it or even in the web.php if you want a whole set of routes protected

React router hashHistory explained

Quote from here https://github.com/reactjs/react-router-tutorial/blob/master/lessons/02-rendering-a-route/README.md:
We're using hashHistory--it manages the routing history with the hash
portion of the url. It's got that extra junk to shim some behavior the
browser has natively when using real urls. We'll change this to use
real urls later and lose the junk, but for now, this works great
because it doesn't require any server-side configuration
Can someone please explain what this means ?
Is this something a begginner should understand ? (This seems to be a beginner tutorial.)
hashhistory simulates a nice url using the hash
symbol
example.com/#/some/path
while browserHistory uses History api to create an url like this one:
example.com/some/path
You can have a reference here: https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md

Suggested strategy for accessing the starting location in react-router onEnter hook

I am trying to implement an authentication/authorization strategy with react-router (using v2.x) via the onEnter hook. (also using redux and react-router-redux)
I think i am most of the way there, but there is a scenario where i am located in either an unprotected-or-authorized location, and i attempt a transition to a protected-and-unauthorized location where i want to "stay put", but when i hit the onEnter hook, the nextState argument is already at the unauthorized location and i am wanting to replace with the original starting location.
I am currently tinkering with saving my own history of locations in redux state to be able to have the starting location available, but it seems like there should be an easier way to accomplish the desired effect.
Any suggestions/guidance appreciated!