Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
klembot committed Feb 1, 2017
2 parents 71c5246 + f182b61 commit 41ab912
Show file tree
Hide file tree
Showing 31 changed files with 208 additions and 59 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Twine",
"version": "2.1.0b5",
"version": "2.1.0",
"author": "Chris Klimas <[email protected]>",
"description": "a GUI for creating nonlinear stories",
"license": "GPL-3.0",
Expand Down Expand Up @@ -58,6 +58,7 @@
"babel-core": "^6.18.2",
"babel-loader": "^6.2.8",
"babel-preset-es2015": "^6.18.0",
"base64-font-loader": "0.0.4",
"chai": "^3.5.0",
"chmodr": "^1.0.2",
"copy-webpack-plugin": "^4.0.1",
Expand Down Expand Up @@ -93,6 +94,7 @@
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2"
"webpack-dev-server": "^1.16.2",
"yargs": "^6.6.0"
}
}
9 changes: 7 additions & 2 deletions scripts/build-nw.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ const fs = require('fs');
const fsExtra = require('fs-extra');
const NwBuilder = require('nw-builder');

var argv = require('yargs').argv;

var platforms = argv.platform ? [argv.platform] :
['osx64', 'win32', 'win64', 'linux32', 'linux64'];

fsExtra.copySync('package.json', 'dist/web/package.json');

