diff --git a/CONFIGURATION.md b/CONFIGURATION.md index a061b4775..bbd303751 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -65,7 +65,7 @@ The media query used to determine when to always display the left menu. "exposeAsideWhen": "(min-width:900px)" ``` -Settings configuration. +#### Settings configuration. ``` "settings": { @@ -80,7 +80,35 @@ Settings configuration. } ``` -Social buttons on the left side menu. You can add any social network account there. The icons must be FontAwesome's icons. +#### Wordpress entries + +For now the homepage is mandatory and cannot be a specific page. + +You can add to the list, a specific category, a specific tag or lists. + +``` +"wordpress": [{ + "trans": "menu.home", + "uiSref": "public.posts", + "icon": "icon ion-home" +},{ + "trans": "Your category", + "uiSref": "public.taxonomies.slug({ term: 'category', slug: 'your-category-slug' })", + "icon": "icon ion-iphone" +}, { + "trans": "menu.categories", + "uiSref": "public.taxonomies({ term: 'category' })", + "icon": "icon ion-folder" +}, { + "trans": "menu.tags", + "uiSref": "public.taxonomies({ term: 'post_tag' })", + "icon": "icon ion-pricetags" +}], +``` + +#### Social buttons + +You can add any social network account there. The icons must be from ionicons.com ``` "social": [{ diff --git a/README.md b/README.md index 71264729c..acf36fe87 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Always use four spaces, no tabs. This goes for any HTML, CSS, or Javascript. - [X] Params Page - [X] Language switch - [X] Accessibility (Post font size) -- [ ] Image cache ngImgCache +- [X] Image cache ngImgCache - [ ] Docker support for easier installation - [ ] Table of content for posts - [ ] Personnalized Logo diff --git a/config.json.dist b/config.json.dist index 92b6019cf..6d5fdf420 100644 --- a/config.json.dist +++ b/config.json.dist @@ -21,6 +21,10 @@ "trans": "menu.home", "uiSref": "public.posts", "icon": "icon ion-home" + },{ + "trans": "Your category", + "uiSref": "public.taxonomies.slug({ term: 'category', slug: 'your-category-slug' })", + "icon": "icon ion-iphone" }, { "trans": "menu.categories", "uiSref": "public.taxonomies({ term: 'category' })", diff --git a/gulpfile.js b/gulpfile.js index 2aa9757fd..f8b19327a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -39,9 +39,10 @@ gulp.task('build:prod', ['cleanWww', 'webpack:prod']); gulp.task('bump', require('gulp-cordova-bump')); gulp.task('cleanWww', function() { - return gulp.src(wwwPath, { + return gulp.src(path.join(wwwPath, '*'), { read: false - }).pipe(rimraf()); + }) + .pipe(rimraf()); }); gulp.task("webpack:dev", function(callback) { @@ -109,4 +110,4 @@ gulp.task('cordova:release', function() { } else if (gutil.env.major) { return incConfigXml('major'); } -}) \ No newline at end of file +}) diff --git a/lib/cacheImg/cacheImg.directive.coffee b/lib/cacheImg/cacheImg.directive.coffee index 0d06a6ea3..9a8c517dd 100644 --- a/lib/cacheImg/cacheImg.directive.coffee +++ b/lib/cacheImg/cacheImg.directive.coffee @@ -9,3 +9,18 @@ module.exports = angular.module 'wordpress-hybrid-client.cacheImg' else ImgCache.cacheFile src, -> ImgCache.useCachedFile el + .directive 'wphcImgBackgroundCache', -> + restrict: 'A' + link: (scope, el, attrs) -> + setBackgroundImage = (src) -> + el.css + 'background-image': "url('#{src}')" + + attrs.$observe 'wphcImgBackgroundCache', (src) -> + ImgCache.isCached src, (path, success) -> + if success + ImgCache.getCachedFileURL src, (src, srcCached)-> + setBackgroundImage srcCached + else + ImgCache.cacheFile src, -> + setBackgroundImage src diff --git a/lib/cacheImg/cacheImg.module.coffee b/lib/cacheImg/cacheImg.module.coffee index 469c8d2cd..e21ddb49e 100644 --- a/lib/cacheImg/cacheImg.module.coffee +++ b/lib/cacheImg/cacheImg.module.coffee @@ -4,4 +4,4 @@ module.exports = angular.module 'wordpress-hybrid-client.cacheImg', [] require "./cacheImg.directive.coffee" require "./cacheImg.service.coffee" -require "./cacheImg.run.coffee" +# require "./cacheImg.run.coffee" diff --git a/lib/cacheImg/cacheImg.run.coffee b/lib/cacheImg/cacheImg.run.coffee index 601fbb1d6..9acc8d67e 100644 --- a/lib/cacheImg/cacheImg.run.coffee +++ b/lib/cacheImg/cacheImg.run.coffee @@ -10,6 +10,7 @@ module.exports = angular.module 'wordpress-hybrid-client.cacheImg' ImgCache.options.skipURIencoding = $WPHCConfig.cache.img.skipURIencoding; $ionicPlatform.ready -> + $log.debug 'ImgCache initialising' ImgCache.init -> $log.debug 'ImgCache init: success!' , -> diff --git a/lib/cacheImg/cacheImg.service.coffee b/lib/cacheImg/cacheImg.service.coffee index 9a44528f9..4f8d26db0 100644 --- a/lib/cacheImg/cacheImg.service.coffee +++ b/lib/cacheImg/cacheImg.service.coffee @@ -1,5 +1,26 @@ module.exports = angular.module 'wordpress-hybrid-client.cacheImg' - .service 'CacheImages', ($q) -> + .service '$WPHCCacheImg', ($q, $WPHCConfig, $log) -> + initialised = false + init: -> + if initialised + return + deferred = $q.defer() + $log.debug 'ImgCache initialising' + 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; + ImgCache.init -> + $log.info 'ImgCache init: success!' + deferred.resolve() + , -> + $log.error 'ImgCache init: error! Check the log for errors' + deferred.reject() + deferred.promise checkCacheStatus: (src) -> deferred = $q.defer() ImgCache.isCached src, (path, success) -> diff --git a/lib/directives/post/post.html b/lib/directives/post/post.html index 666400e80..02c473b87 100644 --- a/lib/directives/post/post.html +++ b/lib/directives/post/post.html @@ -1,5 +1,5 @@
-
+

@@ -49,4 +49,4 @@

{{post.author.name}}

{{'post.openInBrowser' | translate}} -
\ No newline at end of file +
diff --git a/lib/directives/posts/posts.html b/lib/directives/posts/posts.html index 6f7419bc9..4c9c7e14f 100644 --- a/lib/directives/posts/posts.html +++ b/lib/directives/posts/posts.html @@ -1,7 +1,7 @@
-
+

@@ -34,4 +34,4 @@

{{post.author.name}}

-
\ No newline at end of file +
diff --git a/lib/directives/taxonomies/taxonomies.html b/lib/directives/taxonomies/taxonomies.html index 3a690c167..aaaf2824f 100644 --- a/lib/directives/taxonomies/taxonomies.html +++ b/lib/directives/taxonomies/taxonomies.html @@ -2,7 +2,7 @@

{{taxonomy.name}}

- {{taxonomy.description}} + {{taxonomy.count}}
-
\ No newline at end of file + diff --git a/lib/index.coffee b/lib/index.coffee index 599616374..fa2bcd54b 100644 --- a/lib/index.coffee +++ b/lib/index.coffee @@ -38,6 +38,7 @@ module.exports = app = angular.module 'wordpress-hybrid-client', [ require('./language/language.module').name require('./accessibility/accessibility.module').name require('./cacheImg/cacheImg.module').name + require('./init/init.module').name ] app.config ($stateProvider) -> @@ -140,7 +141,8 @@ require "./directives/href/href.coffee" ### RUN ### -app.run ($rootScope, $log, $WPHCConfig, $translate, $WPHCLanguage, $ionicPlatform, $WPHCAccessibility, $cordovaSplashscreen) -> +app.run ($rootScope, $log, $WPHCConfig, $translate, $WPHCLanguage, $ionicPlatform, $WPHCAccessibility, $cordovaSplashscreen, $WPHCInit) -> + $rootScope.appLoaded = undefined # handling debug events if $WPHCConfig.debugEnabled @@ -152,12 +154,14 @@ app.run ($rootScope, $log, $WPHCConfig, $translate, $WPHCLanguage, $ionicPlatfor $WPHCAccessibility.updateBodyClass() $ionicPlatform.ready () -> - # For web debug - if !ionic.Platform.isWebView() - $translate.use $WPHCLanguage.getLocale() - else - $cordovaSplashscreen.hide() + $WPHCInit.init().finally ()-> + $rootScope.appLoaded = true; + # For web debug + if !ionic.Platform.isWebView() + $translate.use $WPHCLanguage.getLocale() + else + $cordovaSplashscreen.hide() # Clean up appLoading - angular.element(document.querySelector 'html').removeClass 'app-loading' - angular.element(document.querySelector '#appLoaderWrapper').remove() + # angular.element(document.querySelector 'html').removeClass 'app-loading' + # angular.element(document.querySelector '#appLoaderWrapper').remove() diff --git a/lib/index.html b/lib/index.html index 7137ff8c8..a024d919b 100644 --- a/lib/index.html +++ b/lib/index.html @@ -15,7 +15,6 @@ - {% for (var chunk in o.htmlWebpackPlugin.assets) { %} @@ -24,4 +23,4 @@ - \ No newline at end of file + diff --git a/lib/init/init.module.coffee b/lib/init/init.module.coffee new file mode 100644 index 000000000..4d782d11f --- /dev/null +++ b/lib/init/init.module.coffee @@ -0,0 +1,3 @@ +module.exports = angular.module 'wordpress-hybrid-client.init', [] + +require "./init.service.coffee" diff --git a/lib/init/init.service.coffee b/lib/init/init.service.coffee new file mode 100644 index 000000000..751cf0bcd --- /dev/null +++ b/lib/init/init.service.coffee @@ -0,0 +1,8 @@ +module.exports = angular.module 'wordpress-hybrid-client.init' + .service '$WPHCInit', ($q, $WPHCConfig, $log, $WPHCCacheImg) -> + init: -> + promises = [] + promises.push $WPHCCacheImg.init() + $q.all promises + .then -> + $log.info 'Init: success!' diff --git a/lib/menu/menu.html b/lib/menu/menu.html index 5058c871f..2641d7422 100644 --- a/lib/menu/menu.html +++ b/lib/menu/menu.html @@ -19,4 +19,4 @@

{{main.appTitle}}

{{setting.trans | translate}} - \ No newline at end of file + diff --git a/lib/views/ion-menu.html b/lib/views/ion-menu.html index 374fe8577..6dca0da05 100644 --- a/lib/views/ion-menu.html +++ b/lib/views/ion-menu.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@ - + - \ No newline at end of file + diff --git a/package.json b/package.json index 78d2628b4..7cf87b1d1 100644 --- a/package.json +++ b/package.json @@ -107,4 +107,4 @@ "locator": "./engine/cordova-android-c0.6.1/" } ] -} \ No newline at end of file +}