mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
angular prototype
This commit is contained in:
15
pom.xml
15
pom.xml
@@ -10,12 +10,14 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<jpa.datasource.name>jdbc/commafeedDS</jpa.datasource.name>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/java</directory>
|
<directory>src/main/java</directory>
|
||||||
@@ -195,11 +197,24 @@
|
|||||||
<artifactId>wicket-webjars</artifactId>
|
<artifactId>wicket-webjars</artifactId>
|
||||||
<version>0.2.0</version>
|
<version>0.2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>angularjs</artifactId>
|
||||||
|
<version>1.0.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.2.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>openshift</id>
|
<id>openshift</id>
|
||||||
|
<properties>
|
||||||
|
<jpa.datasource.name>java:/jdbc/commafeedDS</jpa.datasource.name>
|
||||||
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<finalName>commafeed</finalName>
|
<finalName>commafeed</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import javax.ejb.Singleton;
|
|||||||
import javax.ejb.Startup;
|
import javax.ejb.Startup;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.commafeed.backend.dao.FeedCategoryService;
|
import com.commafeed.backend.dao.FeedCategoryService;
|
||||||
import com.commafeed.backend.dao.FeedService;
|
import com.commafeed.backend.dao.FeedService;
|
||||||
import com.commafeed.backend.dao.FeedSubscriptionService;
|
import com.commafeed.backend.dao.FeedSubscriptionService;
|
||||||
@@ -19,6 +22,8 @@ import com.commafeed.model.User;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class StartupBean {
|
public class StartupBean {
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(StartupBean.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
FeedService feedService;
|
FeedService feedService;
|
||||||
|
|
||||||
@@ -38,6 +43,7 @@ public class StartupBean {
|
|||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
if (userService.getCount() == 0) {
|
if (userService.getCount() == 0) {
|
||||||
|
log.info("Populating database with default values");
|
||||||
User user = new User();
|
User user = new User();
|
||||||
byte[] salt = encryptionService.generateSalt();
|
byte[] salt = encryptionService.generateSalt();
|
||||||
user.setName("admin");
|
user.setName("admin");
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.commafeed.frontend.components.auth.LoginPage;
|
import com.commafeed.frontend.components.auth.LoginPage;
|
||||||
import com.commafeed.frontend.pages.feed.FeedViewPage;
|
import com.commafeed.frontend.pages.feed.FeedSubscriptionsPage;
|
||||||
|
import com.commafeed.frontend.pages.home.HomePage;
|
||||||
import com.commafeed.frontend.utils.exception.DisplayExceptionPage;
|
import com.commafeed.frontend.utils.exception.DisplayExceptionPage;
|
||||||
|
|
||||||
import de.agilecoders.wicket.Bootstrap;
|
import de.agilecoders.wicket.Bootstrap;
|
||||||
@@ -44,7 +45,7 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
|
|||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
mountPage("login", LoginPage.class);
|
mountPage("login", LoginPage.class);
|
||||||
mountPage("feeds", FeedViewPage.class);
|
mountPage("/subscriptions/all", FeedSubscriptionsPage.class);
|
||||||
|
|
||||||
setupInjection();
|
setupInjection();
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Page> getHomePage() {
|
public Class<? extends Page> getHomePage() {
|
||||||
return FeedViewPage.class;
|
return HomePage.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupInjection() {
|
protected void setupInjection() {
|
||||||
|
|||||||
27
src/main/java/com/commafeed/frontend/pages/JSONPage.java
Normal file
27
src/main/java/com/commafeed/frontend/pages/JSONPage.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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() {
|
||||||
|
this(new PageParameters());
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONPage(PageParameters pageParameters) {
|
||||||
|
getRequestCycle().scheduleRequestHandlerAfterCurrent(
|
||||||
|
new TextRequestHandler("application/json", "UTF-8", new Gson()
|
||||||
|
.toJson(getObject())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Object getObject();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,8 +7,8 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import org.apache.wicket.Component;
|
import org.apache.wicket.Component;
|
||||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||||
import org.apache.wicket.markup.html.basic.Label;
|
|
||||||
import org.apache.wicket.model.IModel;
|
import org.apache.wicket.model.IModel;
|
||||||
|
import org.apache.wicket.model.LoadableDetachableModel;
|
||||||
import org.apache.wicket.model.Model;
|
import org.apache.wicket.model.Model;
|
||||||
|
|
||||||
import com.commafeed.backend.dao.FeedCategoryService;
|
import com.commafeed.backend.dao.FeedCategoryService;
|
||||||
@@ -20,6 +20,7 @@ import com.commafeed.frontend.pages.BasePage;
|
|||||||
import com.commafeed.frontend.utils.ModelFactory.MF;
|
import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||||
import com.commafeed.frontend.utils.stateless.StatelessAjaxLink;
|
import com.commafeed.frontend.utils.stateless.StatelessAjaxLink;
|
||||||
import com.commafeed.model.FeedCategory;
|
import com.commafeed.model.FeedCategory;
|
||||||
|
import com.commafeed.model.FeedEntryStatus;
|
||||||
import com.commafeed.model.FeedSubscription;
|
import com.commafeed.model.FeedSubscription;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
@@ -36,7 +37,7 @@ public class FeedViewPage extends BasePage {
|
|||||||
|
|
||||||
public FeedViewPage() {
|
public FeedViewPage() {
|
||||||
add(newTree("tree"));
|
add(newTree("tree"));
|
||||||
add(new Label("entries", Model.of("")));
|
add(newFeedsPanel("entries"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component newTree(String markupId) {
|
private Component newTree(String markupId) {
|
||||||
@@ -113,4 +114,16 @@ public class FeedViewPage extends BasePage {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Component newFeedsPanel(String markupId) {
|
||||||
|
|
||||||
|
new LoadableDetachableModel<List<FeedEntryStatus>>() {
|
||||||
|
@Override
|
||||||
|
protected List<FeedEntryStatus> load() {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<!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>
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:wicket="http://wicket.apache.org">
|
||||||
|
<body>
|
||||||
|
<wicket:extend>
|
||||||
|
<div ng-app="commafeed">
|
||||||
|
<ng:view></ng:view>
|
||||||
|
</div>
|
||||||
|
</wicket:extend>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,8 +1,34 @@
|
|||||||
package com.commafeed.frontend.pages.home;
|
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 com.commafeed.frontend.pages.BasePage;
|
import com.commafeed.frontend.pages.BasePage;
|
||||||
|
import com.commafeed.frontend.references.angular.AngularReference;
|
||||||
|
import com.commafeed.frontend.references.csstree.CssTreeViewReference;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class HomePage extends BasePage {
|
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"))));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.commafeed.frontend.references.angular;
|
||||||
|
|
||||||
|
import org.apache.wicket.markup.head.IHeaderResponse;
|
||||||
|
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
|
||||||
|
|
||||||
|
import de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class AngularReference extends WebjarsJavaScriptResourceReference {
|
||||||
|
|
||||||
|
private static AngularReference instance = new AngularReference();
|
||||||
|
|
||||||
|
public AngularReference() {
|
||||||
|
super("angularjs/current/angular.min.js");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void render(IHeaderResponse response) {
|
||||||
|
response.render(JavaScriptHeaderItem.forReference(instance));
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/main/java/com/commafeed/model/UserSettings.java
Normal file
55
src/main/java/com/commafeed/model/UserSettings.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package com.commafeed.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "USERS")
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class UserSettings implements Serializable {
|
||||||
|
|
||||||
|
public enum ReadingMode {
|
||||||
|
ALL, UNREAD
|
||||||
|
}
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private ReadingMode readingMode;
|
||||||
|
|
||||||
|
public ReadingMode getReadingMode() {
|
||||||
|
return readingMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadingMode(ReadingMode readingMode) {
|
||||||
|
this.readingMode = readingMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
http://java.sun.com/xml/ns/persistence
|
http://java.sun.com/xml/ns/persistence
|
||||||
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
|
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
|
||||||
<persistence-unit name="primary">
|
<persistence-unit name="primary">
|
||||||
<jta-data-source>java:/jdbc/commafeedDS</jta-data-source>
|
<jta-data-source>${jpa.datasource.name}</jta-data-source>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="hibernate.hbm2ddl.auto" value="update" />
|
<property name="hibernate.hbm2ddl.auto" value="update" />
|
||||||
<property name="hibernate.show_sql" value="false" />
|
<property name="hibernate.show_sql" value="false" />
|
||||||
|
|||||||
3
src/main/webapp/css/app.css
Normal file
3
src/main/webapp/css/app.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.css-treeview .selected {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
12
src/main/webapp/directives/category.html
Normal file
12
src/main/webapp/directives/category.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<span> <input type="checkbox" checked="checked" />
|
||||||
|
<label ng-click="categoryClick({id: node.id})"
|
||||||
|
ng-class="{selected: (node.id == selectedId && selectedType == 'category')}">{{node.name}}
|
||||||
|
</label>
|
||||||
|
<ul>
|
||||||
|
<li ng-repeat="feed in node.feeds">
|
||||||
|
<a ng-click="feedClick({id: feed.id})"
|
||||||
|
ng-class="{selected: (feed.id == selectedId && selectedType == 'feed')}">{{feed.name}}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</span>
|
||||||
56
src/main/webapp/js/controllers.js
Normal file
56
src/main/webapp/js/controllers.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
var module = angular.module('commafeed.controllers', []);
|
||||||
|
|
||||||
|
module.controller('CategoryTreeCtrl',
|
||||||
|
function($scope, $routeParams, $location) {
|
||||||
|
|
||||||
|
$scope.selectedType = $routeParams._type;
|
||||||
|
$scope.selectedId = $routeParams._id;
|
||||||
|
|
||||||
|
$scope.root = {
|
||||||
|
children : [ {
|
||||||
|
id : "1",
|
||||||
|
name : "News",
|
||||||
|
feeds : [ {
|
||||||
|
id : "2",
|
||||||
|
name : "Cyanide & Happiness"
|
||||||
|
} ],
|
||||||
|
children : [ {
|
||||||
|
id : "2",
|
||||||
|
name : "Comics",
|
||||||
|
feeds : [ {
|
||||||
|
id : "1",
|
||||||
|
name : "Dilbert"
|
||||||
|
} ]
|
||||||
|
} ]
|
||||||
|
}, {
|
||||||
|
id : '3',
|
||||||
|
name : "Blogs",
|
||||||
|
feeds : [ {
|
||||||
|
id : "3",
|
||||||
|
name : "Engadget"
|
||||||
|
} ]
|
||||||
|
} ]
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.feedClicked = function(id) {
|
||||||
|
$location.path('/feeds/view/feed/' + id);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.categoryClicked = function(id) {
|
||||||
|
$location.path('/feeds/view/category/' + id);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
module.controller('FeedListCtrl', function($scope, $routeParams, $http) {
|
||||||
|
|
||||||
|
$scope.entries = [ {
|
||||||
|
id : '1',
|
||||||
|
title : '',
|
||||||
|
content : '',
|
||||||
|
date : '',
|
||||||
|
feed : '',
|
||||||
|
url : '',
|
||||||
|
read : false,
|
||||||
|
starred : false,
|
||||||
|
} ];
|
||||||
|
});
|
||||||
23
src/main/webapp/js/directives.js
Normal file
23
src/main/webapp/js/directives.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
var module = angular.module('commafeed.directives', []);
|
||||||
|
|
||||||
|
module.directive('category', function($compile) {
|
||||||
|
return {
|
||||||
|
scope: {
|
||||||
|
node: '=',
|
||||||
|
selectedType: '=',
|
||||||
|
selectedId: '=',
|
||||||
|
feedClick: '&',
|
||||||
|
categoryClick: '&'
|
||||||
|
},
|
||||||
|
restrict : 'E',
|
||||||
|
replace: true,
|
||||||
|
templateUrl: 'directives/category.html',
|
||||||
|
link: function(scope, element) {
|
||||||
|
if (scope.node.children) {
|
||||||
|
var ul = element.find('ul');
|
||||||
|
ul.prepend('<category ng-repeat="child in node.children" node="child" feed-click="feedClick({id:id})" category-click="categoryClick({id:id})" selected-type="selectedType" selected-id="selectedId"></category>');
|
||||||
|
$compile(ul.contents())(scope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
11
src/main/webapp/js/main.js
Normal file
11
src/main/webapp/js/main.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
var app = angular.module('commafeed', [ 'commafeed.directives',
|
||||||
|
'commafeed.controllers' ]);
|
||||||
|
|
||||||
|
app.config([ '$routeProvider', function($routeProvider) {
|
||||||
|
$routeProvider.when('/feeds/view/:_type/:_id', {
|
||||||
|
templateUrl : 'templates/feeds.html'
|
||||||
|
});
|
||||||
|
$routeProvider.otherwise({
|
||||||
|
redirectTo : '/feeds/view/category/all'
|
||||||
|
});
|
||||||
|
} ]);
|
||||||
14
src/main/webapp/templates/feeds.html
Normal file
14
src/main/webapp/templates/feeds.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span2" ng-controller="CategoryTreeCtrl">
|
||||||
|
<div class="css-treeview">
|
||||||
|
<ul>
|
||||||
|
<li ng-repeat="node in root.children">
|
||||||
|
<category node="node" feed-click="feedClicked(id)" category-click="categoryClicked(id)" selected-type="selectedType" selected-id="selectedId"></category>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="span10" ng-controller="FeedListCtrl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user