<commit_before>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            build: {
                src: [
                    'bower_components/medium-editor/dist/js/medium-editor.js',
                    'bower_components/MediumButton/src/MediumButton.js',
                    'src/js/jQuery/**',
                    'src/js/lib/**',
                    'src/js/Application/Application.js',
                    'src/js/Application/**/*.js',
                    'src/js/app.js'
                ],
                dest: 'build/js/MagazineTool.js'
            },
        },
        jshint: {
            files: ['Gruntfile.js', 'src/**/*.js'],
            options: {
                // options here to override JSHint defaults
                globals: {
                    jQuery: true
                }
            }
        },
        jscs: {
            files: ['Gruntfile.js', 'src/**/*.js'],
            options: {
                config: 'jscs.json'
            }
        },
        uglify: {
            options: {
                sourceMap: true
            },
            build: {
                files: {
                    'build/js/bookmark.min.js': ['src/js/bookmark-dev.js']
                }
            },
            dist: {
                files: {
                    'dist/js/MagazineTool.min.js': ['<%= concat.build.dest %>'],
                    'dist/js/bookmark.min.js': ['src/js/bookmark-production.js']
                }
            }
        },
        sass: {
            build: {
                options: {
                    sourceMap: true,
                    outputStyle: 'expanded'
                },
                files: {
                    'build/css/app.css': 'src/scss/app.scss'
                }
            },
            dist: {
                options: {
                    sourceMap: true,
                    outputStyle: 'compressed'
                },
                files: {
                    'dist/css/app.min.css': 'src/scss/app.scss'
                }
            }
        },
        copy: {
            build: {
                files: [
                    {
                        expand: true,
                        cwd: 'src/',
                        src: ['tpl/**'],
                        dest: 'build/',
                    }
                ]
            },
            dist: {
                static_mappings: {
                    files: {
                        'dist/js/MagazineTool.js': ['<%= concat.build.dest %>'],
                        'dist/css/app.css': ['<%= concat.build.dest %>']
                    }
                },
                dynamic_mappings: {
                    files: [
                        {
                            expand: true,
                            cwd: 'src/',
                            src: ['tpl/**'],
                            dest: 'dist/',
                        }
                    ]
                }
            }
        },
        watch: {
            js: {
                files: ['<%= jshint.files %>'],
                tasks: ['jshint', 'jscs', 'concat:build', 'uglify:build', 'notify:concat']
            },
            tpl: {
                files: ['src/tpl/**'],
                tasks: ['copy:build']
            },
            sass: {
                files: ['src/scss/**/*.scss'],
                tasks: ['sass:build', 'notify:sass']
            }
        },
        notify: {
            concat: {
                options: {
                    title: 'Concat Complete',
                    message: 'JS files concatenated'
                }
            },
            uglify: {
                options: {
                    title: 'Uglify Complete',
                    message: 'JS files uglified'
                }
            },
            sass: {
                options: {
                    title: 'Sass Complete',
                    message: 'Sass files compiled'
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-notify');

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-jscs');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-concat');

    grunt.loadNpmTasks('grunt-sass');

    grunt.registerTask('default', ['jshint', 'jscs', 'concat:build', 'uglify:build', 'sass:build', 'copy:build', 'notify']);
    grunt.registerTask('dist', ['jshint', 'jscs', 'concat', 'uglify', 'sass', 'copy', 'notify']);
};
<commit_msg>Enable jscs auto fix<commit_after>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            build: {
                src: [
                    'bower_components/medium-editor/dist/js/medium-editor.js',
                    'bower_components/MediumButton/src/MediumButton.js',
                    'src/js/jQuery/**',
                    'src/js/lib/**',
                    'src/js/Application/Application.js',
                    'src/js/Application/**/*.js',
                    'src/js/app.js'
                ],
                dest: 'build/js/MagazineTool.js'
            },
        },
        jshint: {
            files: ['Gruntfile.js', 'src/**/*.js'],
            options: {
                // options here to override JSHint defaults
                globals: {
                    jQuery: true
                }
            }
        },
        jscs: {
            files: ['Gruntfile.js', 'src/**/*.js'],
            options: {
                config: 'jscs.json',
                fix: true
            }
        },
        uglify: {
            options: {
                sourceMap: true
            },
            build: {
                files: {
                    'build/js/bookmark.min.js': ['src/js/bookmark-dev.js']
                }
            },
            dist: {
                files: {
                    'dist/js/MagazineTool.min.js': ['<%= concat.build.dest %>'],
                    'dist/js/bookmark.min.js': ['src/js/bookmark-production.js']
                }
            }
        },
        sass: {
            build: {
                options: {
                    sourceMap: true,
                    outputStyle: 'expanded'
                },
                files: {
                    'build/css/app.css': 'src/scss/app.scss'
                }
            },
            dist: {
                options: {
                    sourceMap: true,
                    outputStyle: 'compressed'
                },
                files: {
                    'dist/css/app.min.css': 'src/scss/app.scss'
                }
            }
        },
        copy: {
            build: {
                files: [
                    {
                        expand: true,
                        cwd: 'src/',
                        src: ['tpl/**'],
                        dest: 'build/',
                    }
                ]
            },
            dist: {
                static_mappings: {
                    files: {
                        'dist/js/MagazineTool.js': ['<%= concat.build.dest %>'],
                        'dist/css/app.css': ['<%= concat.build.dest %>']
                    }
                },
                dynamic_mappings: {
                    files: [
                        {
                            expand: true,
                            cwd: 'src/',
                            src: ['tpl/**'],
                            dest: 'dist/',
                        }
                    ]
                }
            }
        },
        watch: {
            js: {
                files: ['<%= jshint.files %>'],
                tasks: ['jshint', 'jscs', 'concat:build', 'uglify:build', 'notify:concat']
            },
            tpl: {
                files: ['src/tpl/**'],
                tasks: ['copy:build']
            },
            sass: {
                files: ['src/scss/**/*.scss'],
                tasks: ['sass:build', 'notify:sass']
            }
        },
        notify: {
            concat: {
                options: {
                    title: 'Concat Complete',
                    message: 'JS files concatenated'
                }
            },
            uglify: {
                options: {
                    title: 'Uglify Complete',
                    message: 'JS files uglified'
                }
            },
            sass: {
                options: {
                    title: 'Sass Complete',
                    message: 'Sass files compiled'
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-notify');

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-jscs');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-concat');

    grunt.loadNpmTasks('grunt-sass');

    grunt.registerTask('default', ['jshint', 'jscs', 'concat:build', 'uglify:build', 'sass:build', 'copy:build', 'notify']);
    grunt.registerTask('dist', ['jshint', 'jscs', 'concat', 'uglify', 'sass', 'copy', 'notify']);
};
<|endoftext|>


<commit_before>// Generated on 2014-10-10 using generator-angular 0.9.8
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

	// Load grunt tasks automatically
	require('load-grunt-tasks')(grunt);

	// Time how long tasks take. Can help when optimizing build times
	require('time-grunt')(grunt);

	// Configurable paths for the application
	var appConfig = {
		app: require('./bower.json').appPath || 'app',
		dist: 'dist'
	};

	// Define the configuration for all the tasks
	grunt.initConfig({

		// Project settings
		yeoman: appConfig,

		// Watches files for changes and runs tasks based on the changed files
		watch: {
			jade: {
				files: ['<%= yeoman.app %>/**/*.jade'],
				tasks: ['jade'],
				options: {
					livereload: '<%= connect.options.livereload %>'
				}
			},
			js: {
				files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
				tasks: ['newer:jshint:all'],
				options: {
					livereload: '<%= connect.options.livereload %>'
				}
			},
			jsTest: {
				files: ['test/spec/{,*/}*.js'],
				tasks: ['newer:jshint:test', 'karma']
			},
			compass: {
				files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
				tasks: ['compass:server', 'autoprefixer']
			},
			gruntfile: {
				files: ['Gruntfile.js']
			},
			livereload: {
				options: {
					livereload: '<%= connect.options.livereload %>'
				},
				files: [
					'<%= yeoman.app %>/{,*/}*.html',
					'.tmp/styles/{,*/}*.css',
					'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
					'<%= yeoman.app %>/texts/*.json'
				]
			}
		},

		// The actual grunt server settings
		connect: {
			options: {
				port: 9000,
				// Change this to '0.0.0.0' to access the server from outside.
				hostname: 'localhost',
				livereload: 35729
			},
			livereload: {
				options: {
					open: true,
					middleware: function (connect) {
						return [
							require('grunt-connect-proxy/lib/utils').proxyRequest,
							connect.static('.tmp'),
							connect().use(
								'/bower_components',
								connect.static('./bower_components')
							),
							connect.static(appConfig.app)
						];
					}
				}
			},
			test: {
				options: {
					port: 9001,
					middleware: function (connect) {
						return [
							connect.static('.tmp'),
							connect.static('test'),
							connect().use(
								'/bower_components',
								connect.static('./bower_components')
							),
							connect.static(appConfig.app)
						];
					}
				}
			},
			dist: {
				options: {
					open: true,
					base: '<%= yeoman.dist %>'
				}
			},
			proxies: [
				{
					context: '/api',
					host: '127.0.0.1',
					port: 8000,
					https: false
				}

			]
		},

		// Make sure code styles are up to par and there are no obvious mistakes
		jshint: {
			options: {
				jshintrc: '.jshintrc',
				reporter: require('jshint-stylish')
			},
			all: {
				src: [
					'Gruntfile.js',
					'<%= yeoman.app %>/scripts/{,*/}*.js'
				]
			},
			test: {
				options: {
					jshintrc: 'test/.jshintrc'
				},
				src: ['test/spec/{,*/}*.js']
			}
		},

		// Empties folders to start fresh
		clean: {
			dist: {
				files: [
					{
						dot: true,
						src: [
							'.tmp',
							'<%= yeoman.dist %>/{,*/}*',
							'!<%= yeoman.dist %>/.git*'
						]
					}
				]
			},
			server: '.tmp'
		},

		// Add vendor prefixed styles
		autoprefixer: {
			options: {
				browsers: ['last 1 version']
			},
			dist: {
				files: [
					{
						expand: true,
						cwd: '.tmp/styles/',
						src: '{,*/}*.css',
						dest: '.tmp/styles/'
					}
				]
			}
		},

		// Compiles Sass to CSS and generates necessary files if requested
		compass: {
			options: {
				sassDir: '<%= yeoman.app %>/styles',
				cssDir: '.tmp/styles',
				generatedImagesDir: '.tmp/images/generated',
				imagesDir: '<%= yeoman.app %>/images',
				javascriptsDir: '<%= yeoman.app %>/scripts',
				fontsDir: '<%= yeoman.app %>/styles/fonts',
				importPath: './bower_components',
				httpImagesPath: '/images',
				httpGeneratedImagesPath: '/images/generated',
				httpFontsPath: '/styles/fonts',
				relativeAssets: false,
				assetCacheBuster: false,
				raw: 'Sass::Script::Number.precision = 10\n'
			},
			dist: {
				options: {
					generatedImagesDir: '<%= yeoman.dist %>/images/generated'
				}
			},
			server: {
				options: {
					debugInfo: true
				}
			}
		},

		// Renames files for browser caching purposes
		filerev: {
			dist: {
				src: [
					'<%= yeoman.dist %>/scripts/{,*/}*.js',
					'<%= yeoman.dist %>/styles/{,*/}*.css',
					'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
					'<%= yeoman.dist %>/styles/fonts/*'
				]
			}
		},

		// Reads HTML for usemin blocks to enable smart builds that automatically
		// concat, minify and revision files. Creates configurations in memory so
		// additional tasks can operate on them
		useminPrepare: {
			html: '.tmp/index.html',
			options: {
				dest: '<%= yeoman.dist %>',
				flow: {
					html: {
						steps: {
							js: ['concat'], // 'uglifyjs'],
							css: ['concat', 'cssmin']
						},
						post: {}
					}
				}
			}
		},

		// Performs rewrites based on filerev and the useminPrepare configuration
		usemin: {
			html: ['.tmp/{,*/}*.html'],
			css: ['.tmp/{,*/}*.css'],
			options: {
				assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/images']
			}
		},

		// The following *-min tasks will produce minified files in the dist folder
		// By default, your `index.html`'s <!-- Usemin block --> will take care of
		// minification. These next options are pre-configured if you do not wish
		// to use the Usemin blocks.
		// cssmin: {
		//   dist: {
		//     files: {
		//       '<%= yeoman.dist %>/styles/main.css': [
		//         '.tmp/styles/{,*/}*.css'
		//       ]
		//     }
		//   }
		// },
		// uglify: {
		//   dist: {
		//     files: {
		//       '<%= yeoman.dist %>/scripts/scripts.js': [
		//         '<%= yeoman.dist %>/scripts/scripts.js'
		//       ]
		//     }
		//   }
		// },
		// concat: {
		//   dist: {}
		// },

		concat: {
			options: {
				separator: ';',
			},
		},

		imagemin: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.app %>/images',
						src: '{,*/}*.{png,jpg,jpeg,gif}',
						dest: '<%= yeoman.dist %>/images'
					}
				]
			}
		},

		svgmin: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.app %>/images',
						src: '{,*/}*.svg',
						dest: '<%= yeoman.dist %>/images'
					}
				]
			}
		},

		htmlmin: {
			dist: {
				options: {
					collapseWhitespace: true,
					conservativeCollapse: true,
					collapseBooleanAttributes: true,
					removeCommentsFromCDATA: true,
					removeOptionalTags: true
				},
				files: [
					{
						expand: true,
						cwd: '.tmp',
						src: ['*.html', 'views/{,*/}*.html'],
						dest: '<%= yeoman.dist %>'
					}
				]
			}
		},

		// ng-annotate tries to make the code safe for minification automatically
		// by using the Angular long form for dependency injection.
		ngAnnotate: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '.tmp/concat/scripts',
						src: ['*.js', '!oldieshim.js'],
						dest: '.tmp/concat/scripts'
					}
				]
			}
		},

		// Replace Google CDN references
		cdnify: {
			dist: {
				html: ['<%= yeoman.dist %>/*.html']
			}
		},

		// Copies remaining files to places other tasks can use
		copy: {
			dist: {
				files: [
					{
						expand: true,
						dot: true,
						cwd: '<%= yeoman.app %>',
						dest: '<%= yeoman.dist %>',
						src: [
							'*.{ico,png,txt}',
							'.htaccess',
							'*.html',
							'views/{,*/}*.html',
							'images/{,*/}*.{webp}',
							'fonts/*',
							'sitemap.xml',
							'texts/*'
						]
					},
					{
						expand: true,
						cwd: '.tmp/images',
						dest: '<%= yeoman.dist %>/images',
						src: ['generated/*']
					},
					{
						expand: true,
						cwd: '.',
						src: 'bower_components/ultima/**/*',
						dest: '<%= yeoman.dist %>'
					}
				]
			},
			styles: {
				expand: true,
				cwd: '<%= yeoman.app %>/styles',
				dest: '.tmp/styles/',
				src: '{,*/}*.css'
			}
		},

		// Run some tasks in parallel to speed up the build process
		concurrent: {
			server: [
				'compass:server'
			],
			test: [
				'compass'
			],
			dist: [
				'compass:dist',
				'imagemin',
				'svgmin'
			]
		},

		// Test settings
		karma: {
			unit: {
				configFile: 'test/karma.conf.js',
				singleRun: true
			}
		},

		// Jade template engine
		jade: {
			dist: {
				options: {
					pretty: true
				},
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.app %>',
						dest: '.tmp',
						src: ['*.jade', 'views/**/*.jade'],
						ext: '.html'
					}
				]
			}
		},

		// Deploy via sftp
		// authentication information stored in .ftppass (not under version control)
		'sftp-deploy': {
			staging: {
				auth: {
					host: 'desec.io',
					port: 22,
					authKey: 'desec-io'
				},
				src: '<%= yeoman.dist %>',
				dest: '/var/www/webclient',
				exclusions: [],
				serverSep: '/',
				concurrency: 4,
				progress: true
			}
		},
	});

	grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
		if (target === 'dist') {
			return grunt.task.run(['build', 'connect:dist:keepalive']);
		}

		grunt.task.run([
			'clean:server',
			'configureProxies:server',
			'concurrent:server',
			'autoprefixer',
			'jade',
			'connect:livereload',
			'watch'
		]);
	});

	grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
		grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
		grunt.task.run(['serve:' + target]);
	});

	grunt.registerTask('test', [
		'clean:server',
		'concurrent:test',
		'autoprefixer',
		'jade',
		'connect:test',
		'karma'
	]);

	grunt.registerTask('build', [
		'clean:dist',
		'jade',
		'compass',
		'useminPrepare',
		'concat',
		'concurrent:dist',
		'autoprefixer',
		'ngAnnotate',
		'copy:dist',
		'cssmin',
		//'uglify',
		//'filerev',
		'usemin',
		'htmlmin'
	]);

	grunt.registerTask('deploy', [
		'build',
		'sftp-deploy'
	]);

	grunt.registerTask('default', [
		'newer:jshint',
		'test',
		'build'
	]);
};
<commit_msg>fix(): fixed concat separator that inserted ';' in between CSS files<commit_after>// Generated on 2014-10-10 using generator-angular 0.9.8
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

	// Load grunt tasks automatically
	require('load-grunt-tasks')(grunt);

	// Time how long tasks take. Can help when optimizing build times
	require('time-grunt')(grunt);

	// Configurable paths for the application
	var appConfig = {
		app: require('./bower.json').appPath || 'app',
		dist: 'dist'
	};

	// Define the configuration for all the tasks
	grunt.initConfig({

		// Project settings
		yeoman: appConfig,

		// Watches files for changes and runs tasks based on the changed files
		watch: {
			jade: {
				files: ['<%= yeoman.app %>/**/*.jade'],
				tasks: ['jade'],
				options: {
					livereload: '<%= connect.options.livereload %>'
				}
			},
			js: {
				files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
				tasks: ['newer:jshint:all'],
				options: {
					livereload: '<%= connect.options.livereload %>'
				}
			},
			jsTest: {
				files: ['test/spec/{,*/}*.js'],
				tasks: ['newer:jshint:test', 'karma']
			},
			compass: {
				files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
				tasks: ['compass:server', 'autoprefixer']
			},
			gruntfile: {
				files: ['Gruntfile.js']
			},
			livereload: {
				options: {
					livereload: '<%= connect.options.livereload %>'
				},
				files: [
					'<%= yeoman.app %>/{,*/}*.html',
					'.tmp/styles/{,*/}*.css',
					'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
					'<%= yeoman.app %>/texts/*.json'
				]
			}
		},

		// The actual grunt server settings
		connect: {
			options: {
				port: 9000,
				// Change this to '0.0.0.0' to access the server from outside.
				hostname: 'localhost',
				livereload: 35729
			},
			livereload: {
				options: {
					open: true,
					middleware: function (connect) {
						return [
							require('grunt-connect-proxy/lib/utils').proxyRequest,
							connect.static('.tmp'),
							connect().use(
								'/bower_components',
								connect.static('./bower_components')
							),
							connect.static(appConfig.app)
						];
					}
				}
			},
			test: {
				options: {
					port: 9001,
					middleware: function (connect) {
						return [
							connect.static('.tmp'),
							connect.static('test'),
							connect().use(
								'/bower_components',
								connect.static('./bower_components')
							),
							connect.static(appConfig.app)
						];
					}
				}
			},
			dist: {
				options: {
					open: true,
					base: '<%= yeoman.dist %>'
				}
			},
			proxies: [
				{
					context: '/api',
					host: '127.0.0.1',
					port: 8000,
					https: false
				}

			]
		},

		// Make sure code styles are up to par and there are no obvious mistakes
		jshint: {
			options: {
				jshintrc: '.jshintrc',
				reporter: require('jshint-stylish')
			},
			all: {
				src: [
					'Gruntfile.js',
					'<%= yeoman.app %>/scripts/{,*/}*.js'
				]
			},
			test: {
				options: {
					jshintrc: 'test/.jshintrc'
				},
				src: ['test/spec/{,*/}*.js']
			}
		},

		// Empties folders to start fresh
		clean: {
			dist: {
				files: [
					{
						dot: true,
						src: [
							'.tmp',
							'<%= yeoman.dist %>/{,*/}*',
							'!<%= yeoman.dist %>/.git*'
						]
					}
				]
			},
			server: '.tmp'
		},

		// Add vendor prefixed styles
		autoprefixer: {
			options: {
				browsers: ['last 1 version']
			},
			dist: {
				files: [
					{
						expand: true,
						cwd: '.tmp/styles/',
						src: '{,*/}*.css',
						dest: '.tmp/styles/'
					}
				]
			}
		},

		// Compiles Sass to CSS and generates necessary files if requested
		compass: {
			options: {
				sassDir: '<%= yeoman.app %>/styles',
				cssDir: '.tmp/styles',
				generatedImagesDir: '.tmp/images/generated',
				imagesDir: '<%= yeoman.app %>/images',
				javascriptsDir: '<%= yeoman.app %>/scripts',
				fontsDir: '<%= yeoman.app %>/styles/fonts',
				importPath: './bower_components',
				httpImagesPath: '/images',
				httpGeneratedImagesPath: '/images/generated',
				httpFontsPath: '/styles/fonts',
				relativeAssets: false,
				assetCacheBuster: false,
				raw: 'Sass::Script::Number.precision = 10\n'
			},
			dist: {
				options: {
					generatedImagesDir: '<%= yeoman.dist %>/images/generated'
				}
			},
			server: {
				options: {
					debugInfo: true
				}
			}
		},

		// Renames files for browser caching purposes
		filerev: {
			dist: {
				src: [
					'<%= yeoman.dist %>/scripts/{,*/}*.js',
					'<%= yeoman.dist %>/styles/{,*/}*.css',
					'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
					'<%= yeoman.dist %>/styles/fonts/*'
				]
			}
		},

		// Reads HTML for usemin blocks to enable smart builds that automatically
		// concat, minify and revision files. Creates configurations in memory so
		// additional tasks can operate on them
		useminPrepare: {
			html: '.tmp/index.html',
			options: {
				dest: '<%= yeoman.dist %>',
				flow: {
					html: {
						steps: {
							js: ['concat'], // 'uglifyjs'],
							css: ['concat', 'cssmin']
						},
						post: {}
					}
				}
			}
		},

		// Performs rewrites based on filerev and the useminPrepare configuration
		usemin: {
			html: ['.tmp/{,*/}*.html'],
			css: ['.tmp/{,*/}*.css'],
			options: {
				assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/images']
			}
		},

		// The following *-min tasks will produce minified files in the dist folder
		// By default, your `index.html`'s <!-- Usemin block --> will take care of
		// minification. These next options are pre-configured if you do not wish
		// to use the Usemin blocks.
		// cssmin: {
		//   dist: {
		//     files: {
		//       '<%= yeoman.dist %>/styles/main.css': [
		//         '.tmp/styles/{,*/}*.css'
		//       ]
		//     }
		//   }
		// },
		// uglify: {
		//   dist: {
		//     files: {
		//       '<%= yeoman.dist %>/scripts/scripts.js': [
		//         '<%= yeoman.dist %>/scripts/scripts.js'
		//       ]
		//     }
		//   }
		// },
		// concat: {
		//   dist: {}
		// },

		concat: {
			options: {
				separator: '',
				process: function(src, filepath) {
					return (filepath.length > 2 && filepath.substr(-2) == 'js' ? ';' : '') + src;
				},
			},
		},

		imagemin: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.app %>/images',
						src: '{,*/}*.{png,jpg,jpeg,gif}',
						dest: '<%= yeoman.dist %>/images'
					}
				]
			}
		},

		svgmin: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.app %>/images',
						src: '{,*/}*.svg',
						dest: '<%= yeoman.dist %>/images'
					}
				]
			}
		},

		htmlmin: {
			dist: {
				options: {
					collapseWhitespace: true,
					conservativeCollapse: true,
					collapseBooleanAttributes: true,
					removeCommentsFromCDATA: true,
					removeOptionalTags: true
				},
				files: [
					{
						expand: true,
						cwd: '.tmp',
						src: ['*.html', 'views/{,*/}*.html'],
						dest: '<%= yeoman.dist %>'
					}
				]
			}
		},

		// ng-annotate tries to make the code safe for minification automatically
		// by using the Angular long form for dependency injection.
		ngAnnotate: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '.tmp/concat/scripts',
						src: ['*.js', '!oldieshim.js'],
						dest: '.tmp/concat/scripts'
					}
				]
			}
		},

		// Replace Google CDN references
		cdnify: {
			dist: {
				html: ['<%= yeoman.dist %>/*.html']
			}
		},

		// Copies remaining files to places other tasks can use
		copy: {
			dist: {
				files: [
					{
						expand: true,
						dot: true,
						cwd: '<%= yeoman.app %>',
						dest: '<%= yeoman.dist %>',
						src: [
							'*.{ico,png,txt}',
							'.htaccess',
							'*.html',
							'views/{,*/}*.html',
							'images/{,*/}*.{webp}',
							'fonts/*',
							'sitemap.xml',
							'texts/*'
						]
					},
					{
						expand: true,
						cwd: '.tmp/images',
						dest: '<%= yeoman.dist %>/images',
						src: ['generated/*']
					},
					{
						expand: true,
						cwd: '.',
						src: 'bower_components/ultima/**/*',
						dest: '<%= yeoman.dist %>'
					}
				]
			},
			styles: {
				expand: true,
				cwd: '<%= yeoman.app %>/styles',
				dest: '.tmp/styles/',
				src: '{,*/}*.css'
			}
		},

		// Run some tasks in parallel to speed up the build process
		concurrent: {
			server: [
				'compass:server'
			],
			test: [
				'compass'
			],
			dist: [
				'compass:dist',
				'imagemin',
				'svgmin'
			]
		},

		// Test settings
		karma: {
			unit: {
				configFile: 'test/karma.conf.js',
				singleRun: true
			}
		},

		// Jade template engine
		jade: {
			dist: {
				options: {
					pretty: true
				},
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.app %>',
						dest: '.tmp',
						src: ['*.jade', 'views/**/*.jade'],
						ext: '.html'
					}
				]
			}
		},

		// Deploy via sftp
		// authentication information stored in .ftppass (not under version control)
		'sftp-deploy': {
			staging: {
				auth: {
					host: 'desec.io',
					port: 22,
					authKey: 'desec-io'
				},
				src: '<%= yeoman.dist %>',
				dest: '/var/www/webclient',
				exclusions: [],
				serverSep: '/',
				concurrency: 4,
				progress: true
			}
		},
	});

	grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
		if (target === 'dist') {
			return grunt.task.run(['build', 'connect:dist:keepalive']);
		}

		grunt.task.run([
			'clean:server',
			'configureProxies:server',
			'concurrent:server',
			'autoprefixer',
			'jade',
			'connect:livereload',
			'watch'
		]);
	});

	grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
		grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
		grunt.task.run(['serve:' + target]);
	});

	grunt.registerTask('test', [
		'clean:server',
		'concurrent:test',
		'autoprefixer',
		'jade',
		'connect:test',
		'karma'
	]);

	grunt.registerTask('build', [
		'clean:dist',
		'jade',
		'compass',
		'useminPrepare',
		'concat',
		'concurrent:dist',
		'autoprefixer',
		'ngAnnotate',
		'copy:dist',
		'cssmin',
		//'uglify',
		//'filerev',
		'usemin',
		'htmlmin'
	]);

	grunt.registerTask('deploy', [
		'build',
		'sftp-deploy'
	]);

	grunt.registerTask('default', [
		'newer:jshint',
		'test',
		'build'
	]);
};
<|endoftext|>


