Search in sources :

Example 1 with Script

use of org.structr.web.entity.html.Script 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 2 with Script

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

the class ImporterTest method testWidgetWithScriptTags.

@Test
public void testWidgetWithScriptTags() {
    try (final Tx tx = app.tx()) {
        Settings.JsonIndentation.setValue(true);
        Settings.HtmlIndentation.setValue(true);
        final String source = testImportWidget("<div>\n" + "      <script src=\"/structr/js/lib/jquery-1.11.1.min.js\" type=\"text/javascript\"></script>\n" + "      <script type=\"text/javascript\"></script>\n" + "</div>", RenderContext.EditMode.WIDGET, "https://widgets.structr.org/structr/rest/widgets");
        // System.out.println(source);
        assertEquals("<!DOCTYPE html>\n" + "<html>\n" + "	<head></head>\n" + "	<body>\n" + "		<div>\n" + "			<script src=\"/structr/js/lib/jquery-1.11.1.min.js\" type=\"text/javascript\"></script>\n" + "			<script type=\"text/javascript\"></script>\n" + "		</div>\n" + "	</body>\n" + "</html>", source);
        Script secondScriptElement = (Script) app.nodeQuery(Script.class).blank(StructrApp.key(Script.class, "_html_src")).getFirst();
        assertNull(secondScriptElement.getOutgoingRelationship(StructrApp.getConfiguration().getRelationshipEntityClass("LinkSourceLINKLinkable")));
    } catch (FrameworkException ex) {
        logger.warn("", ex);
    }
}
Also used : Script(org.structr.web.entity.html.Script) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Test(org.junit.Test) StructrUiTest(org.structr.web.StructrUiTest)

Example 3 with Script

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

Example 4 with Script

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

the class DeploymentTest method test13EmptyContentElement.

@Test
public void test13EmptyContentElement() {
    // setup
    try (final Tx tx = app.tx()) {
        // create first page
        final Page page = Page.createNewPage(securityContext, "test13");
        final Html html = createElement(page, page, "html");
        final Head head = createElement(page, html, "head");
        createElement(page, head, "title", "test13");
        final Body body = createElement(page, html, "body");
        final Script script1 = createElement(page, body, "script", "");
        tx.success();
    } catch (FrameworkException fex) {
        fail("Unexpected exception.");
    }
    // test
    compare(calculateHash(), false);
}
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

Test (org.junit.Test)4 FrameworkException (org.structr.common.error.FrameworkException)4 Tx (org.structr.core.graph.Tx)4 StructrUiTest (org.structr.web.StructrUiTest)4 Script (org.structr.web.entity.html.Script)4 Page (org.structr.web.entity.dom.Page)3 Body (org.structr.web.entity.html.Body)3 Head (org.structr.web.entity.html.Head)3 Html (org.structr.web.entity.html.Html)3 Content (org.structr.web.entity.dom.Content)1 Div (org.structr.web.entity.html.Div)1