Last active
February 21, 2016 09:39
-
-
Save seventhsense/deb36c7a66cf9dbbadf6 to your computer and use it in GitHub Desktop.
for electron development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp.Application extends Backbone.Marionette.Application | |
$(document).ready -> | |
app = new MyApp.Application | |
app.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "app name", | |
"description": "", | |
"main": "dist/main.js", | |
"authors": [ | |
"seventhsense <[email protected]>" | |
], | |
"license": "ISC", | |
"moduleType": [], | |
"homepage": "", | |
"ignore": [ | |
"**/.*", | |
"node_modules", | |
"bower_components", | |
"test", | |
"tests" | |
], | |
"dependencies": { | |
"jquery": "^2.2.0", | |
"backbone": "^1.2.3", | |
"backbone.marionette": "^2.4.4" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp = require 'gulp' | |
coffee = require 'gulp-coffee' | |
plumber = require 'gulp-plumber' | |
concat = require 'gulp-concat' | |
eco = require 'gulp-eco' | |
gutil = require 'gulp-util' | |
sass = require 'gulp-sass' | |
watch = require 'gulp-watch' | |
notify = require 'gulp-notify' | |
browserify = require 'browserify' | |
source = require 'vinyl-source-stream' | |
electron = require('electron-connect').server.create() | |
gulp.task 'templates', -> | |
gulp.src 'src/templates/**/*.eco' | |
.pipe(eco(basePath: 'src/templates')) | |
.pipe(concat('templates.js')) | |
.pipe(gulp.dest('tmp')) | |
.pipe notify 'templates.js done!!!', {onLast: true} | |
gulp.task 'vendor', -> | |
browserify | |
entries: ['src/coffee/namespace.coffee'] | |
extentions: ['.coffee'] | |
.bundle() | |
.on 'error', (err) -> | |
console.log err.toString() | |
@emit 'end' | |
.pipe source 'vendor.js' | |
.pipe gulp.dest 'tmp' | |
.pipe notify 'vendor.js done!!!', {onLast: true} | |
gulp.task 'app', -> | |
gulp.src [ | |
'src/coffee/application.coffee' | |
'src/coffee/models/**/*.coffee' | |
'src/coffee/collections/**/*.coffee' | |
'src/coffee/views/item_views/*.coffee' | |
'src/coffee/views/collection_views/*.coffee' | |
'src/coffee/views/*.coffee' | |
] | |
.pipe(plumber()) | |
.pipe(coffee()) | |
.pipe(concat('app.js')) | |
.pipe(gulp.dest('tmp')) | |
.pipe notify 'app.js done!!!', {onLast: true} | |
gulp.task 'concat',['templates', 'vendor', 'app'], -> | |
gulp.src ['tmp/vendor.js', 'tmp/templates.js', 'tmp/app.js' ] | |
.pipe(concat('index.js')) | |
.pipe(gulp.dest('dist')) | |
.pipe notify 'index.js done!!!', {onLast: true} | |
gulp.task 'main', -> | |
gulp.src 'src/main.coffee' | |
.pipe(plumber()) | |
.pipe(coffee()) | |
.pipe(gulp.dest('dist')) | |
.pipe notify 'main.js done!!!', {onLast: true} | |
gulp.task 'sass', -> | |
gulp.src 'src/fonts/*.*' | |
.pipe(gulp.dest('dist/fonts')) | |
gulp.src 'src/sass/index.scss' | |
.pipe(sass()) | |
.pipe(gulp.dest('dist/css')) | |
.pipe notify 'index.css done!!!', {onLast: true} | |
gulp.task 'html', -> | |
gulp.src 'src/index.html' | |
.pipe(gulp.dest('dist')) | |
.pipe notify 'index.html done!!!', {onLast: true} | |
gulp.task 'watch', -> | |
electron.start() | |
watch('src/sass/*.scss', (e)-> gulp.start 'sass') | |
watch('src/index.html', (e)-> gulp.start 'html') | |
watch('src/main.coffee', (e)-> gulp.start 'main') | |
watch(['src/coffee/**/*.coffee', 'src/templates/**/*.eco'], (e)-> gulp.start 'concat') | |
watch 'dist/main.js', electron.restart | |
watch ['dist/index.html', 'dist/index.js', 'dist/css/*.css'], electron.reload | |
gulp.task 'default', ['concat', 'main', 'sass', 'html'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### Usage | |
# wget this file | |
# sh init.sh | |
# change app name in package.json | |
# npm install | |
my_gist_url="https://gist.githubusercontent.com/seventhsense/deb36c7a66cf9dbbadf6/raw/9b43ef924dd6a6d58ca00519321d599ccde7b2e7/" | |
echo "${my_gist_url}gulpfile.coffee" | |
wget -N "${my_gist_url}gulpfile.coffee" | |
wget -N "${my_gist_url}package.json" | |
wget -N "${my_gist_url}bower.json" | |
wget -N "${my_gist_url}main.coffee" -P src/ | |
mkdir -pv dist src/coffee src/sass src/template | |
cd src/coffee | |
mkdir -v views models collections item_views collection_views | |
wget -N "${my_gist_url}namespace.coffee" | |
wget -N "${my_gist_url}application.coffee" | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{app, BrowserWindow} = require 'electron' | |
main_window = null | |
app.on 'window-all-closed', -> | |
app.quit() | |
app.on 'ready', -> | |
main_window = new BrowserWindow | |
width: 400 | |
height: 300 | |
main_window.loadURL('file://' + __dirname + '/index.html') | |
main_window.on 'closed', -> | |
main_window = null | |
main_window.webContents.openDevTools() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.jQuery = window.$ = require 'jquery' | |
window._ = require 'underscore' | |
window.Backbone = require 'backbone' | |
Backbone.Marionette = require 'backbone.marionette' | |
window.MyApp = | |
Views: {} | |
Collections: {} | |
Models: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "app name", | |
"version": "0.0.1", | |
"description": "", | |
"main": "dist/main.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"browserify": { | |
"transform": [ | |
"coffeeify", | |
"debowerify" | |
] | |
}, | |
"devDependencies": { | |
"browserify": "^13.0.0", | |
"coffee-script": "^1.10.0", | |
"coffeeify": "^2.0.1", | |
"debowerify": "^1.3.1", | |
"electron-connect": "^0.3.7", | |
"gulp": "^3.9.0", | |
"gulp-coffee": "^2.3.1", | |
"gulp-concat": "^2.6.0", | |
"gulp-eco": "0.0.2", | |
"gulp-notify": "^2.2.0", | |
"gulp-plumber": "^1.1.0", | |
"gulp-sass": "^2.1.1", | |
"gulp-util": "^3.0.7", | |
"gulp-watch": "^4.3.5", | |
"vinyl-source-stream": "^1.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment