diff --git a/CONFIGURATION.md b/CONFIGURATION.md
index 42fcf962f..a061b4775 100644
--- a/CONFIGURATION.md
+++ b/CONFIGURATION.md
@@ -114,6 +114,15 @@ Social buttons on the left side menu. You can add any social network account the
"cacheFlushInterval": null,
"storageMode": "localStorage",
"verifyIntegrity": true
+},
+"img" :{
+ "localCacheFolder": "imgcache", /* name of the cache folder */
+ "useDataURI": false, /* use src="data:.."? otherwise will use src="filesystem:.." */
+ "chromeQuota": 10 * 1024 * 1024, /* allocated cache space : here 10MB */
+ "usePersistentCache": true, /* false = use temporary cache storage */
+ "cacheClearSize": 0, /* size in MB that triggers cache clear on init, 0 to disable */
+ "headers": {}, /* HTTP headers for the download requests -- e.g: headers: { 'Accept': 'application/jpg' } */
+ "skipURIencoding": false /* enable if URIs are already encoded (skips call to sanitizeURI) */
}
```
diff --git a/lib/cacheImg/cacheImg.directive.coffee b/lib/cacheImg/cacheImg.directive.coffee
new file mode 100644
index 000000000..0d06a6ea3
--- /dev/null
+++ b/lib/cacheImg/cacheImg.directive.coffee
@@ -0,0 +1,11 @@
+module.exports = angular.module 'wordpress-hybrid-client.cacheImg'
+ .directive 'wphcImgCache', ->
+ restrict: 'A'
+ link: (scope, el, attrs) ->
+ attrs.$observe 'ngSrc', (src) ->
+ ImgCache.isCached src, (path, success) ->
+ if success
+ ImgCache.useCachedFile el
+ else
+ ImgCache.cacheFile src, ->
+ ImgCache.useCachedFile el
diff --git a/lib/cacheImg/cacheImg.module.coffee b/lib/cacheImg/cacheImg.module.coffee
new file mode 100644
index 000000000..469c8d2cd
--- /dev/null
+++ b/lib/cacheImg/cacheImg.module.coffee
@@ -0,0 +1,7 @@
+require 'imgcache.js'
+
+module.exports = angular.module 'wordpress-hybrid-client.cacheImg', []
+
+require "./cacheImg.directive.coffee"
+require "./cacheImg.service.coffee"
+require "./cacheImg.run.coffee"
diff --git a/lib/cacheImg/cacheImg.run.coffee b/lib/cacheImg/cacheImg.run.coffee
new file mode 100644
index 000000000..601fbb1d6
--- /dev/null
+++ b/lib/cacheImg/cacheImg.run.coffee
@@ -0,0 +1,16 @@
+module.exports = angular.module 'wordpress-hybrid-client.cacheImg'
+ .run ($ionicPlatform, $log, $WPHCConfig) ->
+ ImgCache.options.debug = $WPHCConfig.debugEnabled
+ ImgCache.options.chromeQuota = $WPHCConfig.cache.img.chromeQuota;
+ ImgCache.options.localCacheFolder = $WPHCConfig.cache.img.localCacheFolder;
+ ImgCache.options.useDataURI = $WPHCConfig.cache.img.useDataURI;
+ ImgCache.options.usePersistentCache = $WPHCConfig.cache.img.usePersistentCache;
+ ImgCache.options.cacheClearSize = $WPHCConfig.cache.img.cacheClearSize;
+ ImgCache.options.headers = $WPHCConfig.cache.img.headers;
+ ImgCache.options.skipURIencoding = $WPHCConfig.cache.img.skipURIencoding;
+
+ $ionicPlatform.ready ->
+ ImgCache.init ->
+ $log.debug 'ImgCache init: success!'
+ , ->
+ $log.error 'ImgCache init: error! Check the log for errors'
diff --git a/lib/cacheImg/cacheImg.service.coffee b/lib/cacheImg/cacheImg.service.coffee
new file mode 100644
index 000000000..9a44528f9
--- /dev/null
+++ b/lib/cacheImg/cacheImg.service.coffee
@@ -0,0 +1,18 @@
+module.exports = angular.module 'wordpress-hybrid-client.cacheImg'
+ .service 'CacheImages', ($q) ->
+ checkCacheStatus: (src) ->
+ deferred = $q.defer()
+ ImgCache.isCached src, (path, success) ->
+ if success
+ deferred.resolve path
+ else
+ ImgCache.cacheFile src, ->
+ ImgCache.isCached src, (path, success) ->
+ deferred.resolve path
+ return
+ , deferred.reject
+ return
+ , deferred.reject
+ return
+ , deferred.reject
+ deferred.promise
diff --git a/lib/directives/post/post.html b/lib/directives/post/post.html
index 2b0d573a8..666400e80 100644
--- a/lib/directives/post/post.html
+++ b/lib/directives/post/post.html
@@ -21,7 +21,7 @@
-
+
{{post.author.name}}
{{post.date | date : format : timezone}}
diff --git a/lib/directives/posts/posts.html b/lib/directives/posts/posts.html
index c8876404d..6f7419bc9 100644
--- a/lib/directives/posts/posts.html
+++ b/lib/directives/posts/posts.html
@@ -10,7 +10,7 @@
-
+
{{post.author.name}}
{{post.date | date : format : timezone}}
diff --git a/lib/index.coffee b/lib/index.coffee
index 8c6458305..599616374 100644
--- a/lib/index.coffee
+++ b/lib/index.coffee
@@ -37,6 +37,7 @@ module.exports = app = angular.module 'wordpress-hybrid-client', [
require('./about/about.module').name
require('./language/language.module').name
require('./accessibility/accessibility.module').name
+ require('./cacheImg/cacheImg.module').name
]
app.config ($stateProvider) ->
diff --git a/package.json b/package.json
index f68033c32..78d2628b4 100644
--- a/package.json
+++ b/package.json
@@ -1,106 +1,110 @@
{
- "name": "wordpress-hybrid-client",
- "version": "1.0.0",
- "title": "wordpress-hybrid-client",
- "description": "AngularJS client using Ionic Framework and based on the json-rest-api plugin: https://wordpress.org/plugins/json-rest-api/ with CORS enabled.",
- "main": "index.js",
- "scripts": {
- "install": "bower install",
- "update": "bower update",
- "build": "sh ./release.sh",
- "devserver": "webpack-dev-server --port 9100 --progress",
- "dumpdev": "gulp build",
- "dumpprod": "gulp build:prod"
- },
- "keywords": [
- "wp-api",
- "angular",
- "angularjs",
- "rest",
- "restfull",
- "hybrid",
- "material design",
- "client"
- ],
- "author": "Julien Renaux ",
- "repository": {
- "type": "git",
- "url": "https://github.com/shprink/wordpress-hybrid-client"
- },
- "license": "MIT",
- "bugs": {
- "url": "https://github.com/shprink/wordpress-hybrid-client/issues"
- },
- "homepage": "https://github.com/shprink/wordpress-hybrid-client",
- "devDependencies": {
- "autoprefixer-loader": "^1.1.0",
- "clone": "^0.2.0",
- "coffee-loader": "^0.7.2",
- "coffee-script": "^1.8.0",
- "css-loader": "^0.9.1",
- "exports-loader": "^0.6.2",
- "expose-loader": "^0.6.0",
- "file-loader": "^0.8.1",
- "gulp": "^3.8.10",
- "gulp-bump": "^0.3.0",
- "gulp-cordova-bump": "^1.2.2",
- "gulp-filter": "^2.0.2",
- "gulp-git": "^1.2.3",
- "gulp-header": "^1.2.2",
- "gulp-minify-css": "^0.4.4",
- "gulp-rimraf": "^0.1.1",
- "gulp-tag-version": "^1.2.1",
- "gulp-util": "^3.0.1",
- "gulp-webpack": "^1.1.2",
- "gulp-xml-editor": "^2.2.1",
- "html-loader": "^0.2.3",
- "html-webpack-plugin": "^1.1.0",
- "json-loader": "^0.5.1",
- "markdown-loader": "^0.1.2",
- "ng-annotate": "^0.15.2",
- "ng-annotate-webpack-plugin": "^0.1.2",
- "path": "^0.4.9",
- "sass-loader": "^0.3.1",
- "semver": "^4.3.4",
- "style-loader": "^0.8.3",
- "util": "^0.10.3",
- "webpack": "^1.4.13",
- "xml2js": "^0.4.8"
- },
- "dependencies": {
- "MD5": "^1.2.1",
- "angular": "^1.3.0",
- "angular-animate": "^1.3.0",
- "angular-aria": "^1.3.0",
- "angular-cache": "^4.0.0",
- "angular-filter": "^0.5.4",
- "angular-memory-stats": "^1.0.0-rc4",
- "angular-moment": "^0.9.0",
- "angular-sanitize": "^1.3.0",
- "angular-translate": "^2.5.2",
- "angular-ui-router": "^0.2.13",
- "imagesloaded": "^3.1.8",
- "moment": "^2.9.0",
- "ng-cordova": "^0.1.12-alpha",
- "wp-api-angularjs": "^1.0.0-beta1"
- },
- "cordovaPlugins": [
- "https://github.com/danwilson/google-analytics-plugin.git",
- "com.google.playservices",
- "./engine/cordova-crosswalk-engine-c0.6.1",
- "org.apache.cordova.network-information",
- "org.apache.cordova.splashscreen",
- "com.ionic.keyboard",
- "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git",
- "https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git",
- "https://github.com/apache/cordova-plugin-statusbar.git",
- "org.apache.cordova.globalization",
- "org.apache.cordova.inappbrowser"
- ],
- "cordovaPlatforms": [
- {
- "platform": "android",
- "locator": "./engine/cordova-android-c0.6.1/"
- }
- ]
+ "name": "wordpress-hybrid-client",
+ "version": "1.0.0",
+ "title": "wordpress-hybrid-client",
+ "description": "AngularJS client using Ionic Framework and based on the json-rest-api plugin: https://wordpress.org/plugins/json-rest-api/ with CORS enabled.",
+ "main": "index.js",
+ "scripts": {
+ "install": "bower install",
+ "update": "bower update",
+ "build": "sh ./release.sh",
+ "devserver": "webpack-dev-server --port 9100 --progress",
+ "dumpdev": "gulp build",
+ "dumpprod": "gulp build:prod"
+ },
+ "keywords": [
+ "wp-api",
+ "angular",
+ "angularjs",
+ "rest",
+ "restfull",
+ "hybrid",
+ "material design",
+ "client"
+ ],
+ "author": "Julien Renaux ",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/shprink/wordpress-hybrid-client"
+ },
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/shprink/wordpress-hybrid-client/issues"
+ },
+ "homepage": "https://github.com/shprink/wordpress-hybrid-client",
+ "devDependencies": {
+ "autoprefixer-loader": "^1.1.0",
+ "clone": "^0.2.0",
+ "coffee-loader": "^0.7.2",
+ "coffee-script": "^1.8.0",
+ "css-loader": "^0.9.1",
+ "exports-loader": "^0.6.2",
+ "expose-loader": "^0.6.0",
+ "file-loader": "^0.8.1",
+ "gulp": "^3.8.10",
+ "gulp-bump": "^0.3.0",
+ "gulp-cordova-bump": "^1.2.2",
+ "gulp-filter": "^2.0.2",
+ "gulp-git": "^1.2.3",
+ "gulp-header": "^1.2.2",
+ "gulp-minify-css": "^0.4.4",
+ "gulp-rimraf": "^0.1.1",
+ "gulp-tag-version": "^1.2.1",
+ "gulp-util": "^3.0.1",
+ "gulp-webpack": "^1.1.2",
+ "gulp-xml-editor": "^2.2.1",
+ "html-loader": "^0.2.3",
+ "html-webpack-plugin": "^1.1.0",
+ "json-loader": "^0.5.1",
+ "markdown-loader": "^0.1.2",
+ "ng-annotate": "^0.15.2",
+ "ng-annotate-webpack-plugin": "^0.1.2",
+ "path": "^0.4.9",
+ "sass-loader": "^0.3.1",
+ "semver": "^4.3.4",
+ "style-loader": "^0.8.3",
+ "util": "^0.10.3",
+ "webpack": "^1.4.13",
+ "xml2js": "^0.4.8"
+ },
+ "dependencies": {
+ "MD5": "^1.2.1",
+ "angular": "^1.3.0",
+ "angular-animate": "^1.3.0",
+ "angular-aria": "^1.3.0",
+ "angular-cache": "^4.0.0",
+ "angular-filter": "^0.5.4",
+ "angular-memory-stats": "^1.0.0-rc4",
+ "angular-moment": "^0.9.0",
+ "angular-sanitize": "^1.3.0",
+ "angular-translate": "^2.5.2",
+ "angular-ui-router": "^0.2.13",
+ "imagesloaded": "^3.1.8",
+ "imgcache.js": "^1.0.0",
+ "moment": "^2.9.0",
+ "ng-cordova": "^0.1.12-alpha",
+ "wp-api-angularjs": "^1.0.0-beta1"
+ },
+ "cordovaPlugins": [
+ "https://github.com/danwilson/google-analytics-plugin.git",
+ "com.google.playservices",
+ "./engine/cordova-crosswalk-engine-c0.6.1",
+ "org.apache.cordova.network-information",
+ "org.apache.cordova.splashscreen",
+ "com.ionic.keyboard",
+ "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git",
+ "https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git",
+ "https://github.com/apache/cordova-plugin-statusbar.git",
+ "org.apache.cordova.globalization",
+ "org.apache.cordova.inappbrowser",
+ "org.apache.cordova.file-transfer",
+ "org.apache.cordova.file",
+ "org.apache.cordova.device"
+ ],
+ "cordovaPlatforms": [
+ {
+ "platform": "android",
+ "locator": "./engine/cordova-android-c0.6.1/"
+ }
+ ]
}
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
index 234011250..5448372be 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -44,6 +44,9 @@ module.exports = {
loaders: [{
test: /[\/]angular\.js$/,
loader: 'expose?angular!exports?window.angular'
+ }, {
+ test: /[\/]imgcache\.js$/,
+ loader: 'expose?ImgCache'
}, {
test: /[\/]ionic\.js$/,
loader: 'exports?ionic' // For non commonJs