var nw = new NwBuilder({
files: 'dist/web/**',
platforms: ['osx64', 'win32', 'win64', 'linux32', 'linux64'],
version: '0.18.8',
platforms: platforms,
version: '0.19.5',
buildDir: 'dist/nw',
cacheDir: 'nw-cache/',
macIcns: 'src/common/img/logo.icns',
Expand Down
4 changes: 2 additions & 2 deletions src/common/colors.less
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
@color-highlight: hsl(60, saturation(@color-link), 50%);

/* color used for borders around form elements */
@color-form-line: lighten(@color-text, 50%);
@color-form-line-dark: darken(@color-text-dark, 20%);
@color-form-line: lighten(@color-text, 55%);
@color-form-line-dark: darken(@color-text-dark, 25%);
6 changes: 3 additions & 3 deletions src/common/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ TwineRouter.map({

loadFormat(
this.$store,
story.storyFormat,
story.storyFormatVersion
state.pref.proofingFormat.name,
state.pref.proofingFormat.version
).then(format => {
replaceUI(publishStoryWithFormat(
state.appInfo,
Expand Down Expand Up @@ -145,7 +145,7 @@ TwineRouter.map({
loadFormat(
this.$store,
story.storyFormat,
story.storyFormatName
story.storyFormatVersion
).then(format => {
replaceUI(publishStoryWithFormat(
state.appInfo,
Expand Down
16 changes: 8 additions & 8 deletions src/data/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ const actions = module.exports = {
},
{
name: 'SugarCube',
url: 'story-formats/sugarcube-2.11.0/format.js',
version: '2.11.0',
url: 'story-formats/sugarcube-2.12.1/format.js',
version: '2.12.1',
userAdded: false
}
];
Expand Down Expand Up @@ -463,7 +463,7 @@ const actions = module.exports = {
actions.updateStory(
store,
story.id,
{ storyFormat: 'SugarCube', storyFormatVersion: '2.11.0' }
{ storyFormat: 'SugarCube', storyFormatVersion: '2.12.1' }
);
}
else if (!story.storyFormatVersion) {
Expand All @@ -480,13 +480,13 @@ const actions = module.exports = {
const pVer = semverUtils.parse(prev.version);
const cVer = semverUtils.parse(current.version);

if (parseInt(cVer.major) < parseInt(pVer.major) ||
parseInt(cVer.minor) < parseInt(pVer.minor) ||
parseInt(cVer.patch) < parseInt(pVer.patch)) {
return current;
if (parseInt(pVer.major) < parseInt(cVer.major) ||
parseInt(pVer.minor) < parseInt(cVer.minor) ||
parseInt(pVer.patch) < parseInt(cVer.patch)) {
return prev;
}

return prev;
return current;
});

if (format) {
Expand Down
10 changes: 5 additions & 5 deletions src/data/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ describe('actions data module', () => {
expect(created['SugarCube-1.0.35']).to.exist;
expect(created['SugarCube-1.0.35'].url).to.equal('story-formats/sugarcube-1.0.35/format.js');
expect(created['SugarCube-1.0.35'].userAdded).to.be.false;
expect(created['SugarCube-2.11.0']).to.exist;
expect(created['SugarCube-2.11.0'].url).to.equal('story-formats/sugarcube-2.11.0/format.js');
expect(created['SugarCube-2.11.0'].userAdded).to.be.false;
expect(created['SugarCube-2.12.1']).to.exist;
expect(created['SugarCube-2.12.1'].url).to.equal('story-formats/sugarcube-2.12.1/format.js');
expect(created['SugarCube-2.12.1'].userAdded).to.be.false;
});

it('sets default formats with repairFormats()', () => {
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('actions data module', () => {
{ name: 'Paperthin', version: '1.0.0' },
{ name: 'Snowman', version: '1.3.0' },
{ name: 'SugarCube', version: '1.0.35' },
{ name: 'SugarCube', version: '2.11.0' }
{ name: 'SugarCube', version: '2.12.1' }
]
}
}
Expand Down Expand Up @@ -267,7 +267,7 @@ describe('actions data module', () => {
expect(storiesStore.dispatch.calledWith(
'UPDATE_STORY',
'also-not-a-real-id',
{ storyFormat: 'SugarCube', storyFormatVersion: '2.11.0' }
{ storyFormat: 'SugarCube', storyFormatVersion: '2.12.1' }
)).to.be.true;
});

Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/formats/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</tr>
</thead>
<tbody>
<tr v-for="format in storyFormats" is="format-item" :format="format" transition="fade-in-out"></format-item>
<tr v-for="format in storyFormats" is="format-item" :format="format" transition="fade-in-out" track-by="$index"></format-item>
</tbody>
</table>
</tab-item>
Expand All @@ -38,7 +38,7 @@
</tr>
</thead>
<tbody>
<tr v-for="format in proofingFormats" is="format-item" :format="format" transition="fade-in-out"></format-item>
<tr v-for="format in proofingFormats" is="format-item" :format="format" transition="fade-in-out" track-by="$index"></format-item>
</tbody>
</table>
</tab-item>
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/story-search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ module.exports = Vue.extend({

let result = this.passages.reduce((matches, passage) => {
let numMatches = 0;
let passageName = passage.get('name');
let passageText = passage.get('text');
let passageName = passage.name;
let passageText = passage.text;
let highlightedName = passageName;
let highlightedText = passageText;
let textMatches = passageText.match(this.searchRegexp);
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/story-stats/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</span>

<div class="content">
<table>
<table class="unlined">
<tbody>
<tr>
<td>
Expand Down
53 changes: 37 additions & 16 deletions src/dialogs/story-stats/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// A modal which shows aggregrate statistics for a story.
/*
A modal which shows aggregrate statistics for a story.
*/

const Vue = require('vue');
const moment = require('moment');
Expand Down Expand Up @@ -31,9 +33,10 @@ module.exports = Vue.extend({
},

charDesc() {
// L10n: Character in the sense of individual letters in a word.
// This does not actually include the count, as it is used in a
// table.
/*
L10n: Character in the sense of individual letters in a word. This
does not actually include the count, as it is used in a table.
*/
return locale.sayPlural('Character', 'Characters', this.charCount);
},

Expand All @@ -45,14 +48,15 @@ module.exports = Vue.extend({
},

wordDesc() {
// L10n: Word in the sense of individual words in a sentence.
// This does not actually include the count, as it is used in a
// table.
/*
L10n: Word in the sense of individual words in a sentence. This
does not actually include the count, as it is used in a table.
*/
return locale.sayPlural('Word', 'Words', this.wordCount);
},

links() {
// An array of distinct link names.
/* An array of distinct link names. */

return this.story.passages.reduce(
(links, passage) => [
Expand All @@ -69,8 +73,21 @@ module.exports = Vue.extend({
return this.story.passages.map(passage => passage.name);
},

passageCount() {
return this.story.passages.length;
},

passageDesc() {
/*
L10n: Word in the sense of individual words in a sentence.
This does not actually include the count, as it is used in a
table.
*/
return locale.sayPlural('Passage', 'Passages', this.passageCount);
},

linkCount() {
// This counts repeated links, unlike links().
/* This counts repeated links, unlike links(). */

return this.story.passages.reduce(
(count, passage) => count + linkParser(passage.text).length,
Expand All @@ -79,22 +96,26 @@ module.exports = Vue.extend({
},

linkDesc() {
// L10n: Links in the sense of hypertext links.
// This does not actually include the count, as it is used in a
// table.
/*
L10n: Links in the sense of hypertext links.
This does not actually include the count, as it is used in a
table.
*/
return locale.sayPlural('Link', 'Links', this.linkCount);
},

brokenLinkCount() {
return this.links.filter(
(link) => this.passageNames.indexOf(link) === -1
link => this.passageNames.indexOf(link) === -1
).length;
},

brokenLinkDesc() {
// L10n: Links in the sense of hypertext links.
// This does not actually include the count, as it is used in a
// table.
/*
L10n: Links in the sense of hypertext links.
This does not actually include the count, as it is used in a
table.
*/
return locale.sayPlural(
'Broken Link',
'Broken Links',
Expand Down
1 change: 1 addition & 0 deletions src/dialogs/story-stats/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
td:first-child {
text-align: right;
font-weight: bold;
padding-right: 0.5em;
}
}
10 changes: 7 additions & 3 deletions src/nw/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ module.exports = {
win.focus();
});

/* Add a shift-ctrl-alt-D shortcut for displaying dev tools. */
/*
Add a shift-ctrl-alt-D shortcut for displaying dev tools.
Note: this is deprecated as NW.js now lets you press F12 anywhere.
*/

startupTask = 'adding the debugger keyboard shortcut';

Expand Down Expand Up @@ -93,9 +96,10 @@ module.exports = {
/* When quitting, unlock the story directory. */

startupTask = 'setting up shutdown tasks';
process.on('exit', () => {

gui.Window.get().on('close', function() {
directories.unlockStories();
this.close(true);
});

/*
Expand Down
20 changes: 19 additions & 1 deletion src/nw/patches/store/file-persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ module.exports = {
case 'CREATE_PASSAGE_IN_STORY':
case 'UPDATE_PASSAGE_IN_STORY':
case 'DELETE_PASSAGE_IN_STORY':
/*
Special case: if the user has changed the name of a story, we
need to delete the old file first.
*/

if (mutation.type === 'UPDATE_STORY' && mutation.payload[1].name) {
StoryFile.delete(
previousStories.find(
story => story.id === mutation.payload[0]
),
state.appInfo
);
}

/* Save changes as normal. */

StoryFile.save(
state.story.stories.find(
story => story.id === mutation.payload[0]
Expand All @@ -53,6 +69,8 @@ module.exports = {
We save a copy of the stories structure in aid of deleting, as above.
*/

previousStories = state.story.stories;
previousStories = state.story.stories.map(
s => Object.assign({}, s)
);
}
};
6 changes: 6 additions & 0 deletions src/story-edit-view/passage-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ module.exports = Vue.extend({
},

edit() {
/*
Close any existing passage menu -- it may still be visible if the user double-clicked.
*/

this.$broadcast('drop-down-close');

const oldText = this.passage.text;

new PassageEditor({
Expand Down
2 changes: 1 addition & 1 deletion src/story-edit-view/story-toolbar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div> <!-- .left -->

<div class="right">
<story-search :collection="collection"></story-search>
<story-search :story="story"></story-search>

<span class="zooms">
<button class="zoomSmall subtle" :class="{ active: zoomDesc === 'small' }" @click="setZoom('small')" title="{{ 'Show only story structure' | say }}">
Expand Down
9 changes: 8 additions & 1 deletion src/story-edit-view/story-toolbar/story-search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const SearchDialog = require('../../../dialogs/story-search');
module.exports = Vue.extend({
template: require('./index.html'),

props: {
story: {
type: Object,
required: true
}
},

data: () => ({
search: ''
}),
Expand Down Expand Up @@ -36,7 +43,7 @@ module.exports = Vue.extend({
showModal(e) {
new SearchDialog({
data: {
passages: this.collection,
passages: this.story.passages,
search: this.search,
origin: e.target
}
Expand Down
2 changes: 1 addition & 1 deletion src/story-list-view/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@import '../common/typography.less';

@toolbar-width: 13rem;
@header-height: 4rem;
@header-height: 4.5rem;

#storyListView {
nav.listControls {
Expand Down
Loading

0 comments on commit 41ab912

Please sign in to comment.