Commit 53be7582 authored by Alexandros Georgantas's avatar Alexandros Georgantas

Initial commit

parents
import React from 'react'
import classes from './Reviewer.local.scss'
import { Avatar, Button } from 'xpub-ui'
const EpubFrontend = () => {
return (
<div className="bootstrap">
<button onClick={props.actions.htmlToEpub}>EPUB!!!!</button>
</div>
)
}
export default EpubFrontend
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { htmlToEpub } from './actions'
import EpubFrontend from './EpubFrontend'
function mapDispatch(dispatch) {
return {
actions: bindActionCreators({ htmlToEpub }, dispatch)
}
}
export default connect(mapDispatch)(EpubFrontend)
import request from 'pubsweet-client/src/helpers/api'
import * as T from './types'
function htmlToEpubRequest() {
return {
type: T.HTML_TO_EPUB_CONV_REQUEST,
isFetching: true
}
}
function htmlToEpubSuccess(bookId) {
return {
type: T.HTML_TO_EPUB_CONV_SUCCESS,
isFetching: false,
bookId: bookId
}
}
function htmlToEpubFailure(message) {
return {
type: T.HTML_TO_EPUB_CONV_FAILURE,
isFetching: false,
error: message
}
}
export function htmlToEpub(bookId) {
return dispatch => {
dispatch(htmlToEpubRequest())
let opts = {
method: 'GET',
headers: {
Accept: 'application/epub+zip' // the response is a URL
// TODO: set the Location header of the response instead
}
}
return request(`/collections/${bookId}/epub`, opts).then(
file => dispatch(htmlToEpubSuccess(bookId)),
err => dispatch(htmlToEpubFailure(err))
)
}
}
module.exports = {
frontend: {
components: [() => require('./EpubFrontendContainer')],
actions: () => require('./actions'),
reducers: () => require('./reducers')
}
}
{
"name": "pubsweet-component-epub-frontend",
"version": "0.0.1",
"description": "A frontend component that triggers a conversion of Editoria's Typescript to epub",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gitlab.coko.foundation/pubsweet/pubsweet-components"
},
"keywords": [
"epub",
"html",
"processing",
"conversion",
"frontend",
"pubsweet"
],
"author": "Collaborative Knowledge Foundation",
"license": "MIT",
"dependencies": {
"escape-html": "^1.0.3",
"prop-types": "^15.5.10",
"react-bootstrap": "^0.31.3",
"react-dropzone": "^3.7.3",
"react-redux": "^5.0.6",
"redux": "^3.7.2"
},
"peerDependencies": {
"pubsweet-client": ">=1.0.0-alpha.1",
"react": ">=15"
}
}
import {
HTML_TO_EPUB_CONV_REQUEST,
HTML_TO_EPUB_CONV_SUCCESS,
HTML_TO_EPUB_CONV_FAILURE
} from './types'
export default function htmlToEpub(
state = {
isFetching: false
},
action
) {
switch (action.type) {
case HTML_TO_EPUB_CONV_REQUEST:
return Object.assign({}, state, {
isFetching: true
})
case HTML_TO_EPUB_CONV_SUCCESS:
return Object.assign({}, state, {
isFetching: false,
converted: action.epub
})
case HTML_TO_EPUB_CONV_FAILURE:
return Object.assign({}, state, {
isFetching: false,
error: action.error
})
default:
return state
}
}
export const HTML_TO_EPUB_CONV_REQUEST = 'HTML_TO_EPUB_CONV_REQUEST'
export const HTML_TO_EPUB_CONV_SUCCESS = 'HTML_TO_EPUB_CONV_SUCCESS'
export const HTML_TO_EPUB_CONV_FAILURE = 'HTML_TO_EPUB_CONV_FAILURE'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment