diff --git a/firebase.json b/firebase.json
new file mode 100644
index 0000000..07f2be7
--- /dev/null
+++ b/firebase.json
@@ -0,0 +1,10 @@
+{
+ "firebase": "radiant-fire-882",
+ "public": ".",
+ "ignore": [
+ "firebase.json",
+ "**/.*",
+ "**/node_modules/**",
+ "**/src/**"
+ ]
+}
diff --git a/index.html b/index.html
index bae1534..89eca5a 100644
--- a/index.html
+++ b/index.html
@@ -2,12 +2,20 @@
- Vue.js HN Clone
-
-
+
+
+ Form utang-utang an
+
+
+
+
+
-
+
+
+
+
\ No newline at end of file
diff --git a/package.json b/package.json
index 22669e6..0acf348 100644
--- a/package.json
+++ b/package.json
@@ -23,8 +23,11 @@
"webpack": "^1.8.4"
},
"dependencies": {
+ "bootstrap": "^3.3.4",
+ "css-loader": "^0.14.4",
"director": "^1.2.8",
"firebase": "^2.2.4",
+ "imports-loader": "^0.6.4",
"vue": "^0.12.0-rc"
}
}
diff --git a/runserver.sh b/runserver.sh
new file mode 100755
index 0000000..db92673
--- /dev/null
+++ b/runserver.sh
@@ -0,0 +1 @@
+python -m SimpleHTTPServer 8000
diff --git a/src/app.vue b/src/app.vue
index 4f1a7be..b48e003 100644
--- a/src/app.vue
+++ b/src/app.vue
@@ -1,16 +1,6 @@
-
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index 92396c7..1053b2e 100644
--- a/src/main.js
+++ b/src/main.js
@@ -9,6 +9,14 @@ var router = new Router()
Vue.config.warnExpressionErrors = false
+router.on('/main/', function (page) {
+ app.view = 'main-view'
+})
+
+router.on('/login/', function (page) {
+ app.view = 'login-view'
+})
+
router.on('/news/:page', function (page) {
app.view = 'news-view'
app.params.page = +page
@@ -28,8 +36,8 @@ router.on('/item/:id', function (id) {
router.configure({
notfound: function () {
- router.setRoute('/news/1')
+ router.setRoute('/login/')
}
})
-router.init('/news/1')
\ No newline at end of file
+router.init('/login/')
\ No newline at end of file
diff --git a/src/store.js b/src/store.js
index cf656df..6158ab7 100644
--- a/src/store.js
+++ b/src/store.js
@@ -1,84 +1,129 @@
var Firebase = require('firebase')
-var api = new Firebase('https://hacker-news.firebaseio.com/v0')
-var storiesPerPage = 30
-var cachedStoryIds = []
-var cachedStories = {}
+var api = new Firebase('https://radiant-fire-882.firebaseio.com/utang')
var Emitter = require('events').EventEmitter
var store = module.exports = new Emitter()
+var login_uid = null
-/**
- * Subscribe to real time updates of the top 100 stories,
- * and cache the IDs locally.
- */
-api.child('topstories').on('value', function (snapshot) {
- cachedStoryIds = snapshot.val()
- store.emit('update')
-})
-
-/**
- * Fetch an item data with given id.
- *
- * @param {Number} id
- * @param {Function} cb(item)
- */
-
-store.fetchItem = function (id, cb) {
- if (cachedStories[id]) {
- cb(cachedStories[id])
- } else {
- api.child('item/' + id).once('value', function (snapshot) {
- var story = snapshot.val()
- cachedStories[id] = story
- cb(story)
- })
- }
+store.login = function(username , password , authHandler) {
+ api.authWithPassword({
+ email: username,
+ password: password
+ } , function(error , authData) {
+ if (error == null) {
+ login_uid = authData.uid
+ api.child('users').child(login_uid).update({
+ username: username,
+ lastLogin: Date()
+ })
+ api.child('users').child(login_uid).once('value' , function(s) {
+ var row = s.val()
+ if (row.balanceHutang == null) {
+ api.child('users').child(login_uid).update('balanceHutang').set(0)
+ }
+ })
+ }
+ authHandler(error , authData)
+ })
}
-/**
- * Fetch the given list of items.
- *
- * @param {Array} ids
- * @param {Function} cb(items)
- */
-
-store.fetchItems = function (ids, cb) {
- if (!ids || !ids.length) return cb([])
- var items = []
- ids.forEach(function (id) {
- store.fetchItem(id, addItem)
- })
- function addItem (item) {
- items.push(item)
- if (items.length >= ids.length) {
- cb(items)
+store.createUser = function(username , password , authHandler) {
+ api.createUser({
+ email: username,
+ password: password
+ } , function(error , authData) {
+ if (error == null) {
+ api.child('users').child(authData.uid).set({
+ username: username,
+ lastLogin: null,
+ balanceHutang: 0
+ })
}
- }
+ authHandler(error , authData)
+ })
}
-/**
- * Fetch items for the given page.
- *
- * @param {Number} page
- * @param {Function} cb(stories)
- */
+store.getAuth = function() {
+ return api.getAuth()
+}
-store.fetchItemsByPage = function (page, cb) {
- var start = (page - 1) * storiesPerPage
- var end = page * storiesPerPage
- var ids = cachedStoryIds.slice(start, end)
- store.fetchItems(ids, cb)
+store.logout = function() {
+ api.unauth()
}
-/**
- * Fetch a user data with given id.
- *
- * @param {Number} id
- * @param {Function} cb(user)
- */
+// /**
+// * Subscribe to real time updates of the top 100 stories,
+// * and cache the IDs locally.
+// */
-store.fetchUser = function (id, cb) {
- api.child('user/' + id).once('value', function (snapshot) {
- cb(snapshot.val())
- })
-}
\ No newline at end of file
+// // api.child('topstories').on('value', function (snapshot) {
+// // cachedStoryIds = snapshot.val()
+// // store.emit('update')
+// // })
+
+// /**
+// * Fetch an item data with given id.
+// *
+// * @param {Number} id
+// * @param {Function} cb(item)
+// */
+
+// store.fetchItem = function (id, cb) {
+// if (cachedStories[id]) {
+// cb(cachedStories[id])
+// } else {
+// api.child('item/' + id).once('value', function (snapshot) {
+// var story = snapshot.val()
+// cachedStories[id] = story
+// cb(story)
+// })
+// }
+// }
+
+// /**
+// * Fetch the given list of items.
+// *
+// * @param {Array} ids
+// * @param {Function} cb(items)
+// */
+
+// store.fetchItems = function (ids, cb) {
+// if (!ids || !ids.length) return cb([])
+// var items = []
+// ids.forEach(function (id) {
+// store.fetchItem(id, addItem)
+// })
+// function addItem (item) {
+// items.push(item)
+// if (items.length >= ids.length) {
+// cb(items)
+// }
+// }
+// }
+
+// /**
+// * Fetch items for the given page.
+// *
+// * @param {Number} page
+// * @param {Function} cb(stories)
+// */
+
+// store.fetchItemsByPage = function (page, cb) {
+// var start = (page - 1) * storiesPerPage
+// var end = page * storiesPerPage
+// var ids = cachedStoryIds.slice(start, end)
+// store.fetchItems(ids, cb)
+// }
+
+// /**
+// * Fetch a user data with given id.
+// *
+// * @param {Number} id
+// * @param {Function} cb(user)
+// */
+
+// store.fetchUser = function (id, cb) {
+// api.child('user/' + id).once('value', function (snapshot) {
+// cb(snapshot.val())
+// })
+// }
\ No newline at end of file
diff --git a/src/views/login-view.vue b/src/views/login-view.vue
new file mode 100644
index 0000000..80d40cb
--- /dev/null
+++ b/src/views/login-view.vue
@@ -0,0 +1,142 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/main-view.vue b/src/views/main-view.vue
new file mode 100644
index 0000000..da7167f
--- /dev/null
+++ b/src/views/main-view.vue
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/news-view.vue b/src/views/news-view.vue
index 258d4af..c501c50 100644
--- a/src/views/news-view.vue
+++ b/src/views/news-view.vue
@@ -10,6 +10,11 @@
more...
+
+
+ @
+
+