Skip to content
This repository was archived by the owner on Jan 4, 2019. It is now read-only.

Commit 3f468ba

Browse files
committed
feat: Initial commit
0 parents  commit 3f468ba

28 files changed

+1061
-0
lines changed

.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": ["es2015", "stage-2"],
3+
"plugins": ["transform-runtime"],
4+
"comments": false,
5+
"env": {
6+
"test": {
7+
"plugins": ["istanbul"]
8+
}
9+
}
10+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log
5+
debug.log
6+

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: node_js
2+
cache:
3+
directories:
4+
- node_modules
5+
notifications:
6+
email: false
7+
node_js:
8+
- '7'
9+
- '6'
10+
- '4'
11+
before_script:
12+
- npm prune
13+
after_success:
14+
- npm run semantic-release
15+
branches:
16+
except:
17+
- /^v\d+\.\d+\.\d+$/

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# How to contribute
2+
Thank you for checking out our project! :star2: :sunny: :deciduous_tree: :earth_americas:
3+
4+
Please visit the [contribution guide](https://github.com/SenseNet/sensenet/blob/master/CONTRIBUTING.md) in our main repository for advices on how to help the community.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Todo App example with SN7, Vue.js and Redux
2+
3+
[![Build status](https://img.shields.io/travis/SenseNet/sn-vue-redux-todo-app.svg?style=flat)](https://travis-ci.org/SenseNet/sn-vue-redux-todo-app)
4+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b09d599538fa49e9bb1cb92df4042ada)](https://www.codacy.com/app/herflis33/sn-vue-redux-todo-app?utm_source=github.com&utm_medium=referral&utm_content=SenseNet/sn-react-redux-todo-app&utm_campaign=Badge_Grade)
5+
[![License](https://img.shields.io/github/license/SenseNet/sn-vue-redux-todo-app.svg?style=flat)](https://github.com/SenseNet/sn-client-js/LICENSE.txt)
6+
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat)](https://github.com/semantic-release/semantic-release)
7+
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat)](http://commitizen.github.io/cz-cli/)
8+
9+
This example is simple todo app built with Vue+Redux upon Sense/Net ECM which has been prepared to demonstrate how to use the new Sense/Net ECM related libraries [sn-client-js](https://github.com/SenseNet/sn-client-js)
10+
and [sn-redux](https://github.com/SenseNet/sn-redux).
11+
12+
## Quick start
13+
14+
```
15+
$ git clone https://github.com/SenseNet/sn-vue-redux-todo-app.git
16+
$ cd sn-vue-redux-todo-app
17+
$ npm install
18+
$ npm run dev
19+
```
20+
21+
## Settings
22+
23+
To use this example you'll need a Sense/Net ECM portal. To connect the app with the portal set your site's url as the app's siteUrl
24+
25+
```
26+
import { SetSiteUrl } from 'sn-client-js';
27+
28+
SetSiteUrl('https://mysite.com');
29+
```
30+
31+
Go to your portal's Portal.setting (/Root/System/Settings/Portal.settings) and check the allowed origins. To get the app working you have to add the app's domain as an allowed origin so that the app can send requests to the
32+
portal and get or set data.
33+
34+
```
35+
{
36+
AllowedOriginDomains: [ "localhost:13505" ]
37+
}
38+
```
39+
40+
For further information about CORS in Sense/Net ECM check [this](http://wiki.sensenet.com/Cross-origin_resource_sharing) article.
41+
42+
The example app uses one of the built-in TaskList Content in the default Sense/Net ECM install (/workspaces/Project/budapestprojectworkspace/Tasks). If you removed this Content and its children tasks earlier
43+
or want to try with another TaskList change the value of the ```rootUrl``` variable in ```AddTodo.vue``` and ```App.vue``` to the chosen list's path.
44+
45+
The example app demonstrates not only how to fetching data but also Content creation and delete. The app doesn't provide authentication because of it's simplicity so you have to make some permission changes
46+
in your Sense/Net ECM portal to let Visitor users adding and removing tasks from the chosen parent list.
47+
If you are not familiar with Sense/Net's permission system check the following wiki articles:
48+
* [Sense/Net ECM Permission System](http://wiki.sensenet.com/Permission_System)
49+
* [How to set permissions on a content in Sense/Net ECM](http://wiki.sensenet.com/How_to_set_permissions_on_a_content)
50+
51+
## Related documents
52+
53+
* [sn-client-js API reference](http://www.sensenet.com/documentation/sn-client-js/index.html)
54+
* [sn-redux API reference](http://www.sensenet.com/documentation/sn-redux/index.html)
55+
* [Redux](https://github.com/reactjs/redux)
56+
* [Getting Started with Redux](https://egghead.io/courses/getting-started-with-redux)
57+
* [Vue.js](https://vuejs.org/)
58+
59+
## Build Setup
60+
61+
``` bash
62+
# install dependencies
63+
npm install
64+
65+
# serve with hot reload at localhost:8080
66+
npm run dev
67+
68+
# build for production with minification
69+
npm run build
70+
```
71+
72+
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

build/build.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// https://github.com/shelljs/shelljs
2+
require('./check-versions')()
3+
require('shelljs/global')
4+
env.NODE_ENV = 'production'
5+
6+
var path = require('path')
7+
var config = require('../config')
8+
var ora = require('ora')
9+
var webpack = require('webpack')
10+
var webpackConfig = require('./webpack.prod.conf')
11+
12+
console.log(
13+
' Tip:\n' +
14+
' Built files are meant to be served over an HTTP server.\n' +
15+
' Opening index.html over file:// won\'t work.\n'
16+
)
17+
18+
var spinner = ora('building for production...')
19+
spinner.start()
20+
21+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
22+
rm('-rf', assetsPath)
23+
mkdir('-p', assetsPath)
24+
cp('-R', 'static/*', assetsPath)
25+
26+
webpack(webpackConfig, function (err, stats) {
27+
spinner.stop()
28+
if (err) throw err
29+
process.stdout.write(stats.toString({
30+
colors: true,
31+
modules: false,
32+
children: false,
33+
chunks: false,
34+
chunkModules: false
35+
}) + '\n')
36+
})

build/check-versions.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var semver = require('semver')
2+
var chalk = require('chalk')
3+
var packageConfig = require('../package.json')
4+
var exec = function (cmd) {
5+
return require('child_process')
6+
.execSync(cmd).toString().trim()
7+
}
8+
9+
var versionRequirements = [
10+
{
11+
name: 'node',
12+
currentVersion: semver.clean(process.version),
13+
versionRequirement: packageConfig.engines.node
14+
},
15+
{
16+
name: 'npm',
17+
currentVersion: exec('npm --version'),
18+
versionRequirement: packageConfig.engines.npm
19+
}
20+
]
21+
22+
module.exports = function () {
23+
var warnings = []
24+
for (var i = 0; i < versionRequirements.length; i++) {
25+
var mod = versionRequirements[i]
26+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
27+
warnings.push(mod.name + ': ' +
28+
chalk.red(mod.currentVersion) + ' should be ' +
29+
chalk.green(mod.versionRequirement)
30+
)
31+
}
32+
}
33+
34+
if (warnings.length) {
35+
console.log('')
36+
console.log(chalk.yellow('To use this template, you must update following to modules:'))
37+
console.log()
38+
for (var i = 0; i < warnings.length; i++) {
39+
var warning = warnings[i]
40+
console.log(' ' + warning)
41+
}
42+
console.log()
43+
process.exit(1)
44+
}
45+
}

build/dev-client.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable */
2+
require('eventsource-polyfill')
3+
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4+
5+
hotClient.subscribe(function (event) {
6+
if (event.action === 'reload') {
7+
window.location.reload()
8+
}
9+
})

build/dev-server.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
require('./check-versions')()
2+
var config = require('../config')
3+
if (!process.env.NODE_ENV) process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
4+
var path = require('path')
5+
var express = require('express')
6+
var webpack = require('webpack')
7+
var opn = require('opn')
8+
var proxyMiddleware = require('http-proxy-middleware')
9+
var webpackConfig = require('./webpack.dev.conf')
10+
11+
// default port where dev server listens for incoming traffic
12+
var port = process.env.PORT || config.dev.port
13+
// Define HTTP proxies to your custom API backend
14+
// https://github.com/chimurai/http-proxy-middleware
15+
var proxyTable = config.dev.proxyTable
16+
17+
var app = express()
18+
var compiler = webpack(webpackConfig)
19+
20+
var devMiddleware = require('webpack-dev-middleware')(compiler, {
21+
publicPath: webpackConfig.output.publicPath,
22+
stats: {
23+
colors: true,
24+
chunks: false
25+
}
26+
})
27+
28+
var hotMiddleware = require('webpack-hot-middleware')(compiler)
29+
// force page reload when html-webpack-plugin template changes
30+
compiler.plugin('compilation', function (compilation) {
31+
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
32+
hotMiddleware.publish({ action: 'reload' })
33+
cb()
34+
})
35+
})
36+
37+
// proxy api requests
38+
Object.keys(proxyTable).forEach(function (context) {
39+
var options = proxyTable[context]
40+
if (typeof options === 'string') {
41+
options = { target: options }
42+
}
43+
app.use(proxyMiddleware(context, options))
44+
})
45+
46+
// handle fallback for HTML5 history API
47+
app.use(require('connect-history-api-fallback')())
48+
49+
// serve webpack bundle output
50+
app.use(devMiddleware)
51+
52+
// enable hot-reload and state-preserving
53+
// compilation error display
54+
app.use(hotMiddleware)
55+
56+
// serve pure static assets
57+
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
58+
app.use(staticPath, express.static('./static'))
59+
60+
module.exports = app.listen(port, function (err) {
61+
if (err) {
62+
console.log(err)
63+
return
64+
}
65+
var uri = 'http://localhost:' + port
66+
console.log('Listening at ' + uri + '\n')
67+
68+
// when env is testing, don't need open it
69+
if (process.env.NODE_ENV !== 'testing') {
70+
opn(uri)
71+
}
72+
})

build/utils.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
4+
5+
exports.assetsPath = function (_path) {
6+
var assetsSubDirectory = process.env.NODE_ENV === 'production'
7+
? config.build.assetsSubDirectory
8+
: config.dev.assetsSubDirectory
9+
return path.posix.join(assetsSubDirectory, _path)
10+
}
11+
12+
exports.cssLoaders = function (options) {
13+
options = options || {}
14+
// generate loader string to be used with extract text plugin
15+
function generateLoaders (loaders) {
16+
var sourceLoader = loaders.map(function (loader) {
17+
var extraParamChar
18+
if (/\?/.test(loader)) {
19+
loader = loader.replace(/\?/, '-loader?')
20+
extraParamChar = '&'
21+
} else {
22+
loader = loader + '-loader'
23+
extraParamChar = '?'
24+
}
25+
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
26+
}).join('!')
27+
28+
// Extract CSS when that option is specified
29+
// (which is the case during production build)
30+
if (options.extract) {
31+
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
32+
} else {
33+
return ['vue-style-loader', sourceLoader].join('!')
34+
}
35+
}
36+
37+
// http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
38+
return {
39+
css: generateLoaders(['css']),
40+
postcss: generateLoaders(['css']),
41+
less: generateLoaders(['css', 'less']),
42+
sass: generateLoaders(['css', 'sass?indentedSyntax']),
43+
scss: generateLoaders(['css', 'sass']),
44+
stylus: generateLoaders(['css', 'stylus']),
45+
styl: generateLoaders(['css', 'stylus'])
46+
}
47+
}
48+
49+
// Generate loaders for standalone style files (outside of .vue)
50+
exports.styleLoaders = function (options) {
51+
var output = []
52+
var loaders = exports.cssLoaders(options)
53+
for (var extension in loaders) {
54+
var loader = loaders[extension]
55+
output.push({
56+
test: new RegExp('\\.' + extension + '$'),
57+
loader: loader
58+
})
59+
}
60+
return output
61+
}

0 commit comments

Comments
 (0)