Skip to content

Commit

Permalink
Merge branch 'master' of github.com:makinacorpus/accessimap-lecteur-der
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra Janin committed Apr 6, 2017
2 parents d9d354b + a15a97f commit 9f6baf6
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 98 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ A chaque nouveau commit, travis vérifiera que le build pour electron se constru

Pour ajouter ces builds aux releases, il faut créer une nouvelle release en respectant le [Semantic Versioning](http://semver.org/).

Au préalable, il nous paraît utile et important de mettre à jour les versions
des `package.json` des modules `der-reader` (et les autres s'ils ont changé),
des répertoires `electron` et `cordova/www`.
Les builds produits par `electron` disposent de la version npm.

Travis déclenchera à nouveau un build electron, et attachera les résultats (zip pour windows, AppImage pour Linux) à la dernière release créée.


Expand Down
6 changes: 3 additions & 3 deletions cordova/config.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Lecteur Accessimap</name>
<widget id="com.makinacorpus.mapsense" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MapSense</name>
<description>
Accessimap - Lecteur de documents en relief.
MapSense - Lecteur de documents en relief.
</description>
<author email="[email protected]" href="http://makina-corpus.com">
Makina Corpus
Expand Down
2 changes: 2 additions & 0 deletions cordova/typings/cordova-typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

/// <reference path="../.vscode/typings/cordova/plugins/Splashscreen.d.ts"/>
1 change: 1 addition & 0 deletions modules/der-reader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
},
"dependencies": {
"react-redux": "^5.0.3",
"react-router-redux": "^4.0.8",
"redux": "^3.6.0"
},
"eslintConfig": {
Expand Down
4 changes: 2 additions & 2 deletions modules/der-reader/src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Button = React.createClass({

getInitialState: function() {
return {
label: ''
label: this.props.open ? 'Fermer' : this.props.labelClosed
}
},

Expand Down Expand Up @@ -41,7 +41,7 @@ const Button = React.createClass({
},

handleDoubleClick: function() {
this.props.toggleMenu(this.props.id, this.props.labelOnClose, this.props.labelOnOpen);
this.props.toggleMenu(this.props.id);
},

render: function() {
Expand Down
25 changes: 13 additions & 12 deletions modules/der-reader/src/components/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ const Navigation = React.createClass({
router: React.PropTypes.object.isRequired
},


handleAction: function() {
if (this.props.index === this.props.items.length-1) {
this.context.router.goBack();
}
this.props.action();
},

read: function() {
this.props.read(this.props.items[this.props.index].name);
},

componentWillReceiveProps: function(nextProps) {
if (this.props.read && this.props.index !== nextProps.index) {
this.props.read(nextProps.items[nextProps.index].name);
Expand All @@ -30,8 +42,8 @@ const Navigation = React.createClass({
},

componentDidMount: function() {
this.read();
const modal = document.getElementById('mainMenu');

this.hammer = new Hammer(modal, {});
this.hammer.get('swipe').set({ direction: Hammer.DIRECTION_ALL });
this.hammer.on('swipeup', debounce(() => {
Expand Down Expand Up @@ -76,17 +88,6 @@ const Navigation = React.createClass({
});
},

handleAction: function() {
if (this.props.index === this.props.items.length-1) {
this.context.router.goBack();
}
this.props.action();
},

read: function() {
this.props.read(this.props.items[this.props.index].name);
},

render: function() {
const {items, index} = this.props;
const content = this.props.content || '';
Expand Down
21 changes: 17 additions & 4 deletions modules/der-reader/src/der-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { createStore, applyMiddleware, compose } from 'redux';
import { Provider } from 'react-redux';
import { Router, hashHistory } from 'react-router';
import appReducer from './store/reducers';
import { screenCalibrate, localstorage } from './store/middlewares';
import { screenCalibrate, screenReader } from './middlewares/screen';
import localstorage from './middlewares/localstorage';
import { syncHistoryWithStore, routerReducer } from 'react-router-redux';


const composeEnhancers =
typeof window === 'object' &&
Expand All @@ -27,10 +30,20 @@ const composeEnhancers =
}) : compose;

const store = createStore(
combineReducers({appReducer}),
composeEnhancers(applyMiddleware(localstorage, screenCalibrate))
combineReducers({
appReducer,
routing: routerReducer
}),
composeEnhancers(applyMiddleware(
localstorage,
screenCalibrate,
screenReader
))
);

// Create an enhanced history that syncs navigation events with the store
const history = syncHistoryWithStore(hashHistory, store)

let config = null;

var DerReader = {
Expand Down Expand Up @@ -90,7 +103,7 @@ var DerReader = {

ReactDOM.render(
<Provider store={store}>
<Router routes={routes} history={hashHistory} />
<Router routes={routes} history={history} />
</Provider>,
document.getElementById(config.container)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
import _ from 'lodash';
import {
SET_OPTION,
INIT_CONFIG
} from './actions';
import {
defaultState
} from './reducers';

/**
* Middleware for resize application container to fit with DER.
*/
export const screenCalibrate = () => next => action => {
switch (action.type) {
case SET_OPTION:
if (action.name === 'format') {
document.getElementById('der-reader').className = action.value;
}

if (action.name === 'dpi') {
document.body.style.fontSize = action.value + 'px';
}
break;
case INIT_CONFIG:
var { format, dpi } = action.value;
document.getElementById('der-reader').className = format ? format : action.default.format;
document.body.style.fontSize = dpi ? dpi + 'px' : defaultState.config.dpi + 'px';
break;
default:
break;
}
next(action);
};

/**
* Middleware to manage localStorage on actions
Expand All @@ -42,7 +10,7 @@ export const screenCalibrate = () => next => action => {
* @param {array} localStorage.names - Items names for storage, only for getItem type
* @param {(string|Number|Object)} localStorage.value - Item value (if localStorage.type is 'setItem')
*/
export const localstorage = () => next => action => {
const localstorage = () => next => action => {
const getItem = (name) => {
let item;
try {
Expand Down Expand Up @@ -119,4 +87,6 @@ export const localstorage = () => next => action => {
}
}
next(action);
};
};

export default localstorage;
31 changes: 31 additions & 0 deletions modules/der-reader/src/middlewares/reader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// import {
// SET_OPTION,
// INIT_CONFIG
// } from '../store/actions';
// import {
// defaultState
// } from '../store/reducers';

/**
* Middleware for resize application container to fit with DER.
*/
const reader = state => next => action => {
console.log(action)
if (action.type === '@@router/LOCATION_CHANGE') {
switch (action.payload.pathname) {
case '/menu':
console.log('MENUUUU', state.appReducer)
if (state.appReducer && state.appReducer.config.tts) {
console.log('oo')
state.appReducer.config.tts.speak('une voie qui annonce le menu')
}
break;
default:
break;
}

}
next(action);
};

export default reader;
58 changes: 58 additions & 0 deletions modules/der-reader/src/middlewares/screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { LOCATION_CHANGE } from 'react-router-redux';
import {
SET_OPTION,
INIT_CONFIG
} from '../store/actions';
import {
defaultState
} from '../store/reducers';

let Reader = null;

/**
* Middleware for resize application container to fit with DER.
*/
export const screenCalibrate = () => next => action => {
switch (action.type) {
case SET_OPTION:
if (action.name === 'format') {
document.getElementById('der-reader').className = action.value;
}

if (action.name === 'dpi') {
document.body.style.fontSize = action.value + 'px';
}

if (action.name === 'tts') {
Reader = action.value;
}
break;
case INIT_CONFIG:
var { format, dpi } = action.value;
document.getElementById('der-reader').className = format ? format : action.default.format;
document.body.style.fontSize = dpi ? dpi + 'px' : defaultState.config.dpi + 'px';
break;
default:
break;
}
next(action);
};

/**
* Middleware for resize application container to fit with DER.
*/
export const screenReader = () => next => action => {
if (action.type === LOCATION_CHANGE && Reader) {
switch (action.payload.pathname) {
case 'menu':
Reader.speak('Ouverture du menu');
break;
case 'filters':
Reader.speak('Ouverture des filtres');
break;
default:
break;
}
}
next(action);
};
3 changes: 2 additions & 1 deletion modules/der-reader/src/routes/App.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import App from './App';

const mapStateToProps = (state, ownProps) => {
return {
...state.appReducer
...state.appReducer,
routing: state.routing
}
};

Expand Down
Loading

0 comments on commit 9f6baf6

Please sign in to comment.