Search in sources :

Example 1 with Href

use of org.structr.api.util.html.attr.Href in project structr by structr.

the class StructrConfigHtmlWriter method value.

@Override
public RestWriter value(String value) throws IOException {
    if (!hasName) {
        currentElement = currentElement.block("li");
    }
    if ("id".equals(lastName)) {
        if (currentObject == null) {
            currentElement.inline("a").css("id").attr(new Href(restPath + "/" + value + propertyView)).text("\"", value, "\"");
        } else if (currentObject instanceof AbstractRelationship) {
            currentElement.inline("a").css("id").attr(new Href(restPath + "/" + currentObject.getProperty(AbstractRelationship.type) + "/" + value + propertyView)).text("\"", value, "\"");
        } else {
            currentElement.inline("a").css("id").attr(new Href(restPath + "/" + currentObject.getType() + "/" + value + propertyView)).text("\"", value, "\"");
        }
    } else {
        // escape backslashes in strings
        value = value.replaceAll("\\\\", "\\\\\\\\");
        // escape quotation marks inside strings
        value = value.replaceAll("\"", "\\\\\\\"");
        // Escape for HTML output
        value = StringUtils.replaceEach(value, new String[] { "&", "<", ">" }, new String[] { "&amp;", "&lt;", "&gt;" });
        currentElement.inline("span").css("string").text("\"", value, "\"");
    }
    // end LI
    currentElement = currentElement.parent();
    hasName = false;
    return this;
}
Also used : AbstractRelationship(org.structr.core.entity.AbstractRelationship) Href(org.structr.api.util.html.attr.Href)

Example 2 with Href

use of org.structr.api.util.html.attr.Href in project structr by structr.

the class StructrJsonHtmlWriter method value.

@Override
public RestWriter value(String value) throws IOException {
    if (!hasName) {
        currentElement = currentElement.block("li");
    }
    if ("id".equals(lastName)) {
        if (currentObject == null) {
            currentElement.inline("a").css("id").attr(new Href(restPath + "/" + value + propertyView)).text("\"", value, "\"");
        } else if (currentObject instanceof AbstractRelationship) {
            currentElement.inline("a").css("id").attr(new Href(restPath + "/" + currentObject.getProperty(AbstractRelationship.type) + "/" + value + propertyView)).text("\"", value, "\"");
        } else {
            currentElement.inline("a").css("id").attr(new Href(restPath + "/" + currentObject.getType() + "/" + value + propertyView)).text("\"", value, "\"");
        }
    } else {
        // escape backslashes in strings
        value = value.replaceAll("\\\\", "\\\\\\\\");
        // escape quotation marks inside strings
        value = value.replaceAll("\"", "\\\\\\\"");
        // Escape for HTML output
        value = StringUtils.replaceEach(value, new String[] { "&", "<", ">" }, new String[] { "&amp;", "&lt;", "&gt;" });
        currentElement.inline("span").css("string").text("\"", value, "\"");
    }
    // end LI
    currentElement = currentElement.parent();
    hasName = false;
    return this;
}
Also used : AbstractRelationship(org.structr.core.entity.AbstractRelationship) Href(org.structr.api.util.html.attr.Href)

Example 3 with Href

use of org.structr.api.util.html.attr.Href in project structr by structr.

the class StructrConfigHtmlWriter method beginDocument.

