Reblog a given post
@param blogName the name of the blog to post to
@param postId the id of the post
@param reblogKey the reblog_key of the post
@param options Additional options (or null)
@return The created reblog Post or null
973300
public Post postReblog(String blogName, Long postId, String reblogKey, Map<String, ?> options) {
        if (options == null) {
            options = new HashMap<String, String>();
        }
        Map<String, Object> soptions = JumblrClient.safeOptionMap(options);
        soptions.put("id", postId.toString());
        soptions.put("reblog_key", reblogKey);
        final Long reblogId = requestBuilder.post(JumblrClient.blogPath(blogName, "/post/reblog"), soptions).getId();
        return this.blogPost(blogName, reblogId);
    }
1227619
public function dispatchPostCreateEvent(Blog $blog, Post $post)
    {
        $event = new LogPostCreateEvent($post);

        return $this->dispatch($event);
    }
953758
function set_site_blog_context( $blog_id ) {
            $this->_blog_id = $blog_id;

            $this->_options = FS_Option_Manager::get_manager( $this->_id, false, $this->_blog_id );
        }
1031700
public function dispatchBlogConfigureBannerEvent(BlogOptions $blogOptions, $changeSet)
    {
        $event = new LogBlogConfigureBannerEvent($blogOptions, $changeSet);

        return $this->dispatch($event);
    }
474923
func (b *BlogRef) ReblogPost(p *PostRef, params url.Values) (*PostRef, error) {
	return p.ReblogOnBlog(b.Name, params)
}
748028
public static BlogConnection getBlogConnection(final String type, final String url, final String username, final String password)
            throws BlogClientException {
        BlogConnection blogConnection = null;
        if (type == null || type.equals("metaweblog")) {
            blogConnection = createBlogConnection(METAWEBLOG_IMPL_CLASS, url, username, password);
        } else if (type.equals("atom")) {
            blogConnection = createBlogConnection(ATOMPROTOCOL_IMPL_CLASS, url, username, password);
        } else {
            throw new BlogClientException("Type must be 'atom' or 'metaweblog'");
        }
        return blogConnection;
    }
122209
@Override
    public List<QueryRow> regularQuery(final QueryOptions options) throws CouchbaseLiteException {

        final Predicate<QueryRow> postFilter = options.getPostFilter();

        int tmpLimit = QueryOptions.QUERY_OPTIONS_DEFAULT_LIMIT;
        int tmpSkip = 0;
        if (postFilter != null) {
            // #574: Custom post-filter means skip/limit apply to the filtered rows, not to the
            // underlying query, so handle them specially:
            tmpLimit = options.getLimit();
            tmpSkip = options.getSkip();
            if (tmpLimit == 0)
                return new ArrayList<QueryRow>(); // empty result set
            options.setLimit(QueryOptions.QUERY_OPTIONS_DEFAULT_LIMIT);
            options.setSkip(0);
        }

        final CountDown skip = new CountDown(tmpSkip);
        final CountDown limit = new CountDown(tmpLimit);

        final List<QueryRow> rows = new ArrayList<QueryRow>();

        Status status = runQuery(options, new QueryRowBlock() {
            @Override
            public Status onRow(byte[] keyData, byte[] valueData, String docID, Cursor cursor) {
                JsonDocument keyDoc = new JsonDocument(keyData);
                JsonDocument valueDoc = new JsonDocument(valueData);
                long sequence = Long.parseLong(cursor.getString(3));
                RevisionInternal docRevision = null;
                if (options.isIncludeDocs()) {
                    Object valueObject = valueDoc.jsonObject();
                    String linkedID = null;
                    if (valueObject instanceof Map)
                        linkedID = (String) ((Map) valueObject).get("_id");
                    if (linkedID != null) {
                        // Linked document: http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views#Linked_documents
                        String linkedRev = (String) ((Map) valueObject).get("_rev");
                        Status linkedStatus = new Status();
                        docRevision = store.getDocument(linkedID, linkedRev, true, linkedStatus);
                        sequence = docRevision.getSequence();
                    } else {
                        String revID = cursor.getString(4);
                        byte[] json = cursor.getBlob(5);
                        Map<String, Object> properties = store.documentPropertiesFromJSON(
                                json,
                                docID,
                                revID,
                                false,
                                sequence);
                        docRevision = SQLiteStore.revision(
                                docID,    // docID
                                revID,    // revID
                                false,    // deleted
                                sequence, // sequence
                                properties// properties
                        );
                    }
                }
                QueryRow row = new QueryRow(docID, sequence,
                        keyDoc.jsonObject(), valueDoc.jsonObject(),
                        docRevision);
                if (postFilter != null) {
                    if (!postFilter.apply(row)) {
                        return new Status(Status.OK);
                    }
                    if (skip.getCount() > 0) {
                        skip.countDown();
                        return new Status(Status.OK);
                    }

                }
                rows.add(row);

                if (limit.countDown() == 0)
                    return new Status(0); /// stops the iteration
                return new Status(Status.OK);
            }
        });

        // If given keys, sort the output into that order, and add entries for missing keys:
        if (options.getKeys() != null && options.getKeys().size() > 0) {
            // Group rows by key:
            Map<Object, List<QueryRow>> rowsByKey = new HashMap<Object, List<QueryRow>>();
            for (QueryRow row : rows) {
                List<QueryRow> rs = rowsByKey.get(row.getKey());
                if (rs == null) {
                    rs = new ArrayList<QueryRow>();
                    rowsByKey.put(row.getKey(), rs);
                }
                rs.add(row);
            }

            // Now concatenate them in the order the keys are given in options:
            final List<QueryRow> sortedRows = new ArrayList<QueryRow>();
            for (Object key : options.getKeys()) {
                JsonDocument jsonDoc = null;
                try {
                    byte[] keyBytes = Manager.getObjectMapper().writeValueAsBytes(key);
                    jsonDoc = new JsonDocument(keyBytes);
                } catch (JsonProcessingException e) {
                    throw new CouchbaseLiteException(Status.INTERNAL_SERVER_ERROR);
                }
                List<QueryRow> rs = rowsByKey.get(jsonDoc.jsonObject());
                if (rs != null)
                    sortedRows.addAll(rs);
            }

            return sortedRows;
        }

        return rows;
    }
