Hi KK, Hi Kimhegen.
Just like KK ask to share the code, i already make a live couch backend on my box, that generate json output and show it on android app with angularjs.
This is an old project, and use Intel XDK, so if you want to build it with a newer version of intel XDK, small adjusment maybe required.
Open :
- Code: Select all
www\app\js\controllers.js
- Code: Select all
var artistControllers = angular.module('artistControllers', ['ngAnimate']);
artistControllers.controller('ListController', ['$scope', '$http', function($scope, $http) {
$http.get('http://139.59.236.25/kampret/kamus.php?q=data.json').success(function(data) {
$scope.artists = data;
$scope.artistOrder = 'name';
});
}]);
artistControllers.controller('DetailsController', ['$scope', '$http','$routeParams', function($scope, $http, $routeParams) {
$http.get('http://139.59.236.25/kampret/kamus.php?q=data.json').success(function(data) {
$scope.artists = data;
$scope.whichItem = $routeParams.itemId;
if ($routeParams.itemId > 0) {
$scope.prevItem = Number($routeParams.itemId)-1;
} else {
$scope.prevItem = $scope.artists.length-1;
}
if ($routeParams.itemId < $scope.artists.length-1) {
$scope.nextItem = Number($routeParams.itemId)+1;
} else {
$scope.nextItem = 0;
}
});
}]);
You can see there, i get the couch generated json file from my box. And yes, with that url structure, i use custom route.
If you want to add more data, go here :
- Code: Select all
http://139.59.236.25/kampret/couch
Creds : demo-12345
Add your data, check the generated json, and refresh your app.
This is the code i use on couch :
- Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Isi Kamus' clonable='1' dynamic_folders='1' routable='1'>
<!-- define routes -->
<cms:route name='list_view' path='data{:format}' />
<cms:route_constraints
format='(\.json)'
/>
<!-- define editable -->
<cms:editable
name='mongondow'
label='Mongondow'
type='text'
order='1'
/>
<cms:editable
name='indonesia'
label='Indonesia'
type='text'
order='2'
/>
<cms:editable
name='cara_penggunaan'
label='Cara Penggunaan'
type='textarea'
order='3'
/>
</cms:template>
<cms:match_route debug='0' is_404='1' />
<cms:php>header('Access-Control-Allow-Origin: *');</cms:php>
<cms:if k_matched_route='list_view'>
<cms:content_type 'application/json'/>
[
<cms:pages>
{
"mongondow":"<cms:show mongondow />",
"indonesia":"<cms:show indonesia />",
"kategori":"<cms:show k_page_foldertitle />",
"cara":"<cms:show cara_penggunaan />"
}<cms:if "<cms:not k_paginated_bottom/>">,</cms:if>
</cms:pages>
]
</cms:if>
<?php COUCH::invoke(); ?>
Maybe if i have free time from my work, i will try to expanding the app. Just wanna try with extended user, so the user can sign in on the app, and add a data from app.
Thx!
Note
Btw KK, sorry for use paid license on that, cos the json generate the copyright of couch. Its just for educational purpose, not commercial, i can delete it if you want.
Update :
Here is the compiled apk. Install it on your android device. Tested on kitkat.
Link