@param posts [Integral::Post] collection of posts to convert to JSON-LD

 @return [String] Javascript snippet containing JSON-LD of the provided posts
199649
def render_posts_as_json_ld(posts)
      render_json_ld do
        {
          "@context": 'http://schema.org',
          "@type": 'Blog',
          "name": t('.title'),
          "url": request.original_url,
          "description": t('.description'),
          "publisher": {
            "@type": 'Organization',
            "name": Integral::Settings.website_title
          },
          "blogPosts": posts.map(&:to_json_ld)
        }
      end
    end
808447
function query_posts()
   	{
   		// vars
   		$r = array(
   			'next_page_exists' => 1,
   			'html' => ''
   		);
   		
   		
   		// options
		$options = array(
			'post_type'					=>	'all',
			'taxonomy'					=>	'all',
			'posts_per_page'			=>	10,
			'paged'						=>	1,
			'orderby'					=>	'title',
			'order'						=>	'ASC',
			'post_status'				=>	'any',
			'suppress_filters'			=>	false,
			's'							=>	'',
			'lang'						=>	false,
			'update_post_meta_cache'	=>	false,
			'field_key'					=>	'',
			'nonce'						=>	'',
			'ancestor'					=>	false,
		);
		
		$options = array_merge( $options, $_POST );
		
		
		// validate
		if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
		{
			die();
		}
		
		
		// WPML
		if( $options['lang'] )
		{
			global $sitepress;
			
			if( !empty($sitepress) )
			{
				$sitepress->switch_lang( $options['lang'] );
			}
		}
		
		
		// convert types
		$options['post_type'] = explode(',', $options['post_type']);
		$options['taxonomy'] = explode(',', $options['taxonomy']);
		
		
		// load all post types by default
		if( in_array('all', $options['post_type']) )
		{
			$options['post_type'] = apply_filters('acf/get_post_types', array());
		}
		
		
		// attachment doesn't work if it is the only item in an array???
		if( is_array($options['post_type']) && count($options['post_type']) == 1 )
		{
			$options['post_type'] = $options['post_type'][0];
		}
		
		
		// create tax queries
		if( ! in_array('all', $options['taxonomy']) )
		{
			// vars
			$taxonomies = array();
			$options['tax_query'] = array();
			
			foreach( $options['taxonomy'] as $v )
			{
				
				// find term (find taxonomy!)
				// $term = array( 0 => $taxonomy, 1 => $term_id )
				$term = explode(':', $v); 
				
				
				// validate
				if( !is_array($term) || !isset($term[1]) )
				{
					continue;
				}
				
				
				// add to tax array
				$taxonomies[ $term[0] ][] = $term[1];
				
			}
			
			
			// now create the tax queries
			foreach( $taxonomies as $k => $v )
			{
				$options['tax_query'][] = array(
					'taxonomy' => $k,
					'field' => 'id',
					'terms' => $v,
				);
			}
		}
		
		unset( $options['taxonomy'] );
		
		
		// load field
		$field = array();
		if( $options['ancestor'] )
		{
			$ancestor = apply_filters('acf/load_field', array(), $options['ancestor'] );
			$field = acf_get_child_field_from_parent_field( $options['field_key'], $ancestor );
		}
		else
		{
			$field = apply_filters('acf/load_field', array(), $options['field_key'] );
		}
		
		
		// get the post from which this field is rendered on
		$the_post = get_post( $options['post_id'] );
		
		
		// filters
		$options = apply_filters('acf/fields/relationship/query', $options, $field, $the_post);
		$options = apply_filters('acf/fields/relationship/query/name=' . $field['_name'], $options, $field, $the_post );
		$options = apply_filters('acf/fields/relationship/query/key=' . $field['key'], $options, $field, $the_post );
		
		
		// query
		$wp_query = new WP_Query( $options );

		
		// global
		global $post;
		
		
		// loop
		while( $wp_query->have_posts() ) {
			
			$wp_query->the_post();
			
			
			// get title
			$title = $this->get_result($post, $field, $the_post, $options);
			
			
			// update html
			$r['html'] .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title .  '<span class="acf-button-add"></span></a></li>';
				
		}
		
		
		// next page
		if( (int)$options['paged'] >= $wp_query->max_num_pages ) {
			
			$r['next_page_exists'] = 0;
			
		}
		
		
		// reset
		wp_reset_postdata();
		
		
		// return JSON
		echo json_encode( $r );
		
		die();
			
	}
