Skip to content

Commit

Permalink
Integration with Meteor.js, http://meteor.com
Browse files Browse the repository at this point in the history
  • Loading branch information
dandv committed Nov 26, 2014
1 parent b5f84af commit d16a8cb
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
# node modules
node_modules
bower_components
*.sublime*
*.sublime*
.build*
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,7 @@ module.exports = function (grunt) {

// default: build, test, dist.
grunt.registerTask('default', ['dist']);

// meteor
// TODO - see https://github.com/raix/Meteor-community-discussions/issues/15
};
7 changes: 7 additions & 0 deletions meteor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This is the first attempt at packaging **summernote** for Meteor.js, the most
popular full-stack JavaScript framework on GitHub (http://meteor.com).

The included test demonstrates that instantiation works. However, more work
may need to be done to further integrate the library - in particular, to make
it work with Meteor's reactivity - for example to auto-save to a collection
transparently after the text changes.
33 changes: 33 additions & 0 deletions meteor/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// package metadata file for Meteor.js

var packageName = 'hackerwins:summernote'; // http://atmospherejs.com/hackerswin:summernote
var where = 'client'; // where to install: 'client', 'server', or ['client', 'server']

var packageJson = JSON.parse(Npm.require("fs").readFileSync('package.json'));

Package.describe({
name: packageName,
summary: 'summernote (official): jQuery+Bootstrap+FontAwesome WYSIWYG editor with embedded images support',
version: packageJson.version,
git: 'https://github.com/HackerWins/summernote.git'
});

Package.onUse(function (api) {
api.versionsFrom('0.9.0');
api.use('[email protected]', where);
api.use('mizzao:[email protected]', where);
api.use('fortawesome:[email protected]', where);
// no exports - summernote adds itself to jQuery
api.addFiles([
'dist/summernote.js',
'dist/summernote.css'
], where
);
});

Package.onTest(function (api) {
api.use(packageName, where);
api.use('tinytest', where);

api.addFiles('meteor/test.js', where);
});
23 changes: 23 additions & 0 deletions meteor/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Publish package on Meteor's Atmosphere.js

# Make sure Meteor is installed, per https://www.meteor.com/install. The curl'ed script is totally safe; takes 2 minutes to read its source and check.
type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }

# sanity check: make sure we're in the root directory of the checkout
DIR=$( cd "$( dirname "$0" )" && pwd )
cd $DIR/..

# Meteor expects package.js to be in the root directory of the checkout, so copy it there temporarily
cp meteor/package.js ./

# publish package, creating it if it's the first time we're publishing
PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
PACKAGE_EXISTS=$(meteor search $PACKAGE_NAME 2>/dev/null | wc -l)

if [ $PACKAGE_EXISTS -gt 0 ]; then
meteor publish
else
meteor publish --create
fi

rm package.js
28 changes: 28 additions & 0 deletions meteor/runtests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Test Meteor package before publishing to Atmosphere.js

# Make sure Meteor is installed, per https://www.meteor.com/install. The curl'ed script is totally safe; takes 2 minutes to read its source and check.
type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }

# sanity check: make sure we're in the root directory of the checkout
DIR=$( cd "$( dirname "$0" )" && pwd )
cd $DIR/..

# Meteor expects package.js to be in the root directory of the checkout, so copy it there temporarily
cp meteor/package.js ./

# run tests and delete the temporary package.js even if Ctrl+C is pressed
int_trap() {
echo
echo "Tests interrupted."
}

trap int_trap INT

meteor test-packages ./

PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
rm -rf ".build.$PACKAGE_NAME"
rm -rf ".build.local-test:$PACKAGE_NAME"
rm versions.json 2>/dev/null

rm package.js
9 changes: 9 additions & 0 deletions meteor/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

Tinytest.add('Instantiation', function (test) {
var editor = document.createElement('div');
document.body.appendChild(editor);
$(editor).summernote();

test.isTrue($(editor).code().length >= 3, 'Instantiation');
});

0 comments on commit d16a8cb

Please sign in to comment.