Search in sources :

Example 1 with Html

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

the class DeploymentTest method test18NonNamedNonSharedTemplateWithChildren.

@Test
public void test18NonNamedNonSharedTemplateWithChildren() {
    // setup
    try (final Tx tx = app.tx()) {
        final Page page = Page.createNewPage(securityContext, "test18");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test18");
        final Body body = createElement(page, html, "body");
        final Template template = createTemplate(page, body, "${render(children)}");
        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 2 with Html

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

the class DeploymentTest method test31RoundtripWithEmptyContentElements.

@Test
public void test31RoundtripWithEmptyContentElements() {
    // setup
    try (final Tx tx = app.tx()) {
        final Page page = Page.createNewPage(securityContext, "test31");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test31");
        final Body body = createElement(page, html, "body");
        final Div div1 = createElement(page, body, "div");
        final Div div2 = createElement(page, div1, "div", "");
        final Table table1 = createElement(page, div2, "table");
        final Thead thead = createElement(page, table1, "thead");
        final Tbody tbody = createElement(page, table1, "tbody");
        final Tr tr1 = createElement(page, thead, "tr");
        final Tr tr2 = createElement(page, tbody, "tr");
        final Td td11 = createElement(page, tr1, "td");
        final Content c1 = createContent(page, td11, "");
        final Td td12 = createElement(page, tr1, "td", "content12");
        final P p1 = createElement(page, td12, "p", "");
        final Ul ul = createElement(page, p1, "ul");
        final Li li = createElement(page, ul, "li", "");
        final Td td21 = createElement(page, tr2, "td", "content21");
        final Td td22 = createElement(page, tr2, "td", "content22");
        final Select select = createElement(page, td11, "select");
        final Option option1 = createElement(page, select, "option", "");
        final Option option2 = createElement(page, select, "option", "value2");
        final Content c2 = createContent(page, div2, "");
        final Table table2 = createElement(page, div2, "table");
        // include visibility flags
        page.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
        c1.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
        c2.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
        // modify visibility to produce two consecutive deployment instruction comments
        td12.setProperty(AbstractNode.visibleToPublicUsers, true);
        table2.setProperty(AbstractNode.visibleToPublicUsers, true);
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    compare(calculateHash(), true);
}
Also used : Head(org.structr.web.entity.html.Head) Table(org.structr.web.entity.html.Table) Tx(org.structr.core.graph.Tx) Thead(org.structr.web.entity.html.Thead) 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) Td(org.structr.web.entity.html.Td) P(org.structr.web.entity.html.P) Content(org.structr.web.entity.dom.Content) Ul(org.structr.web.entity.html.Ul) Select(org.structr.web.entity.html.Select) Option(org.structr.web.entity.html.Option) Tbody(org.structr.web.entity.html.Tbody) Body(org.structr.web.entity.html.Body) Li(org.structr.web.entity.html.Li) Tr(org.structr.web.entity.html.Tr) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Example 3 with Html

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

the class DeploymentTest method test35WidgetWithSharedComponentCreation.

@Test
public void test35WidgetWithSharedComponentCreation() {
    // setup
    try (final Tx tx = app.tx()) {
        final Page testPage = Page.createNewPage(securityContext, "WidgetTestPage");
        final Html html = createElement(testPage, testPage, "html");
        final Head head = createElement(testPage, html, "head");
        final Body body = createElement(testPage, html, "body");
        final Div div = createElement(testPage, body, "div");
        final Div div2 = createElement(testPage, body, "div");
        div.setProperty(AbstractNode.name, "WidgetTestPage-Div");
        div2.setProperty(AbstractNode.name, "WidgetTestPage-Div2");
        Widget widgetToImport = app.create(Widget.class, new NodeAttribute<>(StructrApp.key(Widget.class, "name"), "TestWidget"), new NodeAttribute<>(StructrApp.key(Widget.class, "source"), "<structr:component src=\"TestComponent\">\n" + "	<div data-structr-meta-name=\"TestComponent\">\n" + "		Test123\n" + "	</div>\n" + "</structr:component>"), new NodeAttribute<>(StructrApp.key(Widget.class, "configuration"), ""), new NodeAttribute<>(StructrApp.key(Widget.class, "visibleToPublicUsers"), true), new NodeAttribute<>(StructrApp.key(Widget.class, "visibleToAuthenticatedUsers"), true));
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("widgetHostBaseUrl", "https://widgets.structr.org/structr/rest/widgets");
        paramMap.put("parentId", widgetToImport.getProperty(new StartNode<>("owner", PrincipalOwnsNode.class)));
        paramMap.put("source", widgetToImport.getProperty(new StringProperty("source")));
        paramMap.put("processDeploymentInfo", false);
        Widget.expandWidget(securityContext, testPage, div, baseUri, paramMap, false);
        Widget.expandWidget(securityContext, testPage, div, baseUri, paramMap, false);
        makePublic(testPage, html, head, body, div, div2);
        tx.success();
    } catch (FrameworkException fex) {
        logger.warn("", fex);
        fail("Unexpected exception.");
    }
    // test
    try (final Tx tx = app.tx()) {
        Div div = app.nodeQuery(Div.class).andName("WidgetTestPage-Div").getFirst();
        assertEquals(2, div.treeGetChildCount());
        Object obj = null;
        for (DOMNode n : div.getAllChildNodes()) {
            obj = n;
            break;
        }
        assertTrue(Div.class.isAssignableFrom(obj.getClass()));
        Div clonedNode = (Div) obj;
        assertEquals(0, clonedNode.getChildNodes().getLength());
        assertEquals(3, app.nodeQuery(Div.class).andName("TestComponent").getResult().size());
        tx.success();
    } catch (FrameworkException fex) {
        logger.warn("", fex);
        fail("Unexpected exception.");
    }
}
Also used : StartNode(org.structr.core.property.StartNode) Head(org.structr.web.entity.html.Head) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) HashMap(java.util.HashMap) Widget(org.structr.web.entity.Widget) Html(org.structr.web.entity.html.Html) StringProperty(org.structr.core.property.StringProperty) Page(org.structr.web.entity.dom.Page) Div(org.structr.web.entity.html.Div) GraphObject(org.structr.core.GraphObject) DOMNode(org.structr.web.entity.dom.DOMNode) Body(org.structr.web.entity.html.Body) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Example 4 with Html

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

the class DeploymentTest method test11TemplateInTbody.

@Test
public void test11TemplateInTbody() {
    // setup
    try (final Tx tx = app.tx()) {
        // create first page
        final Page page1 = Page.createNewPage(securityContext, "test11");
        final Html html1 = createElement(page1, page1, "html");
        final Head head1 = createElement(page1, html1, "head");
        createElement(page1, head1, "title", "test11_1");
        final Body body1 = createElement(page1, html1, "body");
        final Table table = createElement(page1, body1, "table");
        final Tbody tbody = createElement(page1, table, "tbody");
        final Template template1 = createTemplate(page1, tbody, "<tr><td>${user.name}</td></tr>");
        final PropertyMap template1Properties = new PropertyMap();
        template1Properties.put(StructrApp.key(DOMNode.class, "functionQuery"), "find('User')");
        template1Properties.put(StructrApp.key(DOMNode.class, "dataKey"), "user");
        template1.setProperties(template1.getSecurityContext(), template1Properties);
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    // test
    compare(calculateHash(), true);
}
Also used : Head(org.structr.web.entity.html.Head) Table(org.structr.web.entity.html.Table) PropertyMap(org.structr.core.property.PropertyMap) 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) Tbody(org.structr.web.entity.html.Tbody) DOMNode(org.structr.web.entity.dom.DOMNode) 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 5 with Html

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

the class DeploymentTest method test10SharedComponent.

@Test
public void test10SharedComponent() {
    // setup
    try (final Tx tx = app.tx()) {
        // create first page
        final Page page1 = Page.createNewPage(securityContext, "test10_1");
        final Html html1 = createElement(page1, page1, "html");
        final Head head1 = createElement(page1, html1, "head");
        createElement(page1, head1, "title", "test10_1");
        final Body body1 = createElement(page1, html1, "body");
        final Div div1 = createElement(page1, body1, "div");
        createElement(page1, div1, "div", "test1");
        createElement(page1, div1, "div", "test1");
        final Div component = createComponent(div1);
        // create second page
        final Page page2 = Page.createNewPage(securityContext, "test10_2");
        final Html html2 = createElement(page2, page2, "html");
        final Head head2 = createElement(page2, html2, "head");
        createElement(page2, head2, "title", "test10_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) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Aggregations

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 Body (org.structr.web.entity.html.Body)28 Head (org.structr.web.entity.html.Head)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)7 PropertyMap (org.structr.core.property.PropertyMap)5 DOMNode (org.structr.web.entity.dom.DOMNode)5 GraphObject (org.structr.core.GraphObject)3 Principal (org.structr.core.entity.Principal)3 NodeAttribute (org.structr.core.graph.NodeAttribute)3 User (org.structr.web.entity.User)3 Script (org.structr.web.entity.html.Script)3 Table (org.structr.web.entity.html.Table)3