Skip to content

Commit

Permalink
Moved to Grunt
Browse files Browse the repository at this point in the history
- Online build tool
- Deeper modularity
  • Loading branch information
dimsemenov committed Mar 4, 2013
1 parent cd0caa7 commit f5dff3d
Show file tree
Hide file tree
Showing 54 changed files with 24,953 additions and 1,357 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Gemfile.lock
test/dest
*.gem
pkg/
*.swp
*~
_site/
.bundle/
.DS_Store
bbin/
sftp-config*
_site
.htaccess
private-*
__article/
node_modules
dist/
_production
all.min.css
.sublime-*
202 changes: 202 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
/**
*
* Run 'grunt' to generate JS and CSS in folder 'dist' and site in folder '_site'
*
* Run `grunt production` to generate production site in folder '_production_site'
*
* Run 'grunt watch' to automatically regenerate '_site' when you change files in 'src' or in 'website'
*
*/

module.exports = function(grunt) {

'use strict';

// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('magnific-popup.jquery.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// Task configuration.
clean: {
files: ['dist']
},
sass: {
dist: {
files: {
'dist/magnific-popup.css': 'src/css/main.scss'
}
}
},

jshint: {
all: ['Gruntfile.js', 'src/js/*.js'],
options: {
"curly": false,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"browser": true,

"predef": [
"jQuery",
"define",
"module",
"console",
"mfp",
"$"
]
}

},


mfpbuild: {
all: {
src: [
'inline',
'ajax',
'image',
'iframe',
'gallery'
],
basePath: 'src/js/',
dest: 'dist/jquery.magnific-popup.js',
banner: '<%= banner %>'
}
},
jekyll: {
dev: {
src: 'website',
dest: '_site',
url: 'local'
},
production: {
src: 'website',
dest: '_production',
url: 'production'
}
},

copy: {
main: {
files: [
{src: ['dist/**'], dest: 'website/'}
]
},
dev: {
files: [
{src: ['dist/**'], dest: '_site/'}
]
}
},

uglify: {
my_target: {
files: {
'dist/jquery.magnific-popup.min.js': ['dist/jquery.magnific-popup.js']
}
}
},

watch: { // for development run 'grunt watch'
jekyll: {
files: ['website/**'],
tasks: ['jekyll:dev']
},
files: ['src/**'],
tasks: ['jshint', 'sass', 'mfpbuild', 'copy:dev']
},

cssmin: {
compress: {
files: {
"website/site-assets/all.min.css": ["website/site-assets/site.css", "website/dist/magnific-popup.css"]
}
}
}



});


// Makes Magnific Popup JS file.
// grunt mfpbuild --mfp-exclude=ajax,image
grunt.task.registerMultiTask('mfpbuild', 'Makes Magnific Popup JS file.', function() {

var files = this.data.src,
includes = grunt.option('mfp-exclude'),
basePath = this.data.basePath,
newContents = this.data.banner + ";(function($) {\n";


if(includes) {
includes = includes.split(/[\s,]+/); // 'a,b,c' => ['a','b','c']
var removeA = function (arr) {
var what, a = arguments, L = a.length, ax;
while (L > 1 && arr.length) {
what = a[--L];
while ((ax= arr.indexOf(what)) !== -1) {
arr.splice(ax, 1);
}
}
return arr;
};

includes.forEach(function( name ) {
if(name) {

grunt.log.writeln( 'removed "'+name +'"' );
files = removeA(files, name);
}
});
}

files.unshift('core');

grunt.log.writeln( 'Your build is made of:'+files );

files.forEach(function( name ) {
// Wrap each module with a pience of code to be able to exlude it, stolen for modernizr.com
newContents += "\n/*>>"+name+"*/\n";
newContents += grunt.file.read( basePath + name + '.js' ) + '\n';
newContents += "\n/*>>"+name+"*/\n";
});
newContents+= "})(window.jQuery || window.Zepto);";

grunt.file.write( this.data.dest, newContents );
});


// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');


grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-jekyll');
grunt.loadNpmTasks('grunt-contrib-cssmin');

// Default task.
grunt.registerTask('default', ['jshint', 'sass', 'mfpbuild', 'uglify', 'copy', 'jekyll:dev']);

grunt.registerTask('production', ['jshint', 'sass', 'mfpbuild', 'uglify', 'copy', 'cssmin', 'jekyll:production']);

};
50 changes: 46 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
# Magnific Popup plugin for jQuery and Zepto.js.
# Magnific Popup

**Script is not finished** yet and currently is under active development.
Fast, light and responsive lightbox plugin. More info on [official site](http://dimsemenov.com/plugins/magnific-popup/).

Plugin is licensed under MIT license with a small restriction - You can not use it in public WordPress plugin (because I will create it =), but you can use it in, for example, themes
Project is under development, please wait until I finish it.

Read more about it on [http://dimsemenov.com/plugins/magnific-popup/](http://dimsemenov.com/plugins/magnific-popup/).
## Build

Copy repository

git clone https://github.com/dimsemenov/Magnific-Popup.git

Install grunt globally (if you haven't yet)

npm install -g grunt-cli

Go inside Magnific Popup folder and install Node dependencies

cd Magnific-Popup && npm install

Make sure you that you have grunt installed by testing:

grunt -version


Compile Magnific Popup

grunt


- Generated Magnific Popup JS and CSS files are in folder `dist`.
- Magnific Popup source files are in folder `src`.
- Website (examples & documentation) source is is folder `website`.
- Generated website is in folder `_site`.



## Documentation
_(Coming soon)_

## Examples
_(Coming soon)_

## Release History
_(Nothing yet)_

## License

Script is MIT licensed and free and will always be kept this way. But has a small restriction from me - Please do not create public WordPress plugin based on it, because I will create it.
Loading

0 comments on commit f5dff3d

Please sign in to comment.