<commit_before>'use strict';

// colors for terminal
require('colors');

// utility, lodash
var _ = require('lodash');
_.mixin(require('underscore.string').exports());

var bind = function(f) {
    return Function.prototype.apply.bind(f, null);
}

module.exports = function(grunt) {
    // Hide 'Running task' text from grunt output
    grunt.log.header = function() {};

    // Initial config
    var files  = ['package', 'colors', 'external', 'languages'];
    var config = _.object(files, _.map(files, function(f) {
        return grunt.file.readJSON(f + '.json');
    }));

    var humanized = config.package.humanized;

    // General purpose functions.
    var share = function(key, data) {
            // tasks can share anything into grunt.config:
            grunt.registerTask('__taskshare', '', function() {
                grunt.config(key, data);
            });
            grunt.task.run('__taskshare');
        },
        header = function(msg, before) {
            !before || grunt.log.write('\n' + before.bold);
            var d = _('-').repeat(60);
            grunt.log.subhead(d + '\n' + msg.grey + '\n' + d);
        },
        generating = function(msg) {
            grunt.log.subhead('Generating ' + msg + '...');
        },
        defaultOr = function(name, base, ext) {
            return (name === 'default' ? base : base + ' - ' + _.capitalize(name)) + (ext || '');
        };

    var widgetPrefix = humanized + '/Widget - ' + humanized,
        fileTypesDir = humanized + '/file_types/',
        template = function(path) {
            return 'templates/' + (path || '');
        },
        fileTypeIcon = function(icon) {
            return fileTypesDir + 'icon_' + icon + '.tmPreferences';
        },
        externalRawUrl = function(external) {
            return "https://raw.githubusercontent.com/" + external.repo + '/' + external.version  + '/';
        },
        externalId = function(external) {
            return _.slugify(external.name);
        },
        externalTask = function(external) {
            return 'external-import-' + external.id;
        },
        genColorSchemes = function(copier, func) {
            var colors = grunt.config('colors');
            colors.backgrounds.forEach(function(bg) {
                var renamer = _.partial(func(_.partial(defaultOr, bg.name)), '');
                share('renamer', renamer);
                share('bg', bg);
                share('replace.' + copier + '.src', [renamer() + '.tmTheme']);
                grunt.task.run(['copy:' + copier, 'replace:' + copier]);
            });
        },
        renameTheme = _.curry(function(prefix, dest, src) {
            var ext = _(src).strRight('.').value().replace('hidden-', '');
            return grunt.config('renamer')(prefix) + '.' + ext;
        }),
        copyTask = function(sources, cwd, renamer) {
            var f = {
                expand: true,
                flatten: true,
                src: sources,
                rename: renamer || renameTheme(humanized)
            };
            if ( cwd !== '' ) {
                f.cwd = cwd || template();
            }
            return {files: [f]};
        },
        replacements = function(r) {
            return r.map(function(e) {
                return {
                    from: '{{' + e[0] + '}}',
                    to: _.isString(e[1]) ? '<%= ' + e[1] + ' %>' : e[1]
                };
            });
        },
        replacer = function(repls, overwrite, src) {
            return {
                overwrite: _.isUndefined(overwrite) ? true : overwrite,
                src: src || [],
                replacements: _.reduce(repls, function(result, arr) {
                    return _.union(result, arr);
                })
            }
        },
        nameReplacements = replacements([['name', 'renamer(package.humanized)']]),
        bgReplacements = replacements([
            ['bg_rgb', 'bg.rgb'],
            ['bg_hex', 'bg.hex']
        ]),
        themesReplacements = replacements([
            ['rgb', 'theme.rgb'],
            ['hex', 'theme.hex']
        ]);

    // Tasks options
    var tasks = {
        bump: {
            options: {
                files: ['package.json'],
                updateConfigs: ['package'],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['package.json'],
                createTag: true,
                tagName: 'v%VERSION%',
                tagMessage: 'Version %VERSION%',
                push: true,
                pushTo: 'origin',
                gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
                globalReplace: false
            }
        },
        clean: [
            '*.sublime-theme',
            '*.tmTheme',
            humanized + '/*.stTheme',
            humanized + '/*.sublime-settings',
            fileTypeIcon('*'),
            'build/'
        ],
        copy: {
            external: copyTask([], '' ),
            colorschemes: copyTask('template.hidden-tmTheme'),
            themes: copyTask('template.sublime-theme'),
            widgets: copyTask(['template.sublime-settings', 'template.stTheme'], template(), renameTheme(widgetPrefix))
        },
        replace: {
            external: replacer( [nameReplacements, bgReplacements] ),
            colorschemes: replacer( [nameReplacements, bgReplacements, themesReplacements] ),
            themes: replacer([nameReplacements, themesReplacements, replacements([
                ['widgetName', 'renamer("Widget - " + package.humanized)']])]),
            icons: replacer(
                [replacements([['icon', 'icon.icon'], ['scopes', "icon.scopes.join(', ')"]])],
                false, template('icon.hidden-tmPreferences')),
            languages: replacer([replacements([
                    ['lang', 'lang.lang'],
                    ['scopes', "lang.scopes.join(', ')"],
                    ['include', 'lang.include'],
                    ['files', function() {
                        return grunt.config('lang.files').map(function(f) {
                            return '<string>' + f + '</string>'
                        }).join('')
                    }]
                ])],
                false, template('language.hidden-tmLanguage'))
        },
        'curl': {},
        verbosity: {
            hidden: {
                tasks: ['copy', 'clean', 'curl']
            }
        }
    };

    // Add tasks for importing external colorschemes:
    config.external.external.forEach(function(external) {
        external.id = externalId(external);
        var urlBase = externalRawUrl(external),
            task    = externalTask(external),
            dest    = 'build/' + external.id + '.hidden-tmTheme',
            src     = template('template.hidden-tmTheme');

        // Setup copy & curl tasks:
        tasks.copy.external.files[0].src.push(dest);
        tasks['curl'][task] = {
            dest: dest,
            src: urlBase + src
        };

        // Setup generation task:
        grunt.registerTask(task, 'Imports ' + external.name + ' from its repository', function() {
            generating(external.name);
            grunt.task.run('curl:' + task);
            genColorSchemes('external', function(func) {
                return _.partial(func, external.name);
            });
        });
    });

    // Merge tasks options with config & load them.
    _.merge(config, tasks);
    require('load-grunt-tasks')(grunt);

    // Define grunt tasks:
    grunt.registerTask('default', []);

    // Build task:
    grunt.registerTask('build', 'Build custom themes', function() {
        header('Current version: ' + grunt.config('package.version') + '\n' +
            'Github repository: ' + grunt.config('package.repository'),
             humanized + ' Theme Builder');
        grunt.task.run(['verbosity', 'clean', 'themes', 'languages', 'external-colorschemes']);
    });

    // Import all external colorschemes task:
    grunt.registerTask('external-colorschemes', 'Imports all external from their repositories', function() {
        header('Importing external Color Schemes');
        grunt.task.run(_.map(config.external.external, externalTask));
    });

    // Languages task:
    grunt.registerTask('languages', 'Build language files', function() {
        var data = grunt.config('languages');

        header('Building icon_*.tmPreferences files');

        // Generate icon_*.tmPreferences:
        data.icons.forEach(function(icon) {
            generating('icon_' + icon.icon + '.tmPreferences');
            share('icon', icon);
            share('replace.icons.dest', fileTypeIcon(icon.icon));
            grunt.task.run('replace:icons');
        });

        header('Building dummy *.tmLanguage files');

        // Generate *.tmLanguage:
        data.languages.forEach(function(lang) {
            generating(lang.lang + '.tmLanguage');
            lang.include = lang.scopes.length > 1 ? lang.scopes[0] : 'text.plain';
            share('lang', lang);
            share('replace.languages.dest', fileTypesDir + lang.lang + '.tmLanguage');
            grunt.task.run('replace:languages');
        });
    });

    // Themes task:
    grunt.registerTask('themes', 'Build custom themes', function() {
        header('Building theme files');

        var colors = grunt.config('colors');
        colors.colors.forEach(function(theme) {
            generating(theme.name + ' theme');

            // Generate theme & widget:
            var renamerT = _.partial(defaultOr, theme.name);
            share('renamer', renamerT);
            share('theme', theme);
            share('replace.themes.src', [
                [humanized, '.sublime-theme'],
                [widgetPrefix, '.stTheme'],
                [widgetPrefix, '.sublime-settings']
            ].map(bind(renamerT)));
            grunt.task.run(['copy:themes', 'copy:widgets', 'replace:themes']);

            // Generate color schemes:
            var renamerC = _.partial(renamerT, humanized);
            genColorSchemes('colorschemes', function(func) {
                return _.compose(func, renamerC);
            });
        });
    });

    // Load grunt config
    grunt.initConfig(config);

    // Load all npm tasks at once
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
};
<commit_msg>ES6 rewrite, reduced ~40 lines.<commit_after>'use strict';

