Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
artur root authored and artur root committed Jan 15, 2016
0 parents commit 69cfec6
Show file tree
Hide file tree
Showing 180 changed files with 16,426 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.settings/
.project

private/
libs/
node_modules/
137 changes: 137 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
module.exports = function(grunt) {

var appPath = 'bundle',
buildPath = 'dist',
configPath = 'config/require-config.js';

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-mocha');

grunt.initConfig({
appDir: appPath,
builtDir: buildPath,
pkg: grunt.file.readJSON("package.json"),
requirejs:{
compile:{
options: {
mainConfigFile: '<%= appDir %>/' + configPath,
appDir: '<%= appDir %>',
dir: '<%= builtDir %>',
baseUrl: './',
name: 'main',
removeCombined: true,
findNestedDependencies: true,
keepBuildDir: true,
inlineText: true,
optimize: 'none'
//paths: { "jquery": "empty:" }, //try to exclude
}
}
},

jshint: {
all: [
'Gruntfile.js',
'<%= appDir %>/**/*.js',
]
},

uglify: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */'
},
build:{
files: {
'<%= builtDir %>/grapes.min.js': ['<%= builtDir %>/main.js']
}
}
},

sass: {
dist: {
files: [{
expand: true,
cwd: 'styles/scss',
src: ['**/*.scss'],
dest: 'styles/css',
ext: '.css'
}]
}
},

mocha: {
test: {
src: ['test/index.html'],
options: { log: true, },
},
},

connect: {
/*
app: {
options: {
port: 8001,
open: {
target: 'http://localhost:8001',
//appName: 'Firefox' // 'Google Chrome'
}
}
},
*/
test: {
options: {
open: {
target: 'http://localhost:8000/test',
}
}
}
},

watch: {
script: {
files: [ '<%= appDir %>/**/*.js' ],
tasks: ['jshint']
},
css: {
files: '**/*.scss',
tasks: ['sass']
},
test: {
files: [ 'test/specs/**/*.js' ],
tasks: ['mocha'],
options: { livereload: true }, //default port 35729
}
}

});

/**
* Need to copy require configs cause r.js will try to load them from the path indicated inside
* main.js file. This is the only way I have found to do it and only for the pleasure of using separate config
* requirejs file.
* */
grunt.registerTask('before-requirejs', function() {
//if(grunt.file.exists(buildPath))
//grunt.file.delete(buildPath);
grunt.file.mkdir(buildPath);
grunt.file.copy(appPath + '/' + configPath, buildPath + '/' + appPath + '/' + configPath);
});

grunt.registerTask('after-requirejs', function() {
//grunt.file.copy(buildPath + '/main.js', buildPath + '/main.min.js');
});

grunt.registerTask('dev', ['connect', 'watch']);

grunt.registerTask('test', ['mocha']);

grunt.registerTask('deploy', ['jshint', 'before-requirejs', 'requirejs', 'after-requirejs', 'uglify']);

grunt.registerTask('default', ['dev']);

};
27 changes: 27 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Grapes.js

Copyright (c) Artur Arseniev
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
- Neither the name "Grapes" nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# README #

This README would normally document whatever steps are necessary to get your application up and running.

### What is this repository for? ###

* Quick summary
* Version
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)

### How do I get set up? ###

* Summary of set up
* Configuration
* Dependencies
* Database configuration
* How to run tests
* Deployment instructions

### Contribution guidelines ###

* Writing tests
* Code review
* Other guidelines

### Who do I talk to? ###

* Repo owner or admin
* Other community or team contact
52 changes: 52 additions & 0 deletions bundle/asset_manager/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
define(function () {
return {

// Style prefix
stylePrefix : 'am-',

// Default assets
assets : [],

// Indicates which storage to use. Available: local | remote
storageType : 'local',

// The name that will be used to identify assets inside storage.
// If empty will be used: prefix + 'assets'
storageName : 'assets',

// Where store remote assets
urlStore : 'http://localhost/assets/store',

// Where fetch remote assets
urlLoad : 'http://localhost/assets/load',

// Custom parameters to pass with set request
paramsStore : {},

// Custom parameters to pass with get request
paramsLoad : {},

// Callback before request
beforeSend : function(jqXHR,settings){},

// Callback after request
onComplete : function(jqXHR,status){},

// Url where uploads will be send
urlUpload : 'http://localhost/assets/upload',

// Text on upload input
uploadText : 'Drop files here or click to upload',

// Disable upload input
disableUpload : false,

// Store assets data where the new one is added or deleted
storeOnChange : true,

// It could be useful avoid to send other requests, for saving assets,
// after each upload because the uploader script has already done it
storeAfterUpload : false,

};
});
70 changes: 70 additions & 0 deletions bundle/asset_manager/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
define(function(require) {
/**
* @class AssetManager
* @param {Object} Configurations
*
* @return {Object}
* */
var AssetManager = function(config)
{
var c = config || {},
defaults = require('./config/config'),
Assets = require('./model/Assets'),
AssetsView = require('./view/AssetsView'),
FileUpload = require('./view/FileUploader');

for (var name in defaults) {
if (!(name in c))
c[name] = defaults[name];
}

this.assets = new Assets(c.assets);
var obj = {
collection : this.assets,
config : c,
};

this.am = new AssetsView(obj);
this.fu = new FileUpload(obj);
};

AssetManager.prototype = {

/**
* Get collection of assets
*
* @return {Object}
* */
getAssets : function(){
return this.assets;
},

/**
* Set new target
* @param {Object} m Model
*
* @return void
* */
setTarget : function(m){
this.am.collection.target = m;
},

/**
* Set callback after asset was selected
* @param {Object} f Callback function
*
* @return void
* */
onSelect : function(f){
this.am.collection.onSelect = f;
},

render : function(){
if(!this.rendered)
this.rendered = this.am.render().$el.add(this.fu.render().$el);
return this.rendered;
},
};

return AssetManager;
});
36 changes: 36 additions & 0 deletions bundle/asset_manager/model/Asset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
define(['backbone'],
function (Backbone) {
/**
* @class Asset
* */
return Backbone.Model.extend({

defaults: {
type: 'none', //Type of the asset
src: '', //Location
},

initialize: function(options) {
this.options = options || {};
},

/**
* Get filename of the asset
*
* @return {String}
* */
getFilename: function(){
return this.get('src').split('/').pop();
},

/**
* Get extension of the asset
*
* @return {String}
* */
getExtension: function(){
return this.getFilename().split('.').pop();
},

});
});
18 changes: 18 additions & 0 deletions bundle/asset_manager/model/AssetImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
define(['backbone', './Asset'],
function (Backbone, Asset) {
/**
* @class AssetImage
* */
return Asset.extend({

defaults: _.extend({},Asset.prototype.defaults,
{
type: 'image',
unitDim: 'px',
height: 0,
width: 0,
}
),

});
});
Loading

0 comments on commit 69cfec6

Please sign in to comment.