Skip to content

Commit

Permalink
Merge pull request #70 from insitu-project/develop
Browse files Browse the repository at this point in the history
First Public Release
  • Loading branch information
bmenant authored Sep 30, 2016
2 parents 4885b21 + 90e29cd commit 41a28a6
Show file tree
Hide file tree
Showing 44 changed files with 751 additions and 1,547 deletions.
42 changes: 31 additions & 11 deletions gulp/tasks/build.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
import gulp from 'gulp';
import gutil from 'gulp-util';
import webpack from 'webpack';
import path from 'path';

import devConfig from '../../webpack/dev.config';
import stagingConfig from '../../webpack/staging.config';
import extConfig from '../../webpack/production.config';

const build = (config, callback) => {
let myConfig = Object.create(config);
webpack(myConfig, (err, stats) => {
if (err) {
throw new gutil.PluginError('webpack:build', err);
}
gutil.log('[webpack:build]', stats.toString({ colors: true }));
function compiler(config) {
return webpack(Object.create(config));
}

function staticCompiler(config) {
if (!staticCompiler.instance) {
staticCompiler.instance = compiler(config);
}
return staticCompiler.instance;
}

function build(compiler, callback) {
compiler.run((err, stats) => {
if (err) throw new gutil.PluginError('webpack:build', err);
gutil.log('[webpack:build]', stats.toString({
chunks: false,
colors: true,
}));
callback();
});
};
}

gulp.task('webpack:watch', () => {
const globs = [
path.join(__dirname, '../../src/') + '**/*',
path.join(__dirname, '../../test/') + '**/*',
];
return gulp.watch(globs, ['webpack:build:dev']);
});
gulp.task('webpack:build:dev', (callback) => {
build(devConfig, callback);
// Instance webpack compiler once over multiple times (watch)
build(staticCompiler(devConfig), callback);
});
gulp.task('webpack:build:staging', (callback) => {
build(stagingConfig, callback);
build(compiler(stagingConfig), callback);
});
gulp.task('webpack:build:production', (callback) => {
build(extConfig, callback);
build(compiler(extConfig), callback);
});
13 changes: 0 additions & 13 deletions gulp/tasks/webpack.js

This file was deleted.

3 changes: 2 additions & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ requireDir('./gulp/tasks');

gulp.task('default',['build:dev']);
gulp.task('build:dev',
['webpack:build:dev', 'views:build:dev', 'copy:build:dev', 'copy:watch']);
['webpack:build:dev', 'views:build:dev', 'copy:build:dev',
'copy:watch', 'webpack:watch']);
gulp.task('build:staging',
['webpack:build:staging', 'views:build:staging', 'copy:build:staging']);
gulp.task('build:production',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build:staging": "gulp build:staging",
"build:dev": "gulp build:dev",
"clean": "rm -rf build",
"test": "LMEM_BACKEND_ORIGIN='' NODE_ENV=test mocha --compilers js:babel-core/register test/app --recursive",
"lint": "git ls-files -om --exclude-standard | grep \\.js$ | xargs eslint --fix",
"test": "LMEM_BACKEND_ORIGIN='' LMEM_SCRIPTS_ORIGIN='.' NODE_ENV=test mocha --compilers js:babel-core/register test/app --recursive",
"lint": "git diff-index --name-only --cached HEAD | grep \\.js$ | xargs eslint --fix",
"deploy:production": "gulp deploy:production",
"deploy:staging": "gulp deploy:staging"
},
Expand Down
23 changes: 23 additions & 0 deletions src/app/actions/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { INSTALLED } from '../constants/ActionTypes';

// Promise constructed when the module is first imported (very early)
// in order to not miss the "install" event.
const onInstalledPromise = new Promise(resolve => {
chrome.runtime.onInstalled.addListener(details => {
if (details.reason !== 'install') return;

resolve(Object.assign({}, details, {
datetime: new Date(),
version: chrome.runtime.getManifest().version,
}));
});
});

export default function () {
return dispatch => {
onInstalledPromise.then(onInstalledDetails => dispatch({
type: INSTALLED,
onInstalledDetails
}));
};
}
104 changes: 56 additions & 48 deletions src/app/components/AlternativeHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,25 @@ class AlternativeHeader extends Component {
<div className="menu-content">
<ul className="menu-list">
<li>
<button className="not-button with-image" onClick={ e => onDeactivate({
where: DEACTIVATE_EVERYWHERE,
duration: SESSION_DEACTIVATE_DELAY
}) }
>
<button
className="not-button with-image"
onClick={ e => onDeactivate({
where: DEACTIVATE_EVERYWHERE,
duration: SESSION_DEACTIVATE_DELAY
})}>
<img
role="presentation"
className="lmem-controls-picto"
src={ imagesUrl + 'power-timer.svg' } />
<span>Désactiver partout pour 30mins</span>
</button>
</li><li>
<button className="not-button with-image" onClick={ e => onDeactivate({
where: window.location && location.hostname,
duration: DEACTIVATE_WEBSITE_ALWAYS
}) }
>
<button
className="not-button with-image"
onClick={ e => onDeactivate({
where: window.location && location.hostname,
duration: DEACTIVATE_WEBSITE_ALWAYS
})}>
<img
role="presentation"
className="lmem-controls-picto"
Expand All @@ -84,26 +86,32 @@ class AlternativeHeader extends Component {
const headerButtons = preferenceScreenPanel ?
(<li>
<div className="button-directive">
<button className="button button-compact with-tooltip"
<button
className="button button-compact with-tooltip"
onClick={closePrefScreen}>
<img role="presentation" src={ imagesUrl + 'close.svg' }
<img
role="presentation"
src={ imagesUrl + 'close.svg' }
className="lmem-controls-picto" />
<span className={tooltipButtonClassName}><span>
Fermer l'écran des préférences
Fermer lécran des préférences
</span></span>
</button>
</div>
</li>) :
[(<li>
<div className="button-directive">
<button className="button button-compact with-tooltip"
<button
className="button button-compact with-tooltip"
onClick={e => {
if(reduced){
onExtend();
}
openPrefScreen(PREFERENCE_SCREEN_PANEL_ABOUT);
}}>
<img role="presentation" src={ imagesUrl + 'settings.svg' }
<img
role="presentation"
src={ imagesUrl + 'settings.svg' }
className="lmem-controls-picto" />
<span className={tooltipButtonClassName}><span>
Préférences
Expand All @@ -113,12 +121,13 @@ class AlternativeHeader extends Component {
</li>),
(<li className="with-menu">
<div className="button-directive">
<button className="button button-compact with-tooltip"
onClick={deactivateButtonOnClick}
>
<img role="presentation" src={ imagesUrl + 'power.svg' }
className="lmem-controls-picto"
/>
<button
className="button button-compact with-tooltip"
onClick={deactivateButtonOnClick}>
<img
role="presentation"
src={ imagesUrl + 'power.svg' }
className="lmem-controls-picto" />
<span className={tooltipButtonClassName}><span>
Désactiver
</span></span>
Expand All @@ -128,21 +137,35 @@ class AlternativeHeader extends Component {
<div className="menu-directive menu-deactivate" ref="deactivateMenu">
{ deactivateMenu }
</div>
</li>),
(<li>
<button
className="reduce button-compact with-image with-tooltip"
onClick={this.onClick.bind(this) }>
<img
role="presentation"
src={ imagesUrl + 'arrow.svg' }
className={ buttonButtonClassName }
/>
<span className="button-label">{reduceButtonText}</span>
<span className={tooltipButtonClassName}>
{reduceButtonText}
</span>
</button>
</li>)];



const extendReduceButton = preferenceScreenPanel ? undefined :
(<div className="button-wrapper">
<div className="button-directive">
<button className="button button-compact with-image with-tooltip"
onClick={this.onClick.bind(this) }
>
<button
className="button button-compact with-image with-tooltip"
onClick={this.onClick.bind(this) }>
<img
role="presentation"
src={ imagesUrl + 'arrow.svg' }
className={ buttonButtonClassName }
/>
className={ buttonButtonClassName } />
<span className="button-label">{reduceButtonText}</span>
<span className={tooltipButtonClassName}><span>
{reduceButtonText}
Expand All @@ -158,9 +181,9 @@ class AlternativeHeader extends Component {

return (
<header>
<button className="with-tooltip logo"
onClick={this.onClick.bind(this) }
>
<button
className="with-tooltip logo"
onClick={this.onClick.bind(this) }>
<img width="45" src={ imagesUrl + 'logo-lmem.svg' } alt="" />
<span className="tooltip tooltip-right">
{ reduceButtonText + ' le panneau comparatif' }
Expand All @@ -170,7 +193,7 @@ class AlternativeHeader extends Component {
<div className="separation-bar" />

<h1 className="lmem-topbar-title">
<strong>{headerContent}</strong>
{headerContent}
</h1>


Expand All @@ -179,21 +202,6 @@ class AlternativeHeader extends Component {
</ul>


<button className="reduce button-compact with-image with-tooltip"
onClick={this.onClick.bind(this) }
>
<img
role="presentation"
src={ imagesUrl + 'arrow.svg' }
className={ buttonButtonClassName }
/>
<span className="button-label">{reduceButtonText}</span>
<span className={tooltipButtonClassName}>
{reduceButtonText}
</span>
</button>


</header>
);
}
Expand All @@ -208,21 +216,21 @@ class AlternativeHeader extends Component {

componentWillUnmount() {
this.refs.deactivateMenu.ownerDocument
.removeEventListener('click', this._closeMenuDocumentClickHandler);
.removeEventListener('click', this.closeMenuDocumentClickHandler);
}

watchForMenuExit() {
const menuElement = this.refs.deactivateMenu;

this._closeMenuDocumentClickHandler = event => {
this.closeMenuDocumentClickHandler = event => {
if (!this.state.deactivateMenuOpen) return;

if (!event.target.matches('.menu-deactivate, .menu-deactivate *')) {
this.setState({ deactivateMenuOpen: false });
}
};

menuElement.ownerDocument.addEventListener('click', this._closeMenuDocumentClickHandler);
menuElement.ownerDocument.addEventListener('click', this.closeMenuDocumentClickHandler);
}


Expand Down
6 changes: 4 additions & 2 deletions src/app/components/AlternativeMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ const AlternativeMain = ({ imagesUrl, contributorUrl, recommendation }) => {
<p>{recommendation.description}</p>
</div>
<div className="reco-summary-link-referral">
<img alt="Logo le même en mieux" src={imagesUrl + 'logo-lmem-new.svg'} />
<img
alt="Logo le même en mieux"
src={'https://www.google.com/s2/favicons?domain=' + encodeURIComponent(recommendation.alternatives[0].url_to_redirect)} />
<span>{
recommendation.alternatives[0].url_to_redirect.replace(/^https?:\/\/(www.)?/, '')
}</span>
Expand All @@ -58,7 +60,7 @@ const AlternativeMain = ({ imagesUrl, contributorUrl, recommendation }) => {
</div>
</div>
</a>
</main>)
</main>);
};

AlternativeMain.propTypes = {
Expand Down
8 changes: 6 additions & 2 deletions src/app/components/Alternatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ class Alternatives extends Component {
const { props, state } = this;
const {
recommendation, imagesUrl, reduced, contributorUrl, preferenceScreenPanel, deactivatedWebsites,
onExtend, onReduce, onDeactivate, togglePrefPanel, onReactivateWebsite, closePrefScreen, openPrefScreen
onExtend, onReduce, onDeactivate, togglePrefPanel, onReactivateWebsite, closePrefScreen, openPrefScreen,
onInstalledDetails
} = props;

const body = (preferenceScreenPanel ?
<PreferenceScreen
preferenceScreenPanel={preferenceScreenPanel}
deactivatedWebsites={deactivatedWebsites}
onReactivateWebsite={onReactivateWebsite}
openPrefScreen={openPrefScreen}
imagesUrl={imagesUrl}
onInstalledDetails={onInstalledDetails}
/> :
<AlternativeMain imagesUrl={imagesUrl} recommendation={recommendation} contributorUrl={contributorUrl} />);

Expand Down Expand Up @@ -55,6 +58,7 @@ Alternatives.propTypes = {
reduced: PropTypes.bool.isRequired,
onExtend: PropTypes.func.isRequired,
onReduce: PropTypes.func.isRequired,
onInstalledDetails: PropTypes.object.isRequired,
};

export default Alternatives;
Loading

0 comments on commit 41a28a6

Please sign in to comment.