// colors for terminal
require('colors');

// utility, lodash
const _ = require('lodash');
_.mixin(require('underscore.string').exports());

const bind = f => Function.prototype.apply.bind(f, null);

module.exports = grunt => {
    // Hide 'Running task' text from grunt output
    grunt.log.header = function() {};

    // Initial config
    const files  = ['package', 'colors', 'external', 'languages'];
    const config = _.object(files, _.map(files, f => grunt.file.readJSON(f + '.json')));
    const humanized = config.package.humanized;

    // General purpose functions.
    const share = (key, data) => {
            // tasks can share anything into grunt.config:
            grunt.registerTask('__taskshare', '', () => grunt.config(key, data));
            grunt.task.run('__taskshare');
        },
        header = (msg, before) => {
            !before || grunt.log.write('\n' + before.bold);
            const d = _('-').repeat(60);
            grunt.log.subhead(d + '\n' + msg.grey + '\n' + d);
        },
        generating = msg => grunt.log.subhead('Generating ' + msg + '...'),
        defaultOr = (name, base, ext) => (name === 'default' ? base : base + ' - ' + _.capitalize(name)) + (ext || '');

    const widgetPrefix = humanized + '/Widget - ' + humanized,
        fileTypesDir = humanized + '/file_types/',
        template = path => 'templates/' + (path || ''),
        fileTypeIcon = icon => fileTypesDir + 'icon_' + icon + '.tmPreferences',
        externalRawUrl = external => "https://raw.githubusercontent.com/" + external.repo + '/' + external.version  + '/',
        externalId = external => _.slugify(external.name),
        externalTask = external => 'external-import-' + external.id,
        genColorSchemes = (copier, func) => {
            const colors = grunt.config('colors');
            colors.backgrounds.forEach( bg => {
                const renamer = _.partial(func(_.partial(defaultOr, bg.name)), '');
                share('renamer', renamer);
                share('bg', bg);
                share('replace.' + copier + '.src', [renamer() + '.tmTheme']);
                grunt.task.run(['copy:' + copier, 'replace:' + copier]);
            });
        },
        renameTheme = _.curry( (prefix, dest, src) =>
            grunt.config('renamer')(prefix) + '.' + _(src).strRight('.').value().replace('hidden-', '') ),
        copyTask = (sources, cwd, renamer) => {
            const f = {
                expand: true,
                flatten: true,
                src: sources,
                rename: renamer || renameTheme(humanized)
            };
            if ( cwd !== '' ) {
                f.cwd = cwd || template();
            }
            return {files: [f]};
        },
        replacements = r => r.map(e => ({
            from: '{{' + e[0] + '}}',
            to: _.isString(e[1]) ? '<%= ' + e[1] + ' %>' : e[1]
        })),
        replacer = (repls, overwrite, src) => ({
            overwrite: _.isUndefined(overwrite) ? true : overwrite,
            src: src || [],
             replacements: _.reduce(repls, (result, arr) => _.union(result, arr) )

        }),
        nameReplacements = replacements([['name', 'renamer(package.humanized)']]),
        bgReplacements = replacements([
            ['bg_rgb', 'bg.rgb'],
            ['bg_hex', 'bg.hex']
        ]),
        themesReplacements = replacements([
            ['rgb', 'theme.rgb'],
            ['hex', 'theme.hex']
        ]);

    // Tasks options
    const tasks = {
        bump: {
            options: {
                files: ['package.json'],
                updateConfigs: ['package'],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['package.json'],
                createTag: true,
                tagName: 'v%VERSION%',
                tagMessage: 'Version %VERSION%',
                push: true,
                pushTo: 'origin',
                gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
                globalReplace: false
            }
        },
        clean: [
            '*.sublime-theme',
            '*.tmTheme',
            humanized + '/*.stTheme',
            humanized + '/*.sublime-settings',
            fileTypeIcon('*'),
            'build/'
        ],
        copy: {
            external: copyTask([], '' ),
            colorschemes: copyTask('template.hidden-tmTheme'),
            themes: copyTask('template.sublime-theme'),
            widgets: copyTask(['template.sublime-settings', 'template.stTheme'], template(), renameTheme(widgetPrefix))
        },
        replace: {
            external: replacer( [nameReplacements, bgReplacements] ),
            colorschemes: replacer( [nameReplacements, bgReplacements, themesReplacements] ),
            themes: replacer([nameReplacements, themesReplacements, replacements([
                ['widgetName', 'renamer("Widget - " + package.humanized)']])]),
            icons: replacer(
                [replacements([['icon', 'icon.icon'], ['scopes', "icon.scopes.join(', ')"]])],
                false, template('icon.hidden-tmPreferences')),
            languages: replacer([replacements([
                    ['lang', 'lang.lang'],
                    ['scopes', "lang.scopes.join(', ')"],
                    ['include', 'lang.include'],
                    ['files', () => grunt.config('lang.files').map(f => '<string>' + f + '</string>').join('')]
                ])],
                false, template('language.hidden-tmLanguage'))
        },
        'curl': {},
        verbosity: {
            hidden: {
                tasks: ['copy', 'clean', 'curl']
            }
        }
    };

    // Add tasks for importing external colorschemes:
    config.external.external.forEach(external => {
        external.id = externalId(external);
        const urlBase = externalRawUrl(external),
            task    = externalTask(external),
            dest    = 'build/' + external.id + '.hidden-tmTheme',
            src     = template('template.hidden-tmTheme');

        // Setup copy & curl tasks:
        tasks.copy.external.files[0].src.push(dest);
        tasks['curl'][task] = {
            dest: dest,
            src: urlBase + src
        };

        // Setup generation task:
        grunt.registerTask(task, 'Imports ' + external.name + ' from its repository', () => {
            generating(external.name);
            grunt.task.run('curl:' + task);
            genColorSchemes('external', func => _.partial(func, external.name));
        });
    });

    // Merge tasks options with config & load them.
    _.merge(config, tasks);
    require('load-grunt-tasks')(grunt);

    // Define grunt tasks:
    grunt.registerTask('default', []);

    // Build task:
    grunt.registerTask('build', 'Build custom themes', () => {
        header('Current version: ' + grunt.config('package.version') + '\n' +
            'Github repository: ' + grunt.config('package.repository'),
             humanized + ' Theme Builder');
        grunt.task.run(['verbosity', 'clean', 'themes', 'languages', 'external-colorschemes']);
    });

    // Import all external colorschemes task:
    grunt.registerTask('external-colorschemes', 'Imports all external from their repositories', () => {
        header('Importing external Color Schemes');
        grunt.task.run(_.map(config.external.external, externalTask));
    });

    // Languages task:
    grunt.registerTask('languages', 'Build language files', () => {
        const data = grunt.config('languages');

        header('Building icon_*.tmPreferences files');

        // Generate icon_*.tmPreferences:
        data.icons.forEach(icon => {
            generating('icon_' + icon.icon + '.tmPreferences');
            share('icon', icon);
            share('replace.icons.dest', fileTypeIcon(icon.icon));
            grunt.task.run('replace:icons');
        });

        header('Building dummy *.tmLanguage files');

        // Generate *.tmLanguage:
        data.languages.forEach(lang => {
            generating(lang.lang + '.tmLanguage');
            lang.include = lang.scopes.length > 1 ? lang.scopes[0] : 'text.plain';
            share('lang', lang);
            share('replace.languages.dest', fileTypesDir + lang.lang + '.tmLanguage');
            grunt.task.run('replace:languages');
        });
    });

    // Themes task:
    grunt.registerTask('themes', 'Build custom themes', () => {
        header('Building theme files');

        const colors = grunt.config('colors');
        colors.colors.forEach(theme => {
            generating(theme.name + ' theme');

            // Generate theme & widget:
            const renamerT = _.partial(defaultOr, theme.name);
            share('renamer', renamerT);
            share('theme', theme);
            share('replace.themes.src', [
                [humanized, '.sublime-theme'],
                [widgetPrefix, '.stTheme'],
                [widgetPrefix, '.sublime-settings']
            ].map(bind(renamerT)));
            grunt.task.run(['copy:themes', 'copy:widgets', 'replace:themes']);

            // Generate color schemes:
            const renamerC = _.partial(renamerT, humanized);
            genColorSchemes('colorschemes', func => _.compose(func, renamerC) );
        });
    });

    // Load grunt config
    grunt.initConfig(config);

    // Load all npm tasks at once
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
};
<|endoftext|>


