Created
December 24, 2016 15:37
-
-
Save communiteq/784b6ab975295ed22c83b59fc6b6e0b0 to your computer and use it in GitHub Desktop.
Example latest.json display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
jQuery(document).ready(function($) { | |
var site = 'https://your.discourse.forum'; | |
var size = 50; | |
var data = $.getJSON(site + '/latest.json', function(data) { | |
var userArr = {}; | |
for(var i=0; i<data.users.length; i++) { | |
userArr[data.users[i].id] = data.users[i].avatar_template.replace('{size}',size); | |
} | |
//for(var i=0; i<data.topic_list.topics.length; i++) { | |
var maxtopics = 5; | |
if (data.topic_list.topics.length < maxtopics) { | |
maxtopics = data.topic_list.topics.length; | |
} | |
for(var i=0; i<maxtopics; i++) { | |
var t = data.topic_list.topics[i]; | |
var url = site + '/t/' + t.slug; | |
var avatar = site + userArr[t.posters[0].user_id]; | |
$('#latest').append('<li><a href="'+url+'"><span class="avatar"><img src="'+avatar+'"></span><span class="topic-title">'+t.title+'</span></a></li>'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://manvfat.com/