-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Automattic/add/pluggable-req
[WIP] Add pluggable "request" interface for interacting with the REST API
- Loading branch information
Showing
23 changed files
with
370 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
dist | ||
node_modules | ||
test/data.json | ||
npm-debug.log | ||
tmp | ||
/node_modules | ||
/test/data.json | ||
/npm-debug.log | ||
/tmp | ||
|
||
/example/express/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,48 @@ | ||
|
||
# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 | ||
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) | ||
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) | ||
|
||
# BIN directory | ||
BIN := $(THIS_DIR)/node_modules/.bin | ||
|
||
# applications | ||
NODE ?= node | ||
NPM ?= $(NODE) $(shell which npm) | ||
MOCHA ?= $(NODE) $(BIN)/mocha | ||
BROWSERIFY ?= $(NODE) $(BIN)/browserify | ||
|
||
all: dist/wpcom.js dist/wpcom-proxy.js | ||
|
||
standalone-xhr: dist/wpcom.js | ||
|
||
standalone-proxy: dist/wpcom-proxy.js | ||
|
||
install: node_modules | ||
|
||
clean: | ||
@rm -rf node_modules dist | ||
|
||
dist: | ||
@mkdir -p $@ | ||
|
||
dist/wpcom.js: node_modules index.js wpcom+xhr.js dist lib/* | ||
@$(BROWSERIFY) -s WPCOM wpcom+xhr.js > $@ | ||
|
||
dist/wpcom-proxy.js: node_modules index.js wpcom+proxy.js dist lib/* | ||
@$(BROWSERIFY) -s WPCOM wpcom+proxy.js > $@ | ||
|
||
node_modules: package.json | ||
@NODE_ENV= $(NPM) install | ||
@touch node_modules | ||
|
||
test: | ||
@./node_modules/.bin/mocha \ | ||
@$(MOCHA) \ | ||
--require should \ | ||
--timeout 10s \ | ||
--slow 3s \ | ||
--bail \ | ||
--reporter spec | ||
|
||
|
||
.PHONY: test | ||
.PHONY: standalone install clean test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>wpcom.js browser example</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
</head> | ||
<body> | ||
<script src="../../dist/wpcom-proxy.js"></script> | ||
<script> | ||
var wpcom = WPCOM(); | ||
wpcom.me().get(function(err, me){ | ||
if (err) throw err; | ||
console.log(me); | ||
|
||
var div = document.createElement('div'); | ||
div.innerHTML = 'Your WordPress.com "username" is: <b>@' + me.username + '<\/b>'; | ||
document.body.appendChild(div); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/wpcom.js/example/layout.jade → ...ages/wpcom.js/example/express/layout.jade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/wpcom.js/example/package.json → ...ges/wpcom.js/example/express/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
body { | ||
font: 14px "Helvetica Nueue", "Lucida Grande", Arial, sans-serif; | ||
padding: 50px 80px; | ||
margin: 0; | ||
} | ||
|
||
h1 { | ||
color: #a04; | ||
} | ||
|
||
h2 { | ||
margin-top: 50px; | ||
} | ||
|
||
h2.err { | ||
background-color: #fee; | ||
color: red; | ||
padding: 5px 20px; | ||
} | ||
|
||
h2.ok { | ||
background-color: #efe; | ||
color: #080; | ||
padding: 5px 20px; | ||
} | ||
|
||
ul, | ||
ul li { | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.author em { | ||
color: #a04; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
// anonymous auth since `freshlyPressed()` doesn't require auth | ||
var WPCOM = require('../../')(); | ||
|
||
WPCOM.freshlyPressed(function (err, res) { | ||
if (err) throw err; | ||
console.log(res); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"get": { | ||
"method": "GET", | ||
"path": "/freshly-pressed" | ||
} | ||
} |
Oops, something went wrong.