Skip to content

Commit debfa63

Browse files
committed
update recipe states
1 parent 0e6fe35 commit debfa63

22 files changed

Lines changed: 477 additions & 50 deletions

Gulpfile.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ gulp.task('vendor', function () {
3737
})
3838

3939
gulp.task('styl', function () {
40-
return gulp.src('src/**/app.styl')
40+
return gulp.src('src/browser/main/styles/app.styl')
4141
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
4242
.pipe(styl())
4343
.pipe(autoprefixer())
44-
.pipe(gulp.dest('src'))
44+
.pipe(gulp.dest('src/browser/main/styles/'))
4545
.pipe(livereload())
4646
.pipe(notify('Stylus!!'))
4747
})
4848

4949
gulp.task('bs', function () {
50-
return gulp.src('src/**/bootstrap.styl')
50+
return gulp.src('src/browser/shared/styles/bootstrap.styl')
5151
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
5252
.pipe(styl())
5353
.pipe(autoprefixer())
54-
.pipe(gulp.dest('src'))
54+
.pipe(gulp.dest('src/browser/shared/styles'))
5555
.pipe(notify('Bootstrap compiled!!'))
5656
.pipe(livereload())
5757
})
@@ -75,7 +75,8 @@ gulp.task('watch-main', function () {
7575
gulp.watch(
7676
['src/browser/main/index.inject.html', 'src/browser/main/**/*.js', 'src/browser/main/**/*.css', 'src/browser/shared/**/*.js', 'src/browser/shared/**/*.css'], ['inject-main'])
7777

78-
gulp.watch('src/**/*.styl', ['styl'])
78+
gulp.watch('src/browser/main/styles/**/*.styl', ['styl'])
79+
gulp.watch('src/browser/shared/styles/**/*.styl', ['bs'])
7980
livereload.listen()
8081
})
8182
gulp.task('inject-popup', function () {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* global angular */
2+
angular.module('codexen')
3+
.controller('ExpandRecipeModalController', function (recipe, $modalInstance, $scope, Modal) {
4+
var vm = this
5+
console.log(recipe)
6+
7+
vm.recipe = recipe
8+
9+
vm.cancel = function () {
10+
$modalInstance.dismiss('cancel')
11+
}
12+
13+
vm.insert = function (type) {
14+
$scope.$broadcast('insertRequested', type)
15+
}
16+
17+
vm.insertSnippet = function () {
18+
Modal.selectSnippet()
19+
.then(function (snippet) {
20+
$scope.$broadcast('insertSnippetRequested', snippet)
21+
})
22+
}
23+
})

src/browser/main/controllers/modals/NewRecipeModalController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ angular.module('codexen')
33
.controller('NewRecipeModalController', function (Recipe, Tag, $modalInstance) {
44
var vm = this
55

6-
vm.content = ''
6+
vm.recipe = {}
77

88
vm.submit = function () {
99
var params = {
10-
title: vm.title,
11-
content: vm.content,
12-
Tags: angular.isArray(vm.Tags) ? vm.Tags.map(function (tag) { return tag.name }) : []
10+
title: vm.recipe.title,
11+
content: vm.recipe.content,
12+
Tags: angular.isArray(vm.recipe.Tags) ? vm.recipe.Tags.map(function (tag) { return tag.name }) : []
1313
}
1414

1515
Recipe.create(params)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* global angular */
2+
angular.module('codexen')
3+
.controller('SelectSnippetModalController', function (Snippet, $modalInstance) {
4+
var vm = this
5+
6+
vm.select = function (snippet) {
7+
$modalInstance.close(snippet)
8+
}
9+
10+
vm.cancel = function () {
11+
$modalInstance.dismiss('cancel')
12+
}
13+
14+
Snippet.findMine()
15+
.success(function (snippets) {
16+
vm.snippets = snippets
17+
})
18+
})

src/browser/main/directives/btn-delete-snippet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ angular.module('codexen')
88
link: function (scope, el) {
99
el.on('click', function () {
1010
Modal.deleteSnippet(scope.snippet)
11-
.result.then(function (snippet) {
12-
$rootScope.$broadcast('snippetDeleted', snippet)
11+
.then(function (snippet) {
12+
console.log('deleted', snippet)
1313
}, function () {
1414
console.log('delete snippet modal dismissed')
1515
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* global angular */
2+
angular.module('codexen')
3+
.directive('btnExpandRecipe', function (Modal) {
4+
return {
5+
restrict: 'A',
6+
scope: {
7+
recipe: '=btnExpandRecipe'
8+
},
9+
link: function (scope, el) {
10+
el.on('click', function () {
11+
Modal.expandRecipe(scope.recipe)
12+
})
13+
}
14+
}
15+
})
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ angular.module('codexen')
1212
smartypants: false
1313
})
1414

15-
return function(input) {
15+
return function (input) {
16+
if (!angular.isString(input)) input = ''
1617
return marked(input)
1718
}
1819
})

src/browser/main/index.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,36 @@
3838
<!-- inject:js -->
3939
<script src="app.js"></script>
4040
<script src="config/states.js"></script>
41+
<script src="controllers/AppController.js"></script>
4142
<script src="directives/btn-delete-recipe.js"></script>
4243
<script src="directives/btn-delete-snippet.js"></script>
4344
<script src="directives/btn-edit-recipe.js"></script>
4445
<script src="directives/btn-edit-snippet.js"></script>
46+
<script src="directives/btn-expand-recipe.js"></script>
4547
<script src="directives/btn-new-recipe.js"></script>
4648
<script src="directives/btn-new-snippet.js"></script>
4749
<script src="directives/recipe-item.js"></script>
4850
<script src="directives/side-nav.js"></script>
4951
<script src="directives/snippet-item.js"></script>
5052
<script src="directives/tag-item.js"></script>
5153
<script src="directives/tag-list.js"></script>
52-
<script src="controllers/AppController.js"></script>
53-
<script src="filters/from-now.js"></script>
54-
<script src="filters/search-snippets.js"></script>
55-
<script src="services/Marked.js"></script>
5654
<script src="services/Modal.js"></script>
5755
<script src="services/Recipe.js"></script>
5856
<script src="services/Settings.js"></script>
5957
<script src="services/Tag.js"></script>
6058
<script src="services/User.js"></script>
59+
<script src="filters/from-now.js"></script>
60+
<script src="filters/marked.js"></script>
61+
<script src="filters/search-snippets.js"></script>
6162
<script src="controllers/directives/SideNavController.js"></script>
6263
<script src="controllers/modals/DeleteRecipeModalController.js"></script>
6364
<script src="controllers/modals/DeleteSnippetModalController.js"></script>
6465
<script src="controllers/modals/EditRecipeModalController.js"></script>
6566
<script src="controllers/modals/EditSnippetModalController.js"></script>
67+
<script src="controllers/modals/ExpandRecipeModalController.js"></script>
6668
<script src="controllers/modals/NewRecipeModalController.js"></script>
6769
<script src="controllers/modals/NewSnippetModalController.js"></script>
70+
<script src="controllers/modals/SelectSnippetModalController.js"></script>
6871
<script src="controllers/states/AuthRegisterController.js"></script>
6972
<script src="controllers/states/AuthSignInController.js"></script>
7073
<script src="controllers/states/HomeController.js"></script>

src/browser/main/services/Modal.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ angular.module('codexen')
2525
})
2626
}
2727

28+
var expandRecipe = function (recipe) {
29+
return $modal.open({
30+
size: 'lg',
31+
resolve: {
32+
recipe: function () {
33+
return recipe
34+
}
35+
},
36+
templateUrl: 'tpls/modals/expand-recipe-modal.html',
37+
controller: 'ExpandRecipeModalController as vm'
38+
})
39+
}
40+
2841
var deleteRecipe = function (recipe) {
2942
return $modal.open({
3043
resolve: {
@@ -77,12 +90,21 @@ angular.module('codexen')
7790
})
7891
}
7992

93+
var selectSnippet = function (snippet) {
94+
return $modal.open({
95+
templateUrl: 'tpls/modals/select-snippet-modal.html',
96+
controller: 'SelectSnippetModalController as vm'
97+
}).result
98+
}
99+
80100
return {
81101
newRecipe: newRecipe,
82102
editRecipe: editRecipe,
83103
deleteRecipe: deleteRecipe,
104+
expandRecipe: expandRecipe,
84105
newSnippet: newSnippet,
85106
editSnippet: editSnippet,
86-
deleteSnippet: deleteSnippet
107+
deleteSnippet: deleteSnippet,
108+
selectSnippet: selectSnippet
87109
}
88110
})

src/browser/main/styles/app.css

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
1+
.expand-recipe-modal .expand-editor .editor-pane {
2+
height: 500px;
3+
}
4+
.expand-recipe-modal .expand-editor .editor-pane .ace_editor {
5+
height: 500px;
6+
}
7+
.expand-recipe-modal .expand-editor .preview-pane {
8+
height: 500px;
9+
overflow-y: auto;
10+
}
111
.new-snippet-modal .ace_editor {
212
height: 200px;
313
}
14+
.select-snippet-modal .snippet-list {
15+
list-style: none;
16+
padding: 0;
17+
}
18+
.select-snippet-modal .snippet-list li {
19+
padding: 10px;
20+
border: solid 1px #001a20;
21+
background-color: #003b4a;
22+
border-radius: 5px;
23+
margin-bottom: 5px;
24+
cursor: pointer;
25+
}
26+
.select-snippet-modal .snippet-list li:hover {
27+
background-color: #004b5f;
28+
}
429
#side-view .nav-control-group {
530
margin: auto 10px;
631
}
@@ -402,3 +427,102 @@ body > .ui-select-bootstrap.open {
402427
overflow-y: auto;
403428
background-color: $bgDarker;
404429
}
430+
.marked h1,
431+
.marked h2,
432+
.marked h3,
433+
.marked h4,
434+
.marked h5 {
435+
margin: 0.75em 0;
436+
}
437+
.marked h1:nth-child(1),
438+
.marked h2:nth-child(1),
439+
.marked h3:nth-child(1),
440+
.marked h4:nth-child(1),
441+
.marked h5:nth-child(1) {
442+
margin-top: 0;
443+
}
444+
.marked code {
445+
background-color: #003644;
446+
color: #fff;
447+
border: 1px solid #001a20;
448+
border-radius: 5px;
449+
box-shadow: 0 1px 1px rgba(0,0,0,0.05);
450+
padding: 5px;
451+
line-height: 200%;
452+
}
453+
.marked pre {
454+
margin-bottom: 10px;
455+
background-color: #003644;
456+
color: #fff;
457+
border: 1px solid #001a20;
458+
border-radius: 5px;
459+
box-shadow: 0 1px 1px rgba(0,0,0,0.05);
460+
padding: 5px;
461+
}
462+
.marked pre >code {
463+
background-color: transparent;
464+
color: inherit;
465+
border: none;
466+
border-radius: 0;
467+
box-shadow: none;
468+
padding: 0;
469+
line-height: inherit;
470+
}
471+
.marked blockquote {
472+
font-size: 1em;
473+
border-left: 5px solid #6494ed;
474+
}
475+
.marked a {
476+
text-decoration: underline;
477+
color: #6494ed;
478+
}
479+
.marked table {
480+
width: 100%;
481+
max-width: 100%;
482+
margin-bottom: $line-height-computed;
483+
border: 1px solid #001a20;
484+
margin-bottom: 10px;
485+
}
486+
.marked table > thead > tr > th,
487+
.marked table > tbody > tr > th,
488+
.marked table > tfoot > tr > th,
489+
.marked table > thead > tr > td,
490+
.marked table > tbody > tr > td,
491+
.marked table > tfoot > tr > td {
492+
padding: 10px;
493+
line-height: $line-height-base;
494+
vertical-align: top;
495+
border-top: 1px solid #001a20;
496+
border-right: 1px solid #001a20;
497+
}
498+
.marked table > thead > tr > th:nth-last-child(1),
499+
.marked table > tbody > tr > th:nth-last-child(1),
500+
.marked table > tfoot > tr > th:nth-last-child(1),
501+
.marked table > thead > tr > td:nth-last-child(1),
502+
.marked table > tbody > tr > td:nth-last-child(1),
503+
.marked table > tfoot > tr > td:nth-last-child(1) {
504+
border-right: none;
505+
}
506+
.marked table > thead > tr > th {
507+
vertical-align: bottom;
508+
border-bottom: 2px solid #001a20;
509+
}
510+
.marked table > caption + thead,
511+
.marked table > colgroup + thead,
512+
.marked table > thead:first-child {
513+
background-color: #004b5f;
514+
}
515+
.marked table > caption + thead > tr:first-child > th,
516+
.marked table > colgroup + thead > tr:first-child > th,
517+
.marked table > thead:first-child > tr:first-child > th,
518+
.marked table > caption + thead > tr:first-child > td,
519+
.marked table > colgroup + thead > tr:first-child > td,
520+
.marked table > thead:first-child > tr:first-child > td {
521+
border-top: 0;
522+
}
523+
.marked table > tbody >tr:nth-child(odd) {
524+
background-color: #002b36;
525+
}
526+
.marked table > tbody >tr:nth-child(even) {
527+
background-color: #003644;
528+
}

0 commit comments

Comments
 (0)