@Override
public RestWriter beginDocument(final String baseUrl, final String propertyView) throws IOException {
    String currentType = baseUrl.replace(restPath + "/", "").replace("/" + propertyView, "");
    if (!propertyView.equals("public")) {
        this.propertyView = "/" + propertyView;
    }
    Tag head = doc.block("head");
    // head.empty("link").attr(new Rel("stylesheet"), new Type("text/css"), new Href("/structr/css/rest.css"));
    // head.inline("script").attr(new Type("text/javascript"), new Src("/structr/js/CollapsibleLists.js"));
    head.inline("style").attr(new Type("text/css")).text("body,html{font-family:\"Liberation Mono\",\"DejaVu Sans Mono\",Consolas,Monaco,\"Vera Sans Mono\",\"Lucida Console\",\"Courier New\",monospace!important;font-size:9pt;padding:0;margin:0}div#top{border-bottom:1px solid #a5a5a5;line-height:2em;background:#363636;background:-webkit-gradient(linear,left bottom,left top,from(#363636),to(#666)) no-repeat;background:-moz-linear-gradient(90deg,#363636,#666) no-repeat;filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#666666', EndColorStr='#363636', GradientType=0);padding:20px;font-family:Arial,Helvetica,Sans-serif}div#top a{color:#fff;text-decoration:none;font-weight:700;margin-right:1em}div#left{background-color:#eee;padding:10px 20px}div#left a{color:#666;text-decoration:none;font-weight:700;margin-right:1em}div#right{clear:both;padding-left:20px}ul{list-style-type:none}b{font-weight:700;color:#444}a.id,a.id:visited{color:#00a}span.type{font-weight:400;color:#080}span.id{font-weight:400;color:#999}span.name{font-weight:700;color:#666}span.string{color:#c60}span.boolean,span.number{color:#00a}span.null{color:#999}.collapsibleListOpen{list-style-image:url(data:image/gif;base64,R0lGODlhBwAHAOcYAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+fn6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+vr+/v8DAwMHBwcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3Nzc7Ozs/Pz9DQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc3N3d3d7e3t/f3+Dg4OHh4eLi4uPj4+Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09P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+Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///yH5BAEKAP8ALAAAAAAHAAcAAAgXAP8JHEgwE0GBBgdmWriw4MF/CR8KDAgAOw==);cursor:pointer}.collapsibleList{cursor:default}button.collapse,button.expand{font-family:\"Liberation Mono\",\"DejaVu Sans Mono\",Consolas,Monaco,\"Vera Sans Mono\",\"Lucida Console\",\"Courier New\",monospace!important;float:right;margin:-.3em 1em 0 0}");
    head.inline("script").attr(new Type("text/javascript")).text("var CollapsibleLists=new function(){function g(b){return function(a){a||(a=window.event);for(a=a.target?a.target:a.srcElement;\"LI\"!=a.nodeName;)a=a.parentNode;a==b&&f(b)}}function f(b){for(var a=b.className.match(/(^| )collapsibleListClosed( |$)/),c=b.getElementsByTagName(\"ul\"),d=0;d<c.length;d++){for(var e=c[d];\"LI\"!=e.nodeName;)e=e.parentNode;e==b&&(c[d].style.display=a?\"block\":\"none\")}b.className=b.className.replace(/(^| )collapsibleList(Open|Closed)( |$)/,\"\");0<c.length&&(b.className+=\" collapsibleList\"+\n" + "(a?\"Open\":\"Closed\"))}this.apply=function(b){for(var a=document.getElementsByTagName(\"ul\"),c=0;c<a.length;c++)if(a[c].className.match(/(^| )collapsibleList( |$)/)&&(this.applyTo(a[c],!0),!b))for(var d=a[c].getElementsByTagName(\"ul\"),e=0;e<d.length;e++)d[e].className+=\" collapsibleList\"};this.applyTo=function(b,a){for(var c=b.getElementsByTagName(\"li\"),d=0;d<c.length;d++)a&&b!=c[d].parentNode||(c[d].addEventListener?c[d].addEventListener(\"click\",g(c[d]),!1):c[d].attachEvent(\"onclick\",g(c[d])),f(c[d]))};\n" + "this.openAll=function(){var b = [].slice.call(document.getElementsByClassName(\"collapsibleListClosed\")); [].forEach.call(b, function (el) { f(el); });};this.closeAll=function(){var b = [].slice.call(document.getElementsByClassName(\"collapsibleListOpen\")); [].forEach.call(b, function (el) { f(el); });}};");
    head.inline("title").text(baseUrl);
    Tag body = doc.block("body").attr(new Onload("if (document.querySelectorAll('#right > ul > li > ul > li > ul.collapsibleList > li').length > 5) { CollapsibleLists.apply(true); }"));
    Tag top = body.block("div").id("top");
    final App app = StructrApp.getInstance(securityContext);
    final Tag left = body.block("div").id("left");
    left.inline("button").attr(new Css("collapse right")).attr(new Attr("onclick", "CollapsibleLists.closeAll()")).text(" - ");
    left.inline("button").attr(new Css("expand right")).attr(new Attr("onclick", "CollapsibleLists.openAll()")).text(" + ");
    try (final Tx tx = app.tx()) {
        final List<SchemaNode> schemaNodes = app.nodeQuery(SchemaNode.class).getAsList();
        Collections.sort(schemaNodes);
        for (SchemaNode node : schemaNodes) {
            final String rawType = node.getName();
            top.inline("a").attr(new Href(restPath + "/" + rawType), new If(rawType.equals(currentType), new Css("active"))).text(rawType);
        }
    } catch (Throwable t) {
        logger.warn("", t);
    }
    for (String view : StructrApp.getConfiguration().getPropertyViews()) {
        if (!hiddenViews.contains(view)) {
            left.inline("a").attr(new Href(restPath + "/" + currentType + "/" + view), new If(view.equals(propertyView), new Css("active"))).text(view);
        }
    }
    // main div
    currentElement = body.block("div").id("right");
    // h1 title
    currentElement.block("h1").text(baseUrl);
    // begin ul
    currentElement = currentElement.block("ul");
    return this;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) Css(org.structr.api.util.html.attr.Css) Tx(org.structr.core.graph.Tx) Href(org.structr.api.util.html.attr.Href) Onload(org.structr.api.util.html.attr.Onload) Attr(org.structr.api.util.html.Attr) SchemaNode(org.structr.core.entity.SchemaNode) Type(org.structr.api.util.html.attr.Type) Tag(org.structr.api.util.html.Tag) If(org.structr.api.util.html.attr.If)