<commit_before>/**
 * Pimcore
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.pimcore.org/license
 *
 * @copyright  Copyright (c) 2009-2014 pimcore GmbH (http://www.pimcore.org)
 * @license    http://www.pimcore.org/license     New BSD License
 */

pimcore.registerNS("pimcore.document.properties");
pimcore.document.properties = Class.create(pimcore.element.properties,{

    disallowedKeys: ["language","navigation_exclude","navigation_name","navigation_title","navigation_relation",
                        "navigation_parameters","navigation_anchor","navigation_target","navigation_class",
                        "navigation_tabindex","navigation_accesskey"],

    inheritableKeys: ["language"],

    getPropertyData: function(name){

        // language
        var propertyData;
        var record;
        var recordIndex = this.propertyGrid.getStore().findBy(function (name, rec, id) {
            if(rec.get("name") == name) {
                return true;
            }
        }.bind(this,name));
        if(recordIndex >= 0) {
            record = this.propertyGrid.getStore().getAt(recordIndex);
            if(record.get("data")) {
                propertyData = record.get("data");
            }
        }
        return propertyData;

    },

    getLayout: function ($super) {

        if(!this.layout){

            this.layout = $super();

            var languageData = this.getPropertyData("language");

            var languagestore = [["",t("none")]];
            for (var i=0; i<pimcore.settings.websiteLanguages.length; i++) {
                languagestore.push([pimcore.settings.websiteLanguages[i],pimcore.settings.websiteLanguages[i]]);
            }

            var language = new Ext.form.ComboBox({
                fieldLabel: t('language'),
                name: "language",
                store: languagestore,
                editable: false,
                triggerAction: 'all',
                mode: "local",
                listWidth: 200,
                value: languageData
            });

            this.languagesPanel = new Ext.form.FormPanel({
                layout: "pimcoreform",
                title: t("language_settings"),
                bodyStyle: "padding: 10px;",
                autoWidth: true,
                height: 80,
                collapsible: false,
                items: [language]
            });

            var navigationBasic = new Ext.form.FieldSet({
                title: t('navigation_basic'),
                autoHeight:true,
                collapsible: true,
                collapsed: false,
                items :[{
                            xtype: "textfield",
                            fieldLabel: t("name"),
                            value: this.getPropertyData("navigation_name"),
                            name: "navigation_name"
                        },{
                            xtype: "textfield",
                            fieldLabel: t('title'),
                            name: "navigation_title",
                            value: this.getPropertyData("navigation_title")
                        },{
                            xtype: "combo",
                            fieldLabel: t('navigation_target'),
                            name: "navigation_target",
                            store: ["","_blank","_self","_top","_parent"],
                            value: this.getPropertyData("navigation_target"),
                            editable: false,
                            triggerAction: 'all',
                            mode: "local",
                            width: 130,
                            listWidth: 200
                        },{
                            xtype: "checkbox",
                            fieldLabel: t('navigation_exclude'),
                            name: "navigation_exclude",
                            checked: this.getPropertyData("navigation_exclude")

                }]

            });

            var navigationEnhanced = new Ext.form.FieldSet({
                title: t('navigation_enhanced'),
                autoHeight:true,
                collapsible: true,
                collapsed: true,
                items :[{
                            xtype: "textfield",
                            fieldLabel: t('class'),
                            name: 'navigation_class',
                            value: this.getPropertyData("navigation_class")
                        },{
                            xtype: "textfield",
                            fieldLabel: t('anchor'),
                            name: 'navigation_anchor',
                            value: this.getPropertyData("navigation_anchor")
                        },
                        {
                            xtype: "textfield",
                            fieldLabel: t('parameters'),
                            name: "navigation_parameters",
                            value: this.getPropertyData("navigation_parameters")
                        },
                        {
                            xtype: "textfield",
                            fieldLabel: t('relation'),
                            name: "navigation_relation",
                            value: this.getPropertyData("navigation_relation")
                        },
                        {
                            xtype: "textfield",
                            fieldLabel: t('accesskey'),
                            name: "navigation_accesskey",
                            value: this.getPropertyData("navigation_accesskey")
                        },
                        {
                            xtype: "textfield",
                            fieldLabel: t('tabindex'),
                            name: "navigation_tabindex",
                            value: this.getPropertyData("navigation_tabindex")
                        }]

            });

            this.navigationPanel =  new Ext.form.FormPanel({
                layout: "pimcoreform",
                title: t("navigation_settings"),
                bodyStyle: "padding: 10px;",
                autoWidth: true,
                autoHeight:true,
                collapsible: false,
                items: [navigationBasic,navigationEnhanced]
            });

            var systempropertiesItems = [this.languagesPanel];
            if(this.element.type == "page" || this.element.type == "link") {
                systempropertiesItems = [this.languagesPanel,this.navigationPanel];
            }

            this.systemPropertiesPanel = new Ext.Panel({
                title: t("system_properties"),
                width: 300,
                region: "east",
                autoScroll: true,
                collapsible: true,
                items: systempropertiesItems
            });

            this.layout.add(this.systemPropertiesPanel);
        }
        return this.layout;
    },

    getValues : function ($super) {

        var values = $super();

        var languageValues = this.languagesPanel.getForm().getFieldValues();
        var navigationValues = this.navigationPanel.getForm().getFieldValues();

        var systemValues = array_merge(languageValues,navigationValues);

        for(var i=0;i<this.disallowedKeys.length;i++){

            var name = this.disallowedKeys[i];

            var addProperty = false;
            var unchanged = false;
            if(systemValues[name]) {

                var record;
                var recordIndex = this.propertyGrid.getStore().findBy(function (name,rec, id) {
                    if(rec.get("name") == name) {
                        return true;
                    }
                }.bind(this,name));

                if(recordIndex >= 0) {
                    record = this.propertyGrid.getStore().getAt(recordIndex);
                    if(record.get("data")) {
                        if(record.get("data") != systemValues[name]) {
                            addProperty = true;
                        } else if(record.get("data") == systemValues[name]) {
                            unchanged=true;
                        }
                    } else if (systemValues[name]) {
                        addProperty = true;
                    }
                } else {
                    addProperty = true;
                }

                if(addProperty) {
                    values[name] = {
                        data: systemValues[name],
                        type: "text",
                        inheritable: in_array(name,this.inheritableKeys)
                    };
                }
            }

            if(!addProperty && !unchanged) {
                if(values[name]) {
                    delete values[name];
                }
            }

        }
        return values;
    }

});<commit_msg>documents: navigation properties bugfix<commit_after>/**
 * Pimcore
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.pimcore.org/license
 *
 * @copyright  Copyright (c) 2009-2014 pimcore GmbH (http://www.pimcore.org)
 * @license    http://www.pimcore.org/license     New BSD License
 */

