Search in sources :

Example 21 with Post

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

the class UpdatePostRequest method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("post")) {
        JsonElement jsonPost = jsonObject.get("post");
        if (jsonPost != null) {
            post = new Post();
            post.fromJson(jsonPost.getAsJsonObject());
        }
    }
    if (jsonObject.has("publish")) {
        JsonElement jsonPublish = jsonObject.get("publish");
        if (jsonPublish != null) {
            publish = Boolean.valueOf(jsonPublish.getAsBoolean());
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Post(com.willshex.blogwt.shared.api.datatype.Post)

Example 22 with Post

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

the class SearchAllResponse method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("posts")) {
        JsonElement jsonPosts = jsonObject.get("posts");
        if (jsonPosts != null) {
            posts = new ArrayList<Post>();
            Post item = null;
            for (int i = 0; i < jsonPosts.getAsJsonArray().size(); i++) {
                if (jsonPosts.getAsJsonArray().get(i) != null) {
                    (item = new Post()).fromJson(jsonPosts.getAsJsonArray().get(i).getAsJsonObject());
                    posts.add(item);
                }
            }
        }
    }
    if (jsonObject.has("pages")) {
        JsonElement jsonPages = jsonObject.get("pages");
        if (jsonPages != null) {
            pages = new ArrayList<Page>();
            Page item = null;
            for (int i = 0; i < jsonPages.getAsJsonArray().size(); i++) {
                if (jsonPages.getAsJsonArray().get(i) != null) {
                    (item = new Page()).fromJson(jsonPages.getAsJsonArray().get(i).getAsJsonObject());
                    pages.add(item);
                }
            }
        }
    }
    if (jsonObject.has("users")) {
        JsonElement jsonUsers = jsonObject.get("users");
        if (jsonUsers != null) {
            users = new ArrayList<User>();
            User item = null;
            for (int i = 0; i < jsonUsers.getAsJsonArray().size(); i++) {
                if (jsonUsers.getAsJsonArray().get(i) != null) {
                    (item = new User()).fromJson(jsonUsers.getAsJsonArray().get(i).getAsJsonObject());
                    users.add(item);
                }
            }
        }
    }
}
Also used : User(com.willshex.blogwt.shared.api.datatype.User) JsonElement(com.google.gson.JsonElement) Post(com.willshex.blogwt.shared.api.datatype.Post) Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 23 with Post

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

the class PostHelper method nextPostSlug.

/**
 * @param posts
 * @param slug
 * @return
 */
public static String nextPostSlug(List<Post> posts, String slug) {
    String nextSlug = slug;
    if (posts != null) {
        String strippedSlug;
        int largestSuffix = 0, suffix;
        for (Post post : posts) {
            strippedSlug = post.slug.replace(slug, "");
            if (!strippedSlug.isEmpty()) {
                suffix = Integer.parseInt(strippedSlug);
                if (suffix > largestSuffix) {
                    largestSuffix = suffix;
                }
            }
        }
        if (posts.size() > 0 && largestSuffix >= 0) {
            nextSlug += Integer.toString(largestSuffix + 1);
        }
    }
    return nextSlug;
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post)

Example 24 with Post

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

the class EditPagePage method onfinished.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.client.wizard.PagePlanFinishedHandler#onfinished
	 * (java.util.List) */
@Override
public void onfinished(List<WizardPage<?>> pages) {
    Page page = null;
    Post post = null;
    for (WizardPage<?> wizardPage : pages) {
        if (wizardPage instanceof EditPageWizardPage) {
            page = ((EditPageWizardPage) wizardPage).getData();
            if (page.posts != null) {
                page.posts.clear();
            }
        } else if (wizardPage instanceof SelectPostWizardPage) {
            if (page.posts == null) {
                page.posts = new ArrayList<Post>();
            }
            post = ((SelectPostWizardPage) wizardPage).getData();
            page.posts.add(post);
        }
    }
    if (page.id == null) {
        PageController.get().createPage(page);
    } else {
        PageController.get().updatePage(page);
    }
}
Also used : SelectPostWizardPage(com.willshex.blogwt.client.wizard.page.SelectPostWizardPage) EditPageWizardPage(com.willshex.blogwt.client.wizard.page.EditPageWizardPage) Post(com.willshex.blogwt.shared.api.datatype.Post) ArrayList(java.util.ArrayList) Page(com.willshex.blogwt.shared.api.datatype.Page) EditPageWizardPage(com.willshex.blogwt.client.wizard.page.EditPageWizardPage) WizardPage(com.willshex.blogwt.client.wizard.WizardPage) WizardDialogPage(com.willshex.blogwt.client.page.wizard.WizardDialogPage) SelectPostWizardPage(com.willshex.blogwt.client.wizard.page.SelectPostWizardPage)

Example 25 with Post

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

the class SiteMapServlet method printPosts.

private void printPosts(PrintWriter p, String url) {
    List<Post> posts;
    Pager pager = PagerHelper.createDefaultPager();
    do {
        posts = PostServiceProvider.provide().getPosts(Boolean.FALSE, Boolean.FALSE, pager.start, pager.count, PostSortType.PostSortTypePublished, SortDirectionType.SortDirectionTypeDescending);
        if (posts != null) {
            PagerHelper.moveForward(pager);
            for (Post post : posts) {
                p.println(String.format(LOC_FORMAT, url, "#" + PageType.PostDetailPageType.asTargetHistoryToken(post.slug)));
            }
        }
    } while (posts != null && posts.size() >= pager.count.intValue());
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) Pager(com.willshex.blogwt.shared.api.Pager)

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