Package org.structr.web.entity.dom

Examples of org.structr.web.entity.dom.Page


  // ----- public static methods -----
  public static Page parsePageFromSource(final SecurityContext securityContext, final String source, final String name) throws FrameworkException {

    final Importer importer = new Importer(securityContext, source, null, "source", 0, true, true);
    final App localAppCtx   = StructrApp.getInstance(securityContext);
    Page page               = null;

    try (final Tx tx = localAppCtx.tx()) {

      page   = localAppCtx.create(Page.class, new NodeAttribute<>(Page.name, name));
View Full Code Here


          return new StructrFtpFile((File) file);
        }
      }

      // Look up a page by its name
      Page page = StructrApp.getInstance().nodeQuery(Page.class).andName(PathHelper.getName(requestedPath)).getFirst();
      if (page != null) {
        return page;
      }

//    List<FtpFile> files = cur.listFiles();
View Full Code Here

        defaultValue = "";
      }
    }

    Page _page = this.getPage();
    GraphObject _data = null;

    // walk through template parts
    for (int i = 0; (i < parts.length); i++) {
View Full Code Here

    final Map<String, Object> nodeData = webSocketData.getNodeData();
    final String parentId              = (String) nodeData.get("parentId");
    final String baseUrl               = (String) nodeData.get("widgetHostBaseUrl");
    final App app                      = StructrApp.getInstance(getWebSocket().getSecurityContext());
   
    final Page page      = getPage(pageId);
    final AbstractNode origNode  = getNode(id);
   
    try {
     
      DOMNode existingParent = null;
View Full Code Here

    });

    // test result on the node level
    try (final Tx tx = app.tx()) {

      final Page page = app.nodeQuery(Page.class).andName("test").getFirst();

      assertNotNull(page);

      final NodeList nodes = page.getElementsByTagName("div");
      final List<Div> divs = collectNodes(nodes, Div.class);

      assertEquals("Wrong number of divs returned from node query", 4, divs.size());

      // check first div, should have no siblings and one child
View Full Code Here

    String sourceHtml = null;

    try {

      // create page from source
      final Page sourcePage = Importer.parsePageFromSource(securityContext, source, "test");

      // render page into HTML string
      try (final Tx tx = app.tx()) {
        sourceHtml = sourcePage.getContent(RenderContext.EditMode.RAW);
        tx.success();
      }

      // modify HTML string with transformation function
      final String modifiedHtml = modifier.apply(sourceHtml);

      // parse page from modified source
      final Page modifiedPage = Importer.parsePageFromSource(securityContext, modifiedHtml, "Test");

      // create and apply diff operations
      try (final Tx tx = app.tx()) {

        final List<InvertibleModificationOperation> changeSet = Importer.diffPages(sourcePage, modifiedPage);
View Full Code Here

    final String pageName                 = (String) webSocketData.getNodeData().get(Page.name.dbName());
    final SecurityContext securityContext = getWebSocket().getSecurityContext();

    try {
     
      Page newPage = Page.createNewPage(securityContext, pageName);
      if (newPage != null) {
       
        Element html  = newPage.createElement("html");
        Element head  = newPage.createElement("head");
        Element body  = newPage.createElement("body");
        Element title = newPage.createElement("title");
        Element h1    = newPage.createElement("h1");
        Element div   = newPage.createElement("div");
       
        try {
          // add HTML element to page
          newPage.appendChild(html);
         
          // add HEAD and BODY elements to HTML
          html.appendChild(head);
          html.appendChild(body);
         
          // add TITLE element to HEAD
          head.appendChild(title);
         
          // add H1 element to BODY
          body.appendChild(h1);

          // add DIV element to BODY
          body.appendChild(div);
         
          // add text nodes
          title.appendChild(newPage.createTextNode("${capitalize(page.name)}"));         
          h1.appendChild(newPage.createTextNode("${capitalize(page.name)}"));
          div.appendChild(newPage.createTextNode("Initial body text"));
         
        } catch (DOMException dex) {
         
          dex.printStackTrace();
         
View Full Code Here

TOP

Related Classes of org.structr.web.entity.dom.Page

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.