Bug 28325 - Build Mojolicious controller replacement for tools-home.pl
Summary: Build Mojolicious controller replacement for tools-home.pl
Status: RESOLVED WISHLIST
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-12 00:42 UTC by David Cook
Modified: 2023-11-07 02:34 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 28235: Build core functionality for Mojolicious controllers (14.67 KB, patch)
2021-05-12 09:19 UTC, David Cook
Details | Diff | Splinter Review
Bug 28235: Build core functionality for Mojolicious controllers (14.56 KB, patch)
2021-05-12 09:20 UTC, David Cook
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2021-05-12 00:42:42 UTC
As per an email to koha-devel, I'm going to take the core Mojolicious code from Bug 26791, and try implementing it with a much simpler controller to replace tools-home.pl.

The key prerequisites for the controller are authentication, authorization, and template rendering. 

It may be necessary to split out other bug reports to focus on refactoring Koha's existing code, rather than bolting an alternative onto Koha, which could just create maintenance woes.
Comment 1 David Cook 2021-05-12 09:14:29 UTC
Test plan:

1. cp debian/templates/plack.psgi /etc/koha/sites/kohadev/plack.psgi
2. koha-plack --restart kohadev 
3. koha-translate -i fr-FR
4. Update "language" system preference to include French
5. Go to http://localhost:8081/cgi-bin/koha/staff/tools/home
6. Note that it looks the same as http://localhost:8081/cgi-bin/koha/tools/tools-home.pl
7. Choose "Français" from the language bar
8. Go to http://localhost:8081/cgi-bin/koha/staff/tools/home
9. Note that it looks the same (in French) as http://localhost:8081/cgi-bin/koha/tools/tools-home.pl


NOTES:
- You cannot login at http://localhost:8081/cgi-bin/koha/staff/tools/home. It will redirect you to index.html where you will be prompted to login. You'll then have to navigate back to http://localhost:8081/cgi-bin/koha/staff/tools/home.
Comment 2 David Cook 2021-05-12 09:19:09 UTC
Created attachment 120857 [details] [review]
Bug 28235: Build core functionality for Mojolicious controllers

WIP
Comment 3 David Cook 2021-05-12 09:20:47 UTC
Created attachment 120858 [details] [review]
Bug 28235: Build core functionality for Mojolicious controllers
Comment 4 David Cook 2021-05-12 09:23:21 UTC Comment hidden (obsolete)
Comment 5 David Cook 2021-05-12 09:26:19 UTC
I'm getting the following in the Plack error logs, but that's because C4::Templates is the worst, and I need to refactor it so it's not so tightly coupled to CGI. 

[2021/05/12 09:24:37] [WARN] no query in gettemplate at /kohadevbox/koha/C4/Templates.pm line 206.
[2021/05/12 09:24:37] [WARN] no query in themelanguage at /kohadevbox/koha/C4/Templates.pm line 266.
[2021/05/12 09:24:37] [WARN] no query in themelanguage at /kohadevbox/koha/C4/Templates.pm line 266.
[2021/05/12 09:24:37] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 279.
[2021/05/12 09:24:37] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 280.
[2021/05/12 09:24:37] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 282.
[2021/05/12 09:24:37] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296.
[2021/05/12 09:24:37] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296.
[2021/05/12 09:24:37] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296.
Comment 6 David Cook 2021-05-13 01:26:06 UTC
Bug 15204 makes me think that a Koha::Session module would be a good idea. 

It could be a good idea to actually have authentication in Koha::AuthN and authorization in Koha::AuthZ as well. After all, there are many ways to authenticate with Koha, but there's only one way to authorize. They're two separate activities, so they probably should be separate modules.
Comment 7 David Cook 2023-11-07 02:34:29 UTC
The patch is outdated and realistically we're not moving in this direction anyway