diff --git a/src/components/Facts/FactDetail.js b/src/components/Facts/FactDetail.js
deleted file mode 100644
index cfc49ac..0000000
--- a/src/components/Facts/FactDetail.js
+++ /dev/null
@@ -1,209 +0,0 @@
-import React from 'react';
-import createReactClass from 'create-react-class';
-import { Link } from 'react-router';
-import { getHumanDateFromNow, UCWords, open } from '../../utils/Utils.js';
-import { arrayToFragment, changeFactsUrl } from '../../utils/Fact.js';
-import { SERVICES } from '../../services/Dashboard';
-import Fluxxor from 'fluxxor';
-import { getAdjacentArticles } from '../../utils/Fact.js';
-import Chip from 'material-ui/Chip';
-import MapViewPort from '../dialogs/MapViewPort';
-import Sentiment from '../Graphics/Sentiment';
-import Avatar from 'material-ui/Avatar';
-import FontIcon from 'material-ui/FontIcon';
-
-const sourcesBlackList = ["http://www.alchemyapi.com/", "http://www.bing.com/", "http://www.tadaweb.com/"];
-
-// Material UI style overrides
-const styles = {
- chip: {
- margin: 4,
- }
-};
-
-const FluxMixin = Fluxxor.FluxMixin(React),
- StoreWatchMixin = Fluxxor.StoreWatchMixin("FactsStore");
-
-export const FactDetail = createReactClass({
- mixins: [FluxMixin, StoreWatchMixin],
-
- _loadDetail: function (id) {
- SERVICES.FetchMessageDetail(this.props.siteKey, id, ["tadaweb"], [], (error, response, body) => {
- if (error || response.statusCode !== 200 || !body.data || !body.data.event) {
- console.error("Failed to fetch details for id:", id, error);
- return;
- }
- const payload = body.data.event;
- this.setState({ ...payload });
- });
- },
-
- getStateFromFlux: function () {
- return this.getFlux().store("FactsStore").getState();
- },
-
- componentWillReceiveProps: function (nextProps) {
- if (nextProps.factId !== this.props.factId) {
- this._loadDetail(nextProps.factId);
- this.setState({ properties: null });
- }
- },
-
- componentDidMount() {
- this._loadDetail(this.props.factId);
- },
-
- render() {
- let filter = "";
- if (this.state.selectedTags.length > 0) {
- // const tagNames = filterValues(this.state.tags, this.state.selectedRowKeys);
- filter = "tags/" + arrayToFragment(this.state.selectedTags);
- }
- const back = "/site/{0}/facts/{1}".format(this.props.siteKey, filter);
-
- // loading state
- if (!this.state.properties) {
- return (
-
- );
- }
-
- // error
- if (this.state.error) {
- return (
-
-
-
-
-
-
-
Error, fact data not found.
-
-
-
-
- );
- }
-
- const factDetail = this.state.properties || {};
- const dateCreated = getHumanDateFromNow(factDetail.createdtime, "MM/DD/YYYY HH:mm:s A");
- const text = factDetail.fullText || factDetail.sentence;
- const originalSource = factDetail.properties.originalSources && factDetail.properties.originalSources.length > 0 ? factDetail.properties.originalSources : "";
- const title = factDetail.properties.title || "";
- const tags = factDetail.edges || [];
- const link = factDetail.properties.link || "";
- const sentiment = factDetail.sentiment;
-
- const result = getAdjacentArticles(this.props.factId, this.state.facts);
- const prev = result.prev;
- const next = result.next;
- let prevTitle, nextTitle;
- if (prev) prevTitle = prev.properties.properties.title || prev.properties.sentence;
- if (next) nextTitle = next.properties.properties.title || next.properties.sentence;
-
- return (
-
-
-
-
-
-
-
-
- {prev && ← {prevTitle}}
-
-
-
-
-
-
-
- {next && → {nextTitle}}
-
-
-
-
-
-
- {
- link !== "" ? Read Original
- : undefined
- }
-
-
-
Date created
-
{dateCreated}
-
-
Sentiment
-
-
-
-
-
Sources
-
- {originalSource && originalSource.filter(source => sourcesBlackList.indexOf(source) === -1).map(source => {
- let sourceFormatted = source.replace(/http:\/\/www./g, '').replace(/.com\//g, '').replace(/http:\/\//g, '').replace(/https:\/\//g, '');
-
- return open(source)} style={styles.chip}>
- share} />
- {sourceFormatted}
- ;
- })}
-
-
-
Tags
-
- {tags.map(function (tag) {
- const name = UCWords(tag);
- return this.handleSelectTag(tag)}>{name};
- }, this)}
-
-
-
-
-
-
-
-
- );
- },
-
- handleSelectTag(tag) {
- changeFactsUrl(this.props.siteKey, [tag]);
- },
-
-});
diff --git a/src/index.js b/src/index.js
index 4e6ff30..6508523 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,5 +1,4 @@
import {DataStore} from './stores/DataStore';
-import {FactsStore} from './stores/FactsStore';
import {AdminStore} from './stores/AdminStore';
import {methods as DashboardActions} from './actions/Dashboard';
import {methods as AdminActions} from './actions/Admin';
@@ -17,7 +16,6 @@ let userProfile = constants.USER_PROFILE;
let stores = {
DataStore: new DataStore(userProfile),
- FactsStore: new FactsStore(),
AdminStore: new AdminStore(),
};
diff --git a/src/routes/FactDetailPage.js b/src/routes/FactDetailPage.js
deleted file mode 100644
index 37daa50..0000000
--- a/src/routes/FactDetailPage.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import React from 'react';
-import { FactDetail } from '../components/Facts/FactDetail';
-import '../styles/Facts/Facts.css';
-
-export class FactDetailPage extends React.Component {
- render() {
- return (
-
-
-
- );
- }
-}
\ No newline at end of file
diff --git a/src/routes/FactsPage.js b/src/routes/FactsPage.js
index 547b4a7..c4274a3 100644
--- a/src/routes/FactsPage.js
+++ b/src/routes/FactsPage.js
@@ -1,13 +1,24 @@
import React from 'react';
+import createReactClass from 'create-react-class';
+import Fluxxor from 'fluxxor';
import { FactsList } from '../components/Facts/FactsList';
import '../styles/Facts/Facts.css';
-export class FactsPage extends React.Component {
+const FluxMixin = Fluxxor.FluxMixin(React);
+const StoreWatchMixin = Fluxxor.StoreWatchMixin("DataStore");
+
+export const FactsPage = createReactClass({
+ mixins: [FluxMixin, StoreWatchMixin],
+
+ getStateFromFlux() {
+ return this.getFlux().store("DataStore").getState();
+ },
+
render() {
return (
-
+
);
}
-}
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/src/routes/routes.js b/src/routes/routes.js
index f772327..a5a5b06 100644
--- a/src/routes/routes.js
+++ b/src/routes/routes.js
@@ -2,7 +2,6 @@ import { Route } from 'react-router'
import {AppPage} from './AppPage';
import {EntryPage} from './EntryPage';
import {FactsPage} from './FactsPage';
-import {FactDetailPage} from './FactDetailPage';
import {PredictionsPage} from './PredictionsPage';
import {AdminPage} from './AdminPage';
import React from 'react';
@@ -11,8 +10,6 @@ export const routes = (
-
-
diff --git a/src/stores/FactsStore.js b/src/stores/FactsStore.js
deleted file mode 100644
index a88b659..0000000
--- a/src/stores/FactsStore.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import Fluxxor from 'fluxxor';
-import constants from '../actions/constants';
-
-export const FactsStore = Fluxxor.createStore({
- initialize() {
- this.dataStore = {
- facts: [],
- tags: [],
- selectedTags: [],
- error: null,
- loaded: false,
- skip: 0,
- pageSize: 50,
- pageState: {},
- settings: {},
- language:'en'
- };
-
- this.bindActions(
- constants.APP.CHANGE_LANGUAGE, this.handleLanguageChange,
- constants.FACTS.INITIALIZE, this.intializeSettings,
- constants.FACTS.LOAD_FACTS_SUCCESS, this.handleLoadFactsSuccess,
- constants.FACTS.LOAD_FACTS_FAIL, this.handleLoadFactsFail,
- constants.FACTS.LOAD_TAGS, this.handleLoadTags,
- constants.FACTS.SAVE_PAGE_STATE, this.handleSavePageState,
- );
- },
-
- getState() {
- return this.dataStore;
- },
-
- handleLanguageChange(language){
- this.dataStore.language = language;
- this.emit("change");
- },
-
- handleLoadFactsSuccess(payload) {
- this.dataStore.loaded = true;
- this.dataStore.error = null;
- this.dataStore.facts = this._processResults(payload.response);
- this._incrementSkip(this.dataStore.facts);
- this.emit("change");
- },
-
- handleLoadTags(payload) {
- if(payload.terms && payload.terms.edges){
- this.dataStore.tags = payload.terms.edges;
- this.emit("change");
- }
- },
-
- intializeSettings(siteSettings){
- this.dataStore.settings = siteSettings;
- this.emit("change");
- },
-
- _processResults(results) {
- let facts = results.byEdges.features;
- return this.dataStore.facts.concat(facts);
- },
-
- _incrementSkip(results) {
- // Total no. of items in each new section should be equal to page size...
- var count = results.length;
- if (count === this.dataStore.pageSize) {
- return this.dataStore.skip += this.dataStore.pageSize;
- }
- // Otherwise, skip last remaining items
- return this.dataStore.skip += count;
- },
-
- handleLoadFactsFail(payload) {
- this.dataStore.loaded = true;
- this.dataStore.error = payload.error;
- },
-
- handleSavePageState(pageState) {
- this.dataStore.pageState = pageState;
- },
-
-});
\ No newline at end of file