Merge discourse-links-category into Discourse

(Erick Guan) #1

Links category is going to be a core feature. Links category offers the ability to post a link instead of text as well as displaying the link in the topic list. I’ll work together with the team for all its features. All features shall be working as original after the transition.

It adds an option in the category settings to be enabled. It stores links in the topic’s custom fields. A customized composer which shows only a small input field instead of original one is used to post link topics. The digest email template is also overrided for displaying url.

The implementation of plugins overrides many spots of core model which looks quite awkward to merge directly. I believe another archetype is much promising to try in the new implementation as described here. But that should result in a lot of changes in composer model and post creator. I’d like to know whether it’s the right path to go. @team

Basic Links Plugin
Basic Links Plugin
(Erlend Sogge Heggen) #2

@team I think Erick is blocked on this without any feedback since he needs to know whether archetypes is the way to go or not before doing any significant work.

(Jeff Atwood) #3

I personally would rather prioritize this than Feature Voting, as it is more broadly useful to any Discourse site. But we’ll need to pick one – we don’t have anyone else to allocate at the moment.

(Erick Guan) #4

If archetype is an expensive way to go, I can still merge the plugin in the core with the same implementation. It could be a bit messy in code. But I can improve later.

(Sam Saffron) #5

Adding an archetype construct is going to be a massive amount of work, I am not sure I am keen to take on that work right now.

Instead lets just extend plugin api to support what we need here if bits are missing

cc @eviltrout

(Robin Ward) #6

I am curious what kinds of changes you’d need to the plugin api to support this?

You said the code goes deep into the model which sounds a bit scary.

(Jeff Atwood) #7

This should actually be merged into core, I don’t think this should be a plugin at all. Sharing a link and inviting discussion on that link is an essential feature for all Discourse instances.

We’ll need to allocate someone for this work in the next few weeks.

(Rafael dos Santos Silva) #8

Should this be by category as it is today, or by topic as Reddit and HN?

(Jeff Atwood) #9

Probably by topic. I don’t think a whole category is needed. Some topics will be link based, others won’t.

(Rafael dos Santos Silva) #11

Also (sorry for being so specific) are we keeping the like OP on topic list? And only for link-type topics?

(Erick Guan) #12

Sorry for my communication. I have arrived Sweden and there were things unexpected in the way :frowning: I will make some progress this week.

The code simply uses topic custom field so there are monkey patches in the ComposerController. And I also patched Topic and Composer model. To be merged to core with less work, sounds another model like Warning can do the trick.

As @sam asked, I will look for a way to extend Ember models to carry the field.

(Erick Guan) #13

Well, a short progress report. It’s far more easy to inject the field in the core than writing this in a plugin. So far, using TopicCustomField is quite OK to make needed changes. Let me know if it conflicts anything.

(Erick Guan) #14

Finally, the pull request is ready. It’s enabled by default for all topics if topic_featured_link setting is checked. However, there is a per-category’s option to restrict editing.

Posting topic with link:



Validation is done by server end now. So there isn’t a popup like topic’s title.

Restricted in some categories:

Either a site setting to turn off the raw here:

The link is still stored in TopicCustomField which should be easy to migrate. There are some break changes. So I create a new plugin for those extra bits. This plugin can apply additional styles for links in digest email. Also there is a topic_featured_link_extra_link_ref for adding a ref parameters after the link. I’ll add showing onebox in the post body later.

(Neil Lalonde) #15

FYI I’m reviewing the PR now and hope to merge it soon. Soon!™

(Neil Lalonde) #16

Some more shots.

Composer for link-only style and onebox style:

Topic for onebox style

##Topic for link-only

I don’t know why anyone would prefer the link-only style. The first post body is blank, and the link is hard to spot.

Also, in topic lists the link-only should probably link the topic title to the link too, like Reddit does.

Maybe that’s how it should work for all styles of “link topics”?

(Erick Guan) #20

OK, I’ll remove link-only option. The empty body (without onebox) is the origin spec from @commonpawn since they are using a different design. It’s also easy to hide post body in CSS. shows a button for clicking the links. It’s obvious as of functionality. But it’s too large for the official theme.

The only thing I am afraid is that it might be hard for beginners to find the comment area.

(Neil Lalonde) #21

Ok keep it as is. We can change it later based on feedback.

The only issue that needs fixing before we can merge is the exception thrown when trying to post in a category that doesn’t allow topic links.

(Neil Lalonde) #22

This work was merged today. Thank you @fantasticfears!

Some issues still to fix:

  • Revision history of oneboxed links is showing newer versions of the onebox. raw and cooked aren’t being stored in the revisions.
  • Some wording can still be improved.
  • Composer with tags input needs fixin’.

(Jeff Atwood) #23

16 posts were split to a new topic: Start a topic by pasting a link (like Reddit)

Start a topic by pasting a link (like Reddit)