Skip to content

Commit 0518ad0

Browse files
committed
Merge branch 'release/2.0.0-rc3'
2 parents ddd9569 + 798c5fe commit 0518ad0

13 files changed

+329
-19
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wp-api-angularjs",
3-
"version": "2.0.0-rc2",
3+
"version": "2.0.0-rc3",
44
"description": "WordPress WP-API v2 client for AngularJs",
55
"main": [
66
"dist/wp-api-angularjs.js"

dist/wp-api-angularjs.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wp-api-angularjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wp-api-angularjs.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/terms.service.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class extends Parent {
3535
* @returns {Object} Promise
3636
*/
3737
getCustomList(taxonomiesType, params, data, headers) {
38-
return super.getList(`/terms/${taxonomiesType}`, params, data, headers);
38+
return super.getList(`/${taxonomiesType}`, params, data, headers);
3939
}
4040

4141
/**
@@ -59,7 +59,7 @@ export default class extends Parent {
5959
taxonomiesType,
6060
termId
6161
});
62-
return super.get(`/terms/${taxonomiesType}/${termId}`, params, data, headers);
62+
return super.get(`/${taxonomiesType}/${termId}`, params, data, headers);
6363
}
6464

6565
/**
@@ -87,7 +87,7 @@ export default class extends Parent {
8787
* @returns {Object} Promise
8888
*/
8989
getCategoryList(params, data, headers) {
90-
return super.getList(`/terms/category`, params, data, headers);
90+
return super.getList(`/categories`, params, data, headers);
9191
}
9292

9393
/**
@@ -114,7 +114,7 @@ export default class extends Parent {
114114
* @returns {Object} Promise
115115
*/
116116
getTagList(params, data, headers) {
117-
return super.getList(`/terms/tag`, params, data, headers);
117+
return super.getList(`/tags`, params, data, headers);
118118
}
119119

120120
/**
@@ -136,7 +136,7 @@ export default class extends Parent {
136136
super.requiredInput('$wpApiTerms:get', {
137137
termId
138138
});
139-
return super.get(`/terms/category/${termId}`, params, data, headers);
139+
return super.get(`/categories/${termId}`, params, data, headers);
140140
}
141141

142142
/**
@@ -158,6 +158,6 @@ export default class extends Parent {
158158
super.requiredInput('$wpApiTerms:get', {
159159
termId
160160
});
161-
return super.get(`/terms/tag/${termId}`, params, data, headers);
161+
return super.get(`/tags/${termId}`, params, data, headers);
162162
}
163163
}

lib/v2/parent.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {Inject} from 'angular2/core';
2+
import {Http} from 'angular2/http';
3+
4+
export Parent class {
5+
constructor(@Inject(Http) http:Http) {
6+
7+
8+
this.baseUrl = $injector.get('WpApi').getBaseUrl();
9+
this.defaultHttpProperties = $injector.get('WpApi').getDefaultHttpProperties();
10+
this.$http = $injector.get('$http');
11+
12+
}
13+
14+
getList(suffix, params = {}, data = {}, headers = {}) {
15+
return this.$http(angular.merge({}, this.defaultHttpProperties, {
16+
method: 'GET',
17+
url: this.baseUrl + suffix,
18+
params,
19+
data,
20+
headers
21+
}));
22+
}
23+
24+
get(suffix, params = {}, data = {}, headers = {}) {
25+
return this.$http(angular.merge({}, this.defaultHttpProperties, {
26+
method: 'GET',
27+
url: this.baseUrl + suffix,
28+
params,
29+
data,
30+
headers
31+
}));
32+
}
33+
34+
requiredInput(functionName, inputs) {
35+
angular.forEach(inputs, (value, name) => {
36+
if (typeof value !== 'undefined') return;
37+
throw new Error(`Parameter ${name} from function ${functionName} is required`);
38+
});
39+
}
40+
}

lib/v2/posts.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Parent from './parent.service.js';
2+
3+
export default class extends Parent {
4+
5+
}

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "wp-api-angularjs",
3-
"version": "2.0.0-rc2",
3+
"version": "2.0.0-rc3",
44
"description": "WordPress WP-API v2 client for AngularJs",
55
"main": "dist/wp-api-angularjs.js",
66
"scripts": {
77
"devserver": "webpack-dev-server --port 8080 --json --progress",
8+
"devserverV2": "webpack-dev-server --port 8080 --json --progress --config webpack.config.v2.js",
89
"build": "npm run dumpdev && npm run dumpprod",
910
"dumpdev": "webpack --progress --colors --config webpack.config.dist.js -d",
1011
"watch": "webpack --watch --progress --colors --config webpack.config.dist.js -d",
@@ -29,9 +30,12 @@
2930
},
3031
"homepage": "https://github.com/shprink/wp-api-angularjs",
3132
"devDependencies": {
33+
"@reactivex/rxjs": "5.0.0-alpha.4",
3234
"angular": "^1.4.5",
35+
"angular2": "2.0.0-alpha.45",
3336
"babel-core": "^5.6.15",
3437
"babel-loader": "^5.2.2",
38+
"es6-shim": "^0.33.10",
3539
"exports-loader": "^0.6.2",
3640
"expose-loader": "^0.6.0",
3741
"gulp": "^3.9.0",
@@ -40,9 +44,13 @@
4044
"json-loader": "^0.5.2",
4145
"ng-annotate-loader": "~0.0.6",
4246
"path": "^0.4.9",
47+
"reflect-metadata": "0.1.2",
48+
"ts-loader": "^0.6.0",
49+
"typescript": "1.6.2",
4350
"util": "^0.10.3",
4451
"webpack": "~1.10.0",
45-
"webpack-dev-server": "~1.10.0"
52+
"webpack-dev-server": "~1.10.0",
53+
"zone.js": "0.5.8"
4654
},
4755
"dependencies": {
4856
"js-base64": "^2.1.9"

test/v2/app.ts

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Angular 2 decorators and services
3+
*/
4+
import {Directive, Component, View, ElementRef} from 'angular2/angular2';
5+
import {RouteConfig, Router} from 'angular2/router';
6+
import {Http, Headers} from 'angular2/http';
7+
8+
/*
9+
* Angular Directives
10+
*/
11+
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/angular2';
12+
import {ROUTER_DIRECTIVES} from 'angular2/router';
13+
14+
15+
/*
16+
* App Component
17+
* Top Level Component
18+
*/
19+
@Component({
20+
// The selector is what angular internally uses
21+
// for `document.querySelectorAll(selector)` in our index.html
22+
// where, in this case, selector is the string 'app'
23+
selector: 'app', // <app></app>
24+
// We need to tell Angular's compiler which directives are in our template.
25+
// Doing so will allow Angular to attach our behavior to an element
26+
directives: [ CORE_DIRECTIVES, FORM_DIRECTIVES, ROUTER_DIRECTIVES ],
27+
// Our list of styles in our component. We may add more to compose many styles together
28+
styles: [`
29+
.title {
30+
font-family: Arial, Helvetica, sans-serif;
31+
}
32+
main {
33+
padding: 1em;
34+
}
35+
`],
36+
// Every Angular template is first compiled by the browser before Angular runs it's compiler
37+
template: `
38+
<header>
39+
<h1 class="title">Hello {{ title }}</h1>
40+
</header>
41+
42+
<main>
43+
Your Content Here
44+
<div>
45+
46+
<input type="text" [value]="title" (input)="title = $event.target.value" autofocus>
47+
<!--
48+
Rather than wiring up two-way data-binding ourselves
49+
we can use Angular's [(ng-model)] syntax
50+
<input type="text" [(ng-model)]="title">
51+
-->
52+
</div>
53+
54+
<pre>this.title = {{ title | json }}</pre>
55+
<pre>this.data = {{ data | json }}</pre>
56+
57+
</main>
58+
`
59+
})
60+
export class App {
61+
// These are member type
62+
title: string;
63+
data: Array<any> = []; // default data
64+
// TypeScript public modifiers
65+
constructor(public http: Http) {
66+
this.title = 'Angular 2';
67+
}
68+
69+
onInit() {
70+
// Our API
71+
// Before you start the app, run these commands in another process:
72+
//
73+
// - npm run express-install
74+
// - npm run express
75+
//
76+
// This will start a process that will listen for requests on port 3001
77+
78+
const BASE_URL = 'http://localhost:3001';
79+
const TODO_API_URL = '/api/todos';
80+
const JSON_HEADERS = new Headers();
81+
82+
JSON_HEADERS.append('Accept', 'application/json');
83+
JSON_HEADERS.append('Content-Type', 'application/json');
84+
85+
this.http
86+
.get(BASE_URL + TODO_API_URL, {
87+
headers: JSON_HEADERS
88+
})
89+
.map(res => res.json())
90+
.subscribe(
91+
// onNext callback
92+
data => this.serverData(data),
93+
// onError callback
94+
err => this.errorMessage(err),
95+
// onComplete callback
96+
() => console.log('complete')
97+
);//end http
98+
99+
}
100+
101+
serverData(data) {
102+
console.log('data', data);
103+
this.data = data;
104+
}//serverData
105+
106+
errorMessage(err) {
107+
console.info(`${'\n'
108+
} // You must run these commands in another process for the Http API to work ${'\n'
109+
} npm run express-install ${'\n'
110+
} npm run express
111+
`);
112+
}//errorMessage
113+
114+
}
115+
116+
117+
118+
/*
119+
* Please review the examples/ folder for more angular app examples
120+
* (The examples may not be updated as quickly. Please open an issue on github for us to update it)
121+
* you can change the `entry` in webpack.config to quickly view the examples
122+
* For help or questions please contact us at @AngularClass on twitter
123+
* or our chat on Slack at https://AngularClass.com/slack-join
124+
* or via chat on Gitter at https://gitter.im/AngularClass/angular2-webpack-starter
125+
*/

test/v2/bootstrap.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'es6-shim';
2+
import '@reactivex/rxjs';
3+
import 'zone.js';
4+
import 'reflect-metadata';
5+
6+
import {bootstrap, FORM_PROVIDERS, ELEMENT_PROBE_PROVIDERS} from 'angular2/angular2';
7+
import {ROUTER_PROVIDERS} from 'angular2/router';
8+
import {HTTP_PROVIDERS} from 'angular2/http';
9+
10+
/*
11+
* App Component
12+
* our top level component that holds all of our components
13+
*/
14+
import {App} from './app';
15+
16+
/*
17+
* Bootstrap our Angular app with a top level component `App` and inject
18+
* our Services and Providers into Angular's dependency injection
19+
*/
20+
bootstrap(App, [
21+
// These are dependencies of our App
22+
FORM_PROVIDERS,
23+
ROUTER_PROVIDERS,
24+
HTTP_PROVIDERS,
25+
ELEMENT_PROBE_PROVIDERS
26+
]);

test/v2/index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6+
<title>{%=o.htmlWebpackPlugin.options.pkg.title %}</title>
7+
<style>
8+
.error {
9+
background-color: red;
10+
}
11+
12+
.success {
13+
background-color: green;
14+
}
15+
</style>
16+
</head>
17+
18+
<body>
19+
<app>
20+
Loading...
21+
</app>
22+
{% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %}
23+
<script src="{%=o.htmlWebpackPlugin.files.chunks[chunk].entry %}"></script>
24+
{% } %}
25+
</body>
26+
27+
</html>

0 commit comments

Comments
 (0)