1163957
def set_post_flair post, link_flair_css_class, link_flair_text
      Module.nesting[1].logger.warn "setting flair '#{link_flair_css_class}' with text '#{link_flair_text}' to post '#{post["name"]}'"
      if {"error"=>403} == @flairselector_choices ||= json(:post, "/r/#{@subreddit}/api/flairselector", link: post["name"])
        Module.nesting[1].logger.error "possibly not enough permissions for /r/#{@subreddit}/api/flairselector"
        return
      end
      json :post, "/api/selectflair",
        link: post["name"],
        text: link_flair_text,
        flair_template_id: @flairselector_choices["choices"].find{ |i| i["flair_css_class"] == link_flair_css_class }.tap{ |flair|
          fail "can't find '#{link_flair_css_class}' flair class at https://www.reddit.com/r/#{@subreddit}/about/flair/#link_templates" unless flair
        }["flair_template_id"]
    end
832200
function ctc_get_posts() {

		$posts = array();

		// Base arguments
		$args = array(
			'post_type'			=> 'attachment',
			'post_status'		=> 'inherit', // for attachments
			'post_mime_type'	=> 'image',
			'posts_per_page'	=> $this->ctc_instance['limit'],
			'orderby'			=> $this->ctc_instance['orderby'],
			'order'				=> $this->ctc_instance['order'],
			'no_found_rows'		=> true // faster
		);

		// All Galleries - get images attached to Gallery posts/pages
		if ( 'all' == $this->ctc_instance['post_id'] || empty( $this->ctc_instance['post_id'] ) ) {
			$args['post_parent__in'] = ctc_gallery_posts_ids(); // get all Gallery post IDs into array
		}

		// Specififc Gallery - get images used in shortcodes on post/page
		// Getting IDs from shortcode attributes since post may have images not attached to it
		else {

			// Get data for one post
			$posts = ctc_gallery_posts( array(
				'post_id' => $this->ctc_instance['post_id']
			) );

			// Use ID's from shortcode attributes
			if ( ! empty( $posts[$this->ctc_instance['post_id']]['image_ids'] ) ) {
				$args['post__in'] = $posts[$this->ctc_instance['post_id']]['image_ids'];
			}

		}

		// Get gallery images
		if ( ! empty( $args['post_parent__in'] ) || ! empty( $args['post__in'] ) ) { // if have something to search for
			$images_query = new WP_Query( $args );
			$posts = ! empty( $images_query->posts ) ? $images_query->posts : array();
		}

		// Return filtered
		return apply_filters( 'ctc_gallery_widget_get_posts', $posts );

	}
515021
function getTags (posts) {
  var tags = posts.reduce(function (tags, post) {
    if (!post.tags || !Array.isArray(post.tags)) return tags;
    return tags.concat(post.tags);
  }, []);

  return _.unique(tags).sort();
}
946907
def prepare_param_post(post_or_values, &block)
        post = case post_or_values
          when WWW::Delicious::Post
            post_or_values
          when Hash
            Post.new(post_or_values)
          else
            raise ArgumentError, 'Expected `args` to be `WWW::Delicious::Post` or `Hash`'
          end

        yield(post) if block_given?
        # TODO: validate post with post.validate!
        raise ArgumentError, 'Both `url` and `title` are required' unless post.api_valid?
        post
      end
1179230
def serialize_other_informations
      serialized = {}

      # set pubblication datetime
      serialized[:publication_datetime] = post_parent.publication_datetime

      # set translations links
      serialized[:translations] = {}
      post_parent.posts.published.each do |post|
        next if post.id == id
        serialized[:translations][post.meta_language] = post.serialize_base
      end

      # return serialzed informations
      serialized
    end
1361609
def parse_post_collection(body)
        dom  = parse_and_validate_response(body, :root_name => 'posts')
        dom.root.elements.collect('post') { |xml| Post.from_rexml(xml) }
      end
