Ask A Question

Notifications

You’re not receiving notifications from this thread.

Ideas for building a Wiki in my app

Jay Killeen asked in General

My users are all internal customers of our business. They are pretty information poor when it comes to our systems and processes and our company intranet is not very feature rich. So I'd like to build a wiki style feature inside my app so if they get to something they don't know about they can click help links etc and read about certain business logic etc.

I have seen https://github.com/alno/irwi which doesn't support Rails 4 and also https://github.com/nirnanaaa/gollum_rails which is no longer being supported so it doesn't seem like there is a Rails plugin style Gem to extend the functionality of your existing Rails app.

Anyone have any other ideas on where a good Gem might be?

Otherwise I am going to lookinto irwi a little more and just extract those features into my app. Maybe even one day fork it or build my first open source gem for rails that gives this functionality to your Rails app :) Probably won't happen though haha. Can only dream.

Worse comes to worse I'll just build a static page in the app and manually link it all together.

Reply

Oh and Chris, how did you get it so users can comment using Markdown? That would be a cool video.

Reply

There's a pro episode on using the pipeline gem to support markdown and emoji : https://gorails.com/episodes/markdown-emoji-with-html-pipeline-gem

I used this in an application for our company and simply created a helper method in the application_helper to format any block of user imputed code:

def formatter(content)
        pipeline_context = {gfm: true, asset_root: "https://a248.e.akamai.net/assets.github.com/images/icons/"}
        pipeline = HTML::Pipeline.new [
            HTML::Pipeline::MarkdownFilter, 
            HTML::Pipeline::EmojiFilter,
            HTML::Pipeline::SanitizationFilter,
            ], pipeline_context
            pipeline.call(content)[:output].to_s.html_safe
    end

I can then just call <%= formatter(@post.content) %> whenever I want to support markdown or Emoji

Definitely watch the episode.

Reply

Yeah html-pipeline is an awesome gem.

If you want, you could probably build an HTML::Pipeline plugin to handle Wiki-style links pretty easily. Look for a specific syntax, parse those items out, look them up in your database by title, and replace them with links to those other articles.

On the other hand, you could probably reclaim one of those gems and maintain it.

I'd probably shoot for the HTML::Pipeline plugin because it would be simplest and Markdown already gives you everything else you need. This would definitely be cool to see. Might make for a fun screencast on building an extension too.

Reply

Oh damn that is exactly what I need! I have a polymorphic comments feature that doesn't do the line breaks and things. Thanks Team Gorails!

If I keep learning at the rate I am going then I might have a crack at one of those gems. I have a few use cases for a really easy to build wiki app. I'll let you know how I get on.

Reply

I'd love to see you tackle one of those gems. :)

I think I'm going do a screencast on building an extension to html-pipeline for this feature next week. It's a really good example of something people might want to do and gives you a whole lot of functionality that you can have without implementing some other random gem.

Reply

So happy!! Just shipped my wiki feature which included the ability for me to create pages, edit them as super admin, includes markup, a sidebar panel for quick navigation and I even hooked up Wistia so that I could embed some training videos I had into my wiki!

Also used the existing comments feature from your comments video and made it so users can comment on each wiki post! So freakin' awesome!!

Did I mention I wrapped some Rspec round all this. Still not doing full TDD but happy that it is not breaking without me knowing :smiley:

Reply

Jay,

Congrats on getting it working. I'm looking to implement similar functionality. Do you mind sharing what you came up with?

Reply

That's awesome!! :) Sounds like everything came together really, really well.

Don't worry about doing TDD too much. Having functional code is the most important and you can easily add tests in as you find bugs in production.

Reply

Ill do a gist

Reply

The gist can be found at https://gist.github.com/jaykilleen/b09eb78b85e083368cb5.

I pretty much dumped most of my code relating to the wiki pages here except for the logic around users etc and a few other things. If you have any ideas to improve the code please let me know. I can do with a lot of drying up but it works. I'm lacking in time due to some other features I need to get out so if I improve it I'll update the gist.

Hope it helps someone to get some inspiration. I pretty much went from the irwi gem as the starting point with the migration and then free styled it from that point.

Reply

Oh and the comment bases stuff was pretty much straight from the polymorphic comments video that Chris did and the markdown is from the markdown video :smiley:

Reply

Jay, this looks pretty darn solid actually. There are a few places where you can DRY it up, but those can be handled later in a simple refactor. I noticed you're using conditionals in your views. I'm not a huge fan of conditionals directly in the view but in your case it may not be easy to avoid it. You could always extract into a class method, presenter, or a helper if need be. I had to do something similar and Chris helped me get on the right path with abstraction.

Are you open-sourcing your app or is it private? I'd love to take a look at your codebase if you're open to it. I love looking at other dev's design patterns and learning from them, no matter what the skill level. :)

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.