Example 4 with Href

use of org.structr.api.util.html.attr.Href in project structr by structr.

the class StructrJsonHtmlWriter method beginDocument.

@Override
public RestWriter beginDocument(final String baseUrl, final String propertyView) throws IOException {
    String currentType = baseUrl.replace(restPath + "/", "").replace("/" + propertyView, "");
    if (!propertyView.equals("public")) {
        this.propertyView = "/" + propertyView;
    }
    Tag head = doc.block("head");
    // head.empty("link").attr(new Rel("stylesheet"), new Type("text/css"), new Href("/structr/css/rest.css"));
    // head.inline("script").attr(new Type("text/javascript"), new Src("/structr/js/CollapsibleLists.js"));
    head.inline("style").attr(new Type("text/css")).text("body,html{font-family:\"Liberation Mono\",\"DejaVu Sans Mono\",Consolas,Monaco,\"Vera Sans Mono\",\"Lucida Console\",\"Courier New\",monospace!important;font-size:9pt;padding:0;margin:0}div#top{border-bottom:1px solid #a5a5a5;line-height:2em;background:#363636;background:-webkit-gradient(linear,left bottom,left top,from(#363636),to(#666)) no-repeat;background:-moz-linear-gradient(90deg,#363636,#666) no-repeat;filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#666666', EndColorStr='#363636', GradientType=0);padding:20px;font-family:Arial,Helvetica,Sans-serif}div#top a{color:#fff;text-decoration:none;font-weight:700;margin-right:1em}div#left{background-color:#eee;padding:10px 20px}div#left a{color:#666;text-decoration:none;font-weight:700;margin-right:1em}div#right{clear:both;padding-left:20px}ul{list-style-type:none}b{font-weight:700;color:#444}a.id,a.id:visited{color:#00a}span.type{font-weight:400;color:#080}span.id{font-weight:400;color:#999}span.name{font-weight:700;color:#666}span.string{color:#c60}span.boolean,span.number{color:#00a}span.null{color:#999}span.comma{color:#000}.collapsibleListOpen{list-style-image:url(data:image/gif;base64,R0lGODlhBwAHAOcYAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZG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NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+fn6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+vr+/v8DAwMHBwcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3Nzc7Ozs/Pz9DQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc3N3d3d7e3t/f3+Dg4OHh4eLi4uPj4+Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///yH5BAEKAP8ALAAAAAAHAAcAAAgXAP8JHEgwE0GBBgdmWriw4MF/CR8KDAgAOw==);cursor:pointer}.collapsibleList{cursor:default}button.collapse,button.expand{font-family:\"Liberation Mono\",\"DejaVu Sans Mono\",Consolas,Monaco,\"Vera Sans Mono\",\"Lucida Console\",\"Courier New\",monospace!important;float:right;margin:-.3em 1em 0 0}li.collapsibleListClosed>ul.collapsibleList>li{display:none}li.collapsibleListClosed>ul.collapsibleList::before{content:\"…\"}li.collapsibleListClosed>ul.collapsibleList:empty{display:none}li.collapsibleListClosed>ul.collapsibleList{line-height:11px;display:inline-block;border:1px solid #aaa;border-radius:6px;padding-left:2px;cursor:pointer;background-color:#ddd;padding-right:3px;margin-left:-5px;margin-right:-5px;font-family:initial}");
    head.inline("script").attr(new Type("text/javascript")).text("var CollapsibleLists=new function(){function g(b){return function(a){a||(a=window.event);for(a=a.target?a.target:a.srcElement;\"LI\"!=a.nodeName;)a=a.parentNode;a==b&&f(b)}}function f(b){for(var a=b.className.match(/(^| )collapsibleListClosed( |$)/),c=b.getElementsByTagName(\"ul\"),d=0;d<c.length;d++){for(var e=c[d];\"LI\"!=e.nodeName;)e=e.parentNode}b.className=b.className.replace(/(^| )collapsibleList(Open|Closed)( |$)/,\"\");0<c.length&&(b.className+=\" collapsibleList\"+\n" + "(a?\"Open\":\"Closed\"))}this.apply=function(b){for(var a=document.getElementsByTagName(\"ul\"),c=0;c<a.length;c++)if(a[c].className.match(/(^| )collapsibleList( |$)/)&&(this.applyTo(a[c],!0),!b))for(var d=a[c].getElementsByTagName(\"ul\"),e=0;e<d.length;e++)d[e].className+=\" collapsibleList\"};this.applyTo=function(b,a){for(var c=b.getElementsByTagName(\"li\"),d=0;d<c.length;d++)a&&b!=c[d].parentNode||(c[d].addEventListener?c[d].addEventListener(\"click\",g(c[d]),!1):c[d].attachEvent(\"onclick\",g(c[d])),f(c[d]))};\n" + "this.openAll=function(){var b = [].slice.call(document.getElementsByClassName(\"collapsibleListClosed\")); [].forEach.call(b, function (el) { f(el); });};this.closeAll=function(){var b = [].slice.call(document.getElementsByClassName(\"collapsibleListOpen\")); [].forEach.call(b, function (el) { f(el); });}};");
    head.inline("title").text(baseUrl);
    Tag body = doc.block("body").attr(new Onload("if (document.querySelectorAll('#right > ul > li > ul > li > ul.collapsibleList > li').length > 5) { CollapsibleLists.apply(true); }"));
    Tag top = body.block("div").id("top");
    final App app = StructrApp.getInstance(securityContext);
    final Tag left = body.block("div").id("left");
    left.inline("button").attr(new Css("collapse right")).attr(new Attr("onclick", "CollapsibleLists.closeAll()")).text(" - ");
    left.inline("button").attr(new Css("expand right")).attr(new Attr("onclick", "CollapsibleLists.openAll()")).text(" + ");
    try (final Tx tx = app.tx()) {
        final List<SchemaNode> schemaNodes = app.nodeQuery(SchemaNode.class).getAsList();
        Collections.sort(schemaNodes);
        for (SchemaNode node : schemaNodes) {
            final String rawType = node.getName();
            top.inline("a").attr(new Href(restPath + "/" + rawType), new If(rawType.equals(currentType), new Css("active"))).text(rawType);
        }
    } catch (Throwable t) {
        logger.warn("", t);
    }
    for (String view : StructrApp.getConfiguration().getPropertyViews()) {
        if (!hiddenViews.contains(view)) {
            left.inline("a").attr(new Href(restPath + "/" + currentType + "/" + view), new If(view.equals(propertyView), new Css("active"))).text(view);
        }
    }
    // main div
    currentElement = body.block("div").id("right");
    // h1 title
    currentElement.block("h1").text(baseUrl);
    // begin ul
    currentElement = currentElement.block("ul");
    return this;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) Css(org.structr.api.util.html.attr.Css) Tx(org.structr.core.graph.Tx) Href(org.structr.api.util.html.attr.Href) Onload(org.structr.api.util.html.attr.Onload) Attr(org.structr.api.util.html.Attr) SchemaNode(org.structr.core.entity.SchemaNode) Type(org.structr.api.util.html.attr.Type) Tag(org.structr.api.util.html.Tag) If(org.structr.api.util.html.attr.If)

