Running the demo
Contents
On this page, you’ll run the finished application from this tutorial without going through the chapters. It takes a few minutes and gives you a local Enonic XP instance populated with the completed schemas, sample content and media, ready to inspect in Content Studio and query through Guillotine.
| Want to learn how each part works? Start with the first chapter of the tutorial instead. |
To run the demo you will need the Enonic CLI and Git, in addition to the prerequisites of the tutorial.
Task: Start Enonic
The demo runs in its own sandbox, a local instance of Enonic XP.
-
Create the demo sandbox - Run this command in your terminal. It works from any folder:
enonic sandbox create demo_modeling -t essentials -fThe
essentialstemplate installs Content Studio and the Guillotine GraphQL API. The-fflag accepts the defaults for the remaining prompts, including the latest version of Enonic XP, and starts the sandbox.The demo uses its own sandbox ( demo_modeling), separate from thetutorial_modelingsandbox used in the chapters. All sandboxes share port8080by default, so stop any other running sandbox before starting this one. -
Verify that the sandbox is running - Wait for the terminal to report that Enonic XP has started, then open http://localhost:8080. The Enonic SDK welcome page appears.
Leave the sandbox running in this terminal window. To stop it, press ctrl-c. To start it again later, run enonic sandbox start demo_modeling from any folder.
Task: Deploy the completed app
-
Get the code - Open a new terminal window in the folder where you keep your tutorial projects, and clone the repository:
git clone https://github.com/enonic/tutorial-content-modeling.gitThis creates a
tutorial-content-modeling/folder containing the finishedcom.example.tutorial.modelingapplication and its sample content. -
Link and deploy the app - Enter the folder, link it to the demo sandbox, and deploy:
cd tutorial-content-modeling enonic project sandbox demo_modeling -f enonic project deploy -fThe CLI builds the app and deploys it to
demo_modeling. On first startup, the app creates theMy First Project(my-first-project) content project, imports the sample artists, animals and images, and publishes them.
Task: Explore the content and GraphQL API
-
Inspect the content in Content Studio - On the welcome page at http://localhost:8080, click Log In as Guest, then open
XP menu→Content Studio.Select
My First Projectin the top bar if it is not already open. You’ll see theAnimals,ArtistsandImagesfolders with 11 published content items — open Cardi B, Lion or Lynx to inspect their fields, references, rich text and Editorial mixin tab. -
Query the model in Query Playground - Click the GraphQL icon in Content Studio’s left menu bar, keep
My First Projectselected, and run this query:{ guillotine { queryDsl( query: { term: { field: "type" value: { string: "com.example.tutorial.modeling:artist" } } } sort: [{ field: "displayName", direction: ASC }] ) { displayName ... on com_example_tutorial_modeling_Artist { data { legalName birthday filmography { title year } favoriteAnimal { displayName ... on com_example_tutorial_modeling_Animal { data { otherNames feedingBehavior { _selected } images { ... on media_Image { imageUrl(scale: "block(400,600)") { path queryString } } } } } } } } x { com_example_tutorial_modeling { editorial { notes } } } } } }The response returns Cardi B, Missy Elliott and P!nk along with their filmography item sets, linked favorite animals, feeding behavior option sets, cropped image URL components and editorial mixin notes.
-
Test the public HTTP endpoint - Because the startup task published the content to
masterin a public project, you can also queryhttp://localhost:8080/api/com.enonic.app.guillotine:graphqldirectly from a terminal without authentication:curl 'http://localhost:8080/api/com.enonic.app.guillotine:graphql' \ -H 'Content-Type: application/json' \ --data-binary '{"query":"{ guillotine(project: \"my-first-project\", branch: \"master\") { get(key: \"/animals/lynx\") { displayName ... on com_example_tutorial_modeling_Animal { data { description { processedHtml } } } } } }"}'
How it works
The repository packages both the tutorial’s YAML schemas and a startup task that initializes sample data on first run. Everything lives under src/main/resources/:
-
cms/ -
The YAML schemas built across the tutorial: the
artistandanimalcontent types, thedistributionDataform fragment, theeditorialmixin,cms.yamlandstyle.yaml -
import/ -
Exported content items and image binaries for the
Artists,AnimalsandImagesfolders -
main.jsandtasks/initialize/ -
Schedules a one-time initialization task on startup that creates
my-first-project, assignscom.example.tutorial.modeling, imports the bundled content, and publishes it tomaster(ifmy-first-projectalready exists, your edits are left untouched)
If you want to experiment with changing the schemas in tutorial-content-modeling/ and see updates redeployed automatically, run enonic dev from that folder.
Each schema and query pattern is explained step by step in the tutorial, starting with setting up your environment.