Test mode as config, no more test.html
This commit is contained in:
13
build.sh
13
build.sh
@ -5,17 +5,12 @@ echo -e Copying assets $SERVER
|
||||
rsync -avrs src/assets/ mopidy_iris/static/assets/ 2>&1 >/dev/null
|
||||
|
||||
# create HTML files
|
||||
echo -e Copying index.html and test.html
|
||||
echo -e Copying index.html
|
||||
cp src/index.html mopidy_iris/static/index.html
|
||||
cp src/index.html mopidy_iris/static/test.html
|
||||
|
||||
# process production html
|
||||
CACHEBUSTER=$(date | md5sum | cut -f1 -d' ')
|
||||
echo -e Cachebusting js/css URLs $CACHEBUSTER
|
||||
sed -i 's/app.js/app.min.js?cachebuster='$CACHEBUSTER'/g' mopidy_iris/static/index.html
|
||||
sed -i 's/app.css/app.min.css?cachebuster='$CACHEBUSTER'/g' mopidy_iris/static/index.html
|
||||
sed -i 's/app.js/app.js?cachebuster='$CACHEBUSTER'/g' mopidy_iris/static/test.html
|
||||
sed -i 's/app.css/app.css?cachebuster='$CACHEBUSTER'/g' mopidy_iris/static/test.html
|
||||
sed -i 's/<\/head>/\t<script type="text\/javascript">window._testMode = true;<\/script>\n\n<\/head>/g' mopidy_iris/static/test.html
|
||||
BUILD_VERSION=$(date | md5sum | cut -f1 -d' ')
|
||||
echo -e "Injecting build version to js/css URLs ($BUILD_VERSION)"
|
||||
sed -i 's/BUILD_VERSION_HERE/'$BUILD_VERSION'/g' mopidy_iris/static/index.html
|
||||
|
||||
echo -e "\x1b[32;01m"Done!"\x1b[39;49;00m"
|
||||
@ -15,7 +15,6 @@
|
||||
<link rel="shortcut-icon" href="/iris/assets/favicon.ico" />
|
||||
|
||||
<link href="//fonts.googleapis.com/css?family=Overpass:400,400i,600,700,800" rel="stylesheet">
|
||||
<link href="/iris/app.css" rel="stylesheet" />
|
||||
|
||||
<link rel="manifest" href="/iris/assets/manifest.json">
|
||||
|
||||
@ -28,6 +27,29 @@
|
||||
|
||||
</body>
|
||||
|
||||
<script type="text/javascript" src="/iris/app.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var build_version = "BUILD_VERSION_HERE";
|
||||
|
||||
var js = document.createElement("script");
|
||||
js.type = "application/javascript";
|
||||
|
||||
var css = document.createElement("link");
|
||||
css.rel = "stylesheet";
|
||||
|
||||
// Identify whether we're in test mode, and need to fetch non-minified assets
|
||||
var ui = JSON.parse( localStorage.getItem('ui') );
|
||||
if (typeof(ui) === 'undefined' || typeof(ui.test_mode) === 'undefined' || !ui.test_mode){
|
||||
js.src = '/iris/app.min.js?v='+build_version;
|
||||
css.href = '/iris/app.min.css?v='+build_version;
|
||||
} else {
|
||||
js.src = '/iris/app.js?v='+build_version;
|
||||
css.href = '/iris/app.css?v='+build_version;
|
||||
}
|
||||
|
||||
document.body.appendChild(js);
|
||||
document.body.appendChild(css);
|
||||
</script>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
@ -50,6 +50,10 @@ class App extends React.Component{
|
||||
this.props.coreActions.startServices()
|
||||
this.props.coreActions.getBroadcasts()
|
||||
|
||||
if (this.props.test_mode){
|
||||
this.props.uiActions.createNotification('Welcome to test mode! This provides you with additional debug info by using the non-minified code base. See <a href="https://github.com/jaedb/Iris/wiki/Advanced#test-mode" target="_blank">Wiki</a> for more information.','info','TEST_MODE','Test mode enabled',true)
|
||||
}
|
||||
|
||||
// when we navigate to a new route
|
||||
hashHistory.listen( location => {
|
||||
|
||||
@ -269,7 +273,8 @@ const mapStateToProps = (state, ownProps) => {
|
||||
dragger: state.ui.dragger,
|
||||
modal: state.ui.modal,
|
||||
context_menu: state.ui.context_menu,
|
||||
debug_info: state.ui.debug_info
|
||||
debug_info: state.ui.debug_info,
|
||||
test_mode: (state.ui.test_mode ? state.ui.test_mode : false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ class DebugInfo extends React.Component{
|
||||
Slim mode: {this.props.ui.slim_mode ? 'on' : 'off'}
|
||||
</div>
|
||||
<div className="item">
|
||||
_testMode: {window._testMode ? 'on' : 'off'}
|
||||
Test mode: {this.props.ui.test_mode ? 'on' : 'off'}
|
||||
</div>
|
||||
<div className="item">
|
||||
Touch: {helpers.isTouchDevice() ? 'on' : 'off'}
|
||||
|
||||
@ -62,13 +62,21 @@ class Debug extends React.Component{
|
||||
<div className="field checkbox">
|
||||
<div className="name">Debug</div>
|
||||
<div className="input">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="debug_info"
|
||||
checked={ this.props.test_mode }
|
||||
onChange={ e => this.props.uiActions.set({ test_mode: !this.props.test_mode })} />
|
||||
<span className="label">Test mode</span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="debug_info"
|
||||
checked={ this.props.debug_info }
|
||||
onChange={ e => this.props.uiActions.set({ debug_info: !this.props.debug_info })} />
|
||||
<span className="label">Show debug info panel</span>
|
||||
<span className="label">Debug info</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -211,6 +219,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
log_actions: (state.ui.log_actions ? state.ui.log_actions : false),
|
||||
log_pusher: (state.ui.log_pusher ? state.ui.log_pusher : false),
|
||||
log_mopidy: (state.ui.log_mopidy ? state.ui.log_mopidy : false),
|
||||
test_mode: (state.ui.test_mode ? state.ui.test_mode : false),
|
||||
debug_info: (state.ui.debug_info ? state.ui.debug_info : false),
|
||||
debug_response: state.ui.debug_response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user