fixed direct loading of popular page

v1.18.x
Baris Soner Usakli 11 years ago
parent 817546c6cf
commit ab2b0e6560

@ -0,0 +1,46 @@
define(['forum/recent'], function(recent) {
var Popular = {},
loadingMoreTopics = false,
active = '';
Popular.init = function() {
app.enterRoom('recent_posts');
$('#new-topics-alert').on('click', function() {
$(this).addClass('hide');
});
recent.watchForNewPosts();
active = recent.selectActivePill();
app.enableInfiniteLoading(function() {
if(!loadingMoreTopics) {
loadMoreTopics();
}
});
function loadMoreTopics() {
loadingMoreTopics = true;
socket.emit('topics.loadMoreFromSet', {
set: 'topics:' + $('.nav-pills .active a').html().toLowerCase(),
after: $('#topics-container').attr('data-nextstart')
}, function(err, data) {
if(err) {
return app.alertError(err.message);
}
if (data.topics && data.topics.length) {
recent.onTopicsLoaded('popular', data.topics);
$('#topics-container').attr('data-nextstart', data.nextStart);
} else {
$('#load-more-btn').hide();
}
loadingMoreTopics = false;
});
}
};
return Popular;
});

@ -0,0 +1,84 @@
<ol class="breadcrumb">
<li><a href="{relative_path}/">Home</a></li>
<li class="active">[[global:header.popular]] <a href="{relative_path}/popular.rss"><i class="fa fa-rss-square"></i></a></li>
</ol>
<ul class="nav nav-pills">
<li class=''><a href='{relative_path}/popular/posts'>[[global:posts]]</a></li>
<li class=''><a href='{relative_path}/popular/views'>[[global:views]]</a></li>
</ul>
<br />
<a href="{relative_path}/popular">
<div class="alert alert-warning hide" id="new-topics-alert"></div>
</a>
<!-- IF !topics.length -->
<div class="alert alert-warning" id="category-no-topics">
<strong>There are no popular topics.</strong>
</div>
<!-- ENDIF !topics.length -->
<div class="category row">
<div class="col-md-12">
<ul id="topics-container" data-nextstart="{nextStart}">
<!-- BEGIN topics -->
<li class="category-item {topics.deleted-class}">
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
<a href="{relative_path}/user/{topics.userslug}" class="pull-left">
<img class="img-rounded user-img" src="{topics.picture}" title="{topics.username}" />
</a>
<h3>
<a href="{relative_path}/topic/{topics.slug}">
<span class="topic-title">
<strong>
<i class="fa {topics.pin-icon}"></i>
<i class="fa {topics.lock-icon}"></i>
</strong>
{topics.title}
</span>
</a>
</h3>
<small>
<span class="topic-stats">
posts
<strong class="human-readable-number" title="{topics.postcount}">{topics.postcount}</strong>
</span>
|
<span class="topic-stats">
views
<strong class="human-readable-number" title="{topics.viewcount}">{topics.viewcount}</strong>
</span>
|
<span>
posted in
<a href="{relative_path}/category/{topics.categorySlug}">
<i class="fa {topics.categoryIcon}"></i> {topics.categoryName}
</a>
<span class="timeago" title="{topics.relativeTime}"></span>
</span>
</span>
<span class="pull-right">
<!-- IF topics.unreplied -->
No one has replied
<!-- ELSE -->
<a href="{relative_path}/user/{topics.teaser_userslug}">
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
</a>
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser_pid}">
replied
</a>
<span class="timeago" title="{topics.teaser_timestamp}"></span>
<!-- ENDIF topics.unreplied -->
</span>
</small>
</div>
</li>
<!-- END topics -->
</ul>
</div>
</div>

@ -868,6 +868,16 @@ module.exports.server = server;
}); });
app.get('/popular/:term?', function (req, res) {
app.build_header({
req: req,
res: res
}, function (err, header) {
res.send(header + app.create_route('popular/' + req.params.term, null, 'popular') + templates.footer);
});
});
app.get('/outgoing', function (req, res) { app.get('/outgoing', function (req, res) {
if (!req.query.url) { if (!req.query.url) {
return res.redirect('/404'); return res.redirect('/404');

Loading…
Cancel
Save