From c1962345367bba9a8702b3e4ad1f5e0ad89065ad Mon Sep 17 00:00:00 2001 From: shprink Date: Sat, 26 Dec 2015 20:51:22 -0500 Subject: [PATCH] introducing templating! #7 customPosts can now be displayed #135 --- dist/index.js | 7 +++ dist/templates/customPost-example.html | 3 + dist/templates/customPosts-example.html | 7 +++ dist/templates/index.js | 8 +++ lib/abstract/AbstractItem.js | 1 + lib/abstract/AbstractItemService.js | 15 ++--- lib/abstract/AbstractListService.js | 6 +- lib/bookmark/bookmark.html | 2 +- lib/cordova/cordova.pushNotifications.js | 2 +- lib/customPosts/customPost.controller.js | 1 + lib/customPosts/customPost.html | 2 +- lib/customPosts/customPosts.controller.js | 1 + lib/customPosts/customPosts.html | 2 +- .../directives/customPost/index.js | 27 +++++++++ .../directives/customPosts/index.js | 27 +++++++++ lib/customPosts/index.js | 4 ++ lib/directives/posts/posts.html | 2 +- lib/index.coffee | 5 +- lib/pages/config.js | 4 +- lib/pages/page.controller.js | 1 - lib/post/post.config.coffee | 10 ---- lib/post/post.controller.coffee | 19 ------ lib/post/post.html | 7 --- lib/post/post.module.coffee | 5 -- lib/post/post.service.coffee | 59 ------------------- lib/posts/config.js | 25 +++++--- lib/posts/index.js | 12 ++-- lib/posts/post.controller.js | 12 ++++ lib/posts/post.service.js | 52 ++++++++++++++++ .../{controller.js => posts.controller.js} | 0 lib/posts/{service.js => posts.service.js} | 0 lib/taxonomies/config.js | 2 +- lib/templates/index.js | 10 ++++ .../page.html => templates/module-page.html} | 2 +- .../module-pages.html} | 0 lib/templates/module-post.html | 8 +++ .../module-posts.html} | 0 package.json | 1 + scripts/install.js | 56 +++++------------- 39 files changed, 234 insertions(+), 173 deletions(-) create mode 100644 dist/index.js create mode 100644 dist/templates/customPost-example.html create mode 100644 dist/templates/customPosts-example.html create mode 100644 dist/templates/index.js create mode 100644 lib/customPosts/directives/customPost/index.js create mode 100644 lib/customPosts/directives/customPosts/index.js delete mode 100644 lib/post/post.config.coffee delete mode 100644 lib/post/post.controller.coffee delete mode 100644 lib/post/post.html delete mode 100644 lib/post/post.module.coffee delete mode 100644 lib/post/post.service.coffee create mode 100644 lib/posts/post.controller.js create mode 100644 lib/posts/post.service.js rename lib/posts/{controller.js => posts.controller.js} (100%) rename lib/posts/{service.js => posts.service.js} (100%) create mode 100644 lib/templates/index.js rename lib/{pages/page.html => templates/module-page.html} (82%) rename lib/{pages/pages.html => templates/module-pages.html} (100%) create mode 100644 lib/templates/module-post.html rename lib/{posts/index.html => templates/module-posts.html} (100%) diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 000000000..1d5d3ccc7 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,7 @@ +import templates from './templates/index.js'; + +let mod = angular.module('wordpress-hybrid-client.overwriteModule', [ + templates +]); + +export default mod = mod.name; diff --git a/dist/templates/customPost-example.html b/dist/templates/customPost-example.html new file mode 100644 index 000000000..012c0ef8b --- /dev/null +++ b/dist/templates/customPost-example.html @@ -0,0 +1,3 @@ +
+

+
diff --git a/dist/templates/customPosts-example.html b/dist/templates/customPosts-example.html new file mode 100644 index 000000000..e05ec0e73 --- /dev/null +++ b/dist/templates/customPosts-example.html @@ -0,0 +1,7 @@ +
+ +
diff --git a/dist/templates/index.js b/dist/templates/index.js new file mode 100644 index 000000000..f87299c22 --- /dev/null +++ b/dist/templates/index.js @@ -0,0 +1,8 @@ +let mod = angular.module('wordpress-hybrid-client.overwriteTemplates', []); + +mod.run(($templateCache) => { + $templateCache.put('customPost/example.html', require('!html!./customPost-example.html')); + $templateCache.put('customPosts/example.html', require('!html!./customPosts-example.html')) +}); + +export default mod = mod.name; diff --git a/lib/abstract/AbstractItem.js b/lib/abstract/AbstractItem.js index 63b5698bf..ece19219d 100644 --- a/lib/abstract/AbstractItem.js +++ b/lib/abstract/AbstractItem.js @@ -29,6 +29,7 @@ export default class { if (!this.$stateParams.id){ return this.$q.reject(); } + console.log('this.service', this.service) return this.service.get(this.$stateParams.id, angular.merge(this.getQuery(), _.get(this.config, `[${this.type}].query`) || {})).then((response) => { self.item = response.data; }); diff --git a/lib/abstract/AbstractItemService.js b/lib/abstract/AbstractItemService.js index 450dd334e..3a31b109e 100644 --- a/lib/abstract/AbstractItemService.js +++ b/lib/abstract/AbstractItemService.js @@ -8,19 +8,20 @@ export default class extends AbstractList { super($injector); } - getHttpPromise(id) { - return this.service.get(id); + getHttpPromise(id, query) { + return this.service.get(id, query); } - get(id) { + get(id, query) { + let queryString = JSON.stringify(query); let deferred = this.$q.defer(); - let hash = md5(this.config.api.baseUrl + id); - let itemCache = this.getCache().get('item-' + hash); + let hash = md5(`this.config.api.baseUrl${id}${queryString}`); + let itemCache = this.getCache().get(`item-${hash}`); if (itemCache) { deferred.resolve(itemCache); } else { - this.getHttpPromise(id).then((response) => { - this.getCache().put('item-' + hash, response); + this.getHttpPromise(id, query).then((response) => { + this.getCache().put(`item-${hash}`, response); deferred.resolve(response); }) .catch((error) => { diff --git a/lib/abstract/AbstractListService.js b/lib/abstract/AbstractListService.js index 070be1749..303bc5761 100644 --- a/lib/abstract/AbstractListService.js +++ b/lib/abstract/AbstractListService.js @@ -41,13 +41,13 @@ export default class { get(query) { let queryString = JSON.stringify(query); let deferred = this.$q.defer(); - let hash = md5(this.config.api.baseUrl + queryString); - let listCache = this.getCache().get('list-' + hash); + let hash = md5(`this.config.api.baseUrl${queryString}`); + let listCache = this.getCache().get(`list-${hash}`); if (listCache) { deferred.resolve(listCache); } else { this.getHttpPromise(query).then((response) => { - this.getCache().put('list-' + hash, response); + this.getCache().put(`list-${hash}`, response); deferred.resolve(response); }) .catch((error) => { diff --git a/lib/bookmark/bookmark.html b/lib/bookmark/bookmark.html index 6cdc82265..eea1f8529 100644 --- a/lib/bookmark/bookmark.html +++ b/lib/bookmark/bookmark.html @@ -4,7 +4,7 @@
-
+

{{post.bookmarked | amTimeAgo}}