diff --git a/Gulpfile.js b/Gulpfile.js index 597b426f..9c6dcc3a 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -37,21 +37,21 @@ gulp.task('vendor', function () { }) gulp.task('styl', function () { - return gulp.src('src/**/app.styl') + return gulp.src('src/browser/main/styles/app.styl') .pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')})) .pipe(styl()) .pipe(autoprefixer()) - .pipe(gulp.dest('src')) + .pipe(gulp.dest('src/browser/main/styles/')) .pipe(livereload()) .pipe(notify('Stylus!!')) }) gulp.task('bs', function () { - return gulp.src('src/**/bootstrap.styl') + return gulp.src('src/browser/shared/styles/bootstrap.styl') .pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')})) .pipe(styl()) .pipe(autoprefixer()) - .pipe(gulp.dest('src')) + .pipe(gulp.dest('src/browser/shared/styles')) .pipe(notify('Bootstrap compiled!!')) .pipe(livereload()) }) @@ -75,7 +75,8 @@ gulp.task('watch-main', function () { gulp.watch( ['src/browser/main/index.inject.html', 'src/browser/main/**/*.js', 'src/browser/main/**/*.css', 'src/browser/shared/**/*.js', 'src/browser/shared/**/*.css'], ['inject-main']) - gulp.watch('src/**/*.styl', ['styl']) + gulp.watch('src/browser/main/styles/**/*.styl', ['styl']) + gulp.watch('src/browser/shared/styles/**/*.styl', ['bs']) livereload.listen() }) gulp.task('inject-popup', function () { diff --git a/src/browser/main/controllers/modals/ExpandRecipeModalController.js b/src/browser/main/controllers/modals/ExpandRecipeModalController.js new file mode 100644 index 00000000..9b59309f --- /dev/null +++ b/src/browser/main/controllers/modals/ExpandRecipeModalController.js @@ -0,0 +1,23 @@ +/* global angular */ +angular.module('codexen') + .controller('ExpandRecipeModalController', function (recipe, $modalInstance, $scope, Modal) { + var vm = this + console.log(recipe) + + vm.recipe = recipe + + vm.cancel = function () { + $modalInstance.dismiss('cancel') + } + + vm.insert = function (type) { + $scope.$broadcast('insertRequested', type) + } + + vm.insertSnippet = function () { + Modal.selectSnippet() + .then(function (snippet) { + $scope.$broadcast('insertSnippetRequested', snippet) + }) + } + }) diff --git a/src/browser/main/controllers/modals/NewRecipeModalController.js b/src/browser/main/controllers/modals/NewRecipeModalController.js index 5b1d072e..e1647964 100644 --- a/src/browser/main/controllers/modals/NewRecipeModalController.js +++ b/src/browser/main/controllers/modals/NewRecipeModalController.js @@ -3,13 +3,13 @@ angular.module('codexen') .controller('NewRecipeModalController', function (Recipe, Tag, $modalInstance) { var vm = this - vm.content = '' + vm.recipe = {} vm.submit = function () { var params = { - title: vm.title, - content: vm.content, - Tags: angular.isArray(vm.Tags) ? vm.Tags.map(function (tag) { return tag.name }) : [] + title: vm.recipe.title, + content: vm.recipe.content, + Tags: angular.isArray(vm.recipe.Tags) ? vm.recipe.Tags.map(function (tag) { return tag.name }) : [] } Recipe.create(params) diff --git a/src/browser/main/controllers/modals/SelectSnippetModalController.js b/src/browser/main/controllers/modals/SelectSnippetModalController.js new file mode 100644 index 00000000..be9b78e7 --- /dev/null +++ b/src/browser/main/controllers/modals/SelectSnippetModalController.js @@ -0,0 +1,18 @@ +/* global angular */ +angular.module('codexen') + .controller('SelectSnippetModalController', function (Snippet, $modalInstance) { + var vm = this + + vm.select = function (snippet) { + $modalInstance.close(snippet) + } + + vm.cancel = function () { + $modalInstance.dismiss('cancel') + } + + Snippet.findMine() + .success(function (snippets) { + vm.snippets = snippets + }) + }) diff --git a/src/browser/main/directives/btn-delete-snippet.js b/src/browser/main/directives/btn-delete-snippet.js index 6ae530f6..83e2b0af 100644 --- a/src/browser/main/directives/btn-delete-snippet.js +++ b/src/browser/main/directives/btn-delete-snippet.js @@ -8,8 +8,8 @@ angular.module('codexen') link: function (scope, el) { el.on('click', function () { Modal.deleteSnippet(scope.snippet) - .result.then(function (snippet) { - $rootScope.$broadcast('snippetDeleted', snippet) + .then(function (snippet) { + console.log('deleted', snippet) }, function () { console.log('delete snippet modal dismissed') }) diff --git a/src/browser/main/directives/btn-expand-recipe.js b/src/browser/main/directives/btn-expand-recipe.js new file mode 100644 index 00000000..41f3e2a0 --- /dev/null +++ b/src/browser/main/directives/btn-expand-recipe.js @@ -0,0 +1,15 @@ +/* global angular */ +angular.module('codexen') + .directive('btnExpandRecipe', function (Modal) { + return { + restrict: 'A', + scope: { + recipe: '=btnExpandRecipe' + }, + link: function (scope, el) { + el.on('click', function () { + Modal.expandRecipe(scope.recipe) + }) + } + } + }) diff --git a/src/browser/main/services/Marked.js b/src/browser/main/filters/marked.js similarity index 81% rename from src/browser/main/services/Marked.js rename to src/browser/main/filters/marked.js index 7f3c6422..40b2c311 100644 --- a/src/browser/main/services/Marked.js +++ b/src/browser/main/filters/marked.js @@ -12,7 +12,8 @@ angular.module('codexen') smartypants: false }) - return function(input) { + return function (input) { + if (!angular.isString(input)) input = '' return marked(input) } }) diff --git a/src/browser/main/index.html b/src/browser/main/index.html index 66debe59..f968fea2 100644 --- a/src/browser/main/index.html +++ b/src/browser/main/index.html @@ -38,10 +38,12 @@ + + @@ -49,22 +51,23 @@ - - - - + + + + + diff --git a/src/browser/main/services/Modal.js b/src/browser/main/services/Modal.js index c4eb1dc3..00252c64 100644 --- a/src/browser/main/services/Modal.js +++ b/src/browser/main/services/Modal.js @@ -25,6 +25,19 @@ angular.module('codexen') }) } + var expandRecipe = function (recipe) { + return $modal.open({ + size: 'lg', + resolve: { + recipe: function () { + return recipe + } + }, + templateUrl: 'tpls/modals/expand-recipe-modal.html', + controller: 'ExpandRecipeModalController as vm' + }) + } + var deleteRecipe = function (recipe) { return $modal.open({ resolve: { @@ -77,12 +90,21 @@ angular.module('codexen') }) } + var selectSnippet = function (snippet) { + return $modal.open({ + templateUrl: 'tpls/modals/select-snippet-modal.html', + controller: 'SelectSnippetModalController as vm' + }).result + } + return { newRecipe: newRecipe, editRecipe: editRecipe, deleteRecipe: deleteRecipe, + expandRecipe: expandRecipe, newSnippet: newSnippet, editSnippet: editSnippet, - deleteSnippet: deleteSnippet + deleteSnippet: deleteSnippet, + selectSnippet: selectSnippet } }) diff --git a/src/browser/main/styles/app.css b/src/browser/main/styles/app.css index 71f3d459..9fdebb3a 100644 --- a/src/browser/main/styles/app.css +++ b/src/browser/main/styles/app.css @@ -1,6 +1,31 @@ +.expand-recipe-modal .expand-editor .editor-pane { + height: 500px; +} +.expand-recipe-modal .expand-editor .editor-pane .ace_editor { + height: 500px; +} +.expand-recipe-modal .expand-editor .preview-pane { + height: 500px; + overflow-y: auto; +} .new-snippet-modal .ace_editor { height: 200px; } +.select-snippet-modal .snippet-list { + list-style: none; + padding: 0; +} +.select-snippet-modal .snippet-list li { + padding: 10px; + border: solid 1px #001a20; + background-color: #003b4a; + border-radius: 5px; + margin-bottom: 5px; + cursor: pointer; +} +.select-snippet-modal .snippet-list li:hover { + background-color: #004b5f; +} #side-view .nav-control-group { margin: auto 10px; } @@ -402,3 +427,102 @@ body > .ui-select-bootstrap.open { overflow-y: auto; background-color: $bgDarker; } +.marked h1, +.marked h2, +.marked h3, +.marked h4, +.marked h5 { + margin: 0.75em 0; +} +.marked h1:nth-child(1), +.marked h2:nth-child(1), +.marked h3:nth-child(1), +.marked h4:nth-child(1), +.marked h5:nth-child(1) { + margin-top: 0; +} +.marked code { + background-color: #003644; + color: #fff; + border: 1px solid #001a20; + border-radius: 5px; + box-shadow: 0 1px 1px rgba(0,0,0,0.05); + padding: 5px; + line-height: 200%; +} +.marked pre { + margin-bottom: 10px; + background-color: #003644; + color: #fff; + border: 1px solid #001a20; + border-radius: 5px; + box-shadow: 0 1px 1px rgba(0,0,0,0.05); + padding: 5px; +} +.marked pre >code { + background-color: transparent; + color: inherit; + border: none; + border-radius: 0; + box-shadow: none; + padding: 0; + line-height: inherit; +} +.marked blockquote { + font-size: 1em; + border-left: 5px solid #6494ed; +} +.marked a { + text-decoration: underline; + color: #6494ed; +} +.marked table { + width: 100%; + max-width: 100%; + margin-bottom: $line-height-computed; + border: 1px solid #001a20; + margin-bottom: 10px; +} +.marked table > thead > tr > th, +.marked table > tbody > tr > th, +.marked table > tfoot > tr > th, +.marked table > thead > tr > td, +.marked table > tbody > tr > td, +.marked table > tfoot > tr > td { + padding: 10px; + line-height: $line-height-base; + vertical-align: top; + border-top: 1px solid #001a20; + border-right: 1px solid #001a20; +} +.marked table > thead > tr > th:nth-last-child(1), +.marked table > tbody > tr > th:nth-last-child(1), +.marked table > tfoot > tr > th:nth-last-child(1), +.marked table > thead > tr > td:nth-last-child(1), +.marked table > tbody > tr > td:nth-last-child(1), +.marked table > tfoot > tr > td:nth-last-child(1) { + border-right: none; +} +.marked table > thead > tr > th { + vertical-align: bottom; + border-bottom: 2px solid #001a20; +} +.marked table > caption + thead, +.marked table > colgroup + thead, +.marked table > thead:first-child { + background-color: #004b5f; +} +.marked table > caption + thead > tr:first-child > th, +.marked table > colgroup + thead > tr:first-child > th, +.marked table > thead:first-child > tr:first-child > th, +.marked table > caption + thead > tr:first-child > td, +.marked table > colgroup + thead > tr:first-child > td, +.marked table > thead:first-child > tr:first-child > td { + border-top: 0; +} +.marked table > tbody >tr:nth-child(odd) { + background-color: #002b36; +} +.marked table > tbody >tr:nth-child(even) { + background-color: #003644; +} diff --git a/src/browser/main/styles/app.styl b/src/browser/main/styles/app.styl index 2091d773..09f953ca 100644 --- a/src/browser/main/styles/app.styl +++ b/src/browser/main/styles/app.styl @@ -25,3 +25,77 @@ overflow-x: hidden overflow-y: auto background-color $bgDarker + +.marked + h1, h2, h3, h4, h5 + margin 0.75em 0 + &:nth-child(1) + margin-top 0 + code + background-color lighten($baseBackgroundColor, 3%) + color $textColorSelected + border 1px solid $baseBorderColor + border-radius 5px + box-shadow 0 1px 1px rgba(0, 0, 0, .05) + padding 5px + line-height 200% + pre + margin-bottom 10px + background-color lighten($baseBackgroundColor, 3%) + color $textColorSelected + border 1px solid $baseBorderColor + border-radius 5px + box-shadow 0 1px 1px rgba(0, 0, 0, .05) + padding 5px + >code + background-color transparent + color inherit + border none + border-radius 0 + box-shadow none + padding 0 + line-height inherit + blockquote + font-size 1em + border-left 5px solid $textColorInfo + a + text-decoration underline + color $textColorInfo + table + width 100% + max-width 100% + margin-bottom $line-height-computed + border 1px solid $table-border-color + margin-bottom 10px + + // Cells + > thead, + > tbody, + > tfoot + > tr + > th, + > td + padding 10px + line-height $line-height-base + vertical-align top + border-top 1px solid $table-border-color + border-right 1px solid $table-border-color + &:nth-last-child(1) + border-right none + > thead > tr > th + vertical-align bottom + border-bottom 2px solid $table-border-color + > caption + thead, + > colgroup + thead, + > thead:first-child + background-color $backgroundColorSelected + > tr:first-child + > th, + > td + border-top 0 + > tbody + >tr + &:nth-child(odd) + background-color $baseBackgroundColor + &:nth-child(even) + background-color lighten($baseBackgroundColor, 3%) diff --git a/src/browser/main/styles/modals/expand-recipe-modal.styl b/src/browser/main/styles/modals/expand-recipe-modal.styl new file mode 100644 index 00000000..922114c4 --- /dev/null +++ b/src/browser/main/styles/modals/expand-recipe-modal.styl @@ -0,0 +1,9 @@ +.expand-recipe-modal + .expand-editor + .editor-pane + height 500px + .ace_editor + height 500px + .preview-pane + height 500px + overflow-y auto diff --git a/src/browser/main/styles/modals/select-snippet-modal.styl b/src/browser/main/styles/modals/select-snippet-modal.styl new file mode 100644 index 00000000..d127539b --- /dev/null +++ b/src/browser/main/styles/modals/select-snippet-modal.styl @@ -0,0 +1,13 @@ +.select-snippet-modal + .snippet-list + list-style none + padding 0 + li + padding 10px + border solid 1px $baseBorderColor + background-color $backgroundColorHighlight + border-radius 5px + margin-bottom 5px + cursor pointer + &:hover + background-color $backgroundColorSelected diff --git a/src/browser/main/tpls/directives/snippet-view.html b/src/browser/main/tpls/directives/snippet-view.html new file mode 100644 index 00000000..c8cfb83b --- /dev/null +++ b/src/browser/main/tpls/directives/snippet-view.html @@ -0,0 +1,14 @@ +
diff --git a/src/browser/main/tpls/modals/edit-recipe-modal.html b/src/browser/main/tpls/modals/edit-recipe-modal.html index b6020748..5fc51c8b 100644 --- a/src/browser/main/tpls/modals/edit-recipe-modal.html +++ b/src/browser/main/tpls/modals/edit-recipe-modal.html @@ -14,12 +14,6 @@ Markdown -
- - - -
-
-
+
+
+ + +
+
{{$item.name}} diff --git a/src/browser/main/tpls/modals/expand-recipe-modal.html b/src/browser/main/tpls/modals/expand-recipe-modal.html new file mode 100644 index 00000000..e2d64a31 --- /dev/null +++ b/src/browser/main/tpls/modals/expand-recipe-modal.html @@ -0,0 +1,37 @@ +
+ + + +
diff --git a/src/browser/main/tpls/modals/new-recipe-modal.html b/src/browser/main/tpls/modals/new-recipe-modal.html index e10c12a0..5fc51c8b 100644 --- a/src/browser/main/tpls/modals/new-recipe-modal.html +++ b/src/browser/main/tpls/modals/new-recipe-modal.html @@ -5,7 +5,7 @@