[ARCHIVE] Topic List Previews


(Makary Gołosz) #891

Hi @angus :slight_smile:
As always, a huge fan of your work!
I wonder, is there a relatively easy way to enable TLP’s for topic list that appears on /categories page when desktop category page style is set to Categories and latest topics
It seems to me that it would be perfect use for this awesome “Social media” view, and I’ve tried to figure it out myself in the sources, but unfortunately Ruby still doesn’t speak to me.


(Bart) #892

Absolutely brilliant, thanks Angus!

@ChameleonScales I’ll update the ‘Forum Gallery’ link in the top nav to reflect this.


(grahamtrump) #894

Most of my website’s topics don’t show the thumbnail although those topics have the images.

what’s wrong?


(Angus McLeod) #895

@MakaryGo Applying TLP to the categories page is possible, however the reason I haven’t done it yet is because the structure of the categories route is different from all the other topic list routes, and a fair bit of custom setup would be needed. All the other topic list routes are dynamically generated based on categories and filters. The TLP plugin is largely built around that structure. In contrast, the categories route display options are each seperate components containing topic list components. It would definitely be possible, the utility / resource tradeoff just hasn’t made sense to me as yet.

@nothing Sorry, but I can’t do custom work on your site.

@grahamtrump TLP’s thumbnail feature has a number of different settings configurations. What settings are you using?


(Angus McLeod) #897

The social style assumes you have a larger thumbnail size. To achieve the ‘reddit style’ you referenced above you’ll need to add your own CSS.


(David Kingham) #898

I would also love to see TLP on the categories page for the latest column, it’s the only place they are missing and would really complete the whole package. I understand if it’s too much work, still massively appreciate this plugin Angus!


#899

I made new topic in features category, the requested feature is similar what TLP is about. So I am wondering is it possible to achive something like this with TLP:


(Hakan) #900

These faults are coming out after you go into social mode.


(Angus McLeod) #901

@davidkingham Thanks for your input. I’m thinking about it :slight_smile: .

@Ziil Yup, you could achieve something like that with TLP some substantial CSS additions. You could post a job for it on the #marketplace.

@nothing I’m not seeing any faults in social mode. e.g. social - Angus’ Sandbox.


(Stephen Chung) #902

Hi @angus, will it be difficult to add a filter on images to avoid the ones that are too small, GIF, and other?

The reason being many of my topics are created from email and sometimes the sender has embedded small icons from the email system or virus scanners etc. They got picked up instead of the image attachments.


(Hakan) #903

maybe if you looked at the private message


#904

@angus, is there a new issue? thumbnails are appearing ok in the topic list, but new ‘featured’ tagged ones are no longer appearing in the featured section (though the existing ones are still there) … most odd … on latest build of everything. Anything I can try?


(Angus McLeod) #905

@schungx Ah yes, I did say I would address that. I’ll take a look at it today.

Maybe it’s an order issue? Try changing the featured order using the site setting.


(Angus McLeod) #906

@schungx I’ve added a minimum size to previewed images. Could you test that out with your use case? Interested in the results.


#907

Order makes no difference.

Is there any way to ‘force’ a repopulation of the featured list data or does this happen on every render anyway?


(Angus McLeod) #908

If you’re keen on digging into this that would be great :slight_smile:

Take a look at lib/featured_topics.rb in the plugin. It contains all the server-side featured topics logic. Three things to note:

  • Featured topics are determined according to the query in the featured_topics method in the PreviewsTopicQueryExtension, i.e.

    result = Topic.visible
       .where('NOT topics.closed AND NOT topics.archived AND topics.deleted_at IS NULL')
       .where("topics.id in (
         SELECT topic_id FROM topic_custom_fields
         WHERE name = 'thumbnails' AND 'value' IS NOT NULL
       )")
       .joins(:tags)
       .where("tags.id = ?", tag_id)
       .order(featured_order)
       .limit(limit)
    
  • When you dig into how the results of this query are integrated into the discovery topic lists and the TopicView (i.e. topics), you’ll notice that data is cached in instance variables in various places to avoid running the query more than necessary, i.e.

    @featured_topics ||= begin
      // 
    end
    
  • When appearing above topic lists, featured topics are sent to the client by hitching a ride on the list object. Take a look at the override of the create_list method in the PreviewsTopicQueryExtension.

The issue you’re describing could be a result of an issue with the query, or data being cached inappropriately.

If you’re running this on your local, try printing out the featured topic list at various points to see what’s being loaded, e.g. puts result.inspect, (or something more human readable: puts "FEATURED TOPICS: #{result.to_a.map(&:title)}").

If there is an issue with the selection of featured topics it’s probably on the server, but you could also try printing what ends up on the client. Take a look at preview-route-edits.js.es6 and do a search for ‘featured’. Add a console.log for the list of featured topics that are extracted from the normal topic list.


#909

Whilst setting up dev I noticed that the missing picture appears in the featured section if you clear the following setting:

Use topic image_url in thumbnails directly, rather than generated thumbnails. Warning: this means each full sized topic image will be loaded when the topic list loads and will affect performance.

However, this unfortunately (fortunately?) makes the issue difficult to recreate - clearing and setting has no further effect - … it’s like something was out and is now fixed …!

So my issue is resolved for now, thanks for your long detailed post.


(Stephen Chung) #910

Great! Will test.

Can i just rebuild html on one of the posts to check it?


(Stephen Chung) #911

There are two problems with it.

  1. Can you make it a user-definable setting instead of hard-coding to 100x100 minimum size?

  2. I’m sure what it does right now is SKIP the image altogether if the first image is a junk icon. However, there are many emails that will have brand icons in the signature, FOLLOWED by attached images. You’ll be skipping all those.

I suggest that it might be better to check for image dimensions in extract_post_image and extract the correct one, instead of extracting the first one and then filtering it out.

Instead of .first, maybe put in a filter here and then take the .first of the filtered set?


(Shashank Singla) #912

I am using this plugin in conjunction with the QnA plugin from @angus. My goal was to show preview of an answer on the topic list page. But currently the plugin shows the description of the question as preview by default.

I am unable to find any setting which can let me show the first or last answer text as preview. I have scrolled through this thread and have not found anything.Can you tell me if its possible and if so, how?