Search in sources :

Example 1 with Post

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

the class EditPagePage method getPageSuccess.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.shared.api.page.call.event.GetPageEventHandler#
	 * getPageSuccess(com.willshex.blogwt.shared.api.page.call.GetPageRequest,
	 * com.willshex.blogwt.shared.api.page.call.GetPageResponse) */
@Override
public void getPageSuccess(GetPageRequest input, GetPageResponse output) {
    if (output.status == StatusType.StatusTypeSuccess) {
        PagePlanBuilder builder = new PagePlanBuilder();
        EditPageWizardPage ewp = new EditPageWizardPage();
        ewp.setData(output.page);
        builder.addPage(ewp);
        SelectPostWizardPage spwp = new SelectPostWizardPage();
        for (Post post : output.page.posts) {
            spwp = new SelectPostWizardPage();
            spwp.setData(post);
            builder.addPage(spwp, post != output.page.posts.get(0));
        }
        setPlan(builder.setName("Edit " + output.page.title).addFinishedHandler(this).build());
    }
}
Also used : SelectPostWizardPage(com.willshex.blogwt.client.wizard.page.SelectPostWizardPage) PagePlanBuilder(com.willshex.blogwt.client.wizard.PagePlan.PagePlanBuilder) EditPageWizardPage(com.willshex.blogwt.client.wizard.page.EditPageWizardPage) Post(com.willshex.blogwt.shared.api.datatype.Post)

Example 2 with Post

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

the class PageDetailPage method show.

private void show(Page page) {
    pnlContent.clear();
    SectionPart section;
    for (Post post : page.posts) {
        section = new SectionPart();
        section.setContent(page.slug, post);
        pnlContent.add(section);
    }
    lnkEditPage.setTargetHistoryToken(PageType.EditPagePageType.asTargetHistoryToken(page.slug));
    pnlLoading.setVisible(false);
    FooterPart.get().scrollToTop();
    refreshTitle();
}
Also used : SectionPart(com.willshex.blogwt.client.part.SectionPart) Post(com.willshex.blogwt.shared.api.datatype.Post)

Example 3 with Post

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

the class FeedServlet method getFeed.

protected SyndFeed getFeed(HttpServletRequest request) throws IOException, FeedException {
    SyndFeed feed = new SyndFeedImpl();
    String url = ServletHelper.constructBaseUrl(request);
    feed.setTitle(PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.TITLE).value);
    feed.setLink(url + "/feed");
    feed.setDescription(PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.EXTENDED_TITLE).value);
    List<Post> posts;
    Pager pager = PagerHelper.createDefaultPager();
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    SyndEntry entry;
    SyndContent description;
    MarkdownProcessor processor = new MarkdownProcessor();
    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) {
                entry = new SyndEntryImpl();
                entry.setTitle(post.title);
                entry.setLink(url + "/#" + PageType.PostDetailPageType.asTargetHistoryToken(post.slug));
                entry.setPublishedDate(post.published);
                description = new SyndContentImpl();
                description.setType("text/HTML");
                description.setValue(processor.process(post.summary));
                entry.setDescription(description);
                entries.add(entry);
            }
        }
    } while (posts != null && posts.size() >= pager.count.intValue());
    feed.setEntries(entries);
    return feed;
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) ArrayList(java.util.ArrayList) MarkdownProcessor(org.markdown4j.server.MarkdownProcessor) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SyndContent(com.rometools.rome.feed.synd.SyndContent) Pager(com.willshex.blogwt.shared.api.Pager) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl)

Example 4 with Post

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

the class UpdatePostActionHandler method handle.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.gson.web.service.server.ActionHandler#handle(com.willshex.
	 * gson.web.service.shared.Request,
	 * com.willshex.gson.web.service.shared.Response) */
