mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
major cleanup
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<wicket:child />
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.commafeed.frontend.pages;
|
||||
|
||||
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
|
||||
import org.apache.wicket.markup.head.IHeaderResponse;
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
|
||||
import com.commafeed.frontend.components.auth.Role;
|
||||
|
||||
import de.agilecoders.wicket.Bootstrap;
|
||||
|
||||
@AuthorizeInstantiation(Role.USER)
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class BasePage extends WebPage {
|
||||
|
||||
@Override
|
||||
public void renderHead(IHeaderResponse response) {
|
||||
super.renderHead(response);
|
||||
Bootstrap.renderHead(response);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.commafeed.frontend.pages;
|
||||
|
||||
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
import org.apache.wicket.request.handler.TextRequestHandler;
|
||||
import org.apache.wicket.request.mapper.parameter.PageParameters;
|
||||
|
||||
import com.commafeed.frontend.components.auth.Role;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@AuthorizeInstantiation(Role.USER)
|
||||
public abstract class JSONPage extends WebPage {
|
||||
|
||||
public JSONPage() {
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
package com.commafeed.frontend.pages.feed;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
|
||||
import com.commafeed.backend.dao.FeedCategoryService;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionService;
|
||||
import com.commafeed.frontend.CommaFeedSession;
|
||||
import com.commafeed.frontend.pages.JSONPage;
|
||||
import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||
import com.commafeed.model.FeedCategory;
|
||||
import com.commafeed.model.FeedSubscription;
|
||||
import com.commafeed.model.User;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedSubscriptionsPage extends JSONPage {
|
||||
|
||||
@Inject
|
||||
FeedSubscriptionService feedSubscriptionService;
|
||||
|
||||
@Inject
|
||||
FeedCategoryService FeedCategoryService;
|
||||
|
||||
@Override
|
||||
protected Object getObject() {
|
||||
|
||||
User user = CommaFeedSession.get().getUser();
|
||||
List<FeedCategory> categories = FeedCategoryService.findAll(user);
|
||||
|
||||
Category root = new Category();
|
||||
addChildren(categories, root);
|
||||
for (FeedSubscription subscription : feedSubscriptionService
|
||||
.findByField(MF.i(MF.p(FeedSubscription.class).getCategory()),
|
||||
null)) {
|
||||
Subscription sub = new Subscription();
|
||||
sub.setId(subscription.getId());
|
||||
sub.setName(subscription.getTitle());
|
||||
sub.setUnread(77);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
private void addChildren(List<FeedCategory> categories, Category current) {
|
||||
for (FeedCategory category : categories) {
|
||||
if ((category.getParent() == null && current.getId() == null)
|
||||
|| (category.getParent() != null && (ObjectUtils.equals(
|
||||
category.getParent().getId(), current.getId())))) {
|
||||
Category child = new Category();
|
||||
child.setId(category.getId());
|
||||
child.setName(category.getName());
|
||||
addChildren(categories, child);
|
||||
for (FeedSubscription subscription : category
|
||||
.getSubscriptions()) {
|
||||
Subscription sub = new Subscription();
|
||||
sub.setId(subscription.getId());
|
||||
sub.setName(subscription.getTitle());
|
||||
sub.setUnread(77);
|
||||
}
|
||||
current.getChildren().add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Category {
|
||||
private Long id;
|
||||
private String name;
|
||||
private List<Category> children = Lists.newArrayList();
|
||||
private List<Subscription> feeds = Lists.newArrayList();
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Category> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Category> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public List<Subscription> getFeeds() {
|
||||
return feeds;
|
||||
}
|
||||
|
||||
public void setFeeds(List<Subscription> feeds) {
|
||||
this.feeds = feeds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Subscription {
|
||||
private Long id;
|
||||
private String name;
|
||||
private int unread;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getUnread() {
|
||||
return unread;
|
||||
}
|
||||
|
||||
public void setUnread(int unread) {
|
||||
this.unread = unread;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span2">
|
||||
<div wicket:id="tree"></div>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div wicket:id="entries"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:extend>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,129 +0,0 @@
|
||||
package com.commafeed.frontend.pages.feed;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.wicket.Component;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
|
||||
import com.commafeed.backend.dao.FeedCategoryService;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionService;
|
||||
import com.commafeed.frontend.CommaFeedSession;
|
||||
import com.commafeed.frontend.components.CssTreeView;
|
||||
import com.commafeed.frontend.components.CssTreeView.ITreeProvider;
|
||||
import com.commafeed.frontend.pages.BasePage;
|
||||
import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||
import com.commafeed.frontend.utils.stateless.StatelessAjaxLink;
|
||||
import com.commafeed.model.FeedCategory;
|
||||
import com.commafeed.model.FeedEntryStatus;
|
||||
import com.commafeed.model.FeedSubscription;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedViewPage extends BasePage {
|
||||
|
||||
@Inject
|
||||
FeedSubscriptionService feedSubscriptionService;
|
||||
|
||||
@Inject
|
||||
FeedCategoryService feedCategoryService;
|
||||
|
||||
public FeedViewPage() {
|
||||
add(newTree("tree"));
|
||||
add(newFeedsPanel("entries"));
|
||||
}
|
||||
|
||||
private Component newTree(String markupId) {
|
||||
ITreeProvider<FeedCategory, FeedSubscription> provider = new ITreeProvider<FeedCategory, FeedSubscription>() {
|
||||
|
||||
private List<FeedCategory> cats;
|
||||
private List<FeedSubscription> subsWithoutCategory;
|
||||
|
||||
private void init() {
|
||||
if (cats == null) {
|
||||
cats = feedCategoryService.findAll(CommaFeedSession.get()
|
||||
.getUser());
|
||||
}
|
||||
if (subsWithoutCategory == null) {
|
||||
subsWithoutCategory = feedSubscriptionService.findByField(
|
||||
MF.i(MF.p(FeedSubscription.class).getCategory()),
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<FeedCategory> getChildren(final FeedCategory node) {
|
||||
init();
|
||||
return Lists.newArrayList(Collections2.filter(cats,
|
||||
new Predicate<FeedCategory>() {
|
||||
@Override
|
||||
public boolean apply(FeedCategory cat) {
|
||||
return (node == null && cat.getParent() == null)
|
||||
|| (cat.getParent() != null
|
||||
&& node != null && cat
|
||||
.getParent().getId() == node
|
||||
.getId());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<FeedSubscription> getLeaves(FeedCategory node) {
|
||||
init();
|
||||
if (node == null) {
|
||||
return subsWithoutCategory;
|
||||
}
|
||||
return node.getSubscriptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel<String> getChildLabel(FeedCategory node) {
|
||||
return Model.of(node.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel<FeedSubscription> model(FeedSubscription object) {
|
||||
return Model.of(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
cats = null;
|
||||
}
|
||||
|
||||
};
|
||||
return new CssTreeView<FeedCategory, FeedSubscription>(markupId,
|
||||
provider) {
|
||||
@Override
|
||||
protected Component newLink(String markupId,
|
||||
final IModel<FeedSubscription> model) {
|
||||
return new StatelessAjaxLink<Void>(markupId) {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
System.out.println(model.getObject().getId());
|
||||
}
|
||||
}.setBody(Model.of(model.getObject().getTitle()));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Component newFeedsPanel(String markupId) {
|
||||
|
||||
new LoadableDetachableModel<List<FeedEntryStatus>>() {
|
||||
@Override
|
||||
protected List<FeedEntryStatus> load() {
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div class="accordion-group" wicket:id="entry">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle" data-toggle="collapse" wicket:id="link"
|
||||
data-parent="#accordion2" href="#collapseOne"> Collapsible
|
||||
Group Item #1 </a>
|
||||
</div>
|
||||
<div id="collapseOne" class="accordion-body collapse in" wicket:id="body">
|
||||
<div class="accordion-inner" wicket:id="content">Anim pariatur cliche...</div>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.commafeed.frontend.pages.feed.components;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.AttributeModifier;
|
||||
import org.apache.wicket.markup.ComponentTag;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.GenericPanel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
|
||||
import com.commafeed.model.FeedEntryStatus;
|
||||
|
||||
import de.agilecoders.wicket.markup.html.bootstrap.behavior.CssClassNameAppender;
|
||||
import de.agilecoders.wicket.util.Components;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedsPanel extends GenericPanel<List<FeedEntryStatus>> {
|
||||
|
||||
private AttributeModifier dataParentModifier;
|
||||
|
||||
public FeedsPanel(String id, IModel<List<FeedEntryStatus>> model) {
|
||||
super(id, model);
|
||||
add(new CssClassNameAppender("accordion"));
|
||||
|
||||
dataParentModifier = new AttributeModifier("data-parent", getMarkupId());
|
||||
|
||||
ListView<FeedEntryStatus> listView = new ListView<FeedEntryStatus>(
|
||||
"entry", model) {
|
||||
@Override
|
||||
protected void populateItem(ListItem<FeedEntryStatus> item) {
|
||||
FeedEntryStatus status = item.getModelObject();
|
||||
WebMarkupContainer link = new WebMarkupContainer("link");
|
||||
link.add(dataParentModifier);
|
||||
|
||||
WebMarkupContainer body = new WebMarkupContainer("body");
|
||||
body.add(new Label("content", status.getEntry().getContent())
|
||||
.setEscapeModelStrings(false));
|
||||
|
||||
link.add(new AttributeModifier("href", "#" + body.getMarkupId()));
|
||||
}
|
||||
};
|
||||
add(listView);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onComponentTag(ComponentTag tag) {
|
||||
super.onComponentTag(tag);
|
||||
Components.assertTag(this, tag, "div");
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org">
|
||||
<head>
|
||||
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="vendor/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
|
||||
<link href="vendor/csstreeview/css3-treeview.css" rel="stylesheet">
|
||||
<link href="css/app.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div ng-app="commafeed">
|
||||
<ng:view></ng:view>
|
||||
</div>
|
||||
</wicket:extend>
|
||||
<div ng-app="commafeed">
|
||||
<ng:view></ng:view>
|
||||
</div>
|
||||
|
||||
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="vendor/angular/angular.min.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
<script src="js/controllers.js"></script>
|
||||
<script src="js/directives.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,34 +1,12 @@
|
||||
package com.commafeed.frontend.pages.home;
|
||||
|
||||
import org.apache.wicket.markup.head.CssHeaderItem;
|
||||
import org.apache.wicket.markup.head.IHeaderResponse;
|
||||
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
|
||||
import org.apache.wicket.request.Url;
|
||||
import org.apache.wicket.request.resource.UrlResourceReference;
|
||||
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
|
||||
import com.commafeed.frontend.pages.BasePage;
|
||||
import com.commafeed.frontend.references.angular.AngularReference;
|
||||
import com.commafeed.frontend.references.csstree.CssTreeViewReference;
|
||||
import com.commafeed.frontend.components.auth.Role;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class HomePage extends BasePage {
|
||||
|
||||
@Override
|
||||
public void renderHead(IHeaderResponse response) {
|
||||
super.renderHead(response);
|
||||
AngularReference.render(response);
|
||||
CssTreeViewReference.render(response);
|
||||
response.render(CssHeaderItem.forReference(new UrlResourceReference(Url
|
||||
.parse("css/app.css"))));
|
||||
|
||||
response.render(JavaScriptHeaderItem
|
||||
.forReference(new UrlResourceReference(Url.parse("js/main.js"))));
|
||||
response.render(JavaScriptHeaderItem
|
||||
.forReference(new UrlResourceReference(Url
|
||||
.parse("js/directives.js"))));
|
||||
response.render(JavaScriptHeaderItem
|
||||
.forReference(new UrlResourceReference(Url
|
||||
.parse("js/controllers.js"))));
|
||||
}
|
||||
@AuthorizeInstantiation(Role.USER)
|
||||
public class HomePage extends WebPage {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user