Skip to content

Commit 7f5241c

Browse files
committed
Initial structure + build process
0 parents  commit 7f5241c

14 files changed

+336
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# IDEs
2+
*.sublime-*
3+
.idea
4+
5+
# Built project
6+
dist
7+
8+
# Caches
9+
.sass-cache
10+
11+
# Test
12+
/selenium
13+
test-results-*.xml
14+
15+
# Logs
16+
logs
17+
*.log
18+
19+
# Runtime data
20+
pids
21+
*.pid
22+
*.seed
23+
.tmp
24+
25+
# Directory for instrumented libs generated by jscoverage/JSCover
26+
lib-cov
27+
28+
# Coverage directory used by tools like istanbul
29+
coverage
30+
31+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
32+
.grunt
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Dependency directories
38+
node_modules
39+
bower_components

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Content Snippets
2+
3+
A tool to enable in-page editing of elements, with an adaptable content backend. Drop this into a Web page, compose with a content adapter and credentials via a server framework of your choosing, and begin editing!
4+
5+
### Building/Watching
6+
7+
Install some global dependencies, then project dependencies:
8+
9+
```sh
10+
$ npm -g install bower gulp
11+
$ npm install
12+
$ bower install
13+
```
14+
15+
Now you can build or watch the project! Built and Compiled assets will be plopped into the `dist` directory.
16+
17+
```sh
18+
$ gulp build
19+
or
20+
$ gulp watch
21+
or, to minify assets:
22+
$ gulp compile
23+
````
24+
25+
### Configuration
26+
27+
Coming soon..

bower.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "content-snippets",
3+
"version": "0.0.1",
4+
"ignore": [
5+
"**/.*",
6+
"node_modules",
7+
"components"
8+
],
9+
"dependencies": {
10+
"riot": "~2.0.15",
11+
"q": "~1.3.0",
12+
"qajax": "git@github.com:cb-talent-development/qajax#master",
13+
"underscore": "1.8.3"
14+
},
15+
"resolutions": {
16+
"q": "~1.3.0"
17+
}
18+
}

gulpfile.js

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
'use strict';
2+
3+
var applicationName = 'content-snippets',
4+
basePaths = {
5+
src: 'src/app/',
6+
dest: 'dist/'
7+
},
8+
paths = {
9+
scripts: {
10+
src: basePaths.src,
11+
dest: basePaths.dest
12+
},
13+
styles: {
14+
src: basePaths.src + 'sass/',
15+
dest: basePaths.dest
16+
}
17+
},
18+
appFiles = {
19+
styles: paths.styles.src,
20+
scripts: paths.scripts.src + '**/*.js'
21+
},
22+
vendorFiles = {
23+
scripts: 'src/vendor/**/*.js'
24+
},
25+
destFilenames = {
26+
script: applicationName + '.js',
27+
style: applicationName + '.css',
28+
scriptMin: applicationName + '.min.js',
29+
styleMin: applicationName + '.min.css'
30+
},
31+
gulp = require('gulp'),
32+
es = require('event-stream'),
33+
bowerFiles = require('main-bower-files'),
34+
plugins = require("gulp-load-plugins")({
35+
pattern: ['gulp-*', 'gulp.*'],
36+
replaceString: /\bgulp[\-.]/
37+
});
38+
39+
var changeEvent = function (evt) {
40+
plugins.util.log('File', plugins.util.colors.cyan(evt.path.replace(new RegExp('/.*(?=/' + basePaths.src + ')/'), '')), 'was', plugins.util.colors.magenta(evt.type));
41+
};
42+
43+
var scriptsStream = function () {
44+
return gulp.src([appFiles.scripts, vendorFiles.scripts, '!**/tags/**']);
45+
};
46+
47+
var riotStream = function () {
48+
return gulp.src('**/tags/**')
49+
.pipe(plugins.riot());
50+
};
51+
52+
var bowerStream = function () {
53+
return gulp.src(bowerFiles({
54+
filter: '**/*.js'
55+
}));
56+
};
57+
58+
gulp.task('sass', function () {
59+
return plugins.rubySass(appFiles.styles)
60+
.on('error', function (err) {
61+
new plugins.util.PluginError('SASS', err, {showStack: true});
62+
})
63+
.pipe(plugins.concat(destFilenames.style))
64+
.pipe(plugins.autoprefixer('last 2 versions', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4', 'Firefox >= 4'))
65+
.pipe(plugins.size())
66+
.pipe(gulp.dest(paths.styles.dest));
67+
});
68+
69+
gulp.task('scripts', function () {
70+
return es.merge(scriptsStream(), riotStream(), bowerStream())
71+
.pipe(plugins.concat(destFilenames.script))
72+
.pipe(plugins.size())
73+
.pipe(gulp.dest(paths.scripts.dest));
74+
});
75+
76+
gulp.task('minify-css', ['sass'], function () {
77+
return gulp.src(paths.styles.dest + destFilenames.style)
78+
.pipe(plugins.combineMq())
79+
.pipe(plugins.minifyCss())
80+
.pipe(plugins.rename(destFilenames.styleMin))
81+
.pipe(gulp.dest(paths.styles.dest));
82+
});
83+
84+
gulp.task('minify-scripts', ['scripts'], function () {
85+
return gulp.src(paths.scripts.dest + destFilenames.script)
86+
.pipe(plugins.uglify())
87+
.pipe(plugins.rename(destFilenames.scriptMin))
88+
.pipe(gulp.dest(paths.scripts.dest));
89+
});
90+
91+
gulp.task('build', ['sass', 'scripts']);
92+
93+
gulp.task('watch', ['build'], function () {
94+
gulp.watch(appFiles.styles + '**/*.scss', ['sass']).on('change', function (evt) {
95+
changeEvent(evt);
96+
});
97+
gulp.watch([appFiles.scripts, vendorFiles.scripts], ['scripts']).on('change', function (evt) {
98+
changeEvent(evt);
99+
});
100+
});
101+
102+
gulp.task('compile', ['minify-scripts', 'minify-css']);
103+
104+
gulp.task('default', ['build']);

package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "content-snippets",
3+
"version": "0.0.1",
4+
"description": "A tool to enable in-page editing of elements, with an adaptable content backend",
5+
"author": "Alex Tharp <toastercup@gmail.com>",
6+
"license": "MIT",
7+
"repository": "git://github.com/toastercup/content-snippets.git",
8+
"keywords": [
9+
"editable",
10+
"snippet",
11+
"cms",
12+
"content"
13+
],
14+
"devDependencies": {
15+
"event-stream": "~3.3.0",
16+
"main-bower-files": "~2.7.0",
17+
"gulp": "~3.8.11",
18+
"gulp-load-plugins": "~0.10.0",
19+
"gulp-autoprefixer": "~2.2.0",
20+
"gulp-concat": "~2.5.2",
21+
"gulp-ruby-sass": "~1.0.5",
22+
"gulp-riot": "~0.2.14",
23+
"gulp-size": "~1.2.1",
24+
"gulp-util": "~3.0.4",
25+
"gulp-uglify": "~1.2.0",
26+
"gulp-combine-mq": "~0.4.0",
27+
"gulp-minify-css": "~1.1.1",
28+
"gulp-rename": "~1.2.2",
29+
"gulp-ignore": "~1.2.1"
30+
},
31+
"engines": {
32+
"node": ">=0.10.0"
33+
}
34+
}

src/app/constants.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(function(global) {
2+
'use strict';
3+
4+
global.ACTIONS = {
5+
};
6+
7+
global.settings = {
8+
API_ROUTES: {
9+
}
10+
};
11+
}(this));

src/app/main.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(function(global) {
2+
var stores = {
3+
};
4+
5+
for (var k in stores) {
6+
RiotControl.addStore(stores[k]);
7+
}
8+
9+
global.stores = stores;
10+
11+
}(this));

src/app/sass/main.scss

Whitespace-only changes.

src/app/stores/.keep

Whitespace-only changes.

src/app/tags/.keep

Whitespace-only changes.

src/vendor/api.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
(function(global) {
2+
'use strict';
3+
4+
var csrf = document.querySelector("meta[name='csrf-token']").attributes['content'].value;
5+
6+
function Api(baseUrl) {
7+
this.baseUrl = baseUrl || window.location.origin;
8+
}
9+
10+
Api.prototype._request = function(config) {
11+
config.headers = config.headers || {};
12+
13+
if (csrf) {
14+
config.headers['X-CSRF-Token'] = csrf;
15+
}
16+
17+
config.headers['Accept'] = 'application/json,text/html';
18+
19+
return Qajax(config)
20+
.then(Qajax.filterSuccess)
21+
.then(Qajax.toJSON);
22+
};
23+
24+
Api.prototype.get = function(path) {
25+
return this._request({url: this.baseUrl + path, method: 'GET'})
26+
};
27+
28+
Api.prototype.post = function(path, data) {
29+
return this._request({url: this.baseUrl + path, method: 'POST', data: data});
30+
};
31+
32+
Api.prototype.delete = function(path) {
33+
return Qajax({url: this.baseUrl + path, method: 'DELETE'}).then(Qajax.filterSuccess);
34+
};
35+
36+
Api.prototype.put = function(path, data) {
37+
return this._request({url: this.baseUrl + path, method: 'PUT', data: data});
38+
};
39+
40+
Api.prototype.patch = function(path, data) {
41+
return this._request({url: this.baseUrl + path, method: 'PATCH', data: data});
42+
};
43+
44+
global.Api = Api;
45+
46+
}(this));

src/vendor/fluxable-tag.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// https://github.com/nivardus/riot-fluxable-tag
2+
// Unregisters callbacks on tag unmount
3+
function fluxableTag(tag, dispatcher) {
4+
// callback lookup {fn: 'action'}
5+
var callbacks = {};
6+
7+
tag.on('unmount', function() {
8+
for (var fn in callbacks) {
9+
dispatcher.off(callbacks[fn], fn);
10+
}
11+
});
12+
13+
tag.when = function(action, fn) {
14+
fn = fn.bind(tag);
15+
dispatcher.on(action, fn);
16+
callbacks[fn] = action;
17+
};
18+
}

src/vendor/riotcontrol.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// https://github.com/jimsparkman/RiotControl
2+
var RiotControl = {
3+
_stores: [],
4+
addStore: function(store) {
5+
this._stores.push(store);
6+
}
7+
};
8+
9+
['on','one','off','trigger'].forEach(function(api){
10+
RiotControl[api] = function() {
11+
var args = [].slice.call(arguments);
12+
this._stores.forEach(function(el){
13+
el[api].apply(null, args);
14+
});
15+
};
16+
});

0 commit comments

Comments
 (0)