pimcore.registerNS("pimcore.document.properties");
pimcore.document.properties = Class.create(pimcore.element.properties,{

    disallowedKeys: ["language","navigation_exclude","navigation_name","navigation_title","navigation_relation",
                        "navigation_parameters","navigation_anchor","navigation_target","navigation_class",
                        "navigation_tabindex","navigation_accesskey"],

    inheritableKeys: ["language"],

    getPropertyData: function(name){

        // language
        var propertyData;
        var record;
        var recordIndex = this.propertyGrid.getStore().findBy(function (name, rec, id) {
            if(rec.get("name") == name) {
                return true;
            }
        }.bind(this,name));
        if(recordIndex >= 0) {
            record = this.propertyGrid.getStore().getAt(recordIndex);
            if(record.get("data")) {
                propertyData = record.get("data");
            }
        }
        return propertyData;

    },

    getLayout: function ($super) {

        if(!this.layout){

            this.layout = $super();

            var languageData = this.getPropertyData("language");

            var languagestore = [["",t("none")]];
            for (var i=0; i<pimcore.settings.websiteLanguages.length; i++) {
                languagestore.push([pimcore.settings.websiteLanguages[i],pimcore.settings.websiteLanguages[i]]);
            }

            var language = new Ext.form.ComboBox({
                fieldLabel: t('language'),
                name: "language",
                store: languagestore,
                editable: false,
                triggerAction: 'all',
                mode: "local",
                listWidth: 200,
                value: languageData
            });

            this.languagesPanel = new Ext.form.FormPanel({
                layout: "pimcoreform",
                title: t("language_settings"),
                bodyStyle: "padding: 10px;",
                autoWidth: true,
                height: 80,
                collapsible: false,
                items: [language]
            });

            var navigationBasic = new Ext.form.FieldSet({
                title: t('navigation_basic'),
                autoHeight:true,
                collapsible: true,
                collapsed: false,
                items :[{
                            xtype: "textfield",
                            fieldLabel: t("name"),
                            value: this.getPropertyData("navigation_name"),
                            name: "navigation_name"
                        },{
                            xtype: "textfield",
                            fieldLabel: t('title'),
                            name: "navigation_title",
                            value: this.getPropertyData("navigation_title")
                        },{
                            xtype: "combo",
                            fieldLabel: t('navigation_target'),
                            name: "navigation_target",
                            store: ["","_blank","_self","_top","_parent"],
                            value: this.getPropertyData("navigation_target"),
                            editable: false,
                            triggerAction: 'all',
                            mode: "local",
                            width: 130,
                            listWidth: 200
                        },{
                            xtype: "checkbox",
                            fieldLabel: t('navigation_exclude'),
                            name: "navigation_exclude",
                            checked: this.getPropertyData("navigation_exclude")

                }]

            });

            var navigationEnhanced = new Ext.form.FieldSet({
                title: t('navigation_enhanced'),
                autoHeight:true,
                collapsible: true,
                collapsed: true,
                items :[{
                            xtype: "textfield",
                            fieldLabel: t('class'),
                            name: 'navigation_class',
                            value: this.getPropertyData("navigation_class")
                        },{
                            xtype: "textfield",
                            fieldLabel: t('anchor'),
                            name: 'navigation_anchor',
                            value: this.getPropertyData("navigation_anchor")
                        },
                        {
                            xtype: "textfield",
                            fieldLabel: t('parameters'),
                            name: "navigation_parameters",
                            value: this.getPropertyData("navigation_parameters")
                        },
                        {
                            xtype: "textfield",
                            fieldLabel: t('relation'),
                            name: "navigation_relation",
                            value: this.getPropertyData("navigation_relation")
                        },
                        {
                            xtype: "textfield",
                            fieldLabel: t('accesskey'),
                            name: "navigation_accesskey",
                            value: this.getPropertyData("navigation_accesskey")
                        },
                        {
                            xtype: "textfield",
                            fieldLabel: t('tabindex'),
                            name: "navigation_tabindex",
                            value: this.getPropertyData("navigation_tabindex")
                        }]

            });

            this.navigationPanel =  new Ext.form.FormPanel({
                layout: "pimcoreform",
                title: t("navigation_settings"),
                bodyStyle: "padding: 10px;",
                autoWidth: true,
                autoHeight:true,
                collapsible: false,
                items: [navigationBasic,navigationEnhanced]
            });

            var systempropertiesItems = [this.languagesPanel];
            if(this.element.type == "page" || this.element.type == "link") {
                systempropertiesItems = [this.languagesPanel,this.navigationPanel];
            }

            this.systemPropertiesPanel = new Ext.Panel({
                title: t("system_properties"),
                width: 300,
                region: "east",
                autoScroll: true,
                collapsible: true,
                items: systempropertiesItems
            });

            this.layout.add(this.systemPropertiesPanel);
        }
        return this.layout;
    },

    getValues : function ($super) {

        var values = $super();

        var languageValues = this.languagesPanel.getForm().getFieldValues();
        var navigationValues = this.navigationPanel.getForm().getFieldValues();

        var systemValues = array_merge(languageValues,navigationValues);

        for(var i=0;i<this.disallowedKeys.length;i++){

            var name = this.disallowedKeys[i];

            var addProperty = false;
            var unchanged = false;
            if(typeof systemValues[name] != "undefined") {

                var record;
                var recordIndex = this.propertyGrid.getStore().findBy(function (name,rec, id) {
                    if(rec.get("name") == name) {
                        return true;
                    }
                }.bind(this,name));

                if(recordIndex >= 0) {
                    record = this.propertyGrid.getStore().getAt(recordIndex);
                    if(record.get("data")) {
                        if(record.get("data") != systemValues[name]) {
                            addProperty = true;
                        } else if(record.get("data") == systemValues[name]) {
                            unchanged=true;
                        }
                    } else if (systemValues[name]) {
                        addProperty = true;
                    }
                } else {
                    addProperty = true;
                }

                if(addProperty) {
                    values[name] = {
                        data: systemValues[name],
                        type: "text",
                        inheritable: in_array(name,this.inheritableKeys)
                    };
                }
            }

            if(!addProperty && !unchanged) {
                if(values[name]) {
                    delete values[name];
                }
            }

        }
        return values;
    }

});<|endoftext|>


<commit_before>module.exports = function(grunt) {

  require('load-grunt-tasks')(grunt);

  grunt.loadNpmTasks('grunt-execute');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-regex-replace');

  grunt.initConfig({

    clean: {
      dist: "dist",
      tmp: "tmp",
    },

    copy: {
      src_to_dist: {
        cwd: 'src',
        expand: true,
        src: ['**/*', '!**/*.js', '!**/*.scss'],
        dest: 'dist'
      },
      includes_to_dist: {
        cwd: 'includes',
        expand: true,
        src: ['**/*', '!**/*.js', '!**/*.scss'],
        dest: 'dist'
      },
      pluginDef: {
        expand: true,
        src: ['README.md'],
        dest: 'dist',
      }
    },

    watch: {
      rebuild_all: {
        files: ['src/**/*', 'README.md'],
        tasks: ['rebuild'],
        options: {spawn: false}
      },
    },

    babel: {
      options: {
        sourceMap: true,
        presets:  ["es2015"],
        plugins: ['transform-es2015-modules-systemjs', "transform-es2015-for-of"],
      },
      dist: {
        files: [{
          cwd: 'src',
          expand: true,
          src: ['**/*.js', '!src/directives/*.js', '!src/filters/*.js'],
          dest: 'dist',
          ext:'.js'
        }]
      },
    },

    curl: {
      worldmap: {
        src: 'https://grafana.net/plugins/grafana-worldmap-panel/download',
        dest: 'tmp/worldmap.zip',
      },
    },

    unzip: {
      worldmap: {
        src: 'tmp/worldmap.zip',
        dest: 'dist/grafana-worldmap-panel',
        router: function (filepath) {
          var matches = filepath.match(/^.+?\/dist\/(.+)/);
          if (matches) {
            return matches[1];
          }

          return null;
        },
      },
    },

    "regex-replace": {
      worldmap: {
        src: 'dist/grafana-worldmap-panel/worldmap_ctrl.js',
        actions: [
          {
            name: 'module.html',
            search: "'module.html';",
            replace: "'../../plugins/grafana-worldmap-panel/module.html';",
          },
        ],
      },
    },

    jshint: {
      source: {
        files: {
          src: ['src/**/*.js'],
        }
      },
      options: {
        jshintrc: true,
        reporter: require('jshint-stylish'),
        ignores: [
          'node_modules/*',
          'dist/*',
        ]
      }
    },

    jscs: {
      src: ['src/**/*.js'],
      options: {
        config: ".jscs.json",
      },
    },

    sass: {
      options: {
        sourceMap: true
      },
      dist: {
        files: {
          "dist/css/worldping.dark.css": "src/sass/worldping.dark.scss",
          "dist/css/worldping.light.css": "src/sass/worldping.light.scss",
        }
      }
    }
  });

  grunt.registerTask('default', [
    'clean',
    'sass',
    'copy:src_to_dist',
    'copy:pluginDef',
    'babel',
    'curl:worldmap',
    'unzip:worldmap',
    'regex-replace:worldmap',
    'jshint',
    'jscs',
    ]);

  grunt.registerTask('rebuild', [
    'clean:dist',
    'sass',
    'copy:src_to_dist',
    'copy:pluginDef',
    'babel',
    'unzip:worldmap',
    'regex-replace:worldmap',
    'jshint',
    'jscs',
    ]);

  // does not have sass due to grafana file dependency
  grunt.registerTask('test', [
    'clean',
    'copy:src_to_dist',
    'copy:pluginDef',
    'babel',
    'jshint',
    'jscs',
    ]);
};
<commit_msg>update worldmap-plugin download url<commit_after>module.exports = function(grunt) {

  require('load-grunt-tasks')(grunt);

  grunt.loadNpmTasks('grunt-execute');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-regex-replace');

  grunt.initConfig({

    clean: {
      dist: "dist",
      tmp: "tmp",
    },

    copy: {
      src_to_dist: {
        cwd: 'src',
        expand: true,
        src: ['**/*', '!**/*.js', '!**/*.scss'],
        dest: 'dist'
      },
      includes_to_dist: {
        cwd: 'includes',
        expand: true,
        src: ['**/*', '!**/*.js', '!**/*.scss'],
        dest: 'dist'
      },
      pluginDef: {
        expand: true,
        src: ['README.md'],
        dest: 'dist',
      }
    },

    watch: {
      rebuild_all: {
        files: ['src/**/*', 'README.md'],
        tasks: ['rebuild'],
        options: {spawn: false}
      },
    },

    babel: {
      options: {
        sourceMap: true,
        presets:  ["es2015"],
        plugins: ['transform-es2015-modules-systemjs', "transform-es2015-for-of"],
      },
      dist: {
        files: [{
          cwd: 'src',
          expand: true,
          src: ['**/*.js', '!src/directives/*.js', '!src/filters/*.js'],
          dest: 'dist',
          ext:'.js'
        }]
      },
    },

    curl: {
      worldmap: {
        src: 'https://grafana.com/api/plugins/grafana-worldmap-panel/versions/0.0.16/download',
        dest: 'tmp/worldmap.zip',
      },
    },

    unzip: {
      worldmap: {
        src: 'tmp/worldmap.zip',
        dest: 'dist/grafana-worldmap-panel',
        router: function (filepath) {
          var matches = filepath.match(/^.+?\/dist\/(.+)/);
          if (matches) {
            return matches[1];
          }

          return null;
        },
      },
    },

    "regex-replace": {
      worldmap: {
        src: 'dist/grafana-worldmap-panel/worldmap_ctrl.js',
        actions: [
          {
            name: 'module.html',
            search: "'module.html';",
            replace: "'../../plugins/grafana-worldmap-panel/module.html';",
          },
        ],
      },
    },

    jshint: {
      source: {
        files: {
          src: ['src/**/*.js'],
        }
      },
      options: {
        jshintrc: true,
        reporter: require('jshint-stylish'),
        ignores: [
          'node_modules/*',
          'dist/*',
        ]
      }
    },

    jscs: {
      src: ['src/**/*.js'],
      options: {
        config: ".jscs.json",
      },
    },

    sass: {
      options: {
        sourceMap: true
      },
      dist: {
        files: {
          "dist/css/worldping.dark.css": "src/sass/worldping.dark.scss",
          "dist/css/worldping.light.css": "src/sass/worldping.light.scss",
        }
      }
    }
  });

  grunt.registerTask('default', [
    'clean',
    'sass',
    'copy:src_to_dist',
    'copy:pluginDef',
    'babel',
    'curl:worldmap',
    'unzip:worldmap',
    'regex-replace:worldmap',
    'jshint',
    'jscs',
    ]);

  grunt.registerTask('rebuild', [
    'clean:dist',
    'sass',
    'copy:src_to_dist',
    'copy:pluginDef',
    'babel',
    'unzip:worldmap',
    'regex-replace:worldmap',
    'jshint',
    'jscs',
    ]);

  // does not have sass due to grafana file dependency
  grunt.registerTask('test', [
    'clean',
    'copy:src_to_dist',
    'copy:pluginDef',
    'babel',
    'jshint',
    'jscs',
    ]);
};
<|endoftext|>