Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Fix Makefile targets, update README, add AMD optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
bruth committed Nov 21, 2011
1 parent 9dda107 commit f757156
Show file tree
Hide file tree
Showing 17 changed files with 9,187 additions and 1,416 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
.sass-cache
.watch-pid
dist
build
62 changes: 13 additions & 49 deletions Makefile
@@ -1,27 +1,25 @@
COFFEE_DIR = ./src
JS_SRC_DIR = ./examples/js/synapse
EXAMPLES_DIR = ./examples
DIST_DIR = ./dist
BUILD_DIR = ./build
PID_FILE = .watch-pid

SASS_DIR = ./examples/scss
CSS_DIR = ./examples/css

COMPILE_SASS = `which sass` \
--scss \
--style=compressed \
${SASS_DIR}:${CSS_DIR}
COMPILE_COFFEE = `which coffee` -b -o ${JS_SRC_DIR} -c ${COFFEE_DIR}
WATCH_COFFEE = `which coffee` -w -b -o ${JS_SRC_DIR} -c ${COFFEE_DIR}
REQUIRE_OPTIMIZE = `which node` bin/r.js -o ${STATIC_DIR}/scripts/javascript/app.build.js
COMPILE_SASS = `which sass` --scss --style=compressed ${SASS_DIR}:${CSS_DIR}
COMPILE_COFFEE = `which coffee` -b -o ${BUILD_DIR} -c ${COFFEE_DIR}
WATCH_COFFEE = `which coffee` -w -b -o ${BUILD_DIR} -c ${COFFEE_DIR}
REQUIRE_OPTIMIZE = `which node` bin/r.js -o build.js

LATEST_TAG = `git describe --tags \`git rev-list --tags --max-count=1\``

all: build-submodules watch
all: build watch

build: build-submodules sass coffee optimize
build: sass coffee

dist: build
dist: build optimize
@echo 'Creating a source distributions...'
@python setup.py sdist > /dev/null

sass:
@echo 'Compiling Sass...'
Expand All @@ -44,47 +42,13 @@ unwatch:
rm ${PID_FILE}; \
fi;

init-submodules:
@echo 'Initializing submodules...'
@if [ -d .git ]; then \
if git submodule status | grep -q -E '^-'; then \
git submodule update --init --recursive; \
else \
git submodule update --init --recursive --merge; \
fi; \
fi;

build-submodules: init-submodules requirejs rjs backbone underscore

requirejs:
@echo 'Setting up RequireJS...'
@cp ./modules/requirejs/require.js ${JS_SRC_DIR}/vendor/require.js

rjs:
@echo 'Setting up r.js...'
@cd ./modules/rjs && node dist.js
@mkdir -p ./bin
@cp ./modules/rjs/r.js ./bin

jquery:
@echo 'Setting up jQuery...'
@cd ./modules/jquery && make
@cp ./modules/jquery/dist/jquery.js ${JS_SRC_DIR}/vendor/jquery.js

backbone:
@echo 'Setting up Backbone...'
@cp ./modules/backbone/backbone.js ${JS_SRC_DIR}/vendor/backbone.js

underscore:
@echo 'Setting up Underscore...'
@cp ./modules/underscore/underscore.js ${JS_SRC_DIR}/vendor/underscore.js

optimize: clean
@echo 'Optimizing the javascript...'
@mkdir -p ${JS_MIN_DIR}
@mkdir -p ${DIST_DIR}
@${REQUIRE_OPTIMIZE} > /dev/null
@cp -r ${DIST_DIR}/synapse* ${EXAMPLES_DIR}/js

clean:
@rm -rf ${JS_MIN_DIR}
@rm -rf ${DIST_DIR}

.PHONY: all sass coffee watch unwatch build optimize clean
48 changes: 34 additions & 14 deletions README.md
Expand Up @@ -8,23 +8,43 @@ come in the future.
Read the annotated source to learn your way around a bit:
http://bruth.github.com/synapse/docs/synapse.html

Get It
------
Build
-----
To build from source you must have CoffeeScript (and thus Node)
installed:

```
make build
```

you can also optionally Uglify the built file:
This will output to a `build` directory. You can also optionally optimize
the files:

```
make uglify
make optimize
```

which will output to a ``dist`` directory.

Integrate
--------
**Changes to 0.3** - Synapse now uses the AMD format for keeping code
modularized. The core of Synapse is optimized into a single file, but
no hooks are included by default. The general flow of bootstrapping
Synapse is now:

```javascript
require(['synapse', 'synapse/hooks/jquery', 'synapse/hooks/object'], function(Synapse, jQueryHook, ObjectHook) {
// The order in which hooks are added matter. The more specific the object
// the earlier it should be added.
Synapse.addHooks(jQueryHook, ObjectHook)

// Use Synapse...
});
```

in either case, there will be a ``dist`` directory created that will
contain the built files ``synapse.js`` and ``synapse.min.js``.
This is due mainly to the new Hooks architecture, but also allows developers to
freely define and add their own hooks for their application's use.

Introduction
------------
Expand Down Expand Up @@ -144,12 +164,12 @@ var intA = Synapse(A); // input element interface
intA.get('value'); // gets the 'value' property
intA.get('enabled'); // returns true if the 'disabled' attr is not set
intA.get('visible'); // returns true if the element is visible
intA.get('style:background'); // gets the element's CSS background details
intA.get('style.background'); // gets the element's CSS background details

intA.set('value', 'foobar'); // sets the 'value' property
intA.set('visible', false); // makes the element hidden
intA.set('disabled', true); // makes the element disabled
intA.set('attr:foo', 'bar'); // adds an attribute 'foo=bar' on the element
intA.set('attr.foo', 'bar'); // adds an attribute 'foo=bar' on the element
```

The interfaces registry can be extended by registering new interfaces or
Expand All @@ -175,11 +195,11 @@ result in the element being visible

**Compound**

* ``prop:<key>`` - gets/sets the property ``key``
* ``attr:<key>`` - gets/sets the attribute ``key``
* ``style:<key>`` - gets/sets the CSS style ``key``
* ``css:<key>`` - gets/sets the CSS class name ``key``
* ``data:<key>`` - gets/sets arbitrary data ``key`` using jQuery data API
* ``prop.<key>`` - gets/sets the property ``key``
* ``attr.<key>`` - gets/sets the attribute ``key``
* ``style.<key>`` - gets/sets the CSS style ``key``
* ``css.<key>`` - gets/sets the CSS class name ``key``
* ``data.<key>`` - gets/sets arbitrary data ``key`` using jQuery data API

Channel Configuration
---------------------
Expand Down Expand Up @@ -226,7 +246,7 @@ Synapse('input').notify('span', {
}, {
event: 'blur',
subjectInterface: 'value',
observerInterface: 'data:title'
observerInterface: 'data.title'
});
```

Expand Down

0 comments on commit f757156

Please sign in to comment.