Example 5 with Href

use of org.structr.api.util.html.attr.Href in project structr by structr.

the class ConfigServlet method setupDocument.

// ----- private methods -----
private Tag setupDocument(final HttpServletRequest request, final Document doc) {
    final Tag head = doc.block("head");
    head.block("title").text(TITLE);
    head.empty("meta").attr(new Attr("http-equiv", "Content-Type"), new Attr("content", "text/html;charset=utf-8"));
    head.empty("meta").attr(new Name("viewport"), new Attr("content", "width=1024, user-scalable=yes"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/lib/jquery-ui-1.10.3.custom.min.css"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/main.css"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/config.css"));
    head.empty("link").attr(new Rel("icon"), new Href("favicon.ico"), new Type("image/x-icon"));
    head.block("script").attr(new Src("/structr/js/lib/jquery-1.11.1.min.js"));
    head.block("script").attr(new Src("/structr/js/lib/jquery-ui-1.11.0.custom.min.js"));
    head.block("script").attr(new Src("/structr/js/icons.js"));
    head.block("script").attr(new Src("/structr/js/config.js"));
    final Tag body = doc.block("body");
    final Tag header = body.block("div").id("header");
    header.block("i").css("logo sprite sprite-structr-logo");
    final Tag links = header.block("div").id("menu").css("menu").block("ul");
    if (isAuthenticated(request)) {
        final Tag form = links.block("li").block("form").attr(new Attr("action", ConfigUrl), new Attr("method", "post"), new Style("display: none")).id("logout-form");
        form.empty("input").attr(new Type("hidden"), new Name("action"), new Value("logout"));
        links.block("a").text("Logout").attr(new Style("cursor: pointer"), new OnClick("$('#logout-form').submit();"));
    }
    return body;
}
Also used : Rel(org.structr.api.util.html.attr.Rel) Href(org.structr.api.util.html.attr.Href) Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Aggregations

Href (org.structr.api.util.html.attr.Href)5 Attr (org.structr.api.util.html.Attr)3 Tag (org.structr.api.util.html.Tag)3 Css (org.structr.api.util.html.attr.Css)2 If (org.structr.api.util.html.attr.If)2 Onload (org.structr.api.util.html.attr.Onload)2 Type (org.structr.api.util.html.attr.Type)2 App (org.structr.core.app.App)2 StructrApp (org.structr.core.app.StructrApp)2 AbstractRelationship (org.structr.core.entity.AbstractRelationship)2 SchemaNode (org.structr.core.entity.SchemaNode)2 Tx (org.structr.core.graph.Tx)2 Rel (org.structr.api.util.html.attr.Rel)1