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

feat: Headless readiness #7850

Open
wants to merge 22 commits into
base: develop-4
Choose a base branch
from

Conversation

fsbraun
Copy link
Sponsor Member

@fsbraun fsbraun commented Mar 21, 2024

Description

Regular projects distribute their content through serving pages at their corresponding URL as defined in the page tree. This is achieved by adding path("", include(cms.urls)) to a project's urls.py. Also, the CMS requires CMS_TEMPLATES or CMS_TEMPLATE_DIR to be set.

This PR allows setting up headless-ready projects by:

  1. Not requiring path("", include(cms.urls)) being part of the projects URLs. All editing is done in the admin and the edit, structure and preview endpoints.

    The structure endpoint can be used on read-only objects (such as published pages), too, allowing to view the tree and copy plugins. All modifying actions are disabled for read-only objects.

  2. Not requiring any templates to be defined. If no templates are available, all interaction runs through the structure endpoint. While the editing experience might be limited, this can be a fast way of setting up a project.

  3. This PR moves the create wizard URL to the placeholder admin (which contains all editing endpoints) (but also keeps the previous endpoint in cms.urls for the wizard for compatibility reasons).

  4. The data bridge allows the frontend to update the structure board after changes in the plugin tree. This PR changes the HTML response for changes in the plugin tree from inlining the data in a script to a script tag containing JSON objects which are read and passed to the data bridge.

Related resources

Checklist

  • I have opened this pull request against develop-4
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on Slack to find a “pr review buddy” who is going to review my pull request.

@fsbraun fsbraun added this to the 4.2 milestone Apr 20, 2024
@fsbraun fsbraun changed the title feat: Move data bridge data to script tags for easier extraction. feat: Allow headless projects and move data bridge data to script tags for easier extraction. May 7, 2024
@fsbraun fsbraun removed this from the 4.2 milestone May 8, 2024
@fsbraun fsbraun added the 4.1 label May 8, 2024
@fsbraun fsbraun marked this pull request as ready for review May 8, 2024 20:39
@fsbraun fsbraun requested review from marksweb and a team May 9, 2024 07:04
@vinitkumar
Copy link
Member

@fsbraun Great work on this. I would love to see how this works in practise and what we can do with it?

@fsbraun fsbraun changed the title feat: Allow headless projects and move data bridge data to script tags for easier extraction. feat: Headless readiness May 22, 2024
@fsbraun
Copy link
Sponsor Member Author

fsbraun commented May 22, 2024

This PR includes JS and CSS changes to disable UI items in the structure board. Those changes only become visible after running gulp sass bundle.

Still, a headless-ready project for testing can be quickly set up using these steps:

  • Create a fresh venv: python3 -m venv .venv
  • Activate it: source .venv/bin/activate
  • Install PR: pip install git+https://github.com/fsbraun/django-cms@feat/data-bridge
  • Create project: djangocms headlesstest --template https://github.com/django-cms/cms-template/tarball/feat/headless
  • Spin up test server: cd headlesstest && ./manage.py runserver
  • Go to admin in the browser: http://127.0.0.1/en/admin/

The template only installs djangocms-text as plugins but works with any plugins.

@vinitkumar @marksweb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Review required
Development

Successfully merging this pull request may close these issues.

None yet

2 participants