Skip to content

Commit

Permalink
simplified extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Jun 16, 2015
1 parent da7a67c commit 6702153
Show file tree
Hide file tree
Showing 82 changed files with 303 additions and 114,221 deletions.
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"directory": "bower_components",
"directory": "lib",
"scripts": {
"postinstall": "grunt sync:bowerComponents"
}
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Bower Components
#################

bower_components
lib

#################
## Bower
Expand Down Expand Up @@ -50,9 +50,8 @@ node_modules
*.js.map
*.min.map
!Gruntfile.js
!lib/*.js
!src/js/*.js
!src/*/*/js/*.js
!src/lib/*.js
!src/*/*/lib/*.js
!src/examples/*.js
!src/extensions/*/dependencies.js

Expand Down
82 changes: 21 additions & 61 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ module.exports = function (grunt) {
refresh();

grunt.initConfig({

global:
{
bowerDir: './bower_components',
examplesDir: 'examples',
bowerDir: './lib',
examplesDir: './examples',
extensionsDir: './src/extensions',
minify: 'optimize=none',
modulesDir: './src/modules',
port: '8001',
themesDir: './src/themes'
},

pkg: packageJson,

ts: {
dev: {
src: [
Expand Down Expand Up @@ -80,15 +83,15 @@ module.exports = function (grunt) {
{
expand: true,
flatten: true,
cwd: 'src/js',
cwd: 'src/lib',
src: ['embed.js', 'easyXDM.min.js', 'easyxdm.swf', 'json2.min.js', 'require.js', 'l10n.js', 'base64.min.js'],
dest: '<%= global.buildDir %>/js/'
dest: '<%= global.buildDir %>/lib/'
},
// extension configuration files
{
expand: true,
src: ['src/extensions/**/config/*.config.js'],
dest: '<%= global.buildDir %>/js/',
dest: '<%= global.buildDir %>/lib/',
rename: function(dest, src) {

// get the extension name from the src string.
Expand All @@ -100,11 +103,11 @@ module.exports = function (grunt) {
return dest + extensionName + '.' + fileName;
}
},
// extension dependencies list
// extension dependencies
{
expand: true,
src: ['src/extensions/**/dependencies.js'],
dest: '<%= global.buildDir %>/js/',
dest: '<%= global.buildDir %>/lib/',
rename: function(dest, src) {

// get the extension name from the src string.
Expand All @@ -118,19 +121,19 @@ module.exports = function (grunt) {
{
expand: true,
flatten: true,
src: ['src/extensions/**/js/*'],
dest: '<%= global.buildDir %>/js/'
src: ['src/extensions/**/lib/*'],
dest: '<%= global.buildDir %>/lib/'
},
// anything in the module/js folders that isn't
// a js file. could be swfs or supporting files
// for a 3rd party library.
// for a 3rd party library
{
expand: true,
flatten: true,
src: ['src/modules/**/js/*.*', '!src/modules/**/js/*.js'],
dest: '<%= global.buildDir %>/js/'
src: ['src/modules/**/lib/*.*', '!src/modules/**/lib/*.js'],
dest: '<%= global.buildDir %>/lib/'
},
// l10n localisation files.
// l10n localisation files
{
expand: true,
flatten: false,
Expand All @@ -145,7 +148,7 @@ module.exports = function (grunt) {
return path;
}
},
// module html.
// module html
{
expand: true,
src: ['src/modules/**/html/*'],
Expand Down Expand Up @@ -254,54 +257,24 @@ module.exports = function (grunt) {
exec: {
// concatenate and compress with r.js
build: {
cmd: 'node lib/r.js -o baseUrl=src/ mainConfigFile=src/app.js name=app <%= global.minify %> out=<%= global.buildDir %>/js/app.js'
cmd: 'node lib/r.js/dist/r.js -o baseUrl=src/ mainConfigFile=src/app.js name=app <%= global.minify %> out=<%= global.buildDir %>/lib/app.js'
}
},

replace: {
// convert dependency files to use simplified commonjs wrapper.
dependenciesSimplify: {
src: ['src/extensions/**/dependencies.js'],
overwrite: true,
replacements: [{
from: 'define(["require", "exports"], function(require, exports)',
to: 'define(function()'
}]
},
// replace dependency paths to point to same /js directory.
dependenciesPaths: {
src: ['<%= global.buildDir %>/js/*dependencies.js'],
overwrite: true,
replacements: [{
from: /:.*(?:'|").*\/(.*)(?:'|")/g,
to: ': \'$1\''
}]
},

// ../../extensions/uv-seadragon-extension/dependencies
// becomes
// uv-seadragon-extension-dependencies
dependenciesExtension: {
src: ['<%= global.buildDir %>/js/app.js'],
overwrite: true,
replacements: [{
from: /..\/..\/extensions\/(.*)\/dependencies/g,
to: '$1-dependencies'
}]
},

html: {
src: ['<%= global.buildDir %>/app.html'],
overwrite: true,
replacements: [{
from: 'data-main="app"',
to: 'data-main="js/app"'
to: 'data-main="lib/app"'
}]
},
js: {
// replace window.DEBUG=true
// todo: use a compiler flag when available
src: ['<%= global.buildDir %>/js/app.js'],
src: ['<%= global.buildDir %>/lib/app.js'],
overwrite: true,
replacements: [{
from: /window.DEBUG.*=.*true;/g,
Expand Down Expand Up @@ -419,7 +392,6 @@ module.exports = function (grunt) {

grunt.task.run(
'ts:dev',
'replace:dependenciesSimplify',
'localise:apply',
'theme:create'
);
Expand All @@ -439,28 +411,16 @@ module.exports = function (grunt) {

grunt.task.run(
'ts:build',
'replace:dependenciesSimplify',
'localise:apply',
'clean:build',
'copy:build',
'exec:build',
'replace:html',
'replace:js',
'replace:dependenciesPaths',
'replace:dependenciesExtension',
'theme:create',
'theme:dist',
'replace:moduleimages',
'replace:themeimages'
);
});

// copy into examples folder
grunt.registerTask('examples', '', function() {

refresh();

grunt.task.run(
'replace:themeimages',
'replace:examples',
'clean:examples',
'copy:examples'
Expand Down
46 changes: 24 additions & 22 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
{
"name": "Universal Viewer",
"version": "1.2.2",
"repository": {
"type": "git",
"url": "git://github.com/UniversalViewer/universalviewer"
},
"authors": [
"edsilv <[email protected]>"
],
"ignore": [
"build",
"tests",
"Gruntfile.js",
"**/.*",
"node_modules",
"bower_components"
],
"dependencies": {
"uv-cy-GB-theme": "UniversalViewer/uv-cy-GB-theme",
"uv-en-GB-theme": "UniversalViewer/uv-en-GB-theme"
},
"devDependencies": {}
"name": "Universal Viewer",
"version": "1.2.3",
"repository": {
"type": "git",
"url": "git://github.com/UniversalViewer/universalviewer"
},
"authors": [
"edsilv <[email protected]>"
],
"ignore": [
"build",
"tests",
"Gruntfile.js",
"**/.*",
"node_modules",
"bower_components"
],
"dependencies": {
"uv-cy-GB-theme": "UniversalViewer/uv-cy-GB-theme",
"uv-en-GB-theme": "UniversalViewer/uv-en-GB-theme"
},
"devDependencies": {
"r.js": "~2.1.18"
}
}
Loading

0 comments on commit 6702153

Please sign in to comment.