markuapad 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module Markuapad
2
- VERSION = "0.2.2"
2
+ VERSION = '0.2.3'
3
3
  end
data/package.json CHANGED
@@ -36,6 +36,7 @@
36
36
  "react": "^0.13.1",
37
37
  "react-dnd": "^1.1.2",
38
38
  "react-hot-loader": "^1.2.5",
39
+ "reflux": "^0.2.12",
39
40
  "run-sequence": "^1.0.2",
40
41
  "sass-loader": "^1.0.2",
41
42
  "style-loader": "^0.8.2",
@@ -52,4 +53,4 @@
52
53
  "mocha": "^2.1.0",
53
54
  "should": "^5.2.0"
54
55
  }
55
- }
56
+ }
@@ -0,0 +1,7 @@
1
+ import Reflux from 'reflux';
2
+
3
+ const Actions = Reflux.createActions({
4
+ 'flash': {}
5
+ });
6
+
7
+ export default Actions;
@@ -4,6 +4,7 @@ import FileBrowserListItem from "./file_browser_list_item";
4
4
  import FileAccessor from "../file_accessor";
5
5
  import HTML5Backend from 'react-dnd/modules/backends/HTML5';
6
6
  import { DragDropContext } from 'react-dnd';
7
+ import Actions from '../actions/actions';
7
8
 
8
9
  import _string from "underscore.string";
9
10
  _.string = _string;
@@ -129,15 +130,20 @@ class FileBrowser extends React.Component {
129
130
  // Actually create a new file
130
131
  createFile(e) {
131
132
  let fileNode = this.refs.filename.getDOMNode()
132
- FileAccessor.new(fileNode.value, this.state.fileMode, '', (error, file) => {
133
- fileNode.value = '';
134
- this.setState({ creatingFile: false });
135
- this[`list${_.string.capitalize(this.state.fileMode)}`]()
136
-
137
- // Change to the new file
138
- this.props.onChangeFile(file)
139
- });
140
133
 
134
+ if (this.props.blacklistedFiles.indexOf(fileNode.value.toLowerCase()) !== -1) {
135
+ Actions.flash('error', `You may not create a file with the name ${fileNode.value} as it is a reserved file.`)
136
+ }
137
+ else {
138
+ FileAccessor.new(fileNode.value, this.state.fileMode, '', (error, file) => {
139
+ fileNode.value = '';
140
+ this.setState({ creatingFile: false });
141
+ this[`list${_.string.capitalize(this.state.fileMode)}`]()
142
+
143
+ // Change to the new file
144
+ this.props.onChangeFile(file)
145
+ });
146
+ }
141
147
  e.stopPropagation();
142
148
  e.preventDefault();
143
149
  }
@@ -246,7 +252,8 @@ class FileBrowser extends React.Component {
246
252
  FileBrowser.propTypes = {
247
253
  projectRoot: React.PropTypes.string.isRequired,
248
254
  onChangeFile: React.PropTypes.func.isRequired,
249
- currentFile: React.PropTypes.string
255
+ currentFile: React.PropTypes.string,
256
+ blacklistedFiles: React.PropTypes.array.isRequired
250
257
  };
251
258
 
252
259
  export default DragDropContext(HTML5Backend)(FileBrowser);
data/src/jsx/main.jsx CHANGED
@@ -139,7 +139,7 @@ class Main extends React.Component {
139
139
  />
140
140
  <section className="main-view">
141
141
  <section className={this.getWorkspaceClass()}>
142
- <FileBrowser onPreviewImage={this.onPreviewImage} onChangeFile={this.onChangeFile} currentFile={this.state.currentFile} projectRoot={this.props.projectRoot }/>
142
+ <FileBrowser blacklistedFiles={this.props.options.blacklistedFiles} onPreviewImage={this.onPreviewImage} onChangeFile={this.onChangeFile} currentFile={this.state.currentFile} projectRoot={this.props.projectRoot }/>
143
143
  <Editor
144
144
  onBookContentChanged={this.onBookContentChanged}
145
145
  inLiveMode={this.state.inLiveMode}
data/src/jsx/toolbar.jsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import Actions from '../actions/actions';
2
3
 
3
4
  let PROGRESS_TYPE_MAP = {
4
5
  'manuscript_update': 'Manuscript Updated.',
@@ -8,6 +9,28 @@ let PROGRESS_TYPE_MAP = {
8
9
  }
9
10
 
10
11
  class Toolbar extends React.Component {
12
+ state = {
13
+ flash: null
14
+ }
15
+
16
+ constructor(props) {
17
+ super(props)
18
+
19
+ // Listen to the flash action
20
+ this.unsub = Actions.flash.listen((type, message) => {
21
+ // Clear any existing timers
22
+ clearInterval(this.timer)
23
+
24
+ // Set the flash message
25
+ this.setState({ flash: { type: type, message: message } })
26
+
27
+ // Set up the timer to clear the flash message
28
+ this.timer = setTimeout(() => {
29
+ this.setState({ error: null })
30
+ }, 5000)
31
+ })
32
+ }
33
+
11
34
  render() {
12
35
  return (
13
36
  <nav className="toolbar">
@@ -18,6 +41,13 @@ class Toolbar extends React.Component {
18
41
  { this.props.inProgress ? <i className="fa fa-refresh fa-spin"></i> : null } { PROGRESS_TYPE_MAP[this.props.progressType] || 'Working...' }
19
42
  </a>
20
43
  </li>
44
+ {
45
+ this.state.flash ?
46
+ <li onClick={() => this.setState({ flash: null })} key={this.state.flash.type}>
47
+ <a className={`${this.state.flash.type}`}>{ this.state.flash.message }</a>
48
+ </li>
49
+ : null
50
+ }
21
51
  {
22
52
  this.props.enablePreview ?
23
53
  [
data/src/markuapad.js CHANGED
@@ -12,7 +12,8 @@ _.string = _string;
12
12
 
13
13
  let DEFAULT_OPTIONS = {
14
14
  CHANGED_INTERVAL: 100,
15
- enablePreview: true
15
+ enablePreview: true,
16
+ blacklistedFiles: ['book.txt']
16
17
  }
17
18
 
18
19
  class Markuapad {
@@ -22,7 +23,7 @@ class Markuapad {
22
23
 
23
24
  create(elementId, options = {}) {
24
25
  // apply options to defaults
25
- this.options = _.extend(this.options, options);
26
+ this.options = _.extend({}, this.options, options);
26
27
 
27
28
  // Project Root
28
29
  let projectTitle = options.title || "My First Markuapad Book";
@@ -35,7 +36,7 @@ class Markuapad {
35
36
  FileAccessor.setup(this.options.fileAccessor, projectRoot);
36
37
 
37
38
  // Render the markuapad
38
- React.render(React.createFactory(Main)({ bookTitle: projectTitle, options: options, markua: this.markua, projectRoot: projectRoot }), document.getElementById(elementId));
39
+ React.render(React.createFactory(Main)({ bookTitle: projectTitle, options: this.options, markua: this.markua, projectRoot: projectRoot }), document.getElementById(elementId));
39
40
  }
40
41
  }
41
42
 
@@ -24,12 +24,17 @@
24
24
  &.disabled {
25
25
  color: #aaa;
26
26
  }
27
+
28
+ &.error {
29
+ color: #fff;
30
+ background: #FF6347;
31
+ }
27
32
  }
28
33
 
29
34
  > a.progressMessage {
30
35
  @include transition(opacity 1s ease-in-out);
31
36
  opacity: 0;
32
- border: none;
37
+ border: none;
33
38
  &.active {
34
39
  opacity: .7;
35
40
  background: initial;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markuapad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braden Simpson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,13 +72,10 @@ files:
72
72
  - lib/markuapad.rb
73
73
  - lib/markuapad/engine.rb
74
74
  - lib/markuapad/version.rb
75
- - markuapad-0.1.8.gem
76
- - markuapad-0.1.9.gem
77
- - markuapad-0.2.0.gem
78
- - markuapad-0.2.1.gem
79
75
  - markuapad.gemspec
80
76
  - package.json
81
77
  - prepare_gem.sh
78
+ - src/actions/actions.js
82
79
  - src/dist.js
83
80
  - src/file_accessor.js
84
81
  - src/index.js
data/markuapad-0.1.8.gem DELETED
Binary file
data/markuapad-0.1.9.gem DELETED
Binary file
data/markuapad-0.2.0.gem DELETED
Binary file
data/markuapad-0.2.1.gem DELETED
Binary file