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

Allow to create custom pages and add them to the menu. #2898

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

silenceway
Copy link

@silenceway silenceway commented Sep 26, 2023

This PR creates a new link in the admin page to go to a list of pages or allows to creation of new pages.

It saves basic page information in the database and it creates a markdown file in a pages directory within the config folder.

It shows pages in the sidebar before the books list or after the About link.

Pages can be enabled or disabled to hide them.

@digitalfredy
Copy link

@janeczku

Thanks for this great Open Source Project!

Will be appreciated if you take a look to this PR because we need to add some legal stuff like the Privacy Notice in our public library and will be great if we can have it from mainstream (we want to avoid hacks to get it done)

@digitalfredy
Copy link

@OzzieIsaacs I notice you merged some stuff recently, could you take a look to this MR?

cps/editpage.py Outdated Show resolved Hide resolved
cps/editpage.py Outdated Show resolved Hide resolved
cps/editpage.py Outdated
Comment on lines 44 to 45
page = ub.session.query(ub.Page).filter(ub.Page.id == file).first()
if page:

Choose a reason for hiding this comment

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

you could also do

Suggested change
page = ub.session.query(ub.Page).filter(ub.Page.id == file).first()
if page:
try:
page = ub.session.query(ub.Page).get_or_404(file)

And then check my comment after line 51
https://flask-sqlalchemy.palletsprojects.com/en/2.x/api/#flask_sqlalchemy.BaseQuery.get_or_404

Copy link
Author

Choose a reason for hiding this comment

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

It shows an error with get_or_404, added try.

cps/editpage.py Show resolved Hide resolved
cps/editpage.py Outdated Show resolved Hide resolved
cps/templates/edit_page.html Outdated Show resolved Hide resolved
cps/templates/list_pages.html Outdated Show resolved Hide resolved
cps/templates/page.html Outdated Show resolved Hide resolved
cps/templates/edit_page.html Outdated Show resolved Hide resolved
cps/templates/list_pages.html Outdated Show resolved Hide resolved
@digitalfredy
Copy link

@silenceway

In case your code enhances features of Calibre-Web: Create your pull request for the development branch if your enhancement consists of more than some lines of code in a local section of Calibre-Webs code. This makes it easier to test it and check all implication before it's made public.

From: https://github.com/janeczku/calibre-web/blob/master/CONTRIBUTING.md#contributing-code-to-calibre-web

Copy link

@alejandrok5 alejandrok5 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 !

@apollo1220
Copy link

@OzzieIsaacs could this be considered to be pulled in? This would be a really useful feature.

@OzzieIsaacs
Copy link
Collaborator

@apollo1220 You could speed up the process by writing some tests (https://github.com/OzzieIsaacs/calibre-web-test).

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.

5 participants