1315122
public function getBlogUrl($blogId)
    {
        if (isset($this->blogUrl[$blogId])) {

            return $this->blogUrl[$blogId];

        } else {

            $url = appSetting('url', 'blog-' . $blogId);
            $url = $url ? $url : 'blog/';
            $url = site_url($url);

            $this->blogUrl[$blogId] = $url;

            return $this->blogUrl[$blogId];
        }
    }
12164
public void follow(String blogName) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("url", JumblrClient.blogUrl(blogName));
        requestBuilder.post("/user/follow", map);
    }
1212929
@Override
	@Transactional(enabled = false)
	public CPOptionValue createCPOptionValue(long CPOptionValueId) {
		return cpOptionValuePersistence.create(CPOptionValueId);
	}
1294050
public function getAction(Request $request, Blog $blog, $postId)
    {
        $this->checkPermission('OPEN', $blog->getResourceNode(), [], true);
        $post = $this->postManager->getPostByIdOrSlug($blog, $postId);

        if (is_null($post)) {
            throw new NotFoundHttpException('Post not found');
        }

        $this->trackingManager->dispatchPostReadEvent($post);

        $session = $request->getSession();
        $sessionViewCounterKey = 'blog_post_view_counter_'.$post->getId();
        $now = time();

        if ($now >= ($session->get($sessionViewCounterKey) + $this->logThreshold)) {
            $session->set($sessionViewCounterKey, $now);
            $this->postManager->updatePostViewCount($post);
        }

        return new JsonResponse($this->postSerializer->serialize($post));
    }
305418
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('blogname', action=arguments.TumblrParser)
    group = parser.add_mutually_exclusive_group()
    group.add_argument('--submit', nargs='*')
    group.add_argument('--random', action='store_true')
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return

    if cmdargs.random:
        apikey = args['config']['api']['tumblrconsumerkey']
        # First, get the number of posts
        response = get('https://api.tumblr.com/v2/blog/%s/posts' % cmdargs.blogname, params={'api_key': apikey, 'type': 'text'}).json()
        postcount = response['response']['total_posts']
        if postcount <= 1:
            send("No text posts found.")
            return
        # No random post functionality and we can only get 20 posts per API call, so pick a random offset to get the random post
        offset = randint(0, postcount - 1)
        response = get('https://api.tumblr.com/v2/blog/%s/posts' % cmdargs.blogname,
                       params={
                           'api_key': apikey,
                           'offset': offset,
                           'limit': 1,
                           'type': 'text',
                           'filter': 'text'
                       }).json()
        entry = response['response']['posts'][0]['body']
        # Account for possibility of multiple lines
        lines = entry.splitlines()
        for line in lines:
            send(line)

    elif cmdargs.submit:
        if not cmdargs.submit:
            send('Post what?')
            return
        if isinstance(cmdargs.submit, list):
            cmdargs.submit = ' '.join(cmdargs.submit)
        if args['is_admin']:
            send(post_tumblr(args['config'], cmdargs.blogname, cmdargs.submit)[0])
        else:
            row = Tumblrs(post=cmdargs.submit, submitter=args['nick'], nick=args['nick'], blogname=cmdargs.blogname)
            args['db'].add(row)
            args['db'].flush()
            send("New Tumblr Post: %s -- %s, Submitted by %s" % (cmdargs.submit, cmdargs.blogname, args['nick']),
                 target=args['config']['core']['ctrlchan'])
            send("Issue submitted for approval.", target=args['nick'])
    else:
        send("Did not get an argument (choices are --random, --submit)")
996811
public void postEdit(String blogName, Long id, Map<String, ?> detail) throws IOException {
        Map<String, Object> sdetail = JumblrClient.safeOptionMap(detail);
        sdetail.put("id", id);
        requestBuilder.postMultipart(JumblrClient.blogPath(blogName, "/post/edit"), sdetail);
    }
120645
public Post.Builder selectPost(final long postId) throws SQLException {
      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      Timer.Context ctx = metrics.selectPostTimer.time();
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(selectPostSQL + postsTableName + " WHERE ID=?");
         stmt.setLong(1, postId);
         rs = stmt.executeQuery();
         return rs.next() ? postFromResultSet(rs) : null;
      } finally {
         ctx.stop();
         SQLUtil.closeQuietly(conn, stmt, rs);
      }
   }
266787
public static function runOnBlog( int $blog_id, callable $callback, ...$args ) {
		switch_to_blog( $blog_id );
		$result = call_user_func_array( $callback, $args );
		switch_to_blog( get_current_blog_id() );

		return $result;
	}
415353
public List<Post> tagged(String tag, Map<String, ?> options) {
        if (options == null) {
            options = Collections.emptyMap();
        }
        Map<String, Object> soptions = JumblrClient.safeOptionMap(options);
        soptions.put("api_key", apiKey);
        soptions.put("tag", tag);
        return requestBuilder.get("/tagged", soptions).getTaggedPosts();
    }
813655
public EtcdKeyPostRequest post(String key, String value) {
    return new EtcdKeyPostRequest(client, key, retryHandler).value(value);
  }