mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
add AppController, search-snippets filter
This commit is contained in:
5
src/controllers/AppController.js
Normal file
5
src/controllers/AppController.js
Normal file
@@ -0,0 +1,5 @@
|
||||
/* global angular */
|
||||
angular.module('codexen')
|
||||
.controller('AppController', function ($scope) {
|
||||
|
||||
})
|
||||
16
src/filters/search-snippets.js
Normal file
16
src/filters/search-snippets.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/* global angular */
|
||||
angular.module('codexen')
|
||||
.filter('searchSnippets', function ($filter) {
|
||||
return function (input, needle) {
|
||||
if (!angular.isString(needle)) return input
|
||||
if (needle.match(/^#./)) {
|
||||
var name = needle.match(/^#(.+)/)[1]
|
||||
return input.filter(function (snippet) {
|
||||
return snippet.Tags.some(function (tag) {
|
||||
return tag.name.match(new RegExp(name))
|
||||
})
|
||||
})
|
||||
}
|
||||
else return $filter('filter')(input, needle)
|
||||
}
|
||||
})
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<body ng-controller="AppController as app">
|
||||
<div side-nav id="side-view"></div>
|
||||
<div ui-view name="main-view" id="main-view"></div>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<a ui-sref="auth.signin" class="btn btn-default"><i class="fa fa-signin"></i> Sign In</a>
|
||||
</li>
|
||||
|
||||
<li ng-repeat="snippet in vm.snippets | filter:vm.search" ui-sref="snippets.detail({id:snippet.id})" ui-sref-active="active">
|
||||
<li ng-repeat="snippet in vm.snippets | searchSnippets:vm.search" ui-sref="snippets.detail({id:snippet.id})" ui-sref-active="active">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<img width="25" height="25" class="img-circle" src="http://www.gravatar.com/avatar/ea0b6ad1c11700120d1af08810caa19d" alt="" />
|
||||
|
||||
Reference in New Issue
Block a user