Blog post plugin

Continuing the discussion from Could I show the best posts in a seperate view like WordPress?:

Note: this plugin is broken. It is no longer being maintained.

Edit: I’ve completely rewritten this plugin. See this post for details.


I’ve made a plugin for doing something like this. You can find it here: https://github.com/scossar/discourse-blog-post

It lets you select a category to display with different styles than the rest of your forum. It defaults to the ‘blog’ category, but that can be changed in the settings. It selects an image that has the added class header-image and creates a full-width splash image out of it. The styles are quite basic. They mostly involve removing things. At the moment it’s removing the reply controls. That could be changed. It adds the class blog-post to the body tag for topics of the chosen category. Custom styles can be added by beginning them with the .blog-post selector.

This isn’t quite ready for production. The styles need a few tweaks. Pull requests and suggestions are welcome.

28 Likes

I love this blog view, thanks for sharing this with us.

is it possible to copy a post to post to your blog category? I mean, could i simply add a post from other categories to this post category. I want to use this as a place to show the best posts.

1 Like

The way it works now you would have to change the category of your post to whatever you have set as the blog-post category. Maybe it could be setup to work with tags instead, so that if you tagged a post as ‘featured’ it would get this view.

2 Likes

the idea of tag is brilliant

1 Like

I’ve rewritten this so that it integrates with the Discourse plugin system, instead of just overwriting things with a bunch of jquery. I think it should be safe to use it now.

A data-max-height attribute can be added to the background image to set the image’s max height. The image and the layout scale for mobile.

4 Likes

Is there an URL where we can see the plugin working?

No, at the moment my forum is private. Soon I will try to set up a public category on it that I can use for demos.

3 Likes

It would be great if you could set this blog view as homepage too :smiley:

1 Like

You, @simon, maintain two similiar plugins:

Whats their difference?

I’m not going to be maintaining the curated-home-plugin. I really like it and think that something similar to it would be useful for creating a user-friendly homepage, but I think it will be too difficult and time-consuming for me to maintain. If anyone is interested in using the code, I have a version of it up on github. It is working, but has a few issues.

The blog-post plugin is much simpler. It really just adds a body-class for topics in a chosen category so that that category can be styled separately from the other topics. If it breaks with a Discourse update I should be able to easily fix it.

4 Likes

I don’t understand how to write blog posts. Can’t find any ‘New post’ or similar when I’m in a blog topic.

The plugin creates blog posts out of topics in a certain category. It defaults to ‘blog’, but you can change it in the plugin’s settings.

You then need to create that category in Discourse. Go to ‘Categories>New Category’ and create your chosen blog category. In my case I created the category ‘discover nanaimo’. Don’t use an old category where you have posts with replies - at the moment blog posts can’t handle replies.

To create a header image, upload an image (ideally at the start of your post) and give it the class header-image you can also set the image’s max height by giving it a data-max-height attribute. Here’s an example of how to create a header image:

<img src="//testeleven-forum-assets.s3-us-west-1.amazonaws.com/original/1X/be5f722491f0a827b4604f04e8e5de06497cfb72.jpg" width="690" height="460" class="header-image" data-max-height="500">
4 Likes

how can you do this? “to set the blog view as homepage”.

You can’t, that why I said it would be great to have that possibility :slight_smile:

1 Like

Hi Simon,

Can You help me to setup your plugins into my existing rails application.

Thanks

@simon You have plans to make it work again someday? I did not get to test but it seems wonderful!

It’s hard to find the time to update it. I think it’s a lot more straightforward to use WordPress for this kind of thing, with the wp-discourse plugin.

3 Likes

i understand! thanks for reply!

Thanks to @smartwatchme for funding it, I’ve rewritten this plugin to work with recent versions of Discourse. It now allows you to configure which groups should be allowed to create ‘blog-posts’ (admins and moderators by default), and which categories blog posts should be allowed to be created in. Members of allowed groups can convert the first post in a topic from a regular post into a blog post by clicking on the ‘book’ icon that’s found in the hidden (’…’) post menu buttons.

The plugin converts the first image in a post into a header image. It also adds the css class blog-post to the body tag, and the css class blog-post-content to the cooked content of the first post. It comes with some default styles that are used to style the first post in a topic separately from the replies.

The default styles can be disabled by deselecting the plugin setting the blog post use default styles setting. This could be useful if you only wish to use the header-image functionality of the plugin. See the plugin’s README for more details.

Pull requests, especially for improving the default styles, are welcome.

11 Likes