Search in sources :

Example 11 with Head

use of org.structr.web.entity.html.Head in project structr by structr.

the class DeploymentTest method test08SharedTemplateInTwoPages.

@Test
public void test08SharedTemplateInTwoPages() {
    // setup
    try (final Tx tx = app.tx()) {
        // create first page
        final Page page1 = Page.createNewPage(securityContext, "test08_1");
        final Html html1 = createElement(page1, page1, "html");
        final Head head1 = createElement(page1, html1, "head");
        createElement(page1, head1, "title", "test08_1");
        final Body body1 = createElement(page1, html1, "body");
        final Div div1 = createElement(page1, body1, "div");
        final Template template1 = createTemplate(page1, div1, "template source - öäüÖÄÜß'\"'`");
        final Template component = createComponent(template1);
        // create second page
        final Page page2 = Page.createNewPage(securityContext, "test08_2");
        final Html html2 = createElement(page2, page2, "html");
        final Head head2 = createElement(page2, html2, "head");
        createElement(page2, head2, "title", "test08_2");
        final Body body2 = createElement(page2, html2, "body");
        final Div div2 = createElement(page2, body2, "div");
        // re-use template from above
        cloneComponent(component, div2);
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    // test
    compare(calculateHash(), true);
}
Also used : Div(org.structr.web.entity.html.Div) Head(org.structr.web.entity.html.Head) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Html(org.structr.web.entity.html.Html) Page(org.structr.web.entity.dom.Page) Body(org.structr.web.entity.html.Body) Template(org.structr.web.entity.dom.Template) MailTemplate(org.structr.core.entity.MailTemplate) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Example 12 with Head

use of org.structr.web.entity.html.Head in project structr by structr.

the class DeploymentTest method test20ExportOwnership.

@Test
public void test20ExportOwnership() {
    Principal user1 = null;
    Principal user2 = null;
    try (final Tx tx = app.tx()) {
        user1 = createTestNode(User.class, new NodeAttribute<>(AbstractNode.name, "user1"));
        user2 = createTestNode(User.class, new NodeAttribute<>(AbstractNode.name, "user2"));
        tx.success();
    } catch (FrameworkException ex) {
        fail("Unexpected exception.");
    }
    Assert.assertNotNull("User was not created, test cannot continue", user1);
    Assert.assertNotNull("User was not created, test cannot continue", user2);
    // setup
    final SecurityContext context1 = SecurityContext.getInstance(user1, AccessMode.Backend);
    final App app1 = StructrApp.getInstance(context1);
    try (final Tx tx = app1.tx()) {
        final Page page = Page.createNewPage(context1, "test20");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test20");
        final Body body = createElement(page, html, "body");
        final Div div1 = createElement(page, body, "div");
        final Content content = createContent(page, div1, "<b>Test</b>");
        content.setProperty(StructrApp.key(Content.class, "contentType"), "text/html");
        // set owner to different user
        div1.setProperty(AbstractNode.owner, user2);
        content.setProperty(AbstractNode.owner, user2);
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    // test
    compare(calculateHash(), true, false);
}
Also used : App(org.structr.core.app.App) StructrApp(org.structr.core.app.StructrApp) NodeAttribute(org.structr.core.graph.NodeAttribute) Head(org.structr.web.entity.html.Head) User(org.structr.web.entity.User) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Html(org.structr.web.entity.html.Html) Page(org.structr.web.entity.dom.Page) Div(org.structr.web.entity.html.Div) Content(org.structr.web.entity.dom.Content) SecurityContext(org.structr.common.SecurityContext) Body(org.structr.web.entity.html.Body) Principal(org.structr.core.entity.Principal) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Example 13 with Head

use of org.structr.web.entity.html.Head in project structr by structr.

the class DeploymentTest method test17NamedNonSharedTemplateWithChildren.

@Test
public void test17NamedNonSharedTemplateWithChildren() {
    // setup
    try (final Tx tx = app.tx()) {
        final Page page = Page.createNewPage(securityContext, "test17");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test17");
        final Body body = createElement(page, html, "body");
        final Template template = createTemplate(page, body, "${render(children)}");
        template.setProperty(AbstractNode.name, "a-template");
        final Template sharedTemplate = createComponent(template);
        // remove original template from page
        app.delete(template);
        createElement(page, sharedTemplate, "div");
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    // test
    compare(calculateHash(), true, false);
}
Also used : Head(org.structr.web.entity.html.Head) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Html(org.structr.web.entity.html.Html) Page(org.structr.web.entity.dom.Page) Body(org.structr.web.entity.html.Body) Template(org.structr.web.entity.dom.Template) MailTemplate(org.structr.core.entity.MailTemplate) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Example 14 with Head

use of org.structr.web.entity.html.Head in project structr by structr.

the class CustomHtmlAttributeTest method testCustomHtmlAttribute.

@Test
public void testCustomHtmlAttribute() {
    try (final Tx tx = app.tx()) {
        // create a page
        final Page newPage = Page.createNewPage(securityContext, "customAttributeTestPage");
        final Html html = createElement(newPage, newPage, "html");
        final Head head = createElement(newPage, html, "head");
        final Title title = createElement(newPage, head, "title", "Test Page for custom html attributes");
        final Body body = createElement(newPage, html, "body");
        final Div div1 = createElement(newPage, body, "div", "DIV with old-style data attribute");
        div1.setProperty(new GenericProperty<String>("data-test-attribute-old-style"), "old-style data attribute");
        final Div div2 = createElement(newPage, body, "div", "DIV with new-style custom html attribute");
        div2.setProperty(new GenericProperty<String>("_custom_html_test-attribute-new-style"), "new-style custom attribute");
        final Div div3 = createElement(newPage, body, "div", "DIV with data-attribute as new-style custom html attribute");
        div3.setProperty(new GenericProperty<String>("_custom_html_data-test-attribute-new-style"), "new-style custom data-attribute");
        final RenderContext renderContext = new RenderContext(securityContext);
        newPage.render(renderContext, 0);
        final String renderedHtml = StringUtils.join(renderContext.getBuffer().getQueue(), "");
        final String expectedHtml = "<!DOCTYPE html>\n" + "<html>\n" + "	<head>\n" + "		<title>Test Page for custom html attributes</title>\n" + "	</head>\n" + "	<body>\n" + "		<div data-test-attribute-old-style=\"old-style data attribute\">DIV with old-style data attribute</div>\n" + "		<div test-attribute-new-style=\"new-style custom attribute\">DIV with new-style custom html attribute</div>\n" + "		<div data-test-attribute-new-style=\"new-style custom data-attribute\">DIV with data-attribute as new-style custom html attribute</div>\n" + "	</body>\n" + "</html>";
        Assert.assertEquals(expectedHtml, renderedHtml);
        tx.success();
    } catch (FrameworkException fex) {
        logger.warn("", fex);
    }
}
Also used : Div(org.structr.web.entity.html.Div) RenderContext(org.structr.web.common.RenderContext) Head(org.structr.web.entity.html.Head) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Html(org.structr.web.entity.html.Html) Title(org.structr.web.entity.html.Title) Page(org.structr.web.entity.dom.Page) Body(org.structr.web.entity.html.Body) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Example 15 with Head

use of org.structr.web.entity.html.Head in project structr by structr.

the class DeploymentTest method test12EmptyContentElementWithContentType.

@Test
public void test12EmptyContentElementWithContentType() {
    // setup
    try (final Tx tx = app.tx()) {
        // create first page
        final Page page = Page.createNewPage(securityContext, "test12");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test12");
        final Body body = createElement(page, html, "body");
        final Script script1 = createElement(page, body, "script");
        final Script script2 = createElement(page, body, "script");
        script1.setProperty(StructrApp.key(Script.class, "_html_type"), "text/javascript");
        createContent(page, script1, "");
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    // test
    compare(calculateHash(), true);
}
Also used : Script(org.structr.web.entity.html.Script) Head(org.structr.web.entity.html.Head) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Html(org.structr.web.entity.html.Html) Page(org.structr.web.entity.dom.Page) Body(org.structr.web.entity.html.Body) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Aggregations

Head (org.structr.web.entity.html.Head)30 Body (org.structr.web.entity.html.Body)29 Test (org.junit.Test)28 FrameworkException (org.structr.common.error.FrameworkException)28 Tx (org.structr.core.graph.Tx)28 StructrUiTest (org.structr.web.StructrUiTest)28 Page (org.structr.web.entity.dom.Page)28 Html (org.structr.web.entity.html.Html)28 Div (org.structr.web.entity.html.Div)22 MailTemplate (org.structr.core.entity.MailTemplate)10 Template (org.structr.web.entity.dom.Template)10 Content (org.structr.web.entity.dom.Content)8 PropertyMap (org.structr.core.property.PropertyMap)6 DOMNode (org.structr.web.entity.dom.DOMNode)6 GraphObject (org.structr.core.GraphObject)4 NodeAttribute (org.structr.core.graph.NodeAttribute)4 Principal (org.structr.core.entity.Principal)3 StringProperty (org.structr.core.property.StringProperty)3 User (org.structr.web.entity.User)3 Script (org.structr.web.entity.html.Script)3