Skip to content

Commit

Permalink
bring back hello page #18
Browse files Browse the repository at this point in the history
minor references fix
  • Loading branch information
reisfmb committed Dec 13, 2023
1 parent ea58dba commit 044a4a8
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/content-types.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The content type is defined in a file, looking like this:
.src/main/resources/site/content-types/city/city.xml
[source,xml]
----
include::{sourcedir}/src/main/resources/site/content-types/city/city.xml[]
include::{sourcedir}src/main/resources/site/content-types/city/city.xml[]
----

Visit these links for more information about https://developer.enonic.com/docs/xp/stable/cms/content-types[Content types^] and the https://developer.enonic.com/docs/xp/stable/cms/schemas[schema system^]
8 changes: 4 additions & 4 deletions docs/pages.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ In addition to the controller, this component also uses an html template - aka t

TIP: The JavaScript controller file must use the same name as the component directory.

.src/main/resources/site/pages/hello/hello.js
[source,JavaScript]
.src/main/resources/site/pages/hello/hello.ts
[source,js]
----
include::{sourcedir}/src/main/resources/site/pages/hello/hello.js[]
include::{sourcedir}src/main/resources/site/pages/hello/hello.ts[]
----

.src/main/resources/site/pages/hello/hello.html
[source,HTML]
----
include::{sourcedir}/src/main/resources/site/pages/hello/hello.html[]
include::{sourcedir}src/main/resources/site/pages/hello/hello.html[]
----

NOTE: The view is plain HTML, but also uses a specific syntax known as the https://market.enonic.com/vendors/enonic/thymeleaf-lib[Thymeleaf^] templating language. The Enonic runtime also supports many other options, such as https://market.enonic.com/vendors/enonic/react4xp-lib[React^], https://market.enonic.com/vendors/enonic/mustache-lib[Mustache^] and https://market.enonic.com/vendors/tineikt/freemarker-xp-library[Freemarker^]
Expand Down
2 changes: 1 addition & 1 deletion docs/setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Select the `intro` sandbox from the list, and it will boot up in development mod

TIP: Dev mode will automatically load changes in your code when developing.

== Create app
== Create the app

From a **new terminal window**, run the following command to create the application.

Expand Down
2 changes: 1 addition & 1 deletion docs/static-assets.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Let's put it to work by adding the CSS to the page component:
.src/main/resources/site/pages/hello/hello.html
[source,HTML]
----
include::{sourcedir}/code-samples/pages/hello-static/hello.html[]
include::{sourcedir}code-samples/pages/hello-static/hello.html[]
----

There are only two changes in this file, one line that includes the css file, and a small attribute on the html element to activate dark mode support.
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/site/pages/hello/hello.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title data-th-text="${displayName}">Sample title</title>
</head>
<body>
<h1 data-th-text="${displayName} + ' - we made it!'">Sample header</h1>
</body>
</html>
27 changes: 27 additions & 0 deletions src/main/resources/site/pages/hello/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Response } from '/index.d';

// @ts-expect-error no-types
import {render} from '/lib/thymeleaf';
import {getContent} from '/lib/xp/portal';

// Specify the view file to use
const VIEW = resolve('./hello.html');

// Handle the GET request
export function get(): Response {

// Get the content that is using the page
const content = getContent();

// Prepare the model that will be passed to the view
const model = {
displayName: content.displayName
}

// Prepare the response object
const response: Response = {
body: render(VIEW, model)
};

return response;
}
6 changes: 6 additions & 0 deletions src/main/resources/site/pages/hello/hello.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<page>
<display-name>Hello Page Controller</display-name>
<form>
</form>
</page>

0 comments on commit 044a4a8

Please sign in to comment.