diff --git a/.eslintignore b/.eslintignore index 8254ff89..0dab9088 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ node_modules/ -public/bundle +exports/ index.js -test +test/ diff --git a/client/actions/channel.js b/client/actions/channel.js deleted file mode 100644 index 7c17ed94..00000000 --- a/client/actions/channel.js +++ /dev/null @@ -1,14 +0,0 @@ -import * as actions from 'constants/channel_action_types'; - -// export action creators - -export function updateLoggedInChannel (name, shortId, longId) { - return { - type: actions.CHANNEL_UPDATE, - data: { - name, - shortId, - longId, - }, - }; -}; diff --git a/client/actions/publish.js b/client/actions/publish.js deleted file mode 100644 index 6666e9dd..00000000 --- a/client/actions/publish.js +++ /dev/null @@ -1,87 +0,0 @@ -import * as actions from 'constants/publish_action_types'; - -// export action creators -export function selectFile (file) { - return { - type: actions.FILE_SELECTED, - data: file, - }; -}; - -export function clearFile () { - return { - type: actions.FILE_CLEAR, - }; -}; - -export function updateMetadata (name, value) { - return { - type: actions.METADATA_UPDATE, - data: { - name, - value, - }, - }; -}; - -export function updateClaim (value) { - return { - type: actions.CLAIM_UPDATE, - data: value, - }; -}; - -export function setPublishInChannel (channel) { - return { - type: actions.SET_PUBLISH_IN_CHANNEL, - channel, - }; -}; - -export function updatePublishStatus (status, message) { - return { - type: actions.PUBLISH_STATUS_UPDATE, - data: { - status, - message, - }, - }; -}; - -export function updateError (name, value) { - return { - type: actions.ERROR_UPDATE, - data: { - name, - value, - }, - }; -}; - -export function updateSelectedChannel (channelName) { - return { - type: actions.SELECTED_CHANNEL_UPDATE, - data: channelName, - }; -}; - -export function toggleMetadataInputs (showMetadataInputs) { - return { - type: actions.TOGGLE_METADATA_INPUTS, - data: showMetadataInputs, - }; -}; - -export function onNewThumbnail (file) { - return { - type: actions.THUMBNAIL_NEW, - data: file, - }; -}; - -export function startPublish (history) { - return { - type: actions.PUBLISH_START, - data: { history }, - }; -} diff --git a/client/actions/show.js b/client/actions/show.js deleted file mode 100644 index 03a31c3e..00000000 --- a/client/actions/show.js +++ /dev/null @@ -1,119 +0,0 @@ -import * as actions from 'constants/show_action_types'; - -import { CHANNEL, ASSET_LITE, ASSET_DETAILS } from 'constants/show_request_types'; - -// basic request parsing -export function onHandleShowPageUri (params) { - return { - type: actions.HANDLE_SHOW_URI, - data: params, - }; -}; - -export function onRequestError (error) { - return { - type: actions.REQUEST_ERROR, - data: error, - }; -}; - -export function onNewChannelRequest (channelName, channelId) { - const requestType = CHANNEL; - const requestId = `cr#${channelName}#${channelId}`; - return { - type: actions.CHANNEL_REQUEST_NEW, - data: { requestType, requestId, channelName, channelId }, - }; -}; - -export function onNewAssetRequest (name, id, channelName, channelId, extension) { - const requestType = extension ? ASSET_LITE : ASSET_DETAILS; - const requestId = `ar#${name}#${id}#${channelName}#${channelId}`; - return { - type: actions.ASSET_REQUEST_NEW, - data: { - requestType, - requestId, - name, - modifier: { - id, - channel: { - name: channelName, - id : channelId, - }, - }, - }, - }; -}; - -export function onRequestUpdate (requestType, requestId) { - return { - type: actions.REQUEST_UPDATE, - data: { - requestType, - requestId, - }, - }; -}; - -export function addRequestToRequestList (id, error, key) { - return { - type: actions.REQUEST_LIST_ADD, - data: { id, error, key }, - }; -}; - -// asset actions - -export function addAssetToAssetList (id, error, name, claimId, shortId, claimData) { - return { - type: actions.ASSET_ADD, - data: { id, error, name, claimId, shortId, claimData }, - }; -} - -// channel actions - -export function addNewChannelToChannelList (id, name, shortId, longId, claimsData) { - return { - type: actions.CHANNEL_ADD, - data: { id, name, shortId, longId, claimsData }, - }; -}; - -export function onUpdateChannelClaims (channelKey, name, longId, page) { - return { - type: actions.CHANNEL_CLAIMS_UPDATE_ASYNC, - data: {channelKey, name, longId, page}, - }; -}; - -export function updateChannelClaims (channelListId, claimsData) { - return { - type: actions.CHANNEL_CLAIMS_UPDATE_SUCCESS, - data: {channelListId, claimsData}, - }; -}; - -// display a file - -export function fileRequested (name, claimId) { - return { - type: actions.FILE_REQUESTED, - data: { name, claimId }, - }; -}; - -export function updateFileAvailability (status) { - return { - type: actions.FILE_AVAILABILITY_UPDATE, - data: status, - }; -}; - -export function updateDisplayAssetError (error) { - return { - type: actions.DISPLAY_ASSET_ERROR, - data: error, - }; -}; diff --git a/client/api/assetApi.js b/client/api/assetApi.js deleted file mode 100644 index b6389612..00000000 --- a/client/api/assetApi.js +++ /dev/null @@ -1,34 +0,0 @@ -import Request from 'utils/request'; - -export function getLongClaimId (host, name, modifier) { - let body = {}; - // create request params - if (modifier) { - if (modifier.id) { - body['claimId'] = modifier.id; - } else { - body['channelName'] = modifier.channel.name; - body['channelClaimId'] = modifier.channel.id; - } - } - body['claimName'] = name; - const params = { - method : 'POST', - headers: { 'Content-Type': 'application/json' }, - body : JSON.stringify(body), - }; - // create url - const url = `${host}/api/claim/long-id`; - // return the request promise - return Request(url, params); -}; - -export function getShortId (host, name, claimId) { - const url = `${host}/api/claim/short-id/${claimId}/${name}`; - return Request(url); -}; - -export function getClaimData (host, name, claimId) { - const url = `${host}/api/claim/data/${name}/${claimId}`; - return Request(url); -}; diff --git a/client/api/channelApi.js b/client/api/channelApi.js deleted file mode 100644 index cf5738fc..00000000 --- a/client/api/channelApi.js +++ /dev/null @@ -1,13 +0,0 @@ -import Request from 'utils/request'; - -export function getChannelData (host, id, name) { - if (!id) id = 'none'; - const url = `${host}/api/channel/data/${name}/${id}`; - return Request(url); -}; - -export function getChannelClaims (host, longId, name, page) { - if (!page) page = 1; - const url = `${host}/api/channel/claims/${name}/${longId}/${page}`; - return Request(url); -}; diff --git a/client/api/fileApi.js b/client/api/fileApi.js deleted file mode 100644 index 62c71b78..00000000 --- a/client/api/fileApi.js +++ /dev/null @@ -1,11 +0,0 @@ -import Request from 'utils/request'; - -export function checkFileAvailability (claimId, host, name) { - const url = `${host}/api/file/availability/${name}/${claimId}`; - return Request(url); -} - -export function triggerClaimGet (claimId, host, name) { - const url = `${host}/api/claim/get/${name}/${claimId}`; - return Request(url); -} diff --git a/client/app.js b/client/app.js deleted file mode 100644 index 6a74096a..00000000 --- a/client/app.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { Route, Switch } from 'react-router-dom'; -import { dynamicImport } from 'utils/dynamicImport'; -import AboutPage from 'pages/AboutPage'; -import LoginPage from 'pages/LoginPage'; -import ShowPage from 'pages/ShowPage'; -import FourOhFourPage from 'containers/FourOhFourPage'; -const HomePage = dynamicImport('pages/HomePage'); // or use the provided local homepage - -const App = () => { - return ( - - - - - - - - - ); -}; - -export default App; diff --git a/client/channels/publish.js b/client/channels/publish.js deleted file mode 100644 index bdbfbf19..00000000 --- a/client/channels/publish.js +++ /dev/null @@ -1,48 +0,0 @@ -import {buffers, END, eventChannel} from 'redux-saga'; - -export const makePublishRequestChannel = (fd) => { - return eventChannel(emitter => { - const uri = '/api/claim/publish'; - const xhr = new XMLHttpRequest(); - // add event listeners - const onLoadStart = () => { - emitter({loadStart: true}); - }; - const onProgress = (event) => { - if (event.lengthComputable) { - const percentage = Math.round((event.loaded * 100) / event.total); - emitter({progress: percentage}); - } - }; - const onLoad = () => { - emitter({load: true}); - }; - xhr.upload.addEventListener('loadstart', onLoadStart); - xhr.upload.addEventListener('progress', onProgress); - xhr.upload.addEventListener('load', onLoad); - // set state change handler - xhr.onreadystatechange = () => { - if (xhr.readyState === 4) { - const response = JSON.parse(xhr.response); - if ((xhr.status === 200) && response.success) { - emitter({success: response}); - emitter(END); - } else { - emitter({error: new Error(response.message)}); - emitter(END); - } - } - }; - // open and send - xhr.open('POST', uri, true); - xhr.send(fd); - // clean up - return () => { - xhr.upload.removeEventListener('loadstart', onLoadStart); - xhr.upload.removeEventListener('progress', onProgress); - xhr.upload.removeEventListener('load', onLoad); - xhr.onreadystatechange = null; - xhr.abort(); - }; - }, buffers.sliding(2)); -}; diff --git a/client/client.js b/client/client.js deleted file mode 100644 index bcd817fc..00000000 --- a/client/client.js +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import { hydrate } from 'react-dom'; -import { Provider } from 'react-redux'; -import { createStore, applyMiddleware, compose } from 'redux'; -import { BrowserRouter } from 'react-router-dom'; -import Reducer from 'reducers'; -import createSagaMiddleware from 'redux-saga'; -import rootSaga from 'sagas'; - -import GAListener from 'components/GAListener'; -import App from './app'; - -// get the state from a global variable injected into the server-generated HTML -const preloadedState = window.__PRELOADED_STATE__ || null; - -// Allow the passed state to be garbage-collected -delete window.__PRELOADED_STATE__; - -// create and apply middleware -const sagaMiddleware = createSagaMiddleware(); -const middleware = applyMiddleware(sagaMiddleware); -const reduxMiddleware = window.__REDUX_DEVTOOLS_EXTENSION__ ? compose(middleware, window.__REDUX_DEVTOOLS_EXTENSION__()) : middleware; - -// create teh store -let store; -if (preloadedState) { - store = createStore(Reducer, preloadedState, reduxMiddleware); -} else { - store = createStore(Reducer, reduxMiddleware); -} - -// run the saga middlweare -sagaMiddleware.run(rootSaga); - -// render the app -hydrate( - - - - - - - , - document.getElementById('react-app') -); diff --git a/client/components/ActiveStatusBar/index.jsx b/client/components/ActiveStatusBar/index.jsx deleted file mode 100644 index 69a98440..00000000 --- a/client/components/ActiveStatusBar/index.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -const ActiveStatusBar = () => { - return | ; -}; - -export default ActiveStatusBar; diff --git a/client/components/AssetPreview/index.js b/client/components/AssetPreview/index.js deleted file mode 100644 index e431b9bd..00000000 --- a/client/components/AssetPreview/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { connect } from 'react-redux'; -import View from './view'; - -const mapStateToProps = ({site: {defaults: { defaultThumbnail }}}) => { - return { - defaultThumbnail, - }; -}; - -export default connect(mapStateToProps, null)(View); diff --git a/client/components/AssetPreview/view.jsx b/client/components/AssetPreview/view.jsx deleted file mode 100644 index d98a1f4c..00000000 --- a/client/components/AssetPreview/view.jsx +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; -import { Link } from 'react-router-dom'; - -const AssetPreview = ({ defaultThumbnail, claimData: { name, claimId, fileExt, contentType, thumbnail } }) => { - const directSourceLink = `${claimId}/${name}.${fileExt}`; - const showUrlLink = `/${claimId}/${name}`; - return ( -
- - {(() => { - switch (contentType) { - case 'image/jpeg': - case 'image/jpg': - case 'image/png': - case 'image/gif': - return ( - {name} - ); - case 'video/mp4': - return ( - {name} - ); - default: - return ( -

unsupported file type

- ); - } - })()} - -
- ); -}; - -export default AssetPreview; diff --git a/client/components/ExpandingTextArea/index.jsx b/client/components/ExpandingTextArea/index.jsx deleted file mode 100644 index db83c5d8..00000000 --- a/client/components/ExpandingTextArea/index.jsx +++ /dev/null @@ -1,37 +0,0 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; - -class ExpandingTextarea extends Component { - constructor (props) { - super(props); - this._handleChange = this._handleChange.bind(this); - } - componentDidMount () { - this.adjustTextarea({}); - } - _handleChange (event) { - const { onChange } = this.props; - if (onChange) onChange(event); - this.adjustTextarea(event); - } - adjustTextarea ({ target = this.el }) { - target.style.height = 0; - target.style.height = `${target.scrollHeight}px`; - } - render () { - const { ...rest } = this.props; - return ( -