1303854
def render_post_fields(post)
      post_fields = post.post_fields.visibles.roots.order('position ASC')
      render 'lato_blog/back/posts/shared/fields', post_fields: post_fields
    end
190594
def index
      @search = Snippet.order('title asc').search(params[:q])
      @snippets = @search.result(distinct: true).per_page_kaminari(params[:page]).per(10)

      respond_to do |format|
        format.html # index.html.erb
        format.json { render json: @snippets }
      end
    end
370697
def share_bar_for_post(post)
      return "" unless Blogit.configuration.include_share_bar
      render(partial: "blogit/posts/share_bar", locals: { post: post})
    end
733131
def snippet_objects(locals = {})
      locals = {} unless locals.kind_of?(Hash)
      @snippet_objects ||= snippets.map do |key, snippet|  # Key here is 'snippet_1'
        if snippet['class_name']
          klass = "Effective::Snippets::#{snippet['class_name'].classify}".safe_constantize
          klass.new(snippet.merge!(locals).merge!(:region => self, :id => key)) if klass
        end
      end.compact
    end
209010
static function snippet($text, $keywords, $limit, $max_length, $around = array('<b>', '</b>'))
	{
		$result = array();

		$keywords = self::normalize($keywords);
		list($pre, $post) = $around;
		$prev = array();
		$after = false;

		foreach(self::normalize_hash($text) as $word_orig => $word_norm)
		{
			$is_kw = false;
			if(in_array($word_norm, $keywords))
			{
				$prev[] = $pre.$word_orig.$post;
				$is_kw = true;
			}
			else
				$prev[] = $word_orig;

			if($is_kw)
			{
				if($after)
				{
					$result = array_merge($result, $prev);
					$prev = array();
				}
				else
				{
					$result = array_merge($result, count($prev) > $limit ? array('&#133') : array(), array_slice($prev, -$limit-1));
					$prev = array();
				}

				$after = true;
			}
			else
			{
				if($after && count($prev) >= $limit)
				{
					$after = false;
					$result = array_merge($result, $prev);
					$prev = array();
				}
			}
		}

		if($after)
			$result = array_merge($result, array('&#133'), $prev);

		return strip_text(join(' ', $result).'&#133;', $max_length);
	}
7750
def create_new_post(params)      
      post_title = params['post']['title']
      post_date  = (Time.now).strftime("%Y-%m-%d")

      content    = yaml_data(post_title).to_yaml + "---\n" + params[:post][:content]
      post_file  = (post_date + " " + post_title).to_url + '.md'
      file       = File.join(jekyll_site.source, *%w[_posts], post_file)
      File.open(file, 'w') { |file| file.write(content)}
      post_file
    end
1234359
def update
      @post = LatoBlog::Post.find_by(id: params[:id])
      return unless check_post_presence

      # update for autosaving
      autosaving = params[:autosave] && params[:autosave] == 'true'
      if autosaving
        @post.update(edit_post_params)
        update_fields
        render status: 200, json: {} # render something positive :)
        return
      end

      # check post data update
      unless @post.update(edit_post_params)
        flash[:danger] = @post.errors.full_messages.to_sentence
        redirect_to lato_blog.edit_post_path(@post.id)
        return
      end

      # update single fields
      unless update_fields
        flash[:warning] = LANGUAGES[:lato_blog][:flashes][:post_update_fields_warning]
        redirect_to lato_blog.edit_post_path(@post.id)
        return
      end

      # render positive response
      flash[:success] = LANGUAGES[:lato_blog][:flashes][:post_update_success]
      redirect_to lato_blog.post_path(@post.id)
    end
316743
function _constructPost(f, post) {
    return function _wrapped() {
        var arr = [f.apply(this, arguments)];
        post.apply(this, arr.concat.apply(arr, arguments));
        return arr[0];
    };
}
777031
def update_post(params)
      post_file   = params[:post][:name]
      post        = jekyll_post(post_file)
      yaml_config = merge_config(post.data, params)
      write_post_contents(params[:post][:content], yaml_config, post_file)

      post_file
    end