Search in sources :

Example 6 with Div

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

the class DeploymentTest method test04ContentTypes.

@Test
public void test04ContentTypes() {
    // setup
    try (final Tx tx = app.tx()) {
        final Page page = Page.createNewPage(securityContext, "test04");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test04");
        createElement(page, head, "link");
        createElement(page, head, "link");
        createComment(page, head, "commentöäüÖÄÜß+#");
        final Link link3 = createElement(page, head, "link");
        final PropertyMap link3Properties = new PropertyMap();
        link3Properties.put(StructrApp.key(Link.class, "_html_href"), "/");
        link3Properties.put(StructrApp.key(Link.class, "_html_media"), "screen");
        link3Properties.put(StructrApp.key(Link.class, "_html_type"), "stylesheet");
        link3.setProperties(link3.getSecurityContext(), link3Properties);
        final Body body = createElement(page, html, "body");
        final Div div1 = createElement(page, body, "div");
        createElement(page, div1, "h1", "private");
        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) 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) Body(org.structr.web.entity.html.Body) Link(org.structr.web.entity.html.Link) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Example 7 with Div

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

the class DeploymentTest method test21ExportGrants.

@Test
public void test21ExportGrants() {
    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, "test21");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test21");
        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");
        // create grants
        page.grant(Permission.read, user2);
        div1.grant(Permission.read, user2);
        content.grant(Permission.read, 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 8 with Div

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

the class DeploymentTest method test26Escaping.

@Test
public void test26Escaping() {
    // setup
    try (final Tx tx = app.tx()) {
        final Page page = Page.createNewPage(securityContext, "test25");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test25");
        final Body body = createElement(page, html, "body");
        final Div div1 = createElement(page, body, "div");
        final Content content1 = createContent(page, div1, "<div><script>var test = '<h3>Title</h3>';</script></div>");
        content1.setProperty(StructrApp.key(Content.class, "contentType"), "text/html");
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    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) Content(org.structr.web.entity.dom.Content) 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)

Example 9 with Div

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

the class DeploymentTest method test03ContentTypes.

@Test
public void test03ContentTypes() {
    // setup
    try (final Tx tx = app.tx()) {
        final Page page = Page.createNewPage(securityContext, "test03");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test03");
        final Body body = createElement(page, html, "body");
        final Div div1 = createElement(page, body, "div");
        final Script script = createElement(page, div1, "script");
        final Content content = createContent(page, script, "$(function () {\n\n" + "$('a[data-toggle=\"tab\"]').on('click', function (e) {\n\n" + "var id = $(e.target).attr(\"href\").substr(1) // activated tab\n" + "window.location.hash = id;\n" + "});\n\n" + "});");
        // workaround for strange importer behaviour
        script.setProperty(StructrApp.key(Script.class, "_html_type"), "text/javascript");
        content.setProperty(StructrApp.key(Content.class, "contentType"), "text/javascript");
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    // test
    compare(calculateHash(), true);
}
Also used : Div(org.structr.web.entity.html.Div) 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) Content(org.structr.web.entity.dom.Content) 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)

Example 10 with Div

use of org.structr.web.entity.html.Div 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)

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 Div (org.structr.web.entity.html.Div)28 Body (org.structr.web.entity.html.Body)22 Head (org.structr.web.entity.html.Head)22 Html (org.structr.web.entity.html.Html)22 Content (org.structr.web.entity.dom.Content)11 MailTemplate (org.structr.core.entity.MailTemplate)7 Template (org.structr.web.entity.dom.Template)7 DOMNode (org.structr.web.entity.dom.DOMNode)6 PropertyMap (org.structr.core.property.PropertyMap)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 Table (org.structr.web.entity.html.Table)3 SecurityContext (org.structr.common.SecurityContext)2