mirror of
https://github.com/moparisthebest/www.moparscape.org
synced 2024-08-13 16:53:50 -04:00
Added ssijs to grab forum threads
This commit is contained in:
parent
4d88f2a229
commit
4e02ff6991
@ -45,7 +45,7 @@ titlecase: true # Converts page and post titles to titlecase
|
||||
|
||||
# list each of the sidebar modules you want to include, in the order you want them to appear.
|
||||
# To add custom asides, create files in /source/_includes/custom/asides/ and add them to the list like 'custom/asides/custom_aside_name.html'
|
||||
default_asides: [asides/recent_posts.html, asides/sidead.html, asides/delicious.html, asides/pinboard.html, asides/googleplus.html]
|
||||
default_asides: [asides/ssi.html, asides/recent_posts.html, asides/sidead.html, asides/delicious.html, asides/pinboard.html, asides/googleplus.html]
|
||||
|
||||
# Each layout uses the default asides, but they can have their own asides instead. Simply uncomment the lines below
|
||||
# and add an array with the asides you want to use.
|
||||
@ -102,5 +102,10 @@ google_bannerad_slot: 4021158971
|
||||
google_bannerad_width: 468
|
||||
google_bannerad_height: 60
|
||||
|
||||
# forum announcements
|
||||
ssi_board: 112
|
||||
ssi_limit: 3
|
||||
ssi_length: 200
|
||||
|
||||
# Facebook Like
|
||||
facebook_like: true
|
||||
|
27
source/_includes/asides/ssi.html
Normal file
27
source/_includes/asides/ssi.html
Normal file
@ -0,0 +1,27 @@
|
||||
{% if site.ssi_board %}
|
||||
<section>
|
||||
<h1>Announcements</h1>
|
||||
<ul id="ssi_threads">
|
||||
<li class="loading">Status updating...</li>
|
||||
</ul>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
if (!window.jXHR){
|
||||
var jxhr = document.createElement('script');
|
||||
jxhr.type = 'text/javascript';
|
||||
jxhr.src = '{{ root_url}}/javascripts/libs/jXHR.js';
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(jxhr, s);
|
||||
}
|
||||
|
||||
smf_ssi.showThreads({
|
||||
board: {{site.ssi_board}},
|
||||
limit: {{site.ssi_limit}},
|
||||
length: {{site.ssi_length}},
|
||||
target: '#ssi_threads'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="{{ root_url }}/javascripts/ssi.js" type="text/javascript"> </script>
|
||||
</section>
|
||||
{% endif %}
|
32
source/javascripts/ssi.js
Normal file
32
source/javascripts/ssi.js
Normal file
@ -0,0 +1,32 @@
|
||||
var smf_ssi = (function(){
|
||||
function escapeHtml(str) {
|
||||
str = str.replace(/<(img|br)[^>]*>/g, ' ');
|
||||
//return $('<div/>').text(str).html();
|
||||
return str;
|
||||
}
|
||||
function render(target, data){
|
||||
//alert(data.id);
|
||||
//console.log(data.id);
|
||||
//console.log(data[0].id);
|
||||
if (!data)
|
||||
return;
|
||||
var i = 0, fragment = '', t = $(target)[0];
|
||||
|
||||
for(i = 0; i < data.length; i++) {
|
||||
fragment += '<li><a href="'+data[i].href+'">'+data[i].subject+'</a><p>'+escapeHtml(data[i].body||'')+'</p></li>';
|
||||
}
|
||||
t.innerHTML = fragment;
|
||||
}
|
||||
return {
|
||||
showThreads: function(options){
|
||||
$.ajax({
|
||||
url: "/ssijs.php"
|
||||
//url: "http://www.moparisthebest.com/ssijs.php"
|
||||
, dataType: 'jsonp'
|
||||
, data: { board: options.board, limit: options.limit, length: options.length }
|
||||
, error: function (err, textStatus, errorThrown) { $(options.target + ' li.loading').addClass('error').text("Error loading feed textStatus: '"+textStatus+"' errorThrown: '"+errorThrown+"'"); }
|
||||
, success: function(data) { render(options.target, data); }
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
31
source/ssijs.php
Normal file
31
source/ssijs.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
function getRequest($request, $default = null)
|
||||
{
|
||||
return empty($_REQUEST[$request]) ? $default : $_REQUEST[$request];
|
||||
}
|
||||
|
||||
require_once("/home/www-data/htdocs/moparisthebest.com/smf/SSI.php");
|
||||
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
header('Access-Control-Expose-Headers: Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-OAuth-Scopes, X-Accepted-OAuth-Scopes');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
// do we want JSON, or JSONP
|
||||
$callback = getRequest('callback');
|
||||
|
||||
//function ssi_boardNews($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')
|
||||
$return = ssi_boardNews(getRequest('board'), getRequest('limit', 5), 0, getRequest('length', 100), 'array');
|
||||
//print_r($return);
|
||||
|
||||
if ($callback != null) {
|
||||
header('Content-Type: application/javascript; charset=utf-8');
|
||||
echo $callback . '(';
|
||||
} else {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
if ($callback != null)
|
||||
echo ');';
|
||||
?>
|
Loading…
Reference in New Issue
Block a user