Search in sources :

Example 31 with Post

use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.

the class StaticPage method appendPage.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.page.StaticTemplate#appendPage(java.lang.
	 * StringBuffer) */
@Override
protected void appendPage(StringBuffer markup) {
    Page page = ensurePage();
    if (page != null && page.posts != null) {
        for (Post post : page.posts) {
            if (post.content != null && post.content.body != null) {
                markup.append("<a name=\"!");
                markup.append(page.slug);
                markup.append("/");
                markup.append(post.slug);
                markup.append("\"></a>");
                markup.append("<section><div>");
                markup.append(process(post.content.body));
                markup.append("</div></section>");
            }
        }
    } else {
        markup.append("Page not found.");
    }
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 32 with Post

use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.

the class StaticPost method lookupPost.

private void lookupPost() {
    GetPostRequest input = input(GetPostRequest.class).post(new Post().slug(stack.getAction()));
    output = (new GetPostActionHandler()).handle(input);
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) GetPostRequest(com.willshex.blogwt.shared.api.blog.call.GetPostRequest) GetPostActionHandler(com.willshex.blogwt.server.api.blog.action.GetPostActionHandler)

Example 33 with Post

use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.

the class StaticPosts method showPosts.

protected void showPosts(List<Post> posts, StringBuffer markup) {
    MarkdownProcessor processor = new MarkdownProcessor();
    processor.registerPlugins(new IncludePlugin());
    String link, body;
    for (Post post : posts) {
        body = "Empty... :imp:";
        if (post.summary != null && post.summary.length() > 0) {
            body = post.summary;
        }
        link = "/#" + PageType.PostDetailPageType.asTargetHistoryToken(PostHelper.getSlug(post));
        markup.append("<div><a href=\"");
        markup.append(link);
        markup.append("\">");
        markup.append(process("##" + post.title));
        markup.append("</a><div><span>");
        markup.append(DateTimeHelper.ago(post.published));
        markup.append("</span> by <img src=\"");
        markup.append(post.author.avatar);
        markup.append("?s=");
        markup.append(UserHelper.AVATAR_HEADER_SIZE);
        markup.append("&default=retro\" /> ");
        markup.append(UserHelper.handle(post.author));
        markup.append("</div><div>");
        markup.append(process(body));
        markup.append("</div><a href=\"");
        markup.append(link);
        markup.append("\">Read More</a></div>");
    }
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) IncludePlugin(org.markdown4j.server.IncludePlugin) MarkdownProcessor(org.markdown4j.server.MarkdownProcessor)

Example 34 with Post

use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.

the class ArchiveEntryService method addArchiveEntry.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.service.archiveentry.IArchiveEntryService
	 * #addArchiveEntry(com.willshex.blogwt.shared.api.datatype.ArchiveEntry) */
@Override
public ArchiveEntry addArchiveEntry(ArchiveEntry archiveEntry) {
    if (archiveEntry.created == null) {
        archiveEntry.created = new Date();
    }
    archiveEntry.postKeys = new ArrayList<Key<Post>>();
    for (Post post : archiveEntry.posts) {
        archiveEntry.postKeys.add(Key.create(post));
    }
    Key<ArchiveEntry> key = provide().save().entity(archiveEntry).now();
    archiveEntry.id = keyToId(key);
    return archiveEntry;
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) ArchiveEntry(com.willshex.blogwt.shared.api.datatype.ArchiveEntry) Date(java.util.Date) Key(com.googlecode.objectify.Key)

Example 35 with Post

use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.

the class PageService method updatePage.

@Override
public Page updatePage(Page page) {
    page.postKeys = new ArrayList<Key<Post>>();
    for (Post post : page.posts) {
        page.postKeys.add(Key.create(post));
    }
    if (page.parent != null) {
        page.parentKey = Key.create(page.parent);
    } else {
        page.parentKey = null;
    }
    provide().save().entity(page).now();
    SearchHelper.queueToIndex(getName(), page.id);
    return page;
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) Key(com.googlecode.objectify.Key)

Aggregations

Post (com.willshex.blogwt.shared.api.datatype.Post)52 JsonElement (com.google.gson.JsonElement)11 ArrayList (java.util.ArrayList)11 Pager (com.willshex.blogwt.shared.api.Pager)10 Key (com.googlecode.objectify.Key)8 Page (com.willshex.blogwt.shared.api.datatype.Page)7 Date (java.util.Date)6 InputValidationException (com.willshex.gson.web.service.server.InputValidationException)5 HashMap (java.util.HashMap)5 Tag (com.willshex.blogwt.shared.api.datatype.Tag)4 User (com.willshex.blogwt.shared.api.datatype.User)4 ArchiveEntry (com.willshex.blogwt.shared.api.datatype.ArchiveEntry)3 PostContent (com.willshex.blogwt.shared.api.datatype.PostContent)3 ScoredDocument (com.google.appengine.api.search.ScoredDocument)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 EditPageWizardPage (com.willshex.blogwt.client.wizard.page.EditPageWizardPage)2 SelectPostWizardPage (com.willshex.blogwt.client.wizard.page.SelectPostWizardPage)2 GetPostRequest (com.willshex.blogwt.shared.api.blog.call.GetPostRequest)2 MarkdownProcessor (org.markdown4j.server.MarkdownProcessor)2 Document (com.google.appengine.api.search.Document)1