def render(grouping, name, tags, count)
      # get posts from BibSonomy
      posts = JSON.parse(@bibsonomy.get_posts(grouping, name, 'publication', tags, 0, count))

      # render them with citeproc
      cp = CiteProc::Processor.new style: @style, format: 'html'
      cp.import posts

      # to check for duplicate file names
      file_names = []

      # filter posts by group
      # 2017-05-30, rja, disabled until group information is returned by the API
      # posts.delete_if do |v|
      #   if v["group"] == @group
      #     true
      #   else
      #     print("WARN: " + v["group"])
      #     false
      #   end
      # end

      # sort posts by year
      sorted_keys = posts.keys.sort { |a,b| get_sort_posts(posts[b], posts[a]) }

      result = ""

      # print first heading
      last_year = 0

      if @year_headings and sorted_keys.length > 0
        last_year = get_year(posts[sorted_keys[0]])
        result += "<h3>" + last_year + "</h3>"
      end

      result += "<ul class='#{@css_class}'>\n"
      for post_id in sorted_keys
        post = posts[post_id]

        # print heading
        if @year_headings
          year = get_year(post)
          if year != last_year
            last_year = year
            result += "</ul>\n<h3>" + last_year + "</h3>\n<ul class='#{@css_class}'>\n"
          end
        end

        # render metadata
        csl = cp.render(:bibliography, id: post_id)
        result += "<li class='" + post["type"] + "'>#{csl[0]}"

        # extract the post's id
        intra_hash, user_name = get_intra_hash(post_id)

        # optional parts
        options = []
        # attach documents
        if @pdf_dir
          for doc in get_public_docs(post["documents"])
            # fileHash, fileName, md5hash, userName
            file_path = get_document(@bibsonomy, intra_hash, user_name, doc, @pdf_dir, file_names)
            options << "<a href='#{file_path}'>PDF</a>"
          end
        end
        # attach DOI
        doi = post["DOI"]
        if @doi_link and doi != ""
          doi, doi_url = get_doi(doi)
          options << "DOI:<a href='#{doi_url}'>#{doi}</a>"
        end
        # attach URL
        url = post["URL"]
        if @url_link and url != ""
          options << "<a href='#{url}'>URL</a>"
        end
        # attach BibTeX
        if @bibtex_link
          options << "<a href='https://www.bibsonomy.org/bib/publication/#{intra_hash}/#{user_name}'>BibTeX</a>"
        end
        # attach link to BibSonomy
        if @bibsonomy_link
          options << "<a href='https://www.bibsonomy.org/publication/#{intra_hash}/#{user_name}'>BibSonomy</a>"
        end

        # attach options
        if options.length > 0
          result += " <span class='opt'>[" + options.join(@opt_sep) + "]</span>"
        end

        # attach Altmetric badge
        if @altmetric_badge_type and doi != ""
          doi, doi_url = get_doi(doi)
          result += "<div class='altmetric-embed' data-badge-type='#{@altmetric_badge_type}' data-doi='#{doi}'></div>"
        end

        result += "</li>\n"
      end
      result += "</ul>\n"

      return result
    end
def render(grouping, name, tags, count)
      # get posts from BibSonomy
      posts = JSON.parse(@bibsonomy.get_posts(grouping, name, 'publication', tags, 0, count))

      # render them with citeproc
      cp = CiteProc::Processor.new style: @style, format: 'html'
      cp.import posts

      # to check for duplicate file names
      file_names = []

      # filter posts by group
      # 2017-05-30, rja, disabled until group information is returned by the API
      # posts.delete_if do |v|
      #   if v["group"] == @group
      #     true
      #   else
      #     print("WARN: " + v["group"])
      #     false
      #   end
      # end

      # sort posts by year
      sorted_keys = posts.keys.sort { |a,b| get_sort_posts(posts[b], posts[a]) }

      result = ""

      # print first heading
      last_year = 0

      if @year_headings and sorted_keys.length > 0
        last_year = get_year(posts[sorted_keys[0]])
        result += "<h3>" + last_year + "</h3>"
      end

      result += "<ul class='#{@css_class}'>\n"
      for post_id in sorted_keys
        post = posts[post_id]

        # print heading
        if @year_headings
          year = get_year(post)
          if year != last_year
            last_year = year
            result += "</ul>\n<h3>" + last_year + "</h3>\n<ul class='#{@css_class}'>\n"
          end
        end

        # render metadata
        csl = cp.render(:bibliography, id: post_id)
        result += "<li class='" + post["type"] + "'>#{csl[0]}"

        # extract the post's id
        intra_hash, user_name = get_intra_hash(post_id)

        # optional parts
        options = []
        # attach documents
        if @pdf_dir
          for doc in get_public_docs(post["documents"])
            # fileHash, fileName, md5hash, userName
            file_path = get_document(@bibsonomy, intra_hash, user_name, doc, @pdf_dir, file_names)
            options << "<a href='#{file_path}'>PDF</a>"
          end
        end
        # attach DOI
        doi = post["DOI"]
        if @doi_link and doi != ""
          doi, doi_url = get_doi(doi)
          options << "DOI:<a href='#{doi_url}'>#{doi}</a>"
        end
        # attach URL
        url = post["URL"]
        if @url_link and url != ""
          options << "<a href='#{url}'>URL</a>"
        end
        # attach BibTeX
        if @bibtex_link
          options << "<a href='https://www.bibsonomy.org/bib/publication/#{intra_hash}/#{user_name}'>BibTeX</a>"
        end
        # attach link to BibSonomy
        if @bibsonomy_link
          options << "<a href='https://www.bibsonomy.org/publication/#{intra_hash}/#{user_name}'>BibSonomy</a>"
        end

        # attach options
        if options.length > 0
          result += " <span class='opt'>[" + options.join(@opt_sep) + "]</span>"
        end

        # attach Altmetric badge
        if @altmetric_badge_type and doi != ""
          doi, doi_url = get_doi(doi)
          result += "<div class='altmetric-embed' data-badge-type='#{@altmetric_badge_type}' data-doi='#{doi}'></div>"
        end

        result += "</li>\n"
      end
      result += "</ul>\n"

      return result
    end
Create a new BibSonomy instance.

 @param user_name [String] the BibSonomy user name
 @param api_key [String] the API key of the user (get at https://www.bibsonomy.org/settings?selTab=1)

 Download `count` posts for the given `user` and `tag(s)` and render them with {http://citationstyles.org/ CSL}.

 @param grouping [String] the type of the name (either "user" or "group")
 @param name [String] the name of the group or user
 @param tags [Array<String>] the tags that all posts must contain (can be empty)
 @param count [Integer] number of posts to download
 @return [String] the rendered posts as HTML