Package com.dotcms.repackage.org.jsoup.select

Examples of com.dotcms.repackage.org.jsoup.select.Elements


  public static List<PreviewFileAsset> getFilesInodes(String _body){
    Document templateBody = Jsoup.parse(_body);
    List<PreviewFileAsset> result = new ArrayList<PreviewFileAsset>();
    Element divFilesToAdd = templateBody.getElementById(FILES_TO_ADD_DIV_ID);
    if(null!=divFilesToAdd){
      Elements filesToAdd = divFilesToAdd.getElementsByAttributeValueStarting(ID_ATTRIBUTE, FILE_TO_ADD_START_ID);
      for(Element singleFile : filesToAdd){
        String id = singleFile.attr("id");
        String[] values = id.substring(id.indexOf(FILE_TO_ADD_START_ID)+4).split("_");
        PreviewFileAsset p = new PreviewFileAsset();
        p.setInode(values[0]);
View Full Code Here


  // ************************************************************************************************************
  // *************************************** BEGIN UTILITY METHODS JSOUP ****************************************
  // ************************************************************************************************************

  private static void removeAddContainer(Document templateBody){
    Elements addContainers = templateBody.getElementsByClass(ADD_CONTAINER_SPAN_CLASS);
    for(Element singleDiv : addContainers){
      singleDiv.remove();
    }
  }
View Full Code Here

      singleDiv.remove();
    }
  }

  private static void removeMockContainers(Document templateBody){
    Elements mockContainers = templateBody.getElementsByClass(TITLE_CONTAINER_SPAN_CLASS);
    for(Element singleDiv : mockContainers){
      singleDiv.remove();
    }
  }
View Full Code Here

      singleDiv.remove();
    }
  }

  private static void removeYuiGridContent(Document templateBody){
    Elements h1 = templateBody.getElementsByTag(H1_TAG);
    for(Element singleH1 : h1){
      singleH1.remove();
    }
  }
View Full Code Here

    if(null!=divFilesIcons)
      divFilesIcons.remove();
  }

  private static void getParseContainer(Document templateBody){
    Elements divHiddenParseContainer = templateBody.getElementsByAttributeValue(STYLE_ATTRIBUTE, STYLE_DISPLAY_NONE);
    for(Element singleDiv : divHiddenParseContainer){
      if(!singleDiv.attr(ID_ATTRIBUTE).equals("metatagToAdd")){
        Element parent = singleDiv.parent();
        if(!parent.attr(ID_ATTRIBUTE).equals("metatagToAdd")){
          String html = singleDiv.html();
View Full Code Here

  private static void addJsCssFiles(Document templateBody){
    Element head = templateBody.head();
    Element divFilesToAdd = templateBody.getElementById(FILES_TO_ADD_DIV_ID);
    if(null!=divFilesToAdd){
      Elements filesToAdd = divFilesToAdd.getElementsByAttributeValueStarting(ID_ATTRIBUTE, FILE_TO_ADD_START_ID);
      for(Element singleFile : filesToAdd){
        head.append(replaceHTMLComments(singleFile.html()));
        singleFile.remove();
      }
      divFilesToAdd.remove();
View Full Code Here

    Element globalContainer = templateDrawedBody.getElementsByAttributeValue(NAME_ATTRIBUTE, MAIN_DIV_NAME_VALUE).get(0);
    return globalContainer.attr(ID_ATTRIBUTE);
  }

  private static String getLayout(Document templateDrawedBody){
    Elements layouts = templateDrawedBody.getElementsByAttributeValue(ID_ATTRIBUTE, SIDEBAR_ID);
    if(null!=layouts && layouts.size()>0){
      Element layout = layouts.get(0);
      if(null!=layout)
        return templateDrawedBody.getElementsByAttributeValue(NAME_ATTRIBUTE, MAIN_DIV_NAME_VALUE).get(0).attr(CLASS_ATTRIBUTE);
      else
        return NO_SIDEBAR_VALUE;
    }else
View Full Code Here

     */
    private static void setLayoutBody ( TemplateLayout layout, Document templateDrawedBody, Boolean isPreview ) {

        //***************************************************************
        //Verify if we have a sidebar
        Elements splitSideBar = templateDrawedBody.select( DIV_TAG + "[" + ID_ATTRIBUTE + "=" + SIDEBAR_ID );
        if ( splitSideBar != null && !splitSideBar.isEmpty() ) {//We found our sidebar

            Element sidebar = splitSideBar.get( 0 );

            //Getting the containers for this html fragment
            List<String> containers = getColumnContainers( sidebar );
            //Adding the sidebar to the layout
            layout.setSidebar( containers, isPreview );
        }

        //***************************************************************
        //Split the drawed body in rows
        List<TemplateLayoutRow> splitBodiesList = new ArrayList<TemplateLayoutRow>();
        Elements splitBodies = templateDrawedBody.select( DIV_TAG + "[" + ID_ATTRIBUTE + "~=" + getRegexForSelectBody() );
        for ( int i = 0; i < splitBodies.size(); i++ ) {

            Element splitBody = splitBodies.get( i );
            // gets the identifier of the body div
            String idHtml = splitBody.attr( ID_ATTRIBUTE );
            String id = idHtml.substring( idHtml.indexOf( SPLIT_BODY_ID_PREFIX ) + SPLIT_BODY_ID_PREFIX.length() );
            String layoutType = splitBody.child( 0 ).attr( ID_ATTRIBUTE );

            //Create a template row
            TemplateLayoutRow rowLayout = new TemplateLayoutRow();
            rowLayout.setIdentifier( Integer.parseInt( id ) );
            rowLayout.setId( "select_splitBody" );
            rowLayout.setValue( layoutType );

            //We may have  multiple columns in here
            Elements columns = splitBody.select( DIV_TAG + "." + COLUMN_CONTAINER_CLASS );
            if ( columns != null && !columns.isEmpty() ) {

                //We found multiple columns...
                for ( Element columnElement : columns ) {
                    //Find the containers for this column
                    List<String> containers = getColumnContainers( columnElement );
View Full Code Here

  private static void getMetatagContainers(Document templateBody){
    Element head = templateBody.head();
    Element metatagToAdd = templateBody.getElementById("metatagToAdd");
    if(null!=metatagToAdd){
      Elements metatags = metatagToAdd.getElementsByAttributeValueStarting(ID_ATTRIBUTE, FILE_TO_ADD_START_ID);
      for(Element meta:metatags)
        head.append(meta.html());
      metatagToAdd.remove();
    }
  }
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.jsoup.select.Elements

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.