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

Add landing page at base URL #172

Merged
merged 13 commits into from Feb 10, 2020
Merged

Add landing page at base URL #172

merged 13 commits into from Feb 10, 2020

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Feb 7, 2020

Closes #169.

Ended up using Jinja as it is pretty lightweight and will be much easier for us to maintain and easier for other implementers to write their own landing pages.

Here's what it looks like at my end:
image

Do we need any more info? I haven't mentioned the index meta-db yet but I guess we could get a link to that. We could also render this page for bare versioned URLs too, which currently will 404.

Slightly loathed to add tests for this...

@codecov
Copy link

codecov bot commented Feb 7, 2020

Codecov Report

Merging #172 into master will decrease coverage by 0.13%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #172      +/-   ##
==========================================
- Coverage   86.37%   86.24%   -0.14%     
==========================================
  Files          39       40       +1     
  Lines        1850     1868      +18     
==========================================
+ Hits         1598     1611      +13     
- Misses        252      257       +5     
Flag Coverage Δ
#unittests 86.24% <62.50%> (-0.14%) ⬇️
Impacted Files Coverage Δ
optimade/server/routers/landing.py 66.66% <0.00%> (ø)

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 44b1b9b...2ec6c7f. Read the comment docs.

Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Looks great!

Should be added to the versioned base URLs as well, yeah.
But for those I would update the title to include "versioned" as well as have the available endpoints reflect the version we are currently under - and perhaps the base URL should show only the REQUIRED versioned base URL, i.e., vMAJOR?

To complete it, I think we should have the new OPTiMaDe logo on top when it's finally released as well including the text.

optimade/server/middleware.py Outdated Show resolved Hide resolved
optimade/server/routers/static/landing_page.html Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
.github/workflows/requirements.txt Show resolved Hide resolved
@shyamd
Copy link
Contributor

shyamd commented Feb 7, 2020

Can you add a setting to return just a JSON summary response instead of HTML? I'm not a big fan of mixing the API and the Frontend.

Another option might be to redirect to docs.

@ml-evs
Copy link
Member Author

ml-evs commented Feb 7, 2020

Can you add a setting to return just a JSON summary response instead of HTML? I'm not a big fan of mixing the API and the Frontend.

Another option might be to redirect to docs.

I would agree, and this is what we were doing previously, but there was a long discussion and now this approach is recommended by the spec. See Materials-Consortia/OPTIMADE#240

@ml-evs
Copy link
Member Author

ml-evs commented Feb 7, 2020

Updated image at top with the current iteration. Just grabbing a png logo from our GitHub org at the moment.

@CasperWA
Copy link
Member

CasperWA commented Feb 7, 2020

Looking at your updated landing page, I can see we need to update the default base URL for the index meta-database - the /index/ should be removed. This was otherwise done in #140.

Edit: I will make a commit.

@ml-evs ml-evs requested a review from CasperWA February 7, 2020 19:22
optimade/server/middleware.py Outdated Show resolved Hide resolved
optimade/server/routers/landing.py Show resolved Hide resolved
optimade/server/middleware.py Outdated Show resolved Hide resolved
@ml-evs ml-evs requested a review from CasperWA February 10, 2020 01:04
Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Thanks for this @ml-evs !

I have only one real comment, which concerns the redirect middelware.
But since you need this PR merged, I will create an issue for it and accept and merge this PR.

if request.scope["path"].endswith("/"):
if request.scope["path"].endswith("/") and any(
request.scope["path"].endswith(f"{endpoint}/")
for endpoint in list(ENTRY_COLLECTIONS.keys()) + ["info"]
Copy link
Member

Choose a reason for hiding this comment

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

So this will not catch single-entry endpoints now.

optimade/server/routers/landing.py Show resolved Hide resolved
@CasperWA CasperWA merged commit ee15c4a into master Feb 10, 2020
@CasperWA CasperWA deleted the ml-evs/add_landing_page branch February 13, 2020 16:28
@CasperWA CasperWA mentioned this pull request Feb 13, 2020
CasperWA added a commit that referenced this pull request Feb 13, 2020
Bump to v0.5.0

Changes:
- Possibility for Docker deployment for both the index meta-database
  server as well as the regular server (#140, @ltalirz, @CasperWA)
- Test building and starting Docker images with GitHub Actions CI
  (#140, @CasperWA, @ml-evs, @ltalirz)
- Remove `/index` from the index meta-database's base URL
  (#140, @ltalirz, @CasperWA)
- `include` query parameter (#163, @CasperWA)
- Rename `optimade/server/deps.py` to `optimade/server/query_params.py`
  (#163, @CasperWA)
- Human-readable landing page for versioned base URLs, as well as for
  `/optimade` (#172, @ml-evs)
- Move mapper aliases to config file and out of mapper classes
  (#175, @ml-evs)

Bug fixes:
- Properly build versioned base URLs (#178, @CasperWA)
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.

Implement a landing page for requests to the base URL
3 participants