Search in sources :

Example 21 with Page

use of com.willshex.blogwt.shared.api.datatype.Page 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 22 with Page

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

the class StaticPage method lookupPage.

private void lookupPage() {
    GetPageRequest input = input(GetPageRequest.class).includePosts(Boolean.TRUE).page(new Page().slug(slug));
    output = (new GetPageActionHandler()).handle(input);
}
Also used : Page(com.willshex.blogwt.shared.api.datatype.Page) GetPageRequest(com.willshex.blogwt.shared.api.page.call.GetPageRequest) GetPageActionHandler(com.willshex.blogwt.server.api.page.action.GetPageActionHandler)

Example 23 with Page

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

the class StaticTemplate method appendNavigationLinks.

private void appendNavigationLinks(StringBuffer markup) {
    List<Page> pages = PageServiceProvider.provide().getPages(Boolean.FALSE, Integer.valueOf(0), null, PageSortType.PageSortTypePriority, null);
    if (pages != null) {
        markup.append("<ul>");
        for (Page page : pages) {
            markup.append("<li><a href=\"/#!").append(page.slug).append("\" >").append(page.title).append("</a></li>");
        }
        markup.append("</ul>");
    }
}
Also used : Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 24 with Page

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

the class PageService method search.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.service.search.ISearch#search(java.lang.
	 * String, java.lang.Integer, java.lang.Integer, java.lang.String,
	 * com.willshex.blogwt.shared.api.SortDirectionType) */
@Override
public List<Page> search(String query, Integer start, Integer count, String sortBy, SortDirectionType direction) {
    Results<ScoredDocument> matches = SearchHelper.getIndex().search(query);
    List<Page> pages = new ArrayList<Page>();
    String id;
    Page page;
    int limit = count;
    final String pageServiceName = getName();
    for (ScoredDocument scoredDocument : matches) {
        if (limit == 0) {
            break;
        }
        if ((id = scoredDocument.getId()).startsWith(getName())) {
            page = getPage(Long.valueOf(id.replace(pageServiceName, "")));
            if (page != null) {
                pages.add(page);
            }
        }
        limit--;
    }
    return pages;
}
Also used : ScoredDocument(com.google.appengine.api.search.ScoredDocument) ArrayList(java.util.ArrayList) Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 25 with Page

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

the class PageService method addPage.

@Override
public Page addPage(Page page) {
    if (page.created == null) {
        page.created = new Date();
    }
    page.ownerKey = Key.create(page.owner);
    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);
    }
    Key<Page> key = provide().save().entity(page).now();
    page.id = keyToId(key);
    SearchHelper.queueToIndex(getName(), page.id);
    return page;
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) Page(com.willshex.blogwt.shared.api.datatype.Page) Date(java.util.Date) Key(com.googlecode.objectify.Key)

Aggregations

Page (com.willshex.blogwt.shared.api.datatype.Page)28 JsonElement (com.google.gson.JsonElement)10 Post (com.willshex.blogwt.shared.api.datatype.Post)9 ArrayList (java.util.ArrayList)6 User (com.willshex.blogwt.shared.api.datatype.User)4 HashMap (java.util.HashMap)4 Pager (com.willshex.blogwt.shared.api.Pager)3 GetPageRequest (com.willshex.blogwt.shared.api.page.call.GetPageRequest)3 GWT (com.google.gwt.core.client.GWT)2 Element (com.google.gwt.dom.client.Element)2 Key (com.googlecode.objectify.Key)2 DefaultEventBus (com.willshex.blogwt.client.DefaultEventBus)2 GetPageEventHandler (com.willshex.blogwt.client.api.page.event.GetPageEventHandler)2 NavigationController (com.willshex.blogwt.client.controller.NavigationController)2 PageController (com.willshex.blogwt.client.controller.PageController)2 NavigationChangedEventHandler (com.willshex.blogwt.client.event.NavigationChangedEventHandler)2 PageTypeHelper (com.willshex.blogwt.client.helper.PageTypeHelper)2 WizardDialogPage (com.willshex.blogwt.client.page.wizard.WizardDialogPage)2 WizardPage (com.willshex.blogwt.client.wizard.WizardPage)2 InputValidationException (com.willshex.gson.web.service.server.InputValidationException)2