I’m an advanced rails dev with intermediate JS skills (not Ember, tho), so I decided to hack together a plugin for a new (not yet even soft-launched) community that lets me use my Discourse profile as a kind of blog.
Here’s the plugin: GitHub - dotfire/sayonara: Say goodbye to social media.
Here’s my profile on the new community site: Profile - jonstokes - Open Source Defense
The modifications are simple:
- It makes your bookmarks visible to everyone
- It sets your
/u/usernamedefault route to
- It does some minor stuff like rearranging menus and forcing the expanded profile view up top.
This was super quick-and-dirty weekend hack, so I’d like to make it better. To this end, I have a few plugin dev-related questions that I’ve not yet been able to answer. Thanks in advance for any advice or tips.
Current best practice for plugin dev on OS X
Given that I spend a lot of time in rails, setting up discourse as a rails app on OS X was easy for me. I didn’t bother with any vagrant stuff. But maybe this was a mistake. I say this for a few reasons.
First, I wasn’t able to get sidekiq working right (although I didn’t spend a bunch of time on it. It looks like Sidekiq is trying to connect to localhost:443 and throwing errors… anyway…)
But the bigger problem is that I get different results locally than I do when I deploy to EC2 via docker. For instance, I’ve overridden some JS controllers and routes, and that stuff works in prod but not in dev. I’d like to get better dev/prod parity, so maybe I need to use vagrant and ubuntu?
But I also take this mismatch as a hint that I’m Doing It Wrong and that the fact that prod works is down to some sort of quirk of loading order and asset compilation, which is bad. Which brings me to…
Overriding JS the redirect initializer.
I tried to add a new JS initializer on the model of some other plugins by just declaring it in the same folder as
/initializers/url-redirects.js.es6, but that didn’t seem to work. I’ve since realized my new initializer probably needs to remove the original rewrites from
DiscourseURL, so I’ll do that later. So for now, I’m overriding
Well, this works fine in prod, but in dev it only half works. I redirect to the
Activity page but not all the way to
Bookmarks. No idea what’s going on there.
Manipulating the expanded vs. collapsed profile
At one point I had a build working locally that would expand and collapse the profile up top correctly depending on your path. So for non-
viewingMe in users,
userActvity.bookmarks would show you the larger profile, and the rest would collapse. This worked in dev, not in prod, though.
I ended forcing the profile to be expanded in all
/user views, which is not awesome.
Here are some next steps I’m thinking about for this, once I get the above ironed out:
- The “feed”-style view is only for Bookmarks, and the rest show the normal activity feed.
- I got preview images half working (i.e. I pulled them into the
UserAction.streamquery and serialized them out, but my CSS chops suck so the front-end styling was gross so I’ll deal with it later.)
- Given my headaches with overriding JS, I didn’t want to deal with CSS assets so I just used
styletags. So that has to be fixed.
- Some sort of styling that sets off a share of a reply from a share of a top-level post. That way, if I bookmark/share a reply to a post I’ve already shared, it doesn’t look like a dupe.
- Doing the same thing for the Groups profiles, so that a I hack together a group blog at
.../groupnameby adding the “bloggers” to a group and showing all their bookmarks on one feed.
- Moving away from a bookmarks-based hack to an actual
sharebutton that works just like
bookmarks, but uses a different endpoint and gives me more control over filtering what I show and where. I basically want to be able to write my own queries against the posts and topics tables to show a feed at a location, but I’m a long ways away from untangling how to do that on the front end. (The back-end part of this would be super easy for me… I deal with this sort of API stuff and postgres all day long.)
Anyway, I didn’t mean to make the post this long. Thanks for reading!