Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions brix-plugin-content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,17 @@
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-tinymce3</artifactId>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.Strings;
import org.brixcms.Brix;
import org.brixcms.auth.Action;
Expand All @@ -32,6 +33,7 @@
import org.brixcms.plugin.content.breadcrumb.BreadcrumbTile;
import org.brixcms.plugin.content.folder.FolderNode;
import org.brixcms.plugin.content.folder.FolderNodePlugin;
import org.brixcms.plugin.content.resource.admin.ResourceNodePlugin;
import org.brixcms.plugin.hierarchical.HierarchicalNodePlugin;
import org.brixcms.plugin.hierarchical.HierarchicalPluginLocator;
import org.brixcms.plugin.hierarchical.admin.NodeEditorPlugin;
Expand Down Expand Up @@ -67,9 +69,9 @@ public ContentPlugin(Brix brix) {
registry.register(JcrNodeWrapperFactory.POINT, PostNode.FACTORY);
registry.register(JcrNodeWrapperFactory.POINT, CommentNode.FACTORY);

registry.register(MNTF_POINT, new ContentManageNodeTabFactory());
registry.register(NEP_POINT, new FolderNodePlugin());
registry.register(NEP_POINT, new PostNodePlugin());
registerNodePlugin(new FolderNodePlugin(this));
registerNodePlugin(new PostNodePlugin(this));
registerNodePlugin(new ResourceNodePlugin(this));

registry.register(SimplePostEditorFactory.POINT, new SimplePostEditorFactory());
registry.register(TinymcePostEditorFactory.POINT, new TinymcePostEditorFactory());
Expand Down Expand Up @@ -287,4 +289,15 @@ public static String normalizeValue(final String value, int maxLength) {
protected int getTabPriority() {
return 1000;
}

public void registerNodePlugin(NodeEditorPlugin plugin) {
Args.notNull(plugin, "plugin");
brix.getConfig().getRegistry().register(NEP_POINT, plugin);
}

public void registerManageNodeTabFactory(ManageNodeTabFactory factory) {
Args.notNull(factory, "factory");
brix.getConfig().getRegistry().register(MNTF_POINT, factory);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ content-plugin.title=Title
content-plugin.author=Author
content-plugin.permalink=Permalink
content-plugin.publish=Publish
content-plugin.published=Published
content-plugin.visibility=Visibility
content-plugin.created=Created
content-plugin.lastModified=Last Modified
content-plugin.lastModifiedBy=Last Modified By
content-plugin.state=State
content-plugin.workspace=Workspace
content-plugin.content=Content
content-plugin.tinymceEditor=Tinymce Rich Text Editor
content-plugin.simpleTextEditor=Simple Text Editor
content-plugin.blogLocation=Blog Location
content-plugin.linksPerPage=Links per Page
content-plugin.postsPerPage=Posts per Page
content-plugin.textPreview=Content Preview
content-plugin.visualPreview=Visual Preview
content-plugin.htmlPreview=HTML Preview
content-plugin.name=Name
content-plugin.breadcrumbHome=Home
# tiles
Expand All @@ -40,3 +41,18 @@ content-plugin.submit=Submit
content-plugin.reply=Reply
content-plugin.delete=Delete
content-plugin.comments=Comments
content-plugin.resources=Resources
content-plugin.categories=Categories

content-plugin.uploadFiles=Upload Files
content-plugin.imagePreview=Image Preview
content-plugin.identifier=Identifier
content-plugin.size=Size
content-plugin.mimeType=Mime type
content-plugin.resolution=Resolution
content-plugin.downloadResource=Download Resource
content-plugin.overwriteExistingFiles=Overwrite Existing Files
content-plugin.upload=Upload
content-plugin.featuredImage=Featured Image
content-plugin.showAvailableResources=Show Available Resources

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.brixcms.plugin.content;
package org.brixcms.plugin.content.blog.post;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -8,9 +8,8 @@
import org.apache.wicket.model.ResourceModel;
import org.brixcms.auth.Action.Context;
import org.brixcms.jcr.wrapper.BrixNode;
import org.brixcms.plugin.content.blog.post.PostNode;
import org.brixcms.plugin.content.ContentPlugin;
import org.brixcms.plugin.content.blog.post.admin.PostViewTab;
import org.brixcms.plugin.content.folder.FolderNodeViewTab;
import org.brixcms.plugin.site.ManageNodeTabFactory;
import org.brixcms.web.tab.CachingAbstractTab;
import org.brixcms.web.tab.IBrixTab;
Expand All @@ -19,37 +18,22 @@
* @author dan.simko@gmail.com
*/
@SuppressWarnings("serial")
public class ContentManageNodeTabFactory implements ManageNodeTabFactory {
public class ManagePostNodeTabFactory implements ManageNodeTabFactory {

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({ "rawtypes", "unchecked" })
public List<IBrixTab> getManageNodeTabs(IModel<BrixNode> nodeModel) {
List<IBrixTab> result = new ArrayList<IBrixTab>();
BrixNode node = nodeModel.getObject();
if (node.isFolder()) {
return getFolderTabs(nodeModel);
} else if (node instanceof PostNode) {
return getContentNodeTabs((IModel) nodeModel);
String type = nodeModel.getObject().getNodeType();
if (PostNodePlugin.TYPE.equals(type)) {
return getTabs((IModel) nodeModel);
} else {
return null;
}
return result;
}

public static List<IBrixTab> getFolderTabs(final IModel<BrixNode> folderModel) {
public static List<IBrixTab> getTabs(final IModel<PostNode> nodeModel) {
List<IBrixTab> tabs = new ArrayList<IBrixTab>(1);
tabs.add(new CachingAbstractTab(new ResourceModel("view", "View"), 100) {

@Override
public Panel newPanel(String panelId) {
return new FolderNodeViewTab(panelId, folderModel);
}

});
return tabs;
}

public static List<IBrixTab> getContentNodeTabs(final IModel<PostNode> nodeModel) {
List<IBrixTab> tabs = new ArrayList<IBrixTab>(1);
IBrixTab previewTab = new CachingAbstractTab(new ResourceModel("view", "View"), 100) {
IBrixTab previewTab = new CachingAbstractTab(new ResourceModel("view", "View"), 300) {

@Override
public Panel newPanel(String panelId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package org.brixcms.plugin.content.blog.post;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import javax.jcr.Node;
import javax.jcr.Session;
Expand All @@ -19,16 +15,17 @@
import org.brixcms.jcr.wrapper.BrixFileNode;
import org.brixcms.jcr.wrapper.BrixNode;
import org.brixcms.plugin.content.blog.post.comment.CommentNode;
import org.brixcms.plugin.content.blog.post.comment.Commentable;
import org.brixcms.plugin.content.folder.FolderNode;
import org.brixcms.web.reference.Reference;

/**
* @author dan.simko@gmail.com
*/
@SuppressWarnings("serial")
public class PostNode extends BrixFileNode implements Commentable, Comparable<PostNode> {
public class PostNode extends CommentNode {

public static final int MAX_PERMALINK_LENGTH = 250;
private static final String COMMNETS_FOLDER_NAME = "comments";
private static final String RESOURCES_FOLDER_NAME = "resources";

public static enum State {
Draft, PendingReview, Published
Expand Down Expand Up @@ -118,28 +115,28 @@ public void setPublish(Date date) {
setDateAttribute(Properties.PUBLISH, date);
}

@Override
public List<CommentNode> getComments(int level) {
List<CommentNode> comments = new ArrayList<>();
getNode(COMMNETS_FOLDER_NAME).accept(new CommentsCollector(comments, level));
Collections.sort(comments);
return comments;
public FolderNode getResourcesFolder() {
return (FolderNode) getNode(RESOURCES_FOLDER_NAME);
}

@Override
public void addComment(String comment) {
JcrNode comments = getNode(COMMNETS_FOLDER_NAME);
JcrNode node = comments.addNode(UUID.randomUUID().toString(), "nt:file");
CommentNode commentNode = CommentNode.initialize(node);
commentNode.setData(comment);
comments.save();
public Reference getFeaturedImageReference() {
return Reference.load(this, Properties.FEATURED_IMAGE);
}

public void setFeaturedImageReference(Reference reference) {
if (reference == null) {
reference = new Reference();
}
reference.save(this, Properties.FEATURED_IMAGE);
}

public static PostNode initialize(JcrNode node) {
BrixNode brixNode = (BrixNode) node;
BrixFileNode.initialize(node, "text/html");
BrixFileNode brixNode = BrixFileNode.initialize(node, "text/html");
BrixNode content = (BrixNode) node.getNode("jcr:content");
content.setHidden(true);
brixNode.setNodeType(PostNodePlugin.TYPE);
brixNode.addNode(COMMNETS_FOLDER_NAME, "nt:folder");
brixNode.addNode(RESOURCES_FOLDER_NAME, "nt:folder");
return new PostNode(node.getDelegate(), node.getSession());
}

Expand Down Expand Up @@ -172,13 +169,4 @@ private String loadStringProperty(String attribute) {
public String getUserVisibleType() {
return "Post";
}

@Override
public int compareTo(PostNode o) {
if (getPublish() != null && o.getPublish() != null)
return o.getPublish().compareTo(getPublish());
if (getCreated() != null && o.getCreated() != null)
return o.getCreated().compareTo(getCreated());
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.brixcms.plugin.content.blog.post.admin.CreatePostPanel;
import org.brixcms.plugin.hierarchical.admin.NodeEditorPlugin;
import org.brixcms.plugin.site.SimpleCallback;
import org.brixcms.registry.ExtensionPoint;

/**
* @author dan.simko@gmail.com
Expand All @@ -17,17 +16,9 @@ public class PostNodePlugin implements NodeEditorPlugin {

public static final String TYPE = ContentPlugin.NS_PREFIX + "post";

public static final ExtensionPoint<NodeEditorPlugin> POINT = new ExtensionPoint<NodeEditorPlugin>() {
@Override
public Multiplicity getMultiplicity() {
return Multiplicity.COLLECTION;
}

@Override
public String getUuid() {
return PostNodePlugin.class.getName();
}
};
public PostNodePlugin(ContentPlugin contentPlugin) {
contentPlugin.registerManageNodeTabFactory(new ManagePostNodeTabFactory());
}

@Override
public String getName() {
Expand Down
Loading