Skip to content

Commit

Permalink
Closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
shprink committed May 30, 2015
1 parent a3e31b8 commit 2fdde6f
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 29 deletions.
32 changes: 30 additions & 2 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": [{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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' })",
Expand Down
7 changes: 4 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -109,4 +110,4 @@ gulp.task('cordova:release', function() {
} else if (gutil.env.major) {
return incConfigXml('major');
}
})
})
15 changes: 15 additions & 0 deletions lib/cacheImg/cacheImg.directive.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/cacheImg/cacheImg.module.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions lib/cacheImg/cacheImg.run.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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!'
, ->
Expand Down
23 changes: 22 additions & 1 deletion lib/cacheImg/cacheImg.service.coffee
Original file line number Diff line number Diff line change
@@ -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) ->
Expand Down
4 changes: 2 additions & 2 deletions lib/directives/post/post.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="post padding">
<div class="item item-image" ng-if="::post.featured_image.is_image" ng-style="::{'background-image': 'url({{post.featured_image.attachment_meta.sizes.medium.url}})'}">
<div class="item item-image" ng-if="::post.featured_image.is_image" wphc-img-background-cache="{{post.featured_image.attachment_meta.sizes.medium.url}}">
<div class="img-border"></div>
<h1 class="item-title" ng-bind-html="::post.title"></h1>
</div>
Expand Down Expand Up @@ -49,4 +49,4 @@ <h2>{{post.author.name}}</h2>
{{'post.openInBrowser' | translate}}
</a>
</section>
</div>
</div>
4 changes: 2 additions & 2 deletions lib/directives/posts/posts.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div list="posts">
<div class="list card card-posts repeat-animation" ng-repeat="post in posts track by post.ID">
<div ui-sref="public.post(::{ id: post.ID })">
<div class="item item-image" ng-if="::post.featured_image.is_image" ng-style="::{'background-image': 'url({{post.featured_image.attachment_meta.sizes.medium.url}})'}">
<div class="item item-image" ng-if="::post.featured_image.is_image" wphc-img-background-cache="{{post.featured_image.attachment_meta.sizes.medium.url}}">
<div class="img-border"></div>
<h1 class="item-title" ng-bind-html="::post.title"></h1>
<!-- <img ng-src="{{post.featured_image.attachment_meta.sizes.medium.url}}"> -->
Expand Down Expand Up @@ -34,4 +34,4 @@ <h2>{{post.author.name}}</h2>
</button>
</div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions lib/directives/taxonomies/taxonomies.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a class="item item-icon-left repeat-animation" ng-class="::{'active disabled': isCurrentState(taxonomy.slug)}" ng-disabled="isCurrentState(taxonomy.slug)" ui-sref="public.taxonomies.slug({ slug: taxonomy.slug, term: term })" ng-repeat="taxonomy in taxonomies | orderBy:['count']:true "
ng-click="triggerOnClick(taxonomy)">
<h2>{{taxonomy.name}}</h2>
<small class="balanced">{{taxonomy.description}}</small>
<small class="balanced" bind-and-compile-html="::(taxonomy.description | prepLink)"></small>
<span class="badge badge-energized">{{taxonomy.count}}</span>
</a>
</div>
</div>
20 changes: 12 additions & 8 deletions lib/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down Expand Up @@ -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
Expand All @@ -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()
3 changes: 1 addition & 2 deletions lib/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
</head>

<body ng-strict-di ng-app="wordpress-hybrid-client">
<ion-nav-view></ion-nav-view>
{% for (var chunk in o.htmlWebpackPlugin.assets) { %}
Expand All @@ -24,4 +23,4 @@
</body>
<!-- {%= o.htmlWebpackPlugin.options.pkg.name + ' v' + o.htmlWebpackPlugin.options.pkg.version + ' size: ' + o.htmlWebpackPlugin.assets['main'].size + ' built on ' + new Date() %} -->

</html>
</html>
3 changes: 3 additions & 0 deletions lib/init/init.module.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = angular.module 'wordpress-hybrid-client.init', []

require "./init.service.coffee"
8 changes: 8 additions & 0 deletions lib/init/init.service.coffee
Original file line number Diff line number Diff line change
@@ -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!'
2 changes: 1 addition & 1 deletion lib/menu/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ <h1 class="title">{{main.appTitle}}</h1>
<i class="balanced {{::setting.icon}}"></i> {{setting.trans | translate}}
</ion-item>
</ion-list>
</ion-content>
</ion-content>
6 changes: 3 additions & 3 deletions lib/views/ion-menu.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ion-side-menus enable-menu-with-back-views="true">
<ion-side-menu-content>
<ion-side-menu-content ng-if="::appLoaded">
<ion-nav-bar class="bar-positive">
<ion-nav-back-button>
</ion-nav-back-button>
Expand All @@ -16,7 +16,7 @@
</ion-nav-bar>
<ion-nav-view name="content"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="left" expose-aside-when="{{main.exposeAsideWhen}}" ui-view="menu">
<ion-side-menu ng-if="::appLoaded" side="left" expose-aside-when="{{main.exposeAsideWhen}}" ui-view="menu">

</ion-side-menu>
</ion-side-menus>
</ion-side-menus>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@
"locator": "./engine/cordova-android-c0.6.1/"
}
]
}
}

0 comments on commit 2fdde6f

Please sign in to comment.