From 9a7bf3693ce5c93313e5f46017bef45b2f8547a3 Mon Sep 17 00:00:00 2001 From: Tom Fulton Date: Sat, 11 Jan 2014 22:17:12 -0700 Subject: [PATCH 01/18] Add package:nuget task * Add grunt-nuget * Add nuspec file * Add build task --- .gitignore | 4 +++- Gruntfile.js | 9 +++++++++ build/nuget/package.nuspec | 18 ++++++++++++++++++ package.json | 3 ++- 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 build/nuget/package.nuspec diff --git a/.gitignore b/.gitignore index a02f08f..5683196 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ Desktop.ini $RECYCLE.BIN/ dist/ -node_modules/ \ No newline at end of file +node_modules/ + +build/*.nupkg \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index b727420..4e0e726 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -64,6 +64,13 @@ module.exports = function(grunt) { } }, + nugetpack: { + dist: { + src: 'build/nuget/package.nuspec', + dest: 'build' + } + }, + clean: ['<%= dest %>'] }); @@ -75,8 +82,10 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-nuget'); + grunt.registerTask('package:nuget', ['default', ' nugetpack']); grunt.registerTask('css:build', ['less']); grunt.registerTask('js:build', ['concat']); grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy']); diff --git a/build/nuget/package.nuspec b/build/nuget/package.nuspec new file mode 100644 index 0000000..e6a9720 --- /dev/null +++ b/build/nuget/package.nuspec @@ -0,0 +1,18 @@ + + + + Archetype + 0.0.0.0 + Archetype + imulus, tomfulton + imulus, tomfulton + http://github.com/imulus/archetype + + umbraco + http://github.com/imulus/archetype/raw/master/assets/logo.png + http://www.opensource.org/licenses/mit-license.php + + + + + \ No newline at end of file diff --git a/package.json b/package.json index 209ff87..ec424d9 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "grunt-contrib-watch": "~0.5.3", "grunt-contrib-jshint": "~0.7.2", "grunt-cli": "~0.1.11", - "grunt-contrib-clean": "~0.5.0" + "grunt-contrib-clean": "~0.5.0", + "grunt-nuget": "~0.1.1" } } From eafd2d454ce773ca16cf1ff0a58f257da8d0cfcb Mon Sep 17 00:00:00 2001 From: Tom Fulton Date: Sun, 12 Jan 2014 01:12:50 -0700 Subject: [PATCH 02/18] Inject package version, files into nuspec on build * Move /build/ -> /pkg/ * Add nuspec * Refactor package:nuget workflow to create a temporary directory to build the package from - so we can store the transformed file * Add grunt-template task to transform the nuspec --- .gitignore | 3 ++- Gruntfile.js | 34 +++++++++++++++++++++++++---- package.json | 3 ++- {build => pkg}/nuget/package.nuspec | 6 +++-- 4 files changed, 38 insertions(+), 8 deletions(-) rename {build => pkg}/nuget/package.nuspec (76%) diff --git a/.gitignore b/.gitignore index 5683196..0963175 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ $RECYCLE.BIN/ dist/ node_modules/ -build/*.nupkg \ No newline at end of file +pkg/tmp/ +pkg/*.nupkg \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 4e0e726..4410baf 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,6 +2,9 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), dest: 'dist', + version: '0.0.0', + package_dir: 'pkg', + package_temp_dir: '<%= package_dir %>/tmp/', watch: { less: { @@ -37,6 +40,11 @@ module.exports = function(grunt) { {expand: true, src: ['app/package.manifest'], dest: '<%= dest %>', flatten: true}, {expand: true, src: ['app/views/archetype.html'], dest: '<%= dest %>/views', flatten: true} ] + }, + nuget_prepare: { + files: [ + {expand: true, cwd: '<%= dest %>/', src: ['**'], dest: '<%= package_temp_dir %>/nuget/content/', flatten: false}, + ] } }, @@ -66,12 +74,29 @@ module.exports = function(grunt) { nugetpack: { dist: { - src: 'build/nuget/package.nuspec', - dest: 'build' + src: '<%= package_temp_dir %>/nuget/package.nuspec', + dest: '<%= package_dir %>' } }, - clean: ['<%= dest %>'] + template: { + 'nuget_manifest': { + 'options': { + 'data': { + version: '<%= version %>', + files: [{ path: '..\\..\\..\\<%= dest %>\\**', target: 'content\\App_Plugins\\Archetype'}] + } + }, + 'files': { + '<%= package_temp_dir %>/nuget/package.nuspec': ['<%= package_dir %>/nuget/package.nuspec'] + } + } + }, + + clean: { + build: ['<%= dest %>'], + package_temp: ['<%= package_temp_dir %>'] + } }); @@ -83,9 +108,10 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-nuget'); + grunt.loadNpmTasks('grunt-template'); - grunt.registerTask('package:nuget', ['default', ' nugetpack']); + grunt.registerTask('package:nuget', ['default', 'clean:package_temp', 'copy:nuget_prepare', 'template:nuget_manifest', 'nugetpack', 'clean:package_temp']); grunt.registerTask('css:build', ['less']); grunt.registerTask('js:build', ['concat']); grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy']); diff --git a/package.json b/package.json index ec424d9..547e799 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "grunt-contrib-jshint": "~0.7.2", "grunt-cli": "~0.1.11", "grunt-contrib-clean": "~0.5.0", - "grunt-nuget": "~0.1.1" + "grunt-nuget": "~0.1.1", + "grunt-template": "~0.2.2" } } diff --git a/build/nuget/package.nuspec b/pkg/nuget/package.nuspec similarity index 76% rename from build/nuget/package.nuspec rename to pkg/nuget/package.nuspec index e6a9720..e5143cc 100644 --- a/build/nuget/package.nuspec +++ b/pkg/nuget/package.nuspec @@ -2,7 +2,7 @@ Archetype - 0.0.0.0 + <%= version %> Archetype imulus, tomfulton imulus, tomfulton @@ -13,6 +13,8 @@ http://www.opensource.org/licenses/mit-license.php - + <% for (var file in files) { %> + + <% } %> \ No newline at end of file From 2e0a84852b1bce110dab8367db279bd18a9cc041 Mon Sep 17 00:00:00 2001 From: Tom Fulton Date: Wed, 15 Jan 2014 14:16:17 -0700 Subject: [PATCH 03/18] Add grunt task for creating umbraco package --- .gitignore | 3 +- Gruntfile.js | 25 ++++++++++++++- package.json | 5 ++- tasks/umbraco_package.js | 66 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 tasks/umbraco_package.js diff --git a/.gitignore b/.gitignore index a02f08f..5e0d59a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ Desktop.ini $RECYCLE.BIN/ dist/ -node_modules/ \ No newline at end of file +node_modules/ +pkg/ \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 9f1c3d4..0ea5251 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -73,8 +73,12 @@ module.exports = function(grunt) { files: [ {expand: true, cwd: '<%= dest %>/', src: ['**'], dest: '<%= grunt.option("target") %>\\App_Plugins\\Imulus.Archetype', flatten: false}, ] + }, + umbracopackage: { + files: [ + {expand: true, cwd: '<%= dest %>/', src: ['**'], dest: 'pkg/tmp/umbraco/App_Plugins/Archetype', flatten: false}, + ] } - }, touch: { @@ -84,6 +88,22 @@ module.exports = function(grunt) { } }, + umbracoPackage: { + options: { + packageName: "WAT", + packageVersion: '1.0', + packageLicenseName: 'MIT', + packageLicenseUrl: '#', + packageUrl: 'http://imulus.com', + authorName: 'Imulus', + authorUrl: '#', + manifest: 'pkg/umbraco/package.xml', + readme: 'pkg/umbraco/readme.txt', + sourceDir: 'pkg/tmp/umbraco', + outputDir: 'pkg', + } + }, + clean: ['<%= dest %>'] }); @@ -96,9 +116,12 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-touch'); + grunt.loadTasks('tasks'); + grunt.registerTask('touchwebconfigifenabled', function() { if (grunt.option("touch")) grunt.task.run("touch:webconfig") }); grunt.registerTask('deploy', ['default', 'copy:deploy', 'touchwebconfigifenabled']); + grunt.registerTask('package:umbraco', ['copy:umbracopackage', 'umbracoPackage']); grunt.registerTask('css:build', ['less']); grunt.registerTask('js:build', ['concat']); grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy:build']); diff --git a/package.json b/package.json index 8b9f64f..776d9fc 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,9 @@ "grunt-contrib-jshint": "~0.7.2", "grunt-cli": "~0.1.11", "grunt-contrib-clean": "~0.5.0", - "grunt-touch": "~0.1.0" + "grunt-touch": "~0.1.0", + "guid": "0.0.12", + "adm-zip": "~0.4.3", + "rimraf": "~2.2.5" } } diff --git a/tasks/umbraco_package.js b/tasks/umbraco_package.js new file mode 100644 index 0000000..6652fe1 --- /dev/null +++ b/tasks/umbraco_package.js @@ -0,0 +1,66 @@ +module.exports = function(grunt) { + grunt.registerTask('umbracoPackage', 'Create Umbraco Package', function() { + grunt.config.requires('umbracoPackage.options.packageName'); + grunt.config.requires('umbracoPackage.options.packageVersion'); + grunt.config.requires('umbracoPackage.options.packageLicenseName'); + grunt.config.requires('umbracoPackage.options.packageLicenseUrl'); + grunt.config.requires('umbracoPackage.options.packageUrl'); + grunt.config.requires('umbracoPackage.options.authorName'); + grunt.config.requires('umbracoPackage.options.authorUrl'); + grunt.config.requires('umbracoPackage.options.manifest'); + grunt.config.requires('umbracoPackage.options.readme'); + grunt.config.requires('umbracoPackage.options.outputDir'); + grunt.config.requires('umbracoPackage.options.sourceDir'); + + var fs = require('fs'); + var Guid = require('guid'); + var path = require('path'); + var rimraf = require('rimraf'); + var AdmZip = require('adm-zip'); + + var options = this.options({ + minimumUmbracoVersion: '', + files: [], + cwd: '/' + }); + + var packageFileName = options.packageName + "_" + options.packageVersion + ".zip" + + // Gather files + var filesToPackage = []; + getFilesRecursive(options.sourceDir); + filesToPackage = filesToPackage.map(function(f) { + return { guid: Guid.create(), dir: f.dir.replace(options.sourceDir, ''), name: f.name }; + }); + + // Load / transform Manifest + options.files = filesToPackage; + options.readmeContents = grunt.file.read(options.readme); + var manifest = grunt.file.read(options.manifest); + manifest = grunt.template.process(manifest, {data: options}); + grunt.file.write(path.join(options.sourceDir, "package.xml"), manifest); // TODO: Probably shouldn't use sourceDir - what if under source control + + // Zip + var zip = new AdmZip(); + filesToPackage.forEach(function(f) { + zip.addLocalFile(path.join(options.sourceDir, f.dir, f.name)) + }) + zip.addLocalFile(path.join(options.sourceDir, "package.xml")); + zip.writeZip(path.join(options.outputDir, packageFileName)) + + function getFilesRecursive(dir) { + var files = fs.readdirSync(dir); + for (var i in files) { + if (!files.hasOwnProperty(i)) continue; + + var name = dir+'/'+files[i]; + if (fs.statSync(name).isDirectory()) { + getFilesRecursive(name); + } else { + filesToPackage.push({ dir: dir, name: files[i]}); + } + } + } + + }); +}; \ No newline at end of file From 9d3f4e76dbb4e7e3005add243ae86e979a2b2a0c Mon Sep 17 00:00:00 2001 From: Tom Fulton Date: Fri, 17 Jan 2014 00:12:29 -0700 Subject: [PATCH 04/18] Quick cleanup of packaging tasks --- .gitignore | 1 + Gruntfile.js | 45 ++++++++++++++++++++++++---------------- package.json | 3 ++- pkg/meta.json | 9 ++++++++ pkg/nuget/package.nuspec | 16 +++++++------- pkg/umbraco/package.xml | 39 ++++++++++++++++++++++++++++++++++ pkg/umbraco/readme.txt | 0 tasks/umbraco_package.js | 40 +++++++++++++++++++++-------------- 8 files changed, 111 insertions(+), 42 deletions(-) create mode 100644 pkg/meta.json create mode 100644 pkg/umbraco/package.xml create mode 100644 pkg/umbraco/readme.txt diff --git a/.gitignore b/.gitignore index 89a7373..fa14c32 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ dist/ node_modules/ pkg/tmp/ pkg/*.nupkg +pkg/*.zip [Dd]ebug/ [Bb]uild/ diff --git a/Gruntfile.js b/Gruntfile.js index febcf19..cc78eba 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,11 +1,12 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + pkgMeta: grunt.file.readJSON('pkg/meta.json'), dest: 'dist', - version: '0.0.0', package_dir: 'pkg', package_temp_dir: '<%= package_dir %>/tmp/', + watch: { less: { files: ['app/less/*.less', 'lib/**/*.less'], @@ -78,7 +79,14 @@ module.exports = function(grunt) { 'nuget_manifest': { 'options': { 'data': { - version: '<%= version %>', + name: '<%= pkgMeta.name %>', + version: '<%= pkgMeta.version %>', + url: '<%= pkgMeta.url %>', + license: '<%= pkgMeta.license %>', + licenseUrl: '<%= pkgMeta.licenseUrl %>', + author: '<%= pkgMeta.author %>', + authorUrl: '<%= pkgMeta.authorUrl %>', + files: [{ path: '..\\..\\..\\<%= dest %>\\**', target: 'content\\App_Plugins\\Archetype'}] } }, @@ -89,8 +97,7 @@ module.exports = function(grunt) { }, clean: { - build: ['<%= dest %>'], - package_temp: ['<%= package_temp_dir %>'] + build: ['<%= dest %>'] }, copy: { @@ -103,17 +110,17 @@ module.exports = function(grunt) { }, deploy: { files: [ - {expand: true, cwd: '<%= dest %>/', src: ['**'], dest: '<%= grunt.option("target") %>\\App_Plugins\\Archetype', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['**/*'], dest: '<%= grunt.option("target") %>\\App_Plugins\\Archetype', flatten: false}, ] }, nuget_prepare: { files: [ - {expand: true, cwd: '<%= dest %>/', src: ['**'], dest: '<%= package_temp_dir %>/nuget/content/', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['**/*'], dest: '<%= package_temp_dir %>/nuget/content/', flatten: false}, ] }, umbracopackage: { files: [ - {expand: true, cwd: '<%= dest %>/', src: ['**'], dest: 'pkg/tmp/umbraco/App_Plugins/Archetype', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['**/*'], dest: 'pkg/tmp/umbraco/<%= guid %>/App_Plugins/Archetype', flatten: false}, ] } }, @@ -127,13 +134,13 @@ module.exports = function(grunt) { umbracoPackage: { options: { - packageName: "WAT", - packageVersion: '1.0', - packageLicenseName: 'MIT', - packageLicenseUrl: '#', - packageUrl: 'http://imulus.com', - authorName: 'Imulus', - authorUrl: '#', + name: "<%= pkgMeta.name %>", + version: '<%= pkgMeta.version %>', + url: '<%= pkgMeta.url %>', + license: '<%= pkgMeta.license %>', + licenseUrl: '<%= pkgMeta.licenseUrl %>', + author: '<%= pkgMeta.author %>', + authorUrl: '<%= pkgMeta.authorUrl %>', manifest: 'pkg/umbraco/package.xml', readme: 'pkg/umbraco/readme.txt', sourceDir: 'pkg/tmp/umbraco', @@ -141,9 +148,10 @@ module.exports = function(grunt) { } }, - clean: ['<%= dest %>'] + clean: { + build: ['<%= dest %>'], + package_temp: ['pkg/tmp'], } - }); grunt.loadNpmTasks('grunt-contrib-watch'); @@ -159,10 +167,11 @@ module.exports = function(grunt) { grunt.loadTasks('tasks'); - grunt.registerTask('package:nuget', ['default', 'clean:package_temp', 'copy:nuget_prepare', 'template:nuget_manifest', 'nugetpack', 'clean:package_temp']); + grunt.registerTask('package', ['package:nuget', 'package:umbraco']); + grunt.registerTask('package:nuget', ['copy:nuget_prepare', 'template:nuget_manifest', 'nugetpack', 'clean:package_temp']); + grunt.registerTask('package:umbraco', ['copy:umbracopackage', 'umbracoPackage', 'clean:package_temp']); grunt.registerTask('touchwebconfigifenabled', function() { if (grunt.option("touch")) grunt.task.run("touch:webconfig") }); grunt.registerTask('deploy', ['default', 'copy:deploy', 'touchwebconfigifenabled']); - grunt.registerTask('package:umbraco', ['copy:umbracopackage', 'umbracoPackage']); grunt.registerTask('css:build', ['less']); grunt.registerTask('js:build', ['concat']); grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy:build']); diff --git a/package.json b/package.json index 3b23fd6..b6970fe 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "rimraf": "~2.2.5", "grunt-nuget": "~0.1.1", "grunt-template": "~0.2.2", - "grunt-touch": "~0.1.0" + "grunt-touch": "~0.1.0", + "fs-extra": "~0.8.1" } } diff --git a/pkg/meta.json b/pkg/meta.json new file mode 100644 index 0000000..b641edc --- /dev/null +++ b/pkg/meta.json @@ -0,0 +1,9 @@ +{ + "name": "Archetype", + "version": "0.1.0", + "url": "http://github.com/imulus/archetype/", + "author": "Imulus", + "authorUrl": "http://imulus.com/", + "license": "MIT", + "licenseUrl": "http://opensource.org/licenses/MIT" +} \ No newline at end of file diff --git a/pkg/nuget/package.nuspec b/pkg/nuget/package.nuspec index e5143cc..6baaa87 100644 --- a/pkg/nuget/package.nuspec +++ b/pkg/nuget/package.nuspec @@ -3,18 +3,18 @@ Archetype <%= version %> - Archetype - imulus, tomfulton - imulus, tomfulton + <%= name %> + imulus, kgiszewski, tomfulton + imulus, kgiszewski, tomfulton http://github.com/imulus/archetype - + umbraco http://github.com/imulus/archetype/raw/master/assets/logo.png - http://www.opensource.org/licenses/mit-license.php + <%= licenseUrl %> - <% for (var file in files) { %> - - <% } %> + <% files.forEach(function(file) { %> + + <% }); %> \ No newline at end of file diff --git a/pkg/umbraco/package.xml b/pkg/umbraco/package.xml new file mode 100644 index 0000000..1bb787a --- /dev/null +++ b/pkg/umbraco/package.xml @@ -0,0 +1,39 @@ + + + + + <%= name %> + <%= version %> + <%= license %> + <%= url %> + + 0 + 0 + 0 + + + + <%= author %> + <%= authorUrl %> + + ]]> + + + + + + + + + + + + <% files.forEach(function(file) { %> + + <%= file.guid %>.<%= file.ext %> + <%= file.dir %> + <%= file.name %> + + <% }); %> + + \ No newline at end of file diff --git a/pkg/umbraco/readme.txt b/pkg/umbraco/readme.txt new file mode 100644 index 0000000..e69de29 diff --git a/tasks/umbraco_package.js b/tasks/umbraco_package.js index 6652fe1..e16d16d 100644 --- a/tasks/umbraco_package.js +++ b/tasks/umbraco_package.js @@ -1,22 +1,22 @@ module.exports = function(grunt) { grunt.registerTask('umbracoPackage', 'Create Umbraco Package', function() { - grunt.config.requires('umbracoPackage.options.packageName'); - grunt.config.requires('umbracoPackage.options.packageVersion'); - grunt.config.requires('umbracoPackage.options.packageLicenseName'); - grunt.config.requires('umbracoPackage.options.packageLicenseUrl'); - grunt.config.requires('umbracoPackage.options.packageUrl'); - grunt.config.requires('umbracoPackage.options.authorName'); + grunt.config.requires('umbracoPackage.options.name'); + grunt.config.requires('umbracoPackage.options.version'); + grunt.config.requires('umbracoPackage.options.license'); + grunt.config.requires('umbracoPackage.options.licenseUrl'); + grunt.config.requires('umbracoPackage.options.url'); + grunt.config.requires('umbracoPackage.options.author'); grunt.config.requires('umbracoPackage.options.authorUrl'); grunt.config.requires('umbracoPackage.options.manifest'); grunt.config.requires('umbracoPackage.options.readme'); grunt.config.requires('umbracoPackage.options.outputDir'); grunt.config.requires('umbracoPackage.options.sourceDir'); - var fs = require('fs'); var Guid = require('guid'); var path = require('path'); var rimraf = require('rimraf'); var AdmZip = require('adm-zip'); + var fs = require('fs-extra'); var options = this.options({ minimumUmbracoVersion: '', @@ -24,28 +24,38 @@ module.exports = function(grunt) { cwd: '/' }); - var packageFileName = options.packageName + "_" + options.packageVersion + ".zip" + var packageFileName = options.name + "_" + options.version + ".zip" // Gather files var filesToPackage = []; getFilesRecursive(options.sourceDir); filesToPackage = filesToPackage.map(function(f) { - return { guid: Guid.create(), dir: f.dir.replace(options.sourceDir, ''), name: f.name }; + return { guid: Guid.create(), dir: f.dir.replace(options.sourceDir, ''), name: f.name, ext: f.name.split('.').pop() }; }); - // Load / transform Manifest + // Create temp folder for package zip source + var guidFolder = Guid.create().toString(); + var newDirName = path.join(options.sourceDir, "..\\" + guidFolder); + fs.mkdirSync(newDirName); + newDirName = path.join(newDirName, guidFolder); + fs.mkdirSync(newDirName); + + // Copy flatten structure, with files renamed as . + filesToPackage.forEach(function(f) { + var newFileName = f.name == "package.xml" ? f.name : f.guid.toString() + '.' + f.ext; + fs.copySync(path.join(options.sourceDir, f.dir, f.name), path.join(newDirName, newFileName)); + }); + + // Load / transform XML Manifest options.files = filesToPackage; options.readmeContents = grunt.file.read(options.readme); var manifest = grunt.file.read(options.manifest); manifest = grunt.template.process(manifest, {data: options}); - grunt.file.write(path.join(options.sourceDir, "package.xml"), manifest); // TODO: Probably shouldn't use sourceDir - what if under source control + grunt.file.write(path.join(options.sourceDir, "..\\", guidFolder, guidFolder, "package.xml"), manifest); // TODO: Probably shouldn't use sourceDir - what if under source control // Zip var zip = new AdmZip(); - filesToPackage.forEach(function(f) { - zip.addLocalFile(path.join(options.sourceDir, f.dir, f.name)) - }) - zip.addLocalFile(path.join(options.sourceDir, "package.xml")); + zip.addLocalFolder(path.join(options.sourceDir, "..\\", guidFolder)); zip.writeZip(path.join(options.outputDir, packageFileName)) function getFilesRecursive(dir) { From e9f710ea9ecc62dee2e2cd2b677f614c2078f846 Mon Sep 17 00:00:00 2001 From: Tom Fulton Date: Fri, 17 Jan 2014 02:54:36 -0700 Subject: [PATCH 05/18] Include C# solution in build/package outputs --- Gruntfile.js | 32 +++++++++++++++++++++++++++----- package.json | 3 ++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index cc78eba..00d67b5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -105,22 +105,26 @@ module.exports = function(grunt) { files: [ {expand: true, cwd: 'app/', src: ['package.manifest'], dest: '<%= dest %>', flatten: true}, {expand: true, cwd: 'app/config/', src: ['config.views.js'], dest: '<%= dest %>/js', flatten: true}, - {expand: true, cwd: 'app/views/', src: ['archetype.html', 'archetype.config.html'], dest: '<%= dest %>/views', flatten: true} + {expand: true, cwd: 'app/views/', src: ['archetype.html', 'archetype.config.html'], dest: '<%= dest %>/views', flatten: true}, + {expand: true, cwd: 'app/Umbraco/Umbraco.Archetype/bin/Debug/', src: ['Archetype.dll'], dest: '<%= dest %>/bin', flatten: true} ] }, deploy: { files: [ - {expand: true, cwd: '<%= dest %>/', src: ['**/*'], dest: '<%= grunt.option("target") %>\\App_Plugins\\Archetype', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['**/*', '!bin/*'], dest: '<%= grunt.option("target") %>\\App_Plugins\\Archetype', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['bin/*'], dest: '<%= grunt.option("target") %>\\bin', flatten: false}, ] }, nuget_prepare: { files: [ - {expand: true, cwd: '<%= dest %>/', src: ['**/*'], dest: '<%= package_temp_dir %>/nuget/content/', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['**/*', '!bin/*'], dest: '<%= package_temp_dir %>/nuget/content/', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['bin/*'], dest: '<%= package_temp_dir %>/nuget/lib/net40/', flatten: false} ] }, umbracopackage: { files: [ - {expand: true, cwd: '<%= dest %>/', src: ['**/*'], dest: 'pkg/tmp/umbraco/<%= guid %>/App_Plugins/Archetype', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['**/*', "!bin/*"], dest: 'pkg/tmp/umbraco/App_Plugins/Archetype', flatten: false}, + {expand: true, cwd: '<%= dest %>/', src: ['bin/*'], dest: 'pkg/tmp/umbraco', flatten: false} ] } }, @@ -151,7 +155,24 @@ module.exports = function(grunt) { clean: { build: ['<%= dest %>'], package_temp: ['pkg/tmp'], + }, + + msbuild: { + dev: { + src: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj'], + options: { + projectConfiguration: 'Debug', + targets: ['Clean', 'Rebuild'], + stdout: true, + maxCpuCount: 4, + buildParameters: { + WarningLevel: 2 + }, + verbosity: 'quiet' + } + } } + }); grunt.loadNpmTasks('grunt-contrib-watch'); @@ -164,6 +185,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-nuget'); grunt.loadNpmTasks('grunt-template'); grunt.loadNpmTasks('grunt-touch'); + grunt.loadNpmTasks('grunt-msbuild'); grunt.loadTasks('tasks'); @@ -174,6 +196,6 @@ module.exports = function(grunt) { grunt.registerTask('deploy', ['default', 'copy:deploy', 'touchwebconfigifenabled']); grunt.registerTask('css:build', ['less']); grunt.registerTask('js:build', ['concat']); - grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy:build']); + grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy:build', 'msbuild:dev']); }; diff --git a/package.json b/package.json index b6970fe..89a6a1c 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "grunt-nuget": "~0.1.1", "grunt-template": "~0.2.2", "grunt-touch": "~0.1.0", - "fs-extra": "~0.8.1" + "fs-extra": "~0.8.1", + "grunt-msbuild": "~0.1.9" } } From 5a092daca9ba78c763422ae5ce684a2c838832fa Mon Sep 17 00:00:00 2001 From: Tom Fulton Date: Fri, 17 Jan 2014 03:22:03 -0700 Subject: [PATCH 06/18] Mark package versions as prelease --- app/Umbraco/Umbraco.Archetype/Properties/AssemblyInfo.cs | 5 +++-- pkg/meta.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Umbraco/Umbraco.Archetype/Properties/AssemblyInfo.cs b/app/Umbraco/Umbraco.Archetype/Properties/AssemblyInfo.cs index 20fd3a3..73447cf 100644 --- a/app/Umbraco/Umbraco.Archetype/Properties/AssemblyInfo.cs +++ b/app/Umbraco/Umbraco.Archetype/Properties/AssemblyInfo.cs @@ -32,5 +32,6 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("0.1.0.0")] +[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyInformationalVersion("0.1.0-alpha")] \ No newline at end of file diff --git a/pkg/meta.json b/pkg/meta.json index b641edc..0d1a857 100644 --- a/pkg/meta.json +++ b/pkg/meta.json @@ -1,6 +1,6 @@ { "name": "Archetype", - "version": "0.1.0", + "version": "0.1.0-alpha", "url": "http://github.com/imulus/archetype/", "author": "Imulus", "authorUrl": "http://imulus.com/", From 8a4f3de023d68d588962e8441dc5775bc2494c2a Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Fri, 17 Jan 2014 10:49:43 -0500 Subject: [PATCH 07/18] Update README.md --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a6e5a9e..9999323 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,12 @@ Archetype Add `--touch` to either command to automatically touch the web.config on a deploy -## Installation ## +## Installation +1) Install the package through Umbraco. -To use this package right from this repo you will need to manually download and copy the files into the appropriate spot: +OR + +2) To use this package right from this repo you will need to manually download and copy the files into the appropriate spot: ###/App_Plugins### @@ -35,8 +38,8 @@ Your /App_Plugins should contain this structure: -- archetype.html ###/bin### -- Drop the Imulus.Archetype.dll in the /bin of your Umbraco install (this dll only handles template helpers, PVC's at present) -- You will have to build this yourself or download it here. +- Drop the Archetype.dll in the /bin of your Umbraco install (this dll only handles template helpers, PVC's at present) +- You will have to build this yourself. ## Prevalue Configs ## From 1443149264a0793e6d5369277acf71dc779a8c59 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Fri, 17 Jan 2014 16:42:13 +0000 Subject: [PATCH 08/18] Added 'repository' field to `packages.json`. This removes npm's nag warning. --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 89a6a1c..5ada328 100644 --- a/package.json +++ b/package.json @@ -21,5 +21,9 @@ "grunt-touch": "~0.1.0", "fs-extra": "~0.8.1", "grunt-msbuild": "~0.1.9" + }, + "repository": { + "type": "git", + "url": "https://github.com/imulus/Archetype.git" } } From 8a42c6fdbddc0abe940e6127ae7908c3f9a40479 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Fri, 17 Jan 2014 12:04:03 -0500 Subject: [PATCH 09/18] Update README.md --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9999323..0b7f9bb 100644 --- a/README.md +++ b/README.md @@ -22,24 +22,26 @@ Add `--touch` to either command to automatically touch the web.config on a deplo OR -2) To use this package right from this repo you will need to manually download and copy the files into the appropriate spot: +2) Deploy with Grunt (see above). Recommended if you wish to extend this repo. -###/App_Plugins### +OR -Your /App_Plugins should contain this structure: +3) Not recommended but a down and dirty way is to manually download and copy the files into the appropriate spot: + +Your /App_Plugins (and /bin) should contain this structure: /App_Plugins - package.manifest - /css -- archetype.css - /js - -- archetype.js (our Grunt script concats the controller.js and all directives into one file, you may have to do so manually) + -- archetype.js (our Grunt script concats the controller.js/config.controller.js, services and all directives into one file, you will have to do so manually) + -- config.views.js - /views -- archetype.html - -###/bin### -- Drop the Archetype.dll in the /bin of your Umbraco install (this dll only handles template helpers, PVC's at present) -- You will have to build this yourself. + -- archetype.config.html + /bin + -- archectype.dll (you'll have to build it) ## Prevalue Configs ## From eb2cbf7a8f4cbf175a669884d312e0662e1b75d1 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Fri, 17 Jan 2014 12:16:35 -0500 Subject: [PATCH 10/18] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0b7f9bb..9f4208f 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,17 @@ Archetype Add `--touch` to either command to automatically touch the web.config on a deploy ## Installation -1) Install the package through Umbraco. +1) Install the package through the Umbraco package installer. Recommended if you want to just see the packaged version. OR -2) Deploy with Grunt (see above). Recommended if you wish to extend this repo. +2) Deploy with Grunt (see above). Recommended if you wish to extend this repo as this will inject this project into an existing v7 Umbraco install. OR 3) Not recommended but a down and dirty way is to manually download and copy the files into the appropriate spot: -Your /App_Plugins (and /bin) should contain this structure: +Your /App_Plugins and /bin should contain this structure: /App_Plugins - package.manifest @@ -41,7 +41,7 @@ Your /App_Plugins (and /bin) should contain this structure: -- archetype.html -- archetype.config.html /bin - -- archectype.dll (you'll have to build it) + -- archetype.dll (you'll have to build it) ## Prevalue Configs ## From 4900dcc5b64c9981b4d24b49b07b6800779d5070 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Fri, 17 Jan 2014 14:16:49 -0500 Subject: [PATCH 11/18] Rename getPropertyIdByAlias, convert getFieldsetByAlias to underscore notation --- app/directives/archetypeproperty.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/directives/archetypeproperty.js b/app/directives/archetypeproperty.js index 06dc6da..5ec5b33 100644 --- a/app/directives/archetypeproperty.js +++ b/app/directives/archetypeproperty.js @@ -2,16 +2,12 @@ function getFieldsetByAlias(fieldsets, alias) { - for (var i in fieldsets) - { - if (fieldsets[i].alias == alias) - { - return fieldsets[i]; - } - } + return _.find(fieldsets, function(fieldset){ + return fieldset.alias == alias; + }); } - function getPropertyIdByAlias(properties, alias) + function getPropertyIndexByAlias(properties, alias) { for (var i in properties) { @@ -87,12 +83,12 @@ scope.model.config = {}; //ini the property value after test to make sure a prop exists in the renderModel - var renderModelPropertyIndex = getPropertyIdByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias); + var renderModelPropertyIndex = getPropertyIndexByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias); if (!renderModelPropertyIndex) { scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties.push(eval("({alias: '" + alias + "', value:'" + defaultValue + "'})")); - renderModelPropertyIndex = getPropertyIdByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias); + renderModelPropertyIndex = getPropertyIndexByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias); } scope.model.value = scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties[renderModelPropertyIndex].value; From d5d05cef2fd31bcb8050bb5bf85b2f3da640d897 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Sun, 19 Jan 2014 08:00:09 -0500 Subject: [PATCH 12/18] Rename the propertyEditorService to propertyEditorResource --- Gruntfile.js | 2 +- app/controllers/config.controller.js | 8 ++++---- app/{services => resources}/propertyeditor.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename app/{services => resources}/propertyeditor.js (67%) diff --git a/Gruntfile.js b/Gruntfile.js index 4552698..7258194 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -58,7 +58,7 @@ module.exports = function(grunt) { 'app/controllers/controller.js', 'app/controllers/config.controller.js', 'app/directives/archetypeproperty.js', - 'app/services/propertyeditor.js' + 'app/resources/propertyeditor.js' ], dest: '<%= dest %>/js/archetype.js' } diff --git a/app/controllers/config.controller.js b/app/controllers/config.controller.js index 8a6734f..2117588 100644 --- a/app/controllers/config.controller.js +++ b/app/controllers/config.controller.js @@ -1,4 +1,4 @@ -angular.module("umbraco").controller("Imulus.ArchetypeConfigController", function ($scope, $http, assetsService, propertyEditorService) { +angular.module("umbraco").controller("Imulus.ArchetypeConfigController", function ($scope, $http, assetsService, propertyEditorResource) { //$scope.model.value = ""; //console.log($scope.model.value); @@ -10,12 +10,12 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio $scope.model.value = $scope.model.value || defaultFieldsetConfigModel; initConfigRenderModel(); - + //get the available views - propertyEditorService.getViews().then(function(data){ + propertyEditorResource.getViews().then(function(data){ $scope.availableViews = data; }); - + $scope.sortableOptions = { axis: 'y', cursor: "move", diff --git a/app/services/propertyeditor.js b/app/resources/propertyeditor.js similarity index 67% rename from app/services/propertyeditor.js rename to app/resources/propertyeditor.js index 57bf02b..d24a34c 100644 --- a/app/services/propertyeditor.js +++ b/app/resources/propertyeditor.js @@ -1,5 +1,5 @@ -angular.module('umbraco').factory('propertyEditorService', function($q, $http, umbRequestHelper){ - return { +angular.module('umbraco').factory('propertyEditorResource', function($q, $http, umbRequestHelper){ + return { getViews: function() { return umbRequestHelper.resourcePromise( $http.get("/App_Plugins/Archetype/js/config.views.js"), 'Failed to retreive config for views.' From 41dfac827aff3abac04a225add1b3f362b7ffa13 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Sun, 19 Jan 2014 08:12:51 -0500 Subject: [PATCH 13/18] Remove deep watch b/c we are no longer tracking real-time changes of the config/default value --- app/controllers/config.controller.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/config.controller.js b/app/controllers/config.controller.js index 2117588..76ce477 100644 --- a/app/controllers/config.controller.js +++ b/app/controllers/config.controller.js @@ -101,7 +101,6 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio $scope.archetypeConfigRenderModel = JSON.parse(v); $scope.archetypeConfigRenderModel.toString = stringify; } - }, true); //helper that returns if an item can be removed $scope.canRemoveFieldset = function () From acc27c1976f4a43dff2a2f730db4d303e3f97238 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Sun, 19 Jan 2014 08:13:47 -0500 Subject: [PATCH 14/18] Add missing closing tokens --- app/controllers/config.controller.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/config.controller.js b/app/controllers/config.controller.js index 76ce477..99cc8c6 100644 --- a/app/controllers/config.controller.js +++ b/app/controllers/config.controller.js @@ -101,6 +101,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio $scope.archetypeConfigRenderModel = JSON.parse(v); $scope.archetypeConfigRenderModel.toString = stringify; } + }); //helper that returns if an item can be removed $scope.canRemoveFieldset = function () From 41c43f1b7e32b4e71dc2aa68ae2e25afc25e3519 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Sun, 19 Jan 2014 08:14:19 -0500 Subject: [PATCH 15/18] Remove function no longer used --- app/controllers/controller.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/controllers/controller.js b/app/controllers/controller.js index 39beb32..a6f6b28 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -157,21 +157,6 @@ //ini $scope.focusFieldset(); - //helper returns valid JS or null - function getValidJson(variable, json) - { - if(!json) return null; - - try { - return eval("(" + json + ")"); - } - catch (e) { - console.log("There was an error while using 'eval' on " + variable); - console.log(json); - return null; - } - } - //developerMode helpers $scope.archetypeRenderModel.toString = stringify; From ffc876eed26ec6da5ade007d53c54d65a8931e60 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Sun, 19 Jan 2014 08:14:27 -0500 Subject: [PATCH 16/18] Update comments --- app/controllers/config.controller.js | 10 +++++++++- app/controllers/controller.js | 19 +++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/controllers/config.controller.js b/app/controllers/config.controller.js index 99cc8c6..4d32e25 100644 --- a/app/controllers/config.controller.js +++ b/app/controllers/config.controller.js @@ -3,12 +3,15 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio //$scope.model.value = ""; //console.log($scope.model.value); + //define empty items var newPropertyModel = '{alias: "", remove: false, collapse: false, label: "", helpText: "", view: "", value: "", config: ""}'; var newFieldsetModel = '{alias: "", remove: false, collapse: false, labelTemplate: "", tooltip: "", icon: "", label: "", headerText: "", footerText: "", properties:[' + newPropertyModel + ']}'; var defaultFieldsetConfigModel = eval("({showAdvancedOptions: false, hideFieldsetToolbar: false, enableMultipleFieldsets: false, hideFieldsetControls: false, hideFieldsetLabels: false, hidePropertyLabel: false, maxFieldsets: null, fieldsets: [" + newFieldsetModel + "]})"); + //ini the model $scope.model.value = $scope.model.value || defaultFieldsetConfigModel; + //ini the render model initConfigRenderModel(); //get the available views @@ -16,6 +19,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio $scope.availableViews = data; }); + //config for the sorting $scope.sortableOptions = { axis: 'y', cursor: "move", @@ -28,6 +32,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio } }; + //function that determines how to manage expanding/collapsing fieldsets $scope.focusFieldset = function(fieldset){ var iniState; @@ -58,9 +63,11 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio fieldset.collapse = !iniState; } } - //ini + + //ini the fieldsets $scope.focusFieldset(); + //function that determines how to manage expanding/collapsing properties $scope.focusProperty = function(properties, property){ var iniState; @@ -141,6 +148,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio return count; } + //determines how many properties are visible function countVisibleProperty(fieldset) { var count = 0; diff --git a/app/controllers/controller.js b/app/controllers/controller.js index a6f6b28..8f95650 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -1,16 +1,17 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($scope, $http, $interpolate, assetsService, angularHelper, notificationsService) { //$scope.model.value = ""; - //set default value of the model - //this works by checking to see if there is a model; then cascades to the default model then to an empty fieldset + //get a reference to the current form var form = angularHelper.getCurrentForm($scope); + //set the config equal to our prevalue config $scope.model.config = $scope.model.config.archetypeConfig; + //ini the model $scope.model.value = $scope.model.value || { fieldsets: [getEmptyRenderFieldset($scope.model.config.fieldsets[0])] }; - //ini + //ini the render model $scope.archetypeRenderModel = {}; initArchetypeRenderModel(); @@ -31,10 +32,7 @@ return parsedTemplate; }; - /* add/remove/sort */ - - //defines the options for the jquery sortable - //i used an ng-model="archetypeRenderModel" so the sort updates the right model + //sort config $scope.sortableOptions = { axis: 'y', cursor: "move", @@ -128,7 +126,7 @@ return (typeof property !== 'undefined') ? property.value : ''; }; - //helper for collapsing + //helper for expanding/collapsing fieldsets $scope.focusFieldset = function(fieldset){ var iniState; @@ -154,7 +152,7 @@ } } - //ini + //ini the fieldset expand/collapse $scope.focusFieldset(); //developerMode helpers @@ -213,7 +211,7 @@ }); } - //helper to add an empty fieldset + //helper to add an empty fieldset to the render model function getEmptyRenderFieldset (fieldsetModel) { return eval("({ alias: '" + fieldsetModel.alias + "', remove: false, properties: []})"); @@ -273,6 +271,7 @@ return validation; } + //helper to lookup validity when given a fieldsetIndex and property alias $scope.getPropertyValidity = function(fieldsetIndex, alias) { if($scope.archetypeRenderModel.fieldsets[fieldsetIndex]) From 12428c71a9b1db52da3ae3efa3c4f32f33ecf333 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Sun, 19 Jan 2014 08:51:49 -0500 Subject: [PATCH 17/18] Use JSON.parse in favor of eval() --- app/controllers/config.controller.js | 10 ++--- app/controllers/controller.js | 2 +- app/directives/archetypeproperty.js | 65 ++++++++++++---------------- 3 files changed, 34 insertions(+), 43 deletions(-) diff --git a/app/controllers/config.controller.js b/app/controllers/config.controller.js index 4d32e25..8bd5bd9 100644 --- a/app/controllers/config.controller.js +++ b/app/controllers/config.controller.js @@ -4,9 +4,9 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio //console.log($scope.model.value); //define empty items - var newPropertyModel = '{alias: "", remove: false, collapse: false, label: "", helpText: "", view: "", value: "", config: ""}'; - var newFieldsetModel = '{alias: "", remove: false, collapse: false, labelTemplate: "", tooltip: "", icon: "", label: "", headerText: "", footerText: "", properties:[' + newPropertyModel + ']}'; - var defaultFieldsetConfigModel = eval("({showAdvancedOptions: false, hideFieldsetToolbar: false, enableMultipleFieldsets: false, hideFieldsetControls: false, hideFieldsetLabels: false, hidePropertyLabel: false, maxFieldsets: null, fieldsets: [" + newFieldsetModel + "]})"); + var newPropertyModel = '{"alias": "", "remove": false, "collapse": false, "label": "", "helpText": "", "view": "", "value": "", "config": ""}'; + var newFieldsetModel = '{"alias": "", "remove": false, "collapse": false, "labelTemplate": "", "tooltip": "", "icon": "", "label": "", "headerText": "", "footerText": "", "properties": [' + newPropertyModel + ']}'; + var defaultFieldsetConfigModel = JSON.parse('{"showAdvancedOptions": false, "hideFieldsetToolbar": false, "enableMultipleFieldsets": false, "hideFieldsetControls": false, "hideFieldsetLabels": false, "hidePropertyLabel": false, "maxFieldsets": null, "fieldsets": [' + newFieldsetModel + ']}'); //ini the model $scope.model.value = $scope.model.value || defaultFieldsetConfigModel; @@ -164,7 +164,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio //handles a fieldset add $scope.addFieldsetRow = function ($index, $event) { - $scope.archetypeConfigRenderModel.fieldsets.splice($index + 1, 0, eval("(" + newFieldsetModel + ")")); + $scope.archetypeConfigRenderModel.fieldsets.splice($index + 1, 0, JSON.parse(newFieldsetModel)); $scope.focusFieldset(); } @@ -179,7 +179,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio //handles a property add $scope.addPropertyRow = function (fieldset, $index) { - fieldset.properties.splice($index + 1, 0, eval("(" + newPropertyModel + ")")); + fieldset.properties.splice($index + 1, 0, JSON.parse(newPropertyModel)); } //rather than splice the archetypeConfigRenderModel, we're hiding this and cleaning onFormSubmitting diff --git a/app/controllers/controller.js b/app/controllers/controller.js index 8f95650..e185504 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -214,7 +214,7 @@ //helper to add an empty fieldset to the render model function getEmptyRenderFieldset (fieldsetModel) { - return eval("({ alias: '" + fieldsetModel.alias + "', remove: false, properties: []})"); + return JSON.parse('{"alias": "' + fieldsetModel.alias + '", "remove": false, "properties": []}'); } //helper for validation diff --git a/app/directives/archetypeproperty.js b/app/directives/archetypeproperty.js index 5ec5b33..3202746 100644 --- a/app/directives/archetypeproperty.js +++ b/app/directives/archetypeproperty.js @@ -17,6 +17,31 @@ } } + //helper that returns a JS ojbect from 'value' string or the original string + function jsonOrString(value, developerMode, debugLabel){ + if(value && typeof value == 'string'){ + try{ + if(developerMode == '1'){ + console.log("Trying to parse " + debugLabel + ": " + value); + } + value = JSON.parse(value); + } + catch(exception) + { + if(developerMode == '1'){ + console.log("Failed to parse " + debugLabel + "."); + } + } + } + + if(value && developerMode == '1'){ + console.log(debugLabel + " post-parsing: "); + console.log(value); + } + + return value; + } + var linker = function (scope, element, attrs) { var configFieldsetModel = getFieldsetByAlias(scope.archetypeConfig.fieldsets, scope.fieldset.alias); @@ -28,44 +53,10 @@ var defaultValue = configFieldsetModel.properties[scope.propertyConfigIndex].value; //try to convert the config to a JS object - if(config && typeof config == 'string'){ - try{ - if(scope.archetypeConfig.developerMode == '1'){ - console.log("Trying to eval config: " + config); - } - config = eval("(" + config + ")"); - } - catch(exception) - { - if(scope.archetypeConfig.developerMode == '1'){ - console.log("Failed to eval config."); - } - } - } - - if(config && scope.archetypeConfig.developerMode == '1'){ - console.log("Config post-eval: " + config); - } + config = jsonOrString(config, scope.archetypeConfig.developerMode, "config"); //try to convert the defaultValue to a JS object - if(defaultValue && typeof defaultValue == 'string'){ - try{ - if(scope.archetypeConfig.developerMode == '1'){ - console.log("Trying to eval default value: " + defaultValue); - } - defaultValue = eval("(" + defaultValue + ")"); - } - catch(exception) - { - if(scope.archetypeConfig.developerMode == '1'){ - console.log("Failed to eval defaultValue."); - } - } - } - - if(defaultValue && scope.archetypeConfig.developerMode == '1'){ - console.log("Default value post-eval: " + defaultValue); - } + defaultValue = jsonOrString(defaultValue, scope.archetypeConfig.developerMode, "defaultValue"); if (view) { @@ -87,7 +78,7 @@ if (!renderModelPropertyIndex) { - scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties.push(eval("({alias: '" + alias + "', value:'" + defaultValue + "'})")); + scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties.push(JSON.parse('{"alias": "' + alias + '", "value": "' + defaultValue + '"}')); renderModelPropertyIndex = getPropertyIndexByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias); } scope.model.value = scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties[renderModelPropertyIndex].value; From 3cff83af7272315cb6fda5663825cafcdd505a4b Mon Sep 17 00:00:00 2001 From: Tom Fulton Date: Mon, 27 Jan 2014 00:31:44 -0700 Subject: [PATCH 18/18] Quick UI update --- app/less/archetype.less | 80 ++++++++++++++++++++++++++++++++++------ app/views/archetype.html | 58 ++++++++++++++++++----------- 2 files changed, 105 insertions(+), 33 deletions(-) diff --git a/app/less/archetype.less b/app/less/archetype.less index 9595008..eb06cfc 100644 --- a/app/less/archetype.less +++ b/app/less/archetype.less @@ -1,20 +1,63 @@ .archetypeEditor fieldset{ - border: 1px solid #666; - padding: 5px; + border: 1px solid #dddddd; + padding: 0; margin-bottom: 5px; - background-color: #fff; + background-color: #f1f1f1; clear: both; + display: inline-block; + width: 100%; } -.archetypeEditor label{ - width: 75px; +.archetypeEditor .archetypeFieldsetLabel { + padding: 8px 25px 8px 3px; float: left; + width: 98%; + + span { + font-weight: bold; + } + + &:hover { + cursor: pointer; + + label span { + text-decoration: underline; + } + } + + .caret { + float:left; + margin: 8px 1px 0 7px; + &.caret-right { + border-bottom: 4px solid transparent; + border-top: 4px solid transparent; + border-left: 4px solid #000000; + content: ""; + margin-top: 6px; + } + } + + label{ + width: 75px; + float: left; + } } -.archetypeEditor fieldset>label{ +.archetypeEditor .arechetypeCollapser{ + clear: both; + height: 100%; + margin-top: 10px; + padding-top: 12px; + background-color: #fff; + border-top: 1px solid silver; + border-radius: 0 0 0 5px; +} + +.archetypeEditor fieldset .archetypeFieldsetLabel label{ float: left; - width: 200px; - padding-left: 0; + width: auto; + margin-bottom: 0; + padding: 0; } .archetypeEditor .multiPropertyTextbox{ @@ -23,10 +66,22 @@ .archetypeEditor ul{ list-style: none; + margin-left: 0; } .archetypeEditor .archetypeEditorControls{ float: right; + i:hover { + cursor: pointer; + } +} + +.archetypeEditor form { + margin-left:20px; + + .control-label { + padding-top: 0 !important; + } } .archetypeEditor .archetypeProperty{ @@ -146,10 +201,6 @@ overflow: hidden; } -.archetypeConfig .archetypeFieldsetCollapser{ - margin-top: 10px; -} - .archetypeConfig .archetypeOptions label{ width: 200px; } @@ -187,4 +238,9 @@ margin-bottom: 5px; padding-top: 3px; padding-bottom: 3px; +} + +.ui-sortable-placeholder { + visibility: visible !important; + background-color: #d0e7f1 !important; } \ No newline at end of file diff --git a/app/views/archetype.html b/app/views/archetype.html index c48ff8d..1cba82e 100644 --- a/app/views/archetype.html +++ b/app/views/archetype.html @@ -8,35 +8,51 @@ +
  • - -
    - - - -
    -
    +
    + + + + + +
    + + + +
    +
    +
    +
    {{fieldsetConfigModel.headerText}} -
    -
    - - -
    + +
    +
    + + +
    + +
    +
    +
    + +
    {{fieldsetConfigModel.footerText}} -
    +
    +