Skip to content

Commit

Permalink
Merge pull request #2 from tuchong/v0.4.0
Browse files Browse the repository at this point in the history
v0.4.0 Feature Branch
  • Loading branch information
guo-yu committed Feb 28, 2015
2 parents 24019ee + 7c3ae27 commit 1e3f88c
Show file tree
Hide file tree
Showing 21 changed files with 456 additions and 562 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ $ bower install
$ npm run dev
```

确保在 Web 控制台启用 debug 模式:

```bash
$ debug.enable('tuchong-daily,tuchong-daily:*')
```

### 应用调试

#### 安装插件
Expand Down
2 changes: 0 additions & 2 deletions bin/build-js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

node_modules/.bin/uglifyjs \
src/javascript/app.js \
src/javascript/ui.js \
src/javascript/services/store.js \
src/javascript/services/share.js \
src/javascript/services/imageloader.js \
src/javascript/controllers/home.js \
src/javascript/controllers/collection.js \
--mangle \
--compress \
-o www/dist/javascript/tuchong.min.js \
Expand Down
2 changes: 1 addition & 1 deletion bin/watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ node_modules/.bin/rewatch \
src/less/*.less \
src/javascript/*.js \
src/javascript/**/*.js \
-c 'npm run build-less && npm run build-js'
-c 'npm run build-js'
14 changes: 11 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
"private": true,
"devDependencies": {
"avoscloud": "~0.1.2",
"ionic": "driftyco/ionic-bower#1.0.0-beta.13",
"debug": "[email protected]:visionmedia/debug.git",
"ionic": "driftyco/ionic-bower#master",
"angular-resource": "~1.3.2",
"ngCordova": "~0.1.7-alpha"
"ngCordova": "~0.1.7-alpha",
"mindb": "~0.0.4",
"blobimage": "~1.0.1",
"swiper": "~3.0.1"
},
"resolutions": {
"angular": "1.3.6",
"angular-animate": "1.3.6",
"angular-sanitize": "1.3.6",
"angular-ui-router": "0.2.13"
}
}
2 changes: 1 addition & 1 deletion config-sample.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.tuchong.daily" version="0.2.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="com.tuchong.daily" version="0.4.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>图虫日报</name>
<description>
图虫每日精选 - 图虫网是中国最专业的web2.0摄影社区,下属纪实、风光、人像、生态、黑白、器材、佳能、尼康、宾得等几十个专业摄影社区。海量的照片、相册和图博全部由摄影师共同管理和维护。
Expand Down
96 changes: 10 additions & 86 deletions src/javascript/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
;(function(angular, debug) {
;(function(window) {
'use strict';
var log;

if (!angular)
throw new Error('Angular.js is required');
if (debug)
log = debug('tuchong-daily:app');
var angular = window.angular;

angular
.module('tuchong-daily', [
Expand All @@ -18,6 +14,7 @@
.constant('API_SERVER', appConfigs.API_SERVER)
.constant('API_TOKEN_KEY', 'tuchong-daily-token')
.constant('TC_SERVER', 'http://tuchong.com/api/')
.constant('$ionicLoadingConfig', { template: '<ion-spinner icon="lines"></ion-spinner>' })
.config([
'$httpProvider',
'$stateProvider',
Expand All @@ -35,33 +32,17 @@
'$timeout',
'avoscloud',
'$cordovaDialogs',
'$ionicSlideBoxDelegate',
'$rootScope',
'$state',
init
]);

function init($ionicPlatform, $cordovaDevice, $cordovaNetwork, $cordovaPush, $timeout, avoscloud, $cordovaDialogs, $ionicSlideBoxDelegate, $rootScope, $state) {
// Clear reading history
if (localStorage.lastSlideIndexHome)
localStorage.removeItem('lastSlideIndexHome');

// Listen to page changing event,
// And jump to lastSlideIndex
$rootScope.$on('$stateChangeSuccess', stateChangeSuccess);

// When Push Received,
// Jump to single collection page
$rootScope.$on('pushNotificationReceived', pushNotificationReceived);

function init($ionicPlatform, $cordovaDevice, $cordovaNetwork, $cordovaPush, $timeout, avoscloud, $cordovaDialogs, $state) {
$ionicPlatform.ready(function() {
var device = $cordovaDevice.getDevice();
var newtork = $cordovaNetwork.getNetwork();

if (log) {
log(device);
log(newtork);
}
console.log(device);
console.log(newtork);

if (newtork !== 'wifi' && newtork !== 'Connection.WIFI') {
$cordovaDialogs.alert(
Expand All @@ -72,20 +53,20 @@
}

authPushService(device, function(installation){
if (log) log(installation);
console.log(installation);

avoscloud
.installations
.post(installation, syncInstallationSuccess, syncError);

// When sync device infomation success
function syncInstallationSuccess(result) {
if (log) log(result);
console.log(result);
}

// Ignore the error for tmp.
function syncError(err) {
if (log) log(err);
console.log(err);
}
});
});
Expand All @@ -100,7 +81,6 @@
$cordovaPush
.register(options)
.then(function(token) {
if (log) log('Push service signup success, token: %s', token);

var installation = {};

Expand All @@ -124,59 +104,13 @@

// Ignore the error for tmp.
function pushSignupError(err) {
if (log) log(err);

$cordovaDialogs.alert(
// '(¬_¬)ノ 请手动在 设置 > 通知 启用推送' + err.toString(), // message
err,
'获取推送权限失败...', // title,
'知道了' // button
)
}
}

function pushNotificationReceived(event, notification) {
if (notification.collectionId) {
$state.go('collection', {
id: notification.collectionId
});
return;
}

$cordovaDialogs.alert(
notification.alert, // message
'收到通知', // title,
'知道了' // button
)
}

// When stats changes success, Go to the latest slide index
function stateChangeSuccess(e, toState, toParams, fromState, fromParams) {
if (log) log('%s => %s', fromState.name || 'init', toState.name);

var isGoBackHome = toState.name === 'home' && fromState.name;
var isGoToCollection = fromState.name === 'home' && toState.name === 'collection';
var isBackToCollection = fromState.name === 'collection-single' && toState.name === 'collection';

if (!isGoBackHome && !isGoToCollection && !isBackToCollection) return;
if (isGoToCollection) return;

var gotoIndex = isGoBackHome ?
localStorage.lastSlideIndexHome :
localStorage.lastSlideIndexCollection;

if (!gotoIndex)
gotoIndex = 0;

gotoIndex = parseInt(gotoIndex);

if (log) log('Going back to %s', gotoIndex);

// Slide to last visited index.
$timeout(function(){
$ionicSlideBoxDelegate.slide(gotoIndex);
}, 300);
}
}

function config($httpProvider, $stateProvider, $urlRouterProvider, avoscloudProvider, API_TOKEN, API_TOKEN_KEY) {
Expand All @@ -195,19 +129,9 @@
templateUrl: 'templates/home.html',
controller: 'home'
})
.state('collection', {
url: '/collection/:id',
templateUrl: 'templates/collection.html',
controller: 'collection'
})
.state('collection-single', {
url: '/images?uri',
templateUrl: 'templates/single.html',
controller: 'collection-single'
})

// 404 Router
$urlRouterProvider.otherwise('/');
}

})(window.angular, window.debug);
})(this);
140 changes: 0 additions & 140 deletions src/javascript/controllers/collection.js

This file was deleted.

Loading

0 comments on commit 1e3f88c

Please sign in to comment.