2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-06-11 16:36:18 +09:00
|
|
|
import React from 'react';
|
|
|
|
import { DocumentContainer } from "meteor/utilities:react-list-container";
|
2016-06-23 11:40:35 +09:00
|
|
|
import Posts from "meteor/nova:posts";
|
2016-06-11 16:36:18 +09:00
|
|
|
|
2016-10-19 11:07:21 +02:00
|
|
|
import { graphql } from 'react-apollo';
|
|
|
|
import gql from 'graphql-tag';
|
|
|
|
|
2016-06-11 16:36:18 +09:00
|
|
|
const PostsSingle = (props, context) => {
|
2016-10-19 11:07:21 +02:00
|
|
|
|
|
|
|
const {loading, post} = props.data;
|
|
|
|
|
|
|
|
return loading ? <Telescope.components.Loading/> : <Telescope.components.PostsPage post={post} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
PostsSingle.propTypes = {
|
|
|
|
data: React.PropTypes.shape({
|
|
|
|
loading: React.PropTypes.bool,
|
|
|
|
post: React.PropTypes.object,
|
|
|
|
}).isRequired,
|
|
|
|
params: React.PropTypes.object
|
2016-06-11 16:36:18 +09:00
|
|
|
};
|
|
|
|
|
2016-10-19 11:07:21 +02:00
|
|
|
PostsSingle.contextTypes = {
|
|
|
|
currentUser: React.PropTypes.object
|
|
|
|
};
|
|
|
|
|
2016-10-19 17:38:21 +02:00
|
|
|
// this query is really too big 💥...🚂
|
2016-10-19 11:07:21 +02:00
|
|
|
const PostsSingleWithData = graphql(gql`
|
|
|
|
query getPost($postId: String) {
|
|
|
|
post(_id: $postId) {
|
|
|
|
_id
|
|
|
|
title
|
|
|
|
url
|
|
|
|
slug
|
|
|
|
htmlBody
|
|
|
|
thumbnailUrl
|
|
|
|
baseScore
|
|
|
|
postedAt
|
2016-10-19 17:38:21 +02:00
|
|
|
sticky
|
|
|
|
categories {
|
|
|
|
_id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
commentCount
|
2016-10-19 11:07:21 +02:00
|
|
|
comments {
|
2016-10-19 17:38:21 +02:00
|
|
|
_id
|
2016-10-25 13:13:25 +02:00
|
|
|
# note: currently not used in PostsCommentsThread
|
|
|
|
# parentComment {
|
|
|
|
# htmlBody
|
|
|
|
# postedAt
|
|
|
|
# user {
|
|
|
|
# _id
|
|
|
|
# telescope {
|
|
|
|
# slug
|
|
|
|
# emailHash # used for the avatar
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# }
|
2016-10-19 11:07:21 +02:00
|
|
|
htmlBody
|
|
|
|
postedAt
|
|
|
|
user {
|
|
|
|
_id
|
|
|
|
telescope {
|
|
|
|
slug
|
|
|
|
emailHash # used for the avatar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-19 17:38:21 +02:00
|
|
|
upvoters {
|
|
|
|
_id
|
|
|
|
}
|
|
|
|
downvoters {
|
|
|
|
_id
|
|
|
|
}
|
|
|
|
upvotes # should be asked only for admins?
|
|
|
|
score # should be asked only for admins?
|
|
|
|
viewCount # should be asked only for admins?
|
|
|
|
clickCount # should be asked only for admins?
|
2016-10-19 11:07:21 +02:00
|
|
|
user {
|
|
|
|
_id
|
|
|
|
telescope {
|
|
|
|
displayName
|
|
|
|
slug
|
|
|
|
emailHash
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
`, {
|
|
|
|
options(ownProps) {
|
|
|
|
return {
|
|
|
|
variables: { postId: ownProps.params._id }
|
|
|
|
};
|
|
|
|
},
|
|
|
|
})(PostsSingle);
|
|
|
|
|
2016-06-11 16:36:18 +09:00
|
|
|
PostsSingle.displayName = "PostsSingle";
|
|
|
|
|
2016-10-19 11:07:21 +02:00
|
|
|
module.exports = PostsSingleWithData;
|