@Override
protected void handle(UpdatePostRequest input, UpdatePostResponse output) throws Exception {
    ApiValidator.request(input, UpdatePostRequest.class);
    ApiValidator.accessCode(input.accessCode, "input.accessCode");
    output.session = input.session = SessionValidator.lookupCheckAndExtend(input.session, "input.session");
    UserValidator.authorisation(input.session.user, Arrays.asList(PermissionServiceProvider.provide().getCodePermission(PermissionHelper.MANAGE_POSTS)), "input.session.user");
    Post updatedPost = input.post;
    input.post = PostValidator.lookup(input.post, "input.post");
    input.post.content = PostServiceProvider.provide().getPostContent(input.post);
    updatedPost = PostValidator.validate(updatedPost, "input.post");
    input.post.commentsEnabled = updatedPost.commentsEnabled;
    input.post.content.body = updatedPost.content.body;
    input.post.listed = updatedPost.listed;
    input.post.summary = updatedPost.summary;
    List<String> removedTags = null;
    if (updatedPost.tags == null) {
        removedTags = input.post.tags;
    } else {
        if (input.post.tags != null) {
            removedTags = new ArrayList<String>();
            for (String tag : input.post.tags) {
                if (!updatedPost.tags.contains(tag)) {
                    removedTags.add(tag);
                }
            }
        }
    }
    input.post.tags = updatedPost.tags;
    input.post.title = updatedPost.title;
    // don't change the original publish date
    if (Boolean.TRUE.equals(input.publish) && input.post.published == null) {
        input.post.published = new Date();
    }
    output.post = PostServiceProvider.provide().updatePost(input.post, removedTags);
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) Date(java.util.Date)

Example 5 with Post

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

the class SearchAllActionHandler method handle.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.gson.web.service.server.ActionHandler#handle(com.willshex.
	 * gson.web.service.shared.Request,
	 * com.willshex.gson.web.service.shared.Response) */
@SuppressWarnings("unchecked")
@Override
protected void handle(SearchAllRequest input, SearchAllResponse output) throws Exception {
    ApiValidator.request(input, SearchAllRequest.class);
    ApiValidator.accessCode(input.accessCode, "input.accessCode");
    try {
        output.session = input.session = SessionValidator.lookupCheckAndExtend(input.session, "input.session");
    } catch (InputValidationException ex) {
        output.session = input.session = null;
    }
    if (input.query == null)
        ApiValidator.throwServiceError(InputValidationException.class, ApiError.InvalidValueNull, "String: input.query");
    output.posts = ((ISearch<Post>) PostServiceProvider.provide()).search(input.query, Integer.valueOf(0), SearchHelper.SHORT_SEARCH_LIMIT, null, null);
    Map<Key<User>, User> users = new HashMap<Key<User>, User>();
    if (output.posts != null) {
        for (Post post : output.posts) {
            if (users.get(post.authorKey) == null) {
                users.put(post.authorKey, UserServiceProvider.provide().getUser(keyToId(post.authorKey)));
            }
            post.author = users.get(post.authorKey);
        }
    }
    output.pages = ((ISearch<Page>) PageServiceProvider.provide()).search(input.query, Integer.valueOf(0), SearchHelper.SHORT_SEARCH_LIMIT, null, null);
    if (output.pages != null) {
        for (Page page : output.pages) {
            if (users.get(page.ownerKey) == null) {
                users.put(page.ownerKey, UserServiceProvider.provide().getUser(keyToId(page.ownerKey)));
            }
            page.owner = users.get(page.ownerKey);
        }
    }
    output.users = ((ISearch<User>) UserServiceProvider.provide()).search(input.query, Integer.valueOf(0), SearchHelper.SHORT_SEARCH_LIMIT, null, null);
}
Also used : User(com.willshex.blogwt.shared.api.datatype.User) HashMap(java.util.HashMap) Post(com.willshex.blogwt.shared.api.datatype.Post) InputValidationException(com.willshex.gson.web.service.server.InputValidationException) Page(com.willshex.blogwt.shared.api.datatype.Page) 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