Display a single post
12029
public function init(Request $request, $postType, $id, $method, $customId = '')
    {
    	// Lets validate if the post type exists and if so, continue.
		$postTypeModel = $this->getPostType($postType);
    	if(!$postTypeModel){
    		$errorMessages = 'You are not authorized to do this.';
    		return $this->abort($errorMessages);
		}

		$config = $this->getConfig($postTypeModel);

    	// Check if the post type has a identifier
    	if(empty($postTypeModel->identifier)){
    		$errorMessages = 'The post type does not have a identifier.';
    		if(array_has($postTypeModel->errorMessages, 'post_type_identifier_does_not_exist')){
    			$errorMessages = $postTypeModel->errorMessages['post_type_identifier_does_not_exist'];
    		}
    		return $this->abort($errorMessages, $config);
		}

	    $post = $this->findPostInstance($postTypeModel, $request, $postType, $id, 'show_post');
		if(!$post){
			$errorMessages = 'Post does not exist.';
			if(array_has($postTypeModel->errorMessages, 'post_does_not_exist')){
				$errorMessages = $postTypeModel->errorMessages['post_does_not_exist'];
			}
			return $this->abort($errorMessages, $config);
        }

        if(method_exists($postTypeModel, 'show_custom_get_' . $method)){
            $methodToEdit = 'show_custom_get_' . $method;
            return $postTypeModel->$methodToEdit($request, $id, $customId, $post);
        } else {
            $errorMessages = 'The post type does not have the custom show get method ' . $method . '.';
            if(array_has($postTypeModel->errorMessages, 'post_type_does_not_have_the_support_custom_show_getmethod')){
                $errorMessages = $postTypeModel->errorMessages['post_type_does_not_have_the_support_custom_show_getmethod'];
            }
            return $this->abort($errorMessages);
        }
	}
1207177
function(number, params, headers, callback) {
        var url;
        url = this.client.url() + ("posts/" + (number || '') + "/comments");
        return this.client.post(url, params, headers, callback);
      }
766602
function havePosts( error, post ) {
  this.debug( 'haveSingle' );
  console.log( require( 'util' ).inspect( post, { showHidden: false, colors: true, depth: 4 } ) );
}
38076
function displayResponse(response){
  
  // Gather and display HTTP response data
  var lines = [
    response.statusCode + ' ' + response.statusText,
    headersToString(response.headers)
  ];
  if(response.data){
    lines.push('');
    lines.push(prettyPrint(response.data));
  }
  output(lines.join('\n'));
  
  // Attach listeners to links so that clicking a link will auto-populate
  // the url field
  Array.from($output.querySelectorAll('.link')).forEach(function(link){
    link.addEventListener('click', function(){
      // Remove leading and trailing "
      $url.value = link.innerHTML.slice(1,-1);
      window.scrollTo(0, 0);
    });
  });
}
114485
public function show(Post $post)
    {
        $this->authorize(PostsPolicy::PERMISSION_SHOW);

        $post = $post->load(['author', 'category', 'tags', 'seo']);

        $this->setTitle(trans('blog::posts.titles.post-details'));
        $this->addBreadcrumb($post->title);

        return $this->view('admin.posts.show', compact('post'));
    }
292685
public function post($element = null, $filter_type = null)
    {
        if (!$this->post) {
            $content_type = $this->getContentType();
            if ($content_type === 'application/json') {
                $json = file_get_contents('php://input');
                $this->post = json_decode($json, true);
            } elseif (!empty($_POST)) {
                $this->post = (array)$_POST;
            }

            $event = new Event(['post' => &$this->post]);
            Grav::instance()->fireEvent('onHttpPostFilter', $event);
        }

        if ($this->post && null !== $element) {
            $item = Utils::getDotNotation($this->post, $element);
            if ($filter_type) {
                $item = filter_var($item, $filter_type);
            }
            return $item;
        }

        return $this->post;
    }
994095
public function display ($post)
    {
        echo '<div class="wrap-meta-field type-' . $this->getType() . '">';
        $this->outputLabel();
        $identifier = $post instanceof WP_Post ? $post->ID : $post;
        $this->output($this->getValue($identifier));
        echo '</div>';
    }
767119
def _post(self, url, data=None, json=None, params=None, headers=None):
        """"""
        url = self.clean_url(url)
        response = requests.post(url, data=data, json=json, params=params,
                                 headers=headers, timeout=self.timeout,
                                 verify=self.verify)
        return response
459534
public function display()
    {
        $options = $this->getOptions();

        if (!$this->visible || count($options) === 0) {
            return;
        }

        SwatWidget::display();

        $this->getForm()->addHiddenField($this->id . '_submitted', 1);

        $div_tag = new SwatHtmlTag('div');
        $div_tag->id = $this->id;
        $div_tag->class = $this->getCSSClassString();
        $div_tag->open();

        $input_tag = new SwatHtmlTag('input');
        $input_tag->type = 'checkbox';

        $label_tag = new SwatHtmlTag('label');
        $label_tag->class = 'swat-control';

        echo '<table>';

        if ($this->entry_column_title !== null) {
            echo '<thead><tr><th>&nbsp;</th><th>';
            echo $this->entry_column_title;
            echo '</th></tr></thead>';
        }

        // Only show the check all control if more than one checkable item is
        // displayed.
        if ($this->show_check_all && count($options) > 1) {
            echo '<tfoot><tr><td colspan="2">';
            $this->getCompositeWidget('check_all')->display();
            echo '</td></tr></tfoot>';
        }

        echo '<tbody>';
        foreach ($options as $key => $option) {
            echo '<tr><td>';

            $checkbox_id = $key . '_' . $option->value;

            $input_tag->value = (string) $option->value;
            $input_tag->removeAttribute('checked');
            $input_tag->name = $this->id . '[' . $key . ']';

            if (in_array($option->value, $this->values)) {
                $input_tag->checked = 'checked';
            }

            $input_tag->id = $this->id . '_' . $checkbox_id;
            echo '<span class="swat-checkbox-wrapper">';
            $input_tag->display();
            echo '<span class="swat-checkbox-shim"></span>';
            echo '</span>';

            $label_tag->for = $this->id . '_' . $checkbox_id;
            $label_tag->setContent($option->title, $option->content_type);
            $label_tag->display();

            echo '</td><td>';

            $this->getEntryWidget($option->value)->display();

            echo '</td></tr>';
        }
        echo '</tbody>';

        echo '</table>';

        $div_tag->close();

        Swat::displayInlineJavaScript($this->getInlineJavaScript());
    }
1226560
function filterLayout(posts) {
      var reLayout = new RegExp(layout, 'i');

      return posts.filter(function filterPosts(post) {
        return reLayout.test(post.layout);
      });
    }
454313
function show (req, res, next) {
    var _embed = req.query._embed
    var _expand = req.query._expand
    var id = utils.toNative(req.params.id)
    var resource = db.get(name).getById(id).value()

    if (resource) {
      // Clone resource to avoid making changes to the underlying object
      resource = _.cloneDeep(resource)

      // Embed other resources based on resource id
      // /posts/1?_embed=comments
      embed(resource, _embed)

      // Expand inner resources based on id
      // /posts/1?_expand=user
      expand(resource, _expand)

      res.locals.data = resource
    }

    next()
  }
173811
def post(self):
    """"""
    client_customer_id = self.request.get('clientCustomerId')
    if not client_customer_id:
      self.redirect('/')
    else:
      self.redirect('/showCampaigns?clientCustomerId=%s' % client_customer_id)
978307
def render_item(self, all_posts):
        
        index = all_posts.index(self)
        if index > 0:  # has newer posts
            newer_post = all_posts[index - 1]
        else:
            newer_post = None

        if index < len(all_posts) - 1:  # has older posts
            older_post = all_posts[index + 1]
        else:
            older_post = None
        return settings.JINJA_ENV.get_template(self.template).render(
            post=self,
            newer_post=newer_post,
            older_post=older_post,
            all_posts=all_posts,
            nav_context='post'
        )
1052818
def _format(self, posts):
        
        if posts.__class__ == Post:
            # format a single post
            return posts.dict()
        formated_posts = []
        for post in posts:
            formated_posts.append(post.dict())
        return formated_posts
386051
function getPosts(req, res, next) {
  db.tags.find(req.params.tag, function(err, tag) {
    if(err) { return next(err); }

    db.posts_tags.tagGetPosts(tag.id, function(err, posts) {
      if(err) { return next(err); }
      res.format({
        'text/html': function() {
          res.render('tags/show', {posts: posts, tag: tag});
        },
        'application/json': function() {
          res.json(posts);
        }
      });
    });
  });
}
1249154
def _view_or_add(self, uid):
        '''
        
        '''
        postinfo = MPost.get_by_uid(uid)
        if postinfo:
            self.viewinfo(postinfo)
        elif self.userinfo:
            self._to_add(uid=uid)
        else:
            self.show404()
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