Browse Source

Merge branch 'master' into dev

pull/514/merge
RubaXa 9 years ago
parent
commit
94cd89f626
  1. 2
      README.md
  2. 34
      meteor/.versions
  3. 16
      meteor/README.md
  4. 2
      meteor/example/.meteor/packages
  5. 2
      meteor/example/.meteor/release
  6. 8
      meteor/example/.meteor/versions
  7. 17
      meteor/example/README.md
  8. 11
      meteor/example/run.bat
  9. 14
      meteor/example/run.sh
  10. 74
      meteor/package.js
  11. 22
      meteor/publish.sh
  12. 4
      meteor/reactivize.js
  13. 8
      meteor/runtests.bat
  14. 21
      meteor/runtests.sh

2
README.md

@ -123,7 +123,7 @@ var sortable = new Sortable(el, {
evt.draggedRect; // TextRectangle {left, top, right и bottom}
evt.related; // HTMLElement on which have guided
evt.relatedRect; // TextRectangle
// retrun false; — for cancel
// return false; — for cancel
}
});
```

34
meteor/.versions

@ -0,0 +1,34 @@
base64@1.0.3
binary-heap@1.0.3
blaze@2.1.2
blaze-tools@1.0.3
callback-hook@1.0.3
check@1.0.5
dburles:mongo-collection-instances@0.3.4
ddp@1.1.0
deps@1.0.7
ejson@1.0.6
geojson-utils@1.0.3
html-tools@1.0.4
htmljs@1.0.4
id-map@1.0.3
jquery@1.11.3_2
json@1.0.3
lai:collection-extensions@0.1.4
local-test:rubaxa:sortable@1.2.1
logging@1.0.7
meteor@1.1.6
minifiers@1.1.5
minimongo@1.0.8
mongo@1.1.0
observe-sequence@1.0.6
ordered-dict@1.0.3
random@1.0.3
reactive-var@1.0.5
retry@1.0.3
rubaxa:sortable@1.2.1
spacebars-compiler@1.0.6
templating@1.1.1
tinytest@1.0.5
tracker@1.0.7
underscore@1.0.3

16
meteor/README.md

@ -12,7 +12,7 @@ Demo: http://rubaxa-sortable.meteor.com
If you're new to Meteor, here's what the excitement is all about -
[watch the first two minutes](https://www.youtube.com/watch?v=fsi0aJ9yr2o); you'll be hooked by 1:28.
That screencast is from 2012. In the meantime, Meteor has become a mature JavaScript-everywhere web
development framework. Read more at [Why Meteor](http://www.meteorpedia.com/read/Why_Meteor).
development framework. Read more at [Why Meteor](http://wiki.dandascalescu.com/essays/why_meteor).
# Usage
@ -81,6 +81,20 @@ Template.myTemplate.helpers({
});
```
#### Meteor-specific options
* `selector` - you can specify a collection selector if your list operates only on a subset of the collection. Example:
```js
Template.myTemplate.helpers({
playerOptions: function() {
return {
selector: { city: 'San Francisco' }
}
}
});
```
## Events

2
meteor/example/.meteor/packages

@ -7,6 +7,4 @@ meteor-platform
autopublish
insecure
rubaxa:sortable
dburles:mongo-collection-instances
fezvrasta:bootstrap-material-design
# twbs:bootstrap

2
meteor/example/.meteor/release

@ -1 +1 @@
METEOR@1.1.0.2
METEOR@1.1.0.3

8
meteor/example/.meteor/versions

@ -7,7 +7,7 @@ blaze-tools@1.0.3
boilerplate-generator@1.0.3
callback-hook@1.0.3
check@1.0.5
dburles:mongo-collection-instances@0.3.3
dburles:mongo-collection-instances@0.3.4
ddp@1.1.0
deps@1.0.7
ejson@1.0.6
@ -21,7 +21,7 @@ id-map@1.0.3
insecure@1.0.3
jquery@1.11.3_2
json@1.0.3
lai:collection-extensions@0.1.3
lai:collection-extensions@0.1.4
launch-screen@1.0.2
livedata@1.0.13
logging@1.0.7
@ -39,13 +39,13 @@ reactive-var@1.0.5
reload@1.1.3
retry@1.0.3
routepolicy@1.0.5
rubaxa:sortable@1.2.0
rubaxa:sortable@1.2.1
session@1.1.0
spacebars@1.0.6
spacebars-compiler@1.0.6
templating@1.1.1
tracker@1.0.7
twbs:bootstrap@3.3.4
twbs:bootstrap@3.3.5
ui@1.0.6
underscore@1.0.3
url@1.0.4

17
meteor/example/README.md

@ -9,28 +9,27 @@ It also shows list grouping and control over what lists can give or receive
elements. You can only drag elements from the list to the left onto the list
to the right.
## Usage
The example uses the local package from the checkout, so it needs to wire
up some files (`package.js` and `package.json`). This is done by the handy
run script:
The example uses the local package from the checkout, with the help of the run script:
### Windows
git clone https://github.com/RubaXa/Sortable.git
cd Sortable
git checkout dev
cd meteor\example
run.bat
# git checkout dev # optional
meteor\example\run.bat
### Elsewhere
git clone https://github.com/RubaXa/Sortable.git
cd Sortable
git checkout dev
meteor/example./run.sh
# git checkout dev # optional
meteor/example/run.sh
## Prior art
## [Prior art](http://slides.com/dandv/prior-art)
### Differential

11
meteor/example/run.bat

@ -1,4 +1,7 @@
mklink ..\..\package.js "meteor/package.js"
mklink package.json "../../package.json"
meteor run
del ..\..\package.js package.json
@echo off
REM Sanity check: make sure we're in the directory of the script
set DIR=%~dp0
cd %DIR%
set PACKAGE_DIRS=..\..\
meteor run %*

14
meteor/example/run.sh

@ -1,15 +1,5 @@
# sanity check: make sure we're in the root directory of the example
cd "$( dirname "$0" )"
# delete temp files even if Ctrl+C is pressed
int_trap() {
echo "Cleaning up..."
}
trap int_trap INT
ln -s "meteor/package.js" ../../package.js 2>/dev/null
ln -s "../../package.json" package.json 2>/dev/null
meteor run "$@"
rm ../../package.js package.json
# let Meteor find the local package
PACKAGE_DIRS=../../ meteor run "$@"

74
meteor/package.js

@ -1,35 +1,85 @@
// package metadata file for Meteor.js
// Package metadata file for Meteor.js
'use strict';
var packageName = 'rubaxa:sortable'; // http://atmospherejs.com/rubaxa/sortable
var packageName = 'rubaxa:sortable'; // https://atmospherejs.com/rubaxa/sortable
var gitHubPath = 'RubaXa/Sortable'; // https://github.com/RubaXa/Sortable
var npmPackageName = 'sortablejs'; // https://www.npmjs.com/package/sortablejs - optional but recommended; used as fallback if GitHub fails
var packageJson = JSON.parse(Npm.require("fs").readFileSync('package.json'));
/* All of the below is just to get the version number of the 3rd party library.
* First we'll try to read it from package.json. This works when publishing or testing the package
* but not when running an example app that uses a local copy of the package because the current
* directory will be that of the app, and it won't have package.json. Finding the path of a file is hard:
* http://stackoverflow.com/questions/27435797/how-do-i-obtain-the-path-of-a-file-in-a-meteor-package
* Therefore, we'll fall back to GitHub (which is more frequently updated), and then to NPMJS.
* We also don't have the HTTP package at this stage, and if we use Package.* in the request() callback,
* it will error that it must be run in a Fiber. So we'll use Node futures.
*/
var request = Npm.require('request');
var Future = Npm.require('fibers/future');
var fut = new Future;
var version;
if (!version) try {
var packageJson = JSON.parse(Npm.require('fs').readFileSync('../package.json'));
version = packageJson.version;
} catch (e) {
// if the file was not found, fall back to GitHub
console.warn('Could not find ../package.json to read version number from; trying GitHub...');
var url = 'https://api.github.com/repos/' + gitHubPath + '/tags';
request.get({
url: url,
headers: {
'User-Agent': 'request' // GitHub requires it
}
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
var versions = JSON.parse(body).map(function (version) {
return version['name'].replace(/^\D+/, '') // trim leading non-digits from e.g. "v4.3.0"
}).sort();
fut.return(versions[versions.length -1]);
} else {
// GitHub API rate limit reached? Fall back to npmjs.
console.warn('GitHub request to', url, 'failed:\n ', response && response.statusCode, response && response.body, error || '', '\nTrying NPMJS...');
url = 'http://registry.npmjs.org/' + npmPackageName + '/latest';
request.get(url, function (error, response, body) {
if (!error && response.statusCode === 200)
fut.return(JSON.parse(body).version);
else
fut.throw('Could not get version information from ' + url + ' either (incorrect package name?):\n' + (response && response.statusCode || '') + (response && response.body || '') + (error || ''));
});
}
});
version = fut.wait();
}
// Now that we finally have an accurate version number...
Package.describe({
name: packageName,
summary: 'Sortable: reactive minimalist reorderable drag-and-drop lists on modern browsers and touch devices',
version: packageJson.version,
version: version,
git: 'https://github.com/RubaXa/Sortable.git',
documentation: 'meteor/README.md'
documentation: 'README.md'
});
Package.onUse(function (api) {
api.versionsFrom(['METEOR@0.9.0', 'METEOR@1.0']);
api.use('templating', 'client');
api.use('dburles:mongo-collection-instances@0.3.3'); // to watch collections getting created
api.use('dburles:mongo-collection-instances@0.3.4'); // to watch collections getting created
api.export('Sortable'); // exported on the server too, as a global to hold the array of sortable collections (for security)
api.addFiles([
'Sortable.js',
'meteor/template.html', // the HTML comes first, so reactivize.js can refer to the template in it
'meteor/reactivize.js'
'../Sortable.js',
'template.html', // the HTML comes first, so reactivize.js can refer to the template in it
'reactivize.js'
], 'client');
api.addFiles('meteor/methods-client.js', 'client');
api.addFiles('meteor/methods-server.js', 'server');
api.addFiles('methods-client.js', 'client');
api.addFiles('methods-server.js', 'server');
});
Package.onTest(function (api) {
api.use(packageName, 'client');
api.use('tinytest', 'client');
api.addFiles('meteor/test.js', 'client');
api.addFiles('test.js', 'client');
});

22
meteor/publish.sh

@ -5,16 +5,8 @@
# 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
cd "$( dirname "$0" )/.."
ALL_EXIT_CODE=0
# test any package*.js packages we may have, e.g. package.js, package-compat.js
for PACKAGE_FILE in meteor/package*.js; do
# Meteor expects package.js to be in the root directory of the checkout, so copy there our package file under that name, temporarily
cp $PACKAGE_FILE ./package.js
# sanity check: make sure we're in the directory of the script
cd "$( dirname "$0" )"
# 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)
@ -24,17 +16,11 @@ for PACKAGE_FILE in meteor/package*.js; do
# Attempt to re-publish the package - the most common operation once the initial release has
# been made. If the package name was changed (rare), you'll have to pass the --create flag.
meteor publish "$@"; EXIT_CODE=$?
ALL_EXIT_CODE=$(( $ALL_EXIT_CODE + $EXIT_CODE ))
if (( $EXIT_CODE == 0 )); then
echo "Thanks for releasing a new version. You can see it at"
echo "https://atmospherejs.com/${PACKAGE_NAME/://}"
else
echo "We got an error. Please post it at https://github.com/raix/Meteor-community-discussions/issues/14"
echo "We have an error. Please post it at https://github.com/RubaXa/Sortable/issues"
fi
# rm the temporary build files and package.js
rm -rf ".build.$PACKAGE_NAME" versions.json package.js
done
exit $ALL_EXIT_CODE
exit $EXIT_CODE

4
meteor/reactivize.js

@ -90,7 +90,7 @@ Template.sortable.created = function () {
*/
templateInstance.adjustOrders = function adjustOrders(itemId, orderPrevItem, orderNextItem) {
var orderField = templateInstance.options.sortField;
var selector = {}, modifier = {$set: {}};
var selector = templateInstance.options.selector || {}, modifier = {$set: {}};
var ids = [];
var startOrder = templateInstance.collection.findOne(itemId)[orderField];
if (orderPrevItem !== null) {
@ -197,5 +197,5 @@ Template.sortable.rendered = function () {
Template.sortable.destroyed = function () {
this.sortable.destroy();
if(this.sortable) this.sortable.destroy();
};

8
meteor/runtests.bat

@ -0,0 +1,8 @@
@echo off
REM Test Meteor package before publishing to Atmospherejs.com
REM Sanity check: make sure we're in the directory of the script
set DIR=%~dp0
cd %DIR%
meteor test-packages ./ %*

21
meteor/runtests.sh

@ -5,8 +5,8 @@
# 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
cd "$( dirname "$0" )/.."
# sanity check: make sure we're in the directory of the script
cd "$( dirname "$0" )"
# delete the temporary files even if Ctrl+C is pressed
@ -16,13 +16,7 @@ int_trap() {
trap int_trap INT
ALL_EXIT_CODE=0
# test any package*.js packages we may have, e.g. package.js, package-standalone.js
for PACKAGE_FILE in meteor/package*.js; do
# Meteor expects package.js in the root dir of the checkout, so copy there our package file under that name, temporarily
cp $PACKAGE_FILE ./package.js
EXIT_CODE=0
PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
@ -35,12 +29,7 @@ for PACKAGE_FILE in meteor/package*.js; do
else
# automated/CI test with phantomjs
./node_modules/.bin/spacejam --mongo-url mongodb:// test-packages ./
ALL_EXIT_CODES=$(( $ALL_EXIT_CODES + $? ))
EXIT_CODE=$(( $EXIT_CODE + $? ))
fi
# delete temporary build files and package.js
rm -rf .build.* versions.json package.js
done
exit $ALL_EXIT_CODES
exit $EXIT_CODE

Loading…
Cancel
Save