From 2bb50a71caff167823377fa6468a6aca74661e15 Mon Sep 17 00:00:00 2001 From: nicco Date: Mon, 23 Feb 2015 17:29:09 +0100 Subject: [PATCH 1/8] support relative paths when npm module support relative paths when vue-page is used as an npm module --- README.md | 9 ++++++++- src/index.js | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0fe1147..4683e47 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ window.onload = (function () { keepAlive: true, cssTransitions: true, viewsPath: './views/', + require: require, routes: { '/a': 'a', '/b/:name': 'b' @@ -207,4 +208,10 @@ module.exports = { } ``` -This component declaration is comming directly from vue-webpack-example. \ No newline at end of file +This component declaration is comming directly from vue-webpack-example. + +If vue-page is used as a npm module the viewsPath will be relative to the vue-page module location. If you want viewsPath to be relative to the current file you can add the following attribute + +```javascript +require: require +``` \ No newline at end of file diff --git a/src/index.js b/src/index.js index 219bc6f..e80ad30 100644 --- a/src/index.js +++ b/src/index.js @@ -44,7 +44,8 @@ exports.install = function (Vue, args) { } if (args.viewsPath) { - var path = args.viewsPath + component + '/index.js'; + var path = args.viewsPath + component + '/index'; + var require = args.require ? args.require : require; Vue.component(component, require(path)); } From 4e4c70401f0785a58ed8b49aa49b1e6c573a5492 Mon Sep 17 00:00:00 2001 From: nicco Date: Mon, 23 Feb 2015 17:30:20 +0100 Subject: [PATCH 2/8] remove require attribute from snippet --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 4683e47..8d3e1d2 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,6 @@ window.onload = (function () { keepAlive: true, cssTransitions: true, viewsPath: './views/', - require: require, routes: { '/a': 'a', '/b/:name': 'b' From 239eb7379d92aa2a33093cfc7fc23573126ff8e7 Mon Sep 17 00:00:00 2001 From: nicco Date: Mon, 23 Feb 2015 17:50:37 +0100 Subject: [PATCH 3/8] bump dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f079fea..d436475 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "license": "MIT", "devDependencies": {}, "dependencies": { - "page": "^1.4.1" + "page": "^1.6.1" }, "repository": { "type": "git", From 8b1961db8ef75d91a3c731562c193405c1044438 Mon Sep 17 00:00:00 2001 From: Niccolo Perra Date: Sun, 1 Mar 2015 23:17:46 +0100 Subject: [PATCH 4/8] allow setting up methods for the main app --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index e80ad30..88e44b9 100644 --- a/src/index.js +++ b/src/index.js @@ -82,7 +82,9 @@ exports.install = function (Vue, args) { data: { currentView: null, context: null - } + }, + methods: args.methods + }); if (!args.cssTransitions) { From 033562d49b28311cccb58031d53793fa6b9fabcd Mon Sep 17 00:00:00 2001 From: nicco Date: Mon, 2 Mar 2015 12:35:27 +0100 Subject: [PATCH 5/8] add navigate method --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 88e44b9..5b1acf7 100644 --- a/src/index.js +++ b/src/index.js @@ -65,6 +65,9 @@ exports.install = function (Vue, args) { show: function (path) { page(path); + }, + navigate: function (path) { + page.redirect(path); } } }); @@ -82,8 +85,7 @@ exports.install = function (Vue, args) { data: { currentView: null, context: null - }, - methods: args.methods + } }); From 04f338e69b4bbbad2056df9b0ebf4923f0d97d5a Mon Sep 17 00:00:00 2001 From: nicco Date: Mon, 2 Mar 2015 12:46:15 +0100 Subject: [PATCH 6/8] prototype navigate method --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 5b1acf7..127dc72 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,9 @@ var page = require('page'); exports.install = function (Vue, args) { + Vue.prototype.$navigate: function (path) { + page.redirect(path); + }; var Router = Vue.extend({ created: function () { if (args.default) { @@ -65,9 +68,6 @@ exports.install = function (Vue, args) { show: function (path) { page(path); - }, - navigate: function (path) { - page.redirect(path); } } }); From 45388a56861943798ad3a641a6b6d91c2f9105fb Mon Sep 17 00:00:00 2001 From: nicco Date: Mon, 2 Mar 2015 12:49:14 +0100 Subject: [PATCH 7/8] fix typo --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 127dc72..323e2c5 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ var page = require('page'); exports.install = function (Vue, args) { - Vue.prototype.$navigate: function (path) { + Vue.prototype.$navigate = function (path) { page.redirect(path); }; var Router = Vue.extend({ From f78951aa357116278ca2ae5088414f2a739f55c1 Mon Sep 17 00:00:00 2001 From: nicco Date: Mon, 2 Mar 2015 13:17:06 +0100 Subject: [PATCH 8/8] support history --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 323e2c5..97835fc 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ var page = require('page'); exports.install = function (Vue, args) { Vue.prototype.$navigate = function (path) { - page.redirect(path); + page(path); }; var Router = Vue.extend({ created: function () {