Skip to content
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

added cutomIndexTemplate option to kiwix-serve #607

Merged
merged 2 commits into from Oct 12, 2021
Merged

Conversation

MananJethwani
Copy link
Collaborator

@MananJethwani MananJethwani commented Aug 20, 2021

this fixes #571

@codecov
Copy link

codecov bot commented Aug 20, 2021

Codecov Report

Merging #607 (30e4c54) into master (e46b0c0) will decrease coverage by 2.86%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #607      +/-   ##
==========================================
- Coverage   66.10%   63.23%   -2.87%     
==========================================
  Files          53       53              
  Lines        3815     3452     -363     
  Branches     1913     1933      +20     
==========================================
- Hits         2522     2183     -339     
+ Misses       1291     1266      -25     
- Partials        2        3       +1     
Impacted Files Coverage Δ
src/server/internalServer.h 100.00% <ø> (ø)
src/tools/pathTools.cpp 50.27% <66.66%> (-7.77%) ⬇️
include/server.h 100.00% <100.00%> (ø)
src/server.cpp 70.00% <100.00%> (-19.29%) ⬇️
src/server/internalServer.cpp 82.41% <100.00%> (-1.16%) ⬇️
src/tools/otherTools.cpp 82.56% <0.00%> (-9.99%) ⬇️
src/manager.cpp 75.78% <0.00%> (-2.20%) ⬇️
src/server/request_context.cpp 63.04% <0.00%> (-1.91%) ⬇️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e46b0c0...30e4c54. Read the comment docs.

@MananJethwani
Copy link
Collaborator Author

@mgautierfr @veloman-yunkan, where can I add test for customIndexTemplate, and exactly how, are there any tests for other arguments like withLibraryButton which I can refer to.

@veloman-yunkan
Copy link
Collaborator

@mgautierfr @veloman-yunkan, where can I add test for customIndexTemplate, and exactly how, are there any tests for other arguments like withLibraryButton which I can refer to.

@MananJethwani I don't think there is such a test. I also believe that the best way to test this functionality would be in kiwix-tools, by running the kiwix-serve binary via pytest. Please see kiwix/kiwix-tools#375 for how I had intended to do something similar, before @kelson42 fairly pointed out that that feature better be tested in libkiwix via googletest.

@kelson42
Copy link
Collaborator

I want indeed to have the httpd daemon primitive tested within libkiwix and I don't understand what stop us to do it.

1 similar comment
@kelson42
Copy link
Collaborator

I want indeed to have the httpd daemon primitive tested within libkiwix and I don't understand what stop us to do it.

@MananJethwani
Copy link
Collaborator Author

@kelson42 and @veloman-yunkan can you please have a look at the tests I have created, thanks.

@kelson42 kelson42 marked this pull request as ready for review August 24, 2021 19:05
@kelson42
Copy link
Collaborator

@MananJethwani We should add a document in the README about the template variables which are exposed.

@MananJethwani MananJethwani force-pushed the issue/571 branch 3 times, most recently from 80a4b06 to 24540db Compare August 27, 2021 19:19
@mgautierfr
Copy link
Member

I wonder if this is not a bit too much.
The main need in #571 is to customize the style/text of what is displayed.
With this PR we allow the user to change almost everything. We the constraints that he must correctly do everything.
If he changes the js, he also must do the correctly js call to our server (or it own using our API). It introduces de facto a new public API on our side.

Maybe it is enough to let the user set the index title and allowing it to simply set a custom css ?
For now, this PR make me feel we are opening a Pandora's box.

src/server/internalServer.cpp Outdated Show resolved Hide resolved
src/server/internalServer.cpp Outdated Show resolved Hide resolved
src/server/internalServer.cpp Outdated Show resolved Hide resolved
@kelson42
Copy link
Collaborator

@MananJethwani Hi, any feedback here to Matthieu's comments?

@MananJethwani
Copy link
Collaborator Author

MananJethwani commented Sep 12, 2021

@kelson42 extremely sorry for the delay will update the PR by tomorrow

P.S. - sorry I actually missed the mail😅

Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments in the code.

You've adapted the test code but we don't really test the feature itself as we never try to run a test with a custom template.
A basic test would be to pass a custom template with a specific word/sentence and check that this word is correctly present in the output.

src/server/internalServer.cpp Outdated Show resolved Hide resolved
src/server/internalServer.h Outdated Show resolved Hide resolved
include/tools.h Show resolved Hide resolved
@MananJethwani
Copy link
Collaborator Author

@mgautierfr any updates?

@kelson42
Copy link
Collaborator

I have rebased the branch on origin/master

Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need a bit more testing. To be sure we actually use the custom template index passed.

I think you can also simplify the git history. We probably need two commits :

  • One to add the handling off the customIndexTemplate (and the associated tests)
  • One to expose the 3 helper functions in tools.h

test/server.cpp Outdated Show resolved Hide resolved
src/server/internalServer.cpp Outdated Show resolved Hide resolved
test/server.cpp Outdated Show resolved Hide resolved
test/server.cpp Outdated Show resolved Hide resolved
@MananJethwani
Copy link
Collaborator Author

@mgautierfr any updates?
I have made the changes as requested

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a user perspective, works as expected.

Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet a last easy fix in the test (I could have found this in previous review but miss it because of the double reset).

Everything else is good.

test/server.cpp Outdated Show resolved Hide resolved
@mgautierfr mgautierfr merged commit 08e3d52 into master Oct 12, 2021
@mgautierfr mgautierfr deleted the issue/571 branch October 12, 2021 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kiwix Serve welcome page title should be customizable
4 participants