Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwredfish committed Jan 8, 2016
2 parents a86d262 + df5d63a commit 59650eb
Show file tree
Hide file tree
Showing 80 changed files with 3,071 additions and 2,115 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install:
- cd test && bower install && cd ../
script:
- gulp build
- gulp server:dist &
- gulp --root dist &
- set -e
- gulp nightwatch --env ci; echo $?
- killall gulp
Expand Down
11 changes: 1 addition & 10 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

<link rel="stylesheet" href="styles/core.css">
<link rel="stylesheet" href="styles/theme-default.css">

<script src="bower_components/modernizr/modernizr.js"></script>
</head>
<body class="-noscroll">
Expand All @@ -55,16 +56,6 @@
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->

<script>
// Requirejs compatibility in Electron app
if (window.require) {
window.requireNode = window.require;
window.moduleNode = window.module;

window.require = undefined;
window.module = undefined;
}
</script>
<script data-main="scripts/main" src="bower_components/requirejs/require.js"></script>
</body>
</html>
32 changes: 20 additions & 12 deletions app/scripts/apps/confirm/show/controller.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/**
* Copyright (C) 2015 Laverna project Authors.
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* global define */
define([
'underscore',
'q',
'marionette',
'backbone.radio',
'apps/confirm/show/view'
], function(_, Marionette, Radio, View) {
], function(_, Q, Marionette, Radio, View) {
'use strict';

/**
Expand All @@ -24,21 +25,28 @@ define([
var Controller = Marionette.Object.extend({

initialize: function(options) {
var self = this;

if (typeof options === 'string') {
options = {content: options};
}

// If instead of text a view was provided, render it
if (typeof options.content === 'object') {
options.content = options.content.render().$el.html();
}
// Try to make HTML from supposedly Markdown string
else {
options.content = Radio.request('editor', 'content:html', options.content);
}

this.options = options;
this.show();
new Q((function() {

// If instead of text a view was provided, render it
if (typeof options.content === 'object') {
return options.content.render().$el.html();
}

// Try to make HTML from supposedly Markdown string
return Radio.request('markdown', 'render', options.content);
})())
.then(function(content) {
self.options.content = content;
return self.show();
});

},

onDestroy: function() {
Expand Down
38 changes: 28 additions & 10 deletions app/scripts/apps/notes/form/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,49 @@ define([
},

save: function() {
Radio.request('notes', 'save', this.view.model, this.getContent())
var self = this;

return this.getContent()
.then(function(data) {
return Radio.request('notes', 'save', self.view.model, data);
})
.fail(function(e) {
console.error('Error', e);
});
},

getContent: function() {
return _.extend(Radio.request('editor', 'get:content'), {
title : this.view.ui.title.val().trim(),
notebookId : this.view.notebooks.currentView.ui.notebookId.val().trim(),
var self = this;

return Radio.request('editor', 'get:data')
.then(function(data) {
return _.extend(data, {
title : self.view.ui.title.val().trim(),
notebookId : self.view.notebooks.currentView.ui.notebookId.val().trim(),
});
});
},

/**
* Warn a user that they have made some changes.
*/
showConfirm: function() {
var data = _.pick(this.getContent(), 'title', 'content', 'notebookId'),
model = this.view.model.pick('title', 'content', 'notebookId');
var self = this;

if (_.isEqual(model, data)) {
return this.redirect();
}
return this.getContent()
.then(function(data) {
var model = self.view.model.pick('title', 'content', 'notebookId');
data = _.pick(data, 'title', 'content', 'notebookId');

if (_.isEqual(model, data)) {
return self.redirect();
}

Radio.request('Confirm', 'start', $.t('You have unsaved changes.'));
Radio.request('Confirm', 'start', $.t('You have unsaved changes.'));
})
.fail(function(e) {
console.error('form ShowConfirm', e);
});
},

redirect: function() {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/apps/notes/form/views/formView.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright (C) 2015 Laverna project Authors.
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/apps/notes/list/views/noteSidebarItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright (C) 2015 Laverna project Authors.
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
Expand Down Expand Up @@ -65,7 +65,7 @@ define([
return {
// Show only first 50 characters of the content
getContent: function() {
return this.content.substring(0, 50);
return _.escape(this.content.substring(0, 50));
},

// Strip from HTML tags the title
Expand Down
44 changes: 27 additions & 17 deletions app/scripts/apps/notes/show/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ define([
* 2. channel: appNote, request: `remove:note`
* in order to destroy a model
* 3. channel: global, request: `set:title`
*
* Requests:
* 1. channel: markdown, request: render
* it expects to receive HTML.
*/
var Controller = Marionette.Object.extend({

Expand All @@ -45,11 +49,21 @@ define([
},

_show: function(note, notebook) {
var self = this;

Radio.request('markdown', 'render', note)
.then(function(content) {
return self.render(note, content, notebook);
});
},

render: function(note, content, notebook) {
// Trigger an event that the model is active
Radio.trigger('appNote', 'model:active', note);

this.view = new View({
model : note,
content : content,
notebook : notebook,
args : this.options,
files : [],
Expand Down Expand Up @@ -103,23 +117,19 @@ define([
* counts of completed tasks and content with toggled task.
*/
toggleTask: function(taskId) {
var model = this.view.model,

// Request the content with toggled task.
task = Radio.request('editor', 'task:toggle', {
content : model.get('content'),
taskId : taskId
});

// No reply
if (!task) {
return;
}

// Save the note
Radio.request('notes', 'save', model, {
content : task.content,
taskCompleted : task.completed
var model = this.view.model;

return Radio.request('markdown', 'task:toggle', {
content : model.get('content'),
taskId : taskId
})
.then(function(data) {
if (!data) {
return;
}

// Save the note
Radio.request('notes', 'save', model, _.pick(data, 'content', 'taskCompleted', 'taskAll'));
});
}
});
Expand Down
10 changes: 4 additions & 6 deletions app/scripts/apps/notes/show/noteView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ define([
* 2. channel: noteView, event: view:destroy
* before the view is destroyed.
* Requests:
* 1. channel: editor, request: content:html
* it expects to receive HTML.
* 2. channel: global, request: configs
* 1. channel: global, request: configs
*/
var View = Marionette.ItemView.extend({
template: _.template(Tmpl),
Expand Down Expand Up @@ -134,7 +132,7 @@ define([
* Toggle the status of a task
*/
toggleTask: _.debounce(function(e) {
var $task = $(e.target),
var $task = $(e.target),
taskId = Number($task.attr('data-task'));

$task.blur();
Expand All @@ -154,9 +152,9 @@ define([
},

serializeData: function() {
var content = Radio.request('editor', 'content:html', this.model);
// var content = Radio.request('markdown', 'render', this.model);
return _.extend(this.model.toJSON(), {
content : content || this.model.get('content'),
content : this.options.content || this.model.get('content'),
notebook : this.options.notebook.toJSON(),
uri : Radio.request('uri', 'link:profile', '/')
});
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define(['underscore'], function (_) {

var constants = {};

constants.VERSION = '0.7.1';
constants.VERSION = '0.7.2-RC';
constants.URL = location.origin + location.pathname.replace('index.html', '');

// List of hosts and urls where default dropbox API will work
Expand Down
6 changes: 2 additions & 4 deletions app/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ define([
'apps/help/appHelp',

// Optional modules
'modules/pagedown/module',
'modules/tags/module',
'modules/tasks/module',
'modules/markdown/module',
'modules/codemirror/module',
'modules/linkDialog/module',
'modules/fileDialog/module',
'modules/fuzzySearch/module',
'modules/codePrettify/module',
'modules/importExport/module',
'modules/mathjax/module'
], function(storage) {
Expand Down
54 changes: 15 additions & 39 deletions app/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@ requirejs.config({
nodeRequire: (typeof requireNode === 'undefined' ? null : requireNode),

packages: [
// Ace editor
// Codemirror editor
{
name : 'ace',
location : '../bower_components/ace/lib/ace',
main : 'ace'
name : 'codemirror',
location : '../bower_components/codemirror',
main : 'lib/codemirror'
},
// Pagedown editor
// Prismjs
{
name : 'pagedown',
location : '../bower_components/pagedown',
main : 'Markdown.Editor'
},
// Pagedown-ace editor
{
name : 'pagedown-ace',
location : '../bower_components/pagedown-ace',
main : 'Markdown.Editor'
name : 'prism',
location : '../bower_components/prism',
main : 'bundle'
},
// Xregexp
{
Expand Down Expand Up @@ -69,7 +63,10 @@ requirejs.config({
dropbox : '../bower_components/dropbox/dropbox',

// Markdown
'pagedown-extra' : '../bower_components/pagedown-extra/Markdown.Extra',
'markdown-it' : '../bower_components/markdown-it/dist/markdown-it.min',
'markdown-it-san' : '../bower_components/markdown-it-sanitizer/dist/markdown-it-sanitizer.min',
'markdown-it-hash' : '../bower_components/markdown-it-hashtag/dist/markdown-it-hashtag.min',
'markdown-it-math' : '../bower_components/markdown-it-math/dist/markdown-it-math.min',
'to-markdown' : '../bower_components/to-markdown/src/to-markdown',

// Others
Expand Down Expand Up @@ -122,30 +119,6 @@ requirejs.config({
},

// Markdown
ace: {
exports: 'ace'
},
'pagedown/Markdown.Editor': {
exports: 'Markdown.Editor',
deps: [ 'pagedown-extra' ]
},
'pagedown-ace/Markdown.Editor': {
exports: 'Markdown.Editor',
deps: [ 'pagedown-extra' ]
},
'pagedown-extra': {
exports: 'Markdown',
deps: [
'pagedown/Markdown.Converter',
'pagedown/Markdown.Sanitizer'
]
},
'pagedown/Markdown.Converter': {
exports: 'Markdown'
},
'pagedown/Markdown.Sanitizer': {
deps: [ 'pagedown/Markdown.Converter' ]
},
'to-markdown': {
exports: 'toMarkdown'
},
Expand All @@ -169,6 +142,9 @@ requirejs.config({
sjcl: {
exports: 'sjcl'
},
'prism/bundle': {
exports: 'Prism'
},
bootstrap: {
deps: ['jquery']
},
Expand Down
Loading

0 comments on commit 59650eb

Please sign in to comment.