mirror of
https://github.com/PretendoNetwork/miiverse-api.git
synced 2026-07-16 00:15:39 -05:00
Fixed posting in portal, added support for video posts
This commit is contained in:
parent
1e7add9597
commit
a9828d89ed
|
|
@ -81,12 +81,18 @@ async function getPostsByUserID(userID) {
|
|||
});
|
||||
}
|
||||
|
||||
async function getPostsByCommunity(community, numberOfPosts) {
|
||||
async function getHotPostsByCommunity(community, numberOfPosts) {
|
||||
verifyConnected();
|
||||
return POST.find({
|
||||
title_id: community.title_id
|
||||
}).sort({empathy_count: -1}).limit(numberOfPosts);
|
||||
}
|
||||
async function getPostsByCommunity(community, numberOfPosts) {
|
||||
verifyConnected();
|
||||
return POST.find({
|
||||
title_id: community.title_id
|
||||
}).limit(numberOfPosts);
|
||||
}
|
||||
|
||||
async function getPostsByCommunityKey(community, numberOfPosts, search_key) {
|
||||
verifyConnected();
|
||||
|
|
@ -125,6 +131,7 @@ module.exports = {
|
|||
getCommunityByID,
|
||||
getDiscoveryHosts,
|
||||
getPostsByCommunity,
|
||||
getHotPostsByCommunity,
|
||||
getPostsByCommunityKey,
|
||||
getPostsByUserID,
|
||||
getPostByID,
|
||||
|
|
|
|||
|
|
@ -104,19 +104,7 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<ul class="list-content-with-icon-column" id="community-top-content">
|
||||
<li id="community-4490545270232728351" class="">
|
||||
<span class="icon-container"><img src="/img/title-icon-default.png" class="icon"></span>
|
||||
<a href="/titles/4490545270232728350/4490545270232728351" data-pjax="#body" class="scroll to-community-button"></a>
|
||||
<div class="body">
|
||||
<div class="body-content">
|
||||
<span class="community-name title">GameName (UniqueID: 0x01769)</span>
|
||||
<span class="platform-tag platform-tag-wiiu"></span>
|
||||
<span class="text">Wii U Games</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
OLV_WIIU_NEW_COMMUNITIES
|
||||
<a href="/communities/categories/wiiu_all" data-pjax="#body" class="more-button scroll">Show More</a>
|
||||
|
||||
<h2 class="headline headline-special">Special</h2>
|
||||
|
|
@ -185,43 +173,5 @@
|
|||
|
||||
<button type="button" class="accesskey-L" style="display: none;"></button><button type="button" class="accesskey-R" style="display: none;"></button><button type="button" class="accesskey-Y" style="display: none;">
|
||||
</button>
|
||||
<script>
|
||||
getCommunities()
|
||||
function getCommunities() {
|
||||
var xhttp;
|
||||
xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
var communities = JSON.parse(this.responseText);
|
||||
var communityBody = '<ul class="list-content-with-icon-column" id="community-top-content">';
|
||||
for(var i = 0; i < communities.length; i++)
|
||||
{
|
||||
communityBody += '<li id="community-' + communities[i].community_id + '" class="">' +
|
||||
'<span class="icon-container"><img src="' + communities[i].browser_icon + '" class="icon"></span>' +
|
||||
'<a href="/titles/' + communities[i].community_id + '" data-pjax="#body" class="scroll to-community-button"></a>' +
|
||||
'<div class="body">' +
|
||||
'<div class="body-content">' +
|
||||
'<span class="community-name title">' + communities[i].name + '</span>';
|
||||
switch(parseInt(communities[i].platform_id))
|
||||
{
|
||||
case 0:
|
||||
communityBody += '<span class="platform-tag platform-tag-wiiu"></span><span class="text">Wii U Games</span>';
|
||||
break;
|
||||
case 1:
|
||||
communityBody += '<span class="platform-tag platform-tag-3ds"></span><span class="text">3DS Games</span>';
|
||||
break;
|
||||
case 2:
|
||||
communityBody += '<span class="platform-tag platform-tag-wiiu-3ds"></span><span class="text">Both Platform Games</span>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
document.getElementById("community-top-content").innerHTML = communityBody + '</div></div></li>';
|
||||
|
||||
}
|
||||
};
|
||||
xhttp.open("GET", "/v1/communities/list?format=1", true);
|
||||
xhttp.send();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,109 +1,96 @@
|
|||
<title>Communities</title>
|
||||
<header id="header">
|
||||
<title>Communities</title>
|
||||
<header id="header">
|
||||
<a id="header-favorites-button" href="/communities/favorites" data-pjax="#body">Favorite Communities</a>
|
||||
|
||||
<h1 id="page-title" class="left">Communities</h1>
|
||||
<h1 id="page-title" class="left">Communities</h1>
|
||||
<div class="region dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" data-sound="SE_WAVE_BALLOON_OPEN" href="#">Americas</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="/communities?view_region_id=4"
|
||||
class="button checkbox-button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Europe and Oceania</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities?view_region_id=1"
|
||||
class="button checkbox-button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Japan</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities?view_region_id=2"
|
||||
class="button checkbox-button selected" onclick="return false;"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Americas</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" data-sound="SE_WAVE_BALLOON_OPEN" href="#">Americas</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="/communities?view_region_id=4"
|
||||
class="button checkbox-button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Europe and Oceania</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities?view_region_id=1"
|
||||
class="button checkbox-button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Japan</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities?view_region_id=2"
|
||||
class="button checkbox-button selected" onclick="return false;"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Americas</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</header>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="body-content" id="community-top"
|
||||
data-region="USA">
|
||||
<div class="body-content" id="community-top"
|
||||
data-region="USA">
|
||||
|
||||
|
||||
<div class="community-list community-list-wiiu">
|
||||
|
||||
<div class="banner-container">
|
||||
<a href="/identified_user_posts?view_region_id=2" data-pjax="#body" class="button identified-user-button">
|
||||
<span class="title">Get the latest news here!</span>
|
||||
<span class="text">Posts from Verified Users</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="headline with-filter headline-wiiu">
|
||||
<h2>New Communities</h2>
|
||||
<div class="banner-container">
|
||||
<a href="/identified_user_posts?view_region_id=2" data-pjax="#body" class="button identified-user-button">
|
||||
<span class="title">Get the latest news here!</span>
|
||||
<span class="text">Posts from Verified Users</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="headline with-filter headline-wiiu">
|
||||
<h2>New Communities</h2>
|
||||
|
||||
<div class="with-filter-right">
|
||||
<div class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" data-sound="SE_WAVE_BALLOON_OPEN" href="#">Filter</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="/communities/categories/wiiu_all"
|
||||
class="button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>All Software</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities/categories/wiiu_game"
|
||||
class="button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Wii U Games</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities/categories/wiiu_virtualconsole"
|
||||
class="button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Virtual Console</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities/categories/wiiu_other"
|
||||
class="button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Others</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="with-filter-right">
|
||||
<div class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" data-sound="SE_WAVE_BALLOON_OPEN" href="#">Filter</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="/communities/categories/wiiu_all"
|
||||
class="button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>All Software</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities/categories/wiiu_game"
|
||||
class="button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Wii U Games</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities/categories/wiiu_virtualconsole"
|
||||
class="button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Virtual Console</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/communities/categories/wiiu_other"
|
||||
class="button" data-pjax="#body"
|
||||
data-sound="SE_WAVE_TOGGLE_CHECK"
|
||||
>Others</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
OLV_WIIU_NEW_COMMUNITIES
|
||||
<a href="/communities/categories/wiiu_all" data-pjax="#body" class="more-button scroll">Show More</a>
|
||||
|
||||
<h2 class="headline headline-special">Special</h2>
|
||||
<ul class="list-content-with-icon-column" id="community-top-content">
|
||||
</ul>
|
||||
|
||||
<div class="community-list-footer">
|
||||
<a href="/communities?view_platform=3ds" class="platform-button platform-button-3ds" data-pjax="#body">3DS Communities</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<ul class="list-content-with-icon-column" id="community-top-content">
|
||||
<li id="community-4490545270232728351" class="">
|
||||
<span class="icon-container"><img src="/img/title-icon-default.png" class="icon"></span>
|
||||
<a href="/titles/4490545270232728350/4490545270232728351" data-pjax="#body" class="scroll to-community-button"></a>
|
||||
<div class="body">
|
||||
<div class="body-content">
|
||||
<span class="community-name title">GameName (UniqueID: 0x01769)</span>
|
||||
<span class="platform-tag platform-tag-wiiu"></span>
|
||||
<span class="text">Wii U Games</span>
|
||||
<span type="button" class="fixed-bottom-button search-button" id="community-search">Search<input name="query" class="title-search-query" minlength="2" maxlength="20" inputform="monospace" guidestring="Search Communities" data-pjax="#body"></span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="/communities/categories/wiiu_all" data-pjax="#body" class="more-button scroll">Show More</a>
|
||||
|
||||
<h2 class="headline headline-special">Special</h2>
|
||||
<ul class="list-content-with-icon-column" id="community-top-content">
|
||||
</ul>
|
||||
|
||||
<div class="community-list-footer">
|
||||
<a href="/communities?view_platform=3ds" class="platform-button platform-button-3ds" data-pjax="#body">3DS Communities</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<span type="button" class="fixed-bottom-button search-button" id="community-search">Search<input name="query" class="title-search-query" minlength="2" maxlength="20" inputform="monospace" guidestring="Search Communities" data-pjax="#body"></span>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -22,9 +22,9 @@
|
|||
</div>
|
||||
<menu class="tab-header">
|
||||
<li id="tab-header-post" class="tab-button selected" data-show-post-button="1">
|
||||
<a href="/titles/14866558072985245728/14866558073038702637/new" data-pjax-replace="1" data-pjax="#community-tab-body" data-pjax-cache-container="#body" data-sound="SE_WAVE_SELECT_TAB"><span class="new-post">All Posts</span></a>
|
||||
<a onclick="getPosts('COMMUNITY_TITLE_ID_STANDIN', 0)" data-pjax-replace="1" data-pjax="#community-tab-body" data-pjax-cache-container="#body" data-sound="SE_WAVE_SELECT_TAB"><span class="new-post">All Posts</span></a>
|
||||
</li>
|
||||
<li id="tab-header-hot-post" class="tab-button"><a href="/titles/14866558072985245728/14866558073038702637/hot" data-pjax="#community-tab-body" data-pjax-cache-container="#body" data-pjax-replace="1" data-sound="SE_WAVE_SELECT_TAB"><span>Popular posts</span></a></li>
|
||||
<li id="tab-header-hot-post" class="tab-button"><a onclick="getPosts('COMMUNITY_TITLE_ID_STANDIN', 1)" data-pjax="#community-tab-body" data-pjax-cache-container="#body" data-pjax-replace="1" data-sound="SE_WAVE_SELECT_TAB"><span>Popular posts</span></a></li>
|
||||
</menu>
|
||||
<div id="title-settings-page" class="window-page none" data-modal-types="title-settings">
|
||||
<div class="window">
|
||||
|
|
@ -158,7 +158,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function getPosts(str) {
|
||||
function getPosts(str, type) {
|
||||
var xhttp;
|
||||
if (str === "") {
|
||||
document.getElementById("Posts").innerHTML = "";
|
||||
|
|
@ -175,6 +175,7 @@
|
|||
var postBody = '';
|
||||
for(var i = 0; i < posts.length; i++)
|
||||
{
|
||||
console.log(posts[i]);
|
||||
postBody += '<div id="post-' + posts[i].id + '" class="post scroll post-subtype-default" data-post-permalink-url="/posts/' + posts[i].id + '">\n' +
|
||||
'<a href="1" class="user-icon-container scroll-focus" data-pjax="#body"><img src="" class="user-icon"></a>\n' +
|
||||
' <div class="post-body-content">\n' +
|
||||
|
|
@ -188,6 +189,17 @@
|
|||
if(posts[i].screenshot !== undefined && posts[i].screenshot !== '')
|
||||
postBody += '<p class="post-content-text">' + posts[i].body + '</p>'+
|
||||
'<p class="post-content-memo"><img src="data:image/png;base64,' + posts[i].screenshot +'" class="post-screenshot"></p>';
|
||||
if(posts[i].url !== undefined)
|
||||
{
|
||||
var ytLink = posts[i].url;
|
||||
console.log(ytLink);
|
||||
postBody += '<div class="post-content">' +
|
||||
'<div class="title-capture-container video-container">' +
|
||||
'<a class="video-thumbnail" href="/posts/' + posts[i].id + '" data-pjax="#body">' +
|
||||
'<span><img width="120" height="90" src="https://i.ytimg.com/vi/' + ytLink.replace("https://www.youtube.com/watch?v=", "") +'/default.jpg">' +
|
||||
'</span></a></div>' +
|
||||
'<p class="post-content-text">' + posts[i].body + '</p></div>';
|
||||
}
|
||||
else if(posts[i].painting_uri !== undefined && posts[i].painting_uri !== '')
|
||||
postBody += '<p class="post-content-memo"><img src="' + posts[i].painting_uri +'" class="post-memo"></p>';
|
||||
else
|
||||
|
|
@ -208,8 +220,8 @@
|
|||
|
||||
}
|
||||
};
|
||||
xhttp.open("GET", "/v1/posts?community_id=" + str + "&limit=100&format=2", true);
|
||||
xhttp.open("GET", "/v1/posts?community_id=" + str + "&limit=100&format=2&type=" + type, true);
|
||||
xhttp.send();
|
||||
}
|
||||
getPosts('COMMUNITY_TITLE_ID_STANDIN')
|
||||
getPosts('COMMUNITY_TITLE_ID_STANDIN', 0)
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
<div class="body-content" id="messages-list">
|
||||
<div class="no-content-window"><div class="window">
|
||||
<p>This would normally be loading the activity feed. But it has not been implemented yet. Check back later!</p>
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/wO2TLZ6Pqo4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
</div></div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -31,7 +31,7 @@
|
|||
data-is-post="1"
|
||||
data-is-permalink="1"
|
||||
data-can-report-spoiler="1"
|
||||
data-community-id="4490545270232728351" data-url-id="AYECAAAEAAAsUZ8kcv4hUQ" data-track-label="default" data-title-id="4490545270232728350" data-track-action="openReportModal" data-track-category="reportViolation"
|
||||
data-community-id="4490545270232728351" data-url-id="OLV_POST_ID" data-track-label="default" data-title-id="4490545270232728350" data-track-action="openReportModal" data-track-category="reportViolation"
|
||||
>Report Violation</a>
|
||||
|
||||
<div class="expression">
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
data-action="/posts/OLV_POST_ID/empathies"
|
||||
data-other-empathy-count="0"
|
||||
data-sound="SE_WAVE_MII_ADD"
|
||||
data-community-id="4490545270232728351" data-url-id="AYECAAAEAAAsUZ8kcv4hUQ" data-track-label="default" data-title-id="4490545270232728350" data-track-action="yeah" data-track-category="empathy"
|
||||
data-community-id="4490545270232728351" data-url-id="OLV_POST_ID" data-track-label="default" data-title-id="4490545270232728350" data-track-action="yeah" data-track-category="empathy"
|
||||
>Yeah!</button>
|
||||
</div>
|
||||
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
<h1 class="page-title">Comment on OLV_DISPLAY_NAME's Post
|
||||
</h1>
|
||||
</header>
|
||||
<form method="post" action="/posts/AYECAAAEAAAsUZ8kcv4hUQ/replies" class="test-reply-form">
|
||||
<form method="post" action="/posts/OLV_POST_ID/replies" class="test-reply-form">
|
||||
|
||||
<div class="add-post-page-content">
|
||||
<div class="feeling-selector expression">
|
||||
|
|
@ -178,7 +178,7 @@
|
|||
</div>
|
||||
<input type="button" class="olv-modal-close-button fixed-bottom-button left" value="Cancel" data-sound="SE_WAVE_CANCEL">
|
||||
<input type="button" class="post-button fixed-bottom-button" value="Post"
|
||||
data-community-id="4490545270232728351" data-url-id="AYECAAAEAAAsUZ8kcv4hUQ" data-track-label="default" data-title-id="4490545270232728350" data-track-action="sendReply" data-track-category="reply"
|
||||
data-community-id="4490545270232728351" data-url-id="OLV_POST_ID" data-track-label="default" data-title-id="4490545270232728350" data-track-action="sendReply" data-track-category="reply"
|
||||
|
||||
data-post-content-type="text"
|
||||
|
||||
|
|
@ -224,7 +224,7 @@
|
|||
data-is-template="1">
|
||||
<div class="window">
|
||||
<h1 class="window-title">Report Violation to Miiverse Administrators</h1>
|
||||
<form method="post" action="/posts/AYECAAAEAAAsUZ8kcv4hUQ/violations">
|
||||
<form method="post" action="/posts/OLV_POST_ID/violations">
|
||||
<div class="window-body"><div class="window-body-inner message">
|
||||
<p class="description">
|
||||
You are about to report a post with content which violates the Miiverse Code of Conduct. This report will be sent to Nintendo's Miiverse administrators and not to the creator of the post. </p>
|
||||
|
|
@ -260,7 +260,7 @@
|
|||
<div class="window-bottom-buttons">
|
||||
<input type="button" class="olv-modal-close-button button" value="Cancel" data-sound="SE_WAVE_CANCEL">
|
||||
<input type="submit" class="post-button button" value="Submit Report"
|
||||
data-community-id="4490545270232728351" data-url-id="AYECAAAEAAAsUZ8kcv4hUQ" data-track-label="default" data-title-id="4490545270232728350" data-track-action="openReportModal" data-track-category="reportViolation">
|
||||
data-community-id="4490545270232728351" data-url-id="OLV_POST_ID" data-track-label="default" data-title-id="4490545270232728350" data-track-action="openReportModal" data-track-category="reportViolation">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -277,9 +277,9 @@
|
|||
<div class="select-button"><span class="select-button-content">Select an option.</span>
|
||||
<select name="edit-type">
|
||||
<option value="" data-action="" selected>Select an option.</option>
|
||||
<option value="spoiler" data-action="/posts/AYECAAAEAAAsUZ8kcv4hUQ.set_spoiler" >Set as Spoiler</option>
|
||||
<option value="delete" data-action="/posts/AYECAAAEAAAsUZ8kcv4hUQ.delete"
|
||||
data-community-id="4490545270232728351" data-url-id="AYECAAAEAAAsUZ8kcv4hUQ" data-track-label="default" data-title-id="4490545270232728350" data-track-action="deletePost" data-track-category="post">
|
||||
<option value="spoiler" data-action="/posts/OLV_POST_ID.set_spoiler" >Set as Spoiler</option>
|
||||
<option value="delete" data-action="/posts/OLV_POST_ID.delete"
|
||||
data-community-id="4490545270232728351" data-url-id="OLV_POST_ID" data-track-label="default" data-title-id="4490545270232728350" data-track-action="deletePost" data-track-category="post">
|
||||
Delete
|
||||
</option>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ const PostSchema = new Schema({
|
|||
pid: Number,
|
||||
platform_id: Number,
|
||||
region_id: Number,
|
||||
parent_post: Number,
|
||||
reply_count: {
|
||||
type: Number,
|
||||
default: 0
|
||||
|
|
@ -76,6 +77,20 @@ PostSchema.methods.downEmpathy = async function() {
|
|||
await this.save();
|
||||
};
|
||||
|
||||
PostSchema.methods.upReply = async function() {
|
||||
const replyCount = this.get('reply_count');
|
||||
this.set('reply_count', replyCount + 1);
|
||||
|
||||
await this.save();
|
||||
};
|
||||
|
||||
PostSchema.methods.downReply = async function() {
|
||||
const replyCount = this.get('reply_count');
|
||||
this.set('reply_count', replyCount - 1);
|
||||
|
||||
await this.save();
|
||||
};
|
||||
|
||||
const POST = model('POST', PostSchema);
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
|
|
@ -8,23 +8,27 @@ const router = express.Router();
|
|||
|
||||
// Router to handle the subdomain restriction
|
||||
const api = express.Router();
|
||||
const web = express.Router();
|
||||
const ctr = express.Router();
|
||||
const portal = express.Router();
|
||||
|
||||
// Create subdomains
|
||||
logger.info('[MIIVERSE] Creating \'web api\' subdomain');
|
||||
router.use(subdomain('web.olv', api));
|
||||
router.use(subdomain('ctr.olv', api));
|
||||
router.use(subdomain('web.olv', web));
|
||||
router.use(subdomain('ctr.olv', ctr));
|
||||
router.use(subdomain('portal.olv', portal));
|
||||
|
||||
// Setup routes
|
||||
api.use('/web', routes.WEB);
|
||||
api.use('/titles/show', routes.CTR);
|
||||
web.use('/', routes.WEB);
|
||||
ctr.use('/titles/show', routes.CTR);
|
||||
portal.use('/', routes.PORTAL);
|
||||
portal.use('/v1/communities/', routes.COMMUNITY);
|
||||
portal.use('/v1/posts/', routes.POST);
|
||||
portal.use('/post', routes.NEWPOST);
|
||||
web.use('/v1/communities/', routes.COMMUNITY);
|
||||
api.use('/v1/communities/', routes.COMMUNITY);
|
||||
api.use('/v1/posts/', routes.POST);
|
||||
api.use('/post/', routes.POST);
|
||||
api.use('/post', routes.NEWPOST);
|
||||
api.use('/users/', routes.USERS);
|
||||
portal.use('/users/', routes.USERS);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ var express = require('express');
|
|||
var router = express.Router();
|
||||
const database = require('../../../database');
|
||||
const fs = require('fs-extra');
|
||||
const util = require('../../../util/authentication');
|
||||
const comPostGen = require('../../../util/CommunityPostGen');
|
||||
const processHeaders = require('../../../util/authentication');
|
||||
|
||||
/* GET post titles. */
|
||||
router.get('/titles/show', function (req, res) {
|
||||
res.header('X-Nintendo-WhiteList','1|http,youtube.com,,2|https,youtube.com,,2|http,.youtube.com,,2|https,.youtube.com,,2|http,.ytimg.com,,2|https,.ytimg.com,,2|http,.googlevideo.com,,2|https,.googlevideo.com,,2|https,youtube.com,/embed/,6|https,youtube.com,/e/,6|https,youtube.com,/v/,6|https,www.youtube.com,/embed/,6|https,www.youtube.com,/e/,6|https,www.youtube.com,/v/,6|https,youtube.googleapis.com,/e/,6|https,youtube.googleapis.com,/v/,6|http,maps.googleapis.com,/maps/api/streetview,2|https,maps.googleapis.com,/maps/api/streetview,2|http,cbk0.google.com,/cbk,2|https,cbk0.google.com,/cbk,2|http,cbk1.google.com,/cbk,2|https,cbk1.google.com,/cbk,2|http,cbk2.google.com,/cbk,2|https,cbk2.google.com,/cbk,2|http,cbk3.google.com,/cbk,2|https,cbk3.google.com,/cbk,2|https,.cloudfront.net,,2|https,www.google-analytics.com,/,2|https,stats.g.doubleclick.net,,2|https,www.google.com,/ads/,2|https,ssl.google-analytics.com,,2')
|
||||
res.redirect('/communities');
|
||||
});
|
||||
router.get('/settings/profile', function (req, res) {
|
||||
|
|
@ -45,36 +47,137 @@ router.get('/*/portal.js', function (req, res) {
|
|||
router.get('/*/portal.css', function (req, res) {
|
||||
res.sendFile("portal.css", { root: 'src/html/portal' });
|
||||
});
|
||||
router.get('/posts/*', function (req, res) {
|
||||
database.connect().then(async e => {
|
||||
router.post('/posts/*/empathies', function (req, res, next) {
|
||||
let paramPackData = util.data.decodeParamPack(req.headers["x-nintendo-parampack"]);
|
||||
let pid = req.originalUrl.replace('/posts/', '').replace('/empathies','').trim();
|
||||
console.log(pid);
|
||||
database.connect().then(async emp => {
|
||||
let post = await database.getPostByID(parseInt(pid));
|
||||
await post.upEmpathy();
|
||||
});
|
||||
res.status(200);
|
||||
res.send();
|
||||
});
|
||||
router.post('/posts/*/empathies.delete', function (req, res, next) {
|
||||
let paramPackData = util.data.decodeParamPack(req.headers["x-nintendo-parampack"]);
|
||||
let pid = req.originalUrl.replace('/posts/', '').replace('/empathies.delete','').trim();
|
||||
console.log(pid);
|
||||
database.connect().then(async emp => {
|
||||
let post = await database.getPostByID(parseInt(pid));
|
||||
await post.downEmpathy();
|
||||
});
|
||||
res.status(200);
|
||||
res.send();
|
||||
});
|
||||
router.post('/posts/*/replies', async function (req, res, next) {
|
||||
try
|
||||
{
|
||||
let postID = req.originalUrl.replace('/posts', '').split('/').pop().split('?')[0];
|
||||
console.log(postID);
|
||||
let post = await database.getPostByID(postID);
|
||||
let community = await database.getCommunityByTitleID(post.title_id);
|
||||
if(post === null)
|
||||
res.sendStatus(404);
|
||||
let pid = util.data.processServiceToken(req.headers["x-nintendo-servicetoken"]);
|
||||
if(pid == null)
|
||||
{
|
||||
throw new Error('The User token was not valid');
|
||||
}
|
||||
else
|
||||
{
|
||||
let file = '';
|
||||
if (req.query._pjax === "#body")
|
||||
file = await fs.readFile(`src/html/portal/post_body.html`, 'utf-8');
|
||||
let usrObj;
|
||||
usrObj = await util.data.processUser(pid);
|
||||
const creationDate = moment().format('YYYY-MM-DD HH:MM:SS');
|
||||
let appData = "";
|
||||
if (req.body.app_data) {
|
||||
appData = req.body.app_data.replace(/\0/g, "").trim();
|
||||
}
|
||||
let painting = "";
|
||||
if (req.body.painting) {
|
||||
painting = req.body.painting.replace(/\0/g, "").trim();
|
||||
}
|
||||
let paintingURI = "";
|
||||
if (req.body.painting) {
|
||||
paintingURI = await util.data.processPainting(painting);
|
||||
}
|
||||
let screenshot = "";
|
||||
if (req.body.screenshot) {
|
||||
screenshot = req.body.screenshot.replace(/\0/g, "").trim();
|
||||
}
|
||||
const document = {
|
||||
title_id: req.body.olive_title_id,
|
||||
screen_name: usrObj.user_id,
|
||||
body: req.body.body,
|
||||
app_data: appData,
|
||||
painting: painting,
|
||||
painting_uri: paintingURI,
|
||||
screenshot: screenshot,
|
||||
url: req.body.url,
|
||||
created_at: creationDate,
|
||||
feeling_id: req.body.feeling_id,
|
||||
id: snowflake.nextId(),
|
||||
is_autopost: req.body.is_autopost,
|
||||
is_spoiler: req.body.is_spoiler,
|
||||
mii: usrObj.mii,
|
||||
mii_face_url: "http://mii-images.account.pretendo.cc/",
|
||||
};
|
||||
const newPost = new POST(document);
|
||||
newPost.save();
|
||||
res.sendStatus(200);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
res.set("Content-Type", "application/xml");
|
||||
res.statusCode = 400;
|
||||
response = {
|
||||
result: {
|
||||
has_error: 1,
|
||||
version: 1,
|
||||
code: 400,
|
||||
error_code: 7,
|
||||
message: "POSTING_FROM_NNID"
|
||||
}
|
||||
};
|
||||
res.send("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xml(response));
|
||||
}
|
||||
|
||||
});
|
||||
router.get('/posts/*', function (req, res) {
|
||||
database.connect().then(async e => {
|
||||
try
|
||||
{
|
||||
let postID = req.originalUrl.replace('/posts', '').split('/').pop().split('?')[0];
|
||||
console.log(postID);
|
||||
let post = await database.getPostByID(parseInt(postID));
|
||||
let community = await database.getCommunityByTitleID(post.title_id);
|
||||
if(post === null)
|
||||
res.sendStatus(404);
|
||||
else
|
||||
file = await fs.readFile(`src/html/portal/post.html`, 'utf-8');
|
||||
let newFile = file.replace(/OLV_DISPLAY_NAME/g, post.screen_name)
|
||||
.replace(/OLV_TOPIC_TAG/g, post.topic_tag)
|
||||
.replace(/OLV_ICON_STANDIN/g, community.browser_icon)
|
||||
.replace(/OLV_COMMUNITY_ID/g, community.community_id)
|
||||
.replace(/OLV_POST_TIMESTAMP/g, post.created_at)
|
||||
.replace(/OLV_PAGE_TITLE_STANDIN/g, community.name);
|
||||
let postContent = '';
|
||||
if(post.screenshot !== undefined && post.screenshot !== '')
|
||||
postContent = '<p class="post-content-text">' + post.body + '</p>'+
|
||||
'<p class="post-content-memo"><img src="data:image/png;base64,' + post.screenshot +'" class="post-screenshot"></p>';
|
||||
else if(post.painting_uri !== undefined && post.painting_uri !== '')
|
||||
postContent = '<p class="post-content-memo"><img src="' + post.painting_uri +'" class="post-memo"></p>';
|
||||
else
|
||||
postContent = '<p class="post-content-text">' + post.body + '</p>';
|
||||
res.send(newFile.replace('OLV_POST_CONTENT', postContent));
|
||||
{
|
||||
let file = '';
|
||||
if (req.query._pjax === "#body")
|
||||
file = await fs.readFile(`src/html/portal/post_body.html`, 'utf-8');
|
||||
else
|
||||
file = await fs.readFile(`src/html/portal/post.html`, 'utf-8');
|
||||
let newFile = file.replace(/OLV_DISPLAY_NAME/g, post.screen_name)
|
||||
.replace(/OLV_TOPIC_TAG/g, post.topic_tag)
|
||||
.replace(/OLV_ICON_STANDIN/g, community.browser_icon)
|
||||
.replace(/OLV_COMMUNITY_ID/g, community.community_id)
|
||||
.replace(/OLV_POST_TIMESTAMP/g, post.created_at)
|
||||
.replace(/OLV_PAGE_TITLE_STANDIN/g, community.name)
|
||||
.replace(/OLV_POST_ID/g, post.id);
|
||||
let postContent = '';
|
||||
if(post.painting_uri !== undefined && post.painting_uri !== '')
|
||||
postContent += '<p class="post-content-memo"><img src="' + post.painting_uri +'" class="post-memo"></p>';
|
||||
else
|
||||
postContent += '<p class="post-content-text">' + post.body + '</p>';
|
||||
if(post.screenshot !== undefined && post.screenshot !== '')
|
||||
postContent += '<p class="post-content-text">' + post.body + '</p>'+
|
||||
'<p class="post-content-memo"><img src="data:image/png;base64,' + post.screenshot +'" class="post-screenshot"></p>';
|
||||
else if(post.url !== undefined && post.url !== '')
|
||||
postContent += '<iframe width="560" height="315" src="' + post.url.replace('/watch?v=', '/embed/') +'" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
|
||||
|
||||
res.send(newFile.replace('OLV_POST_CONTENT', postContent));
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
res.sendStatus(404);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -92,10 +195,10 @@ router.get('/titles/*', function (req, res) {
|
|||
file = await fs.readFile(`src/html/portal/community_body.html`, 'utf-8');
|
||||
else
|
||||
file = await fs.readFile(`src/html/portal/community.html`, 'utf-8');
|
||||
let newFile = file.replace('COMMUNITY_TITLE_ID_STANDIN', communityID)
|
||||
.replace('OLV_TITLEID_STANDIN', communityID)
|
||||
.replace('OLV_ICON_STANDIN', community.browser_icon)
|
||||
.replace('OLV_HEADER_STANDIN', community.WiiU_browser_header)
|
||||
let newFile = file.replace(/COMMUNITY_TITLE_ID_STANDIN/g, communityID)
|
||||
.replace(/OLV_TITLEID_STANDIN/g, community.title_id[0])
|
||||
.replace(/OLV_ICON_STANDIN/g, community.browser_icon)
|
||||
.replace(/OLV_HEADER_STANDIN/g, community.WiiU_browser_header)
|
||||
.replace(/OLV_PAGE_TITLE_STANDIN/g, community.name)
|
||||
res.send(newFile);
|
||||
}
|
||||
|
|
@ -104,9 +207,42 @@ router.get('/titles/*', function (req, res) {
|
|||
});
|
||||
|
||||
router.get('/communities', function (req, res) {
|
||||
if (req.query._pjax === "#body")
|
||||
res.sendFile("communities_body.html", { root: 'src/html/portal' });
|
||||
else
|
||||
res.sendFile("communities.html", { root: 'src/html/portal' });
|
||||
database.connect().then(async e => {
|
||||
let communities = await database.getCommunities(6);
|
||||
if(communities === null)
|
||||
res.sendStatus(404);
|
||||
else
|
||||
{
|
||||
let file = '';
|
||||
if (req.query._pjax === "#body")
|
||||
file = await fs.readFile(`src/html/portal/communities_body.html`, 'utf-8');
|
||||
else
|
||||
file = await fs.readFile(`src/html/portal/communities.html`, 'utf-8');
|
||||
let communityBody = '<ul class="list-content-with-icon-column" id="community-top-content">';
|
||||
for(let i = 0; i < communities.length; i++)
|
||||
{
|
||||
communityBody += '<li id="community-' + communities[i].community_id + '" class="">' +
|
||||
'<span class="icon-container"><img src="' + communities[i].browser_icon + '" class="icon"></span>' +
|
||||
'<a href="/titles/' + communities[i].community_id + '" data-pjax="#body" class="scroll to-community-button"></a>' +
|
||||
'<div class="body">' +
|
||||
'<div class="body-content">' +
|
||||
'<span class="community-name title">' + communities[i].name + '</span>';
|
||||
switch(parseInt(communities[i].platform_id))
|
||||
{
|
||||
case 0:
|
||||
communityBody += '<span class="platform-tag platform-tag-wiiu"></span><span class="text">Wii U Games</span>';
|
||||
break;
|
||||
case 1:
|
||||
communityBody += '<span class="platform-tag platform-tag-3ds"></span><span class="text">3DS Games</span>';
|
||||
break;
|
||||
case 2:
|
||||
communityBody += '<span class="platform-tag platform-tag-wiiu-3ds"></span><span class="text">Both Platform Games</span>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
res.send(file.replace('OLV_WIIU_NEW_COMMUNITIES', communityBody + '</div></div></li>'));
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = router;
|
||||
|
|
@ -9,7 +9,17 @@ router.get('/', function (req, res) {
|
|||
//const paramPack = processHeaders.data.decodeParamPack(req.headers["x-nintendo-parampack"]);
|
||||
//"[0:1]=1407375153523200"
|
||||
let community = await database.getCommunityByID(req.query.community_id);
|
||||
let posts = await database.getPostsByCommunity(community, parseInt(req.query.limit));
|
||||
let posts;
|
||||
console.log(parseFloat(req.query.community_id));
|
||||
switch(parseFloat(req.query.type))
|
||||
{
|
||||
case 0:
|
||||
posts = await database.getPostsByCommunity(community, parseInt(req.query.limit));
|
||||
break;
|
||||
case 1:
|
||||
posts = await database.getHotPostsByCommunity(community, parseInt(req.query.limit));
|
||||
break;
|
||||
}
|
||||
let formatType = parseInt(req.query.format);
|
||||
let body = '';
|
||||
let